Skip to content

Commit a61bfb6

Browse files
authored
Merge d040de5 into fd87988
2 parents fd87988 + d040de5 commit a61bfb6

2 files changed

Lines changed: 42 additions & 3 deletions

File tree

CefSharp.Core.Runtime/Internals/CefSharpApp.h

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,42 @@ namespace CefSharp
209209

210210
if (kvp->Key == "disable-features" || kvp->Key == "enable-features")
211211
{
212-
//Temp workaround so we can set the disable-features/enable-features command line argument
213-
// See https://github.com/cefsharp/CefSharp/issues/2408
214-
commandLine->AppendSwitchWithValue(name, value);
212+
if (CefSharpSettings::MergeFeaturesCommandLineArgs)
213+
{
214+
CefString existingValue = commandLine->GetSwitchValue(name);
215+
if (existingValue.empty())
216+
{
217+
commandLine->AppendSwitchWithValue(name, value);
218+
}
219+
else
220+
{
221+
bool missing = false;
222+
String^ currentValue = StringUtils::ToClr(existingValue);
223+
List<String^>^ existingFeatures = gcnew List<String^>(currentValue->Split(','));
224+
for each(String ^ feature in kvp->Value->Split(','))
225+
{
226+
if (!existingFeatures->Contains(feature))
227+
{
228+
missing = true;
229+
break;
230+
}
231+
}
232+
if (missing)
233+
{
234+
commandLine->RemoveSwitch(name);
235+
commandLine->AppendSwitchWithValue(name, StringUtils::ToNative(currentValue + "," + kvp->Value));
236+
}
237+
}
238+
}
239+
else
240+
{
241+
//Temp workaround so we can set the disable-features/enable-features command line argument
242+
// See https://github.com/cefsharp/CefSharp/issues/2408
243+
commandLine->RemoveSwitch(name);
244+
commandLine->AppendSwitchWithValue(name, value);
245+
}
215246
}
247+
216248
// Right now the command line args handed to the application (global command line) have higher
217249
// precedence than command line args provided by the app
218250
else if (!commandLine->HasSwitch(name))

CefSharp/CefSharpSettings.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ static CefSharpSettings()
2121
WcfTimeout = TimeSpan.FromSeconds(2);
2222
#endif
2323
SubprocessExitIfParentProcessClosed = true;
24+
MergeFeaturesCommandLineArgs = true;
2425
}
2526

2627
#if !NETCOREAPP
@@ -82,6 +83,12 @@ static CefSharpSettings()
8283
/// </summary>
8384
public static bool FocusedNodeChangedEnabled { get; set; }
8485

86+
/// <summary>
87+
/// Any enable-features/disable-features command line arguments will be automatically merged with existing values if supplied.
88+
/// This currently defaults to true.
89+
/// </summary>
90+
public static bool MergeFeaturesCommandLineArgs { get; set; }
91+
8592
/// <summary>
8693
/// CefSharp.WinForms and CefSharp.Wpf.HwndHost ONLY!
8794
/// The default is to create <see cref="CefRuntimeStyle.Alloy"/>

0 commit comments

Comments
 (0)