Skip to content

Commit 754ee71

Browse files
authored
Merge eaf122d into fd87988
2 parents fd87988 + eaf122d commit 754ee71

2 files changed

Lines changed: 41 additions & 3 deletions

File tree

CefSharp.Core.Runtime/Internals/CefSharpApp.h

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,41 @@ 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+
bool missing = false;
223+
for each(String ^ feature in kvp->Value->Split(','))
224+
{
225+
if (!currentValue->Contains(feature->Trim()))
226+
{
227+
missing = true;
228+
break;
229+
}
230+
}
231+
if (missing)
232+
{
233+
commandLine->RemoveSwitch(name);
234+
commandLine->AppendSwitchWithValue(name, StringUtils::ToNative(currentValue + "," + kvp->Value));
235+
}
236+
}
237+
}
238+
else
239+
{
240+
//Temp workaround so we can set the disable-features/enable-features command line argument
241+
// See https://github.com/cefsharp/CefSharp/issues/2408
242+
commandLine->RemoveSwitch(name);
243+
commandLine->AppendSwitchWithValue(name, value);
244+
}
215245
}
246+
216247
// Right now the command line args handed to the application (global command line) have higher
217248
// precedence than command line args provided by the app
218249
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)