Skip to content

Commit c7cf2e3

Browse files
authored
Merge eea20a1 into fd87988
2 parents fd87988 + eea20a1 commit c7cf2e3

2 files changed

Lines changed: 32 additions & 3 deletions

File tree

CefSharp.Core.Runtime/Internals/CefSharpApp.h

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,32 @@ 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+
String^ currentValue = StringUtils::ToClr(existingValue);
222+
if (!currentValue->Contains(kvp->Value))
223+
{
224+
commandLine->RemoveSwitch(name);
225+
commandLine->AppendSwitchWithValue(name, StringUtils::ToNative(currentValue + "," + kvp->Value));
226+
}
227+
}
228+
}
229+
else
230+
{
231+
//Temp workaround so we can set the disable-features/enable-features command line argument
232+
// See https://github.com/cefsharp/CefSharp/issues/2408
233+
commandLine->RemoveSwitch(name);
234+
commandLine->AppendSwitchWithValue(name, value);
235+
}
215236
}
237+
216238
// Right now the command line args handed to the application (global command line) have higher
217239
// precedence than command line args provided by the app
218240
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)