diff --git a/CefSharp.Core.Runtime/Internals/CefSharpApp.h b/CefSharp.Core.Runtime/Internals/CefSharpApp.h index f4cfffc7f5..b471a0a810 100644 --- a/CefSharp.Core.Runtime/Internals/CefSharpApp.h +++ b/CefSharp.Core.Runtime/Internals/CefSharpApp.h @@ -209,10 +209,42 @@ namespace CefSharp if (kvp->Key == "disable-features" || kvp->Key == "enable-features") { - //Temp workaround so we can set the disable-features/enable-features command line argument - // See https://github.com/cefsharp/CefSharp/issues/2408 - commandLine->AppendSwitchWithValue(name, value); + if (CefSharpSettings::MergeFeaturesCommandLineArgs) + { + CefString existingValue = commandLine->GetSwitchValue(name); + if (existingValue.empty()) + { + commandLine->AppendSwitchWithValue(name, value); + } + else + { + bool missing = false; + String^ currentValue = StringUtils::ToClr(existingValue); + List^ existingFeatures = gcnew List(currentValue->Split(',')); + for each(String ^ feature in kvp->Value->Split(',')) + { + if (!existingFeatures->Contains(feature)) + { + missing = true; + break; + } + } + if (missing) + { + commandLine->RemoveSwitch(name); + commandLine->AppendSwitchWithValue(name, StringUtils::ToNative(currentValue + "," + kvp->Value)); + } + } + } + else + { + //Temp workaround so we can set the disable-features/enable-features command line argument + // See https://github.com/cefsharp/CefSharp/issues/2408 + commandLine->RemoveSwitch(name); + commandLine->AppendSwitchWithValue(name, value); + } } + // Right now the command line args handed to the application (global command line) have higher // precedence than command line args provided by the app else if (!commandLine->HasSwitch(name)) diff --git a/CefSharp/CefSharpSettings.cs b/CefSharp/CefSharpSettings.cs index d5ca8754c6..7a9f585115 100644 --- a/CefSharp/CefSharpSettings.cs +++ b/CefSharp/CefSharpSettings.cs @@ -21,6 +21,7 @@ static CefSharpSettings() WcfTimeout = TimeSpan.FromSeconds(2); #endif SubprocessExitIfParentProcessClosed = true; + MergeFeaturesCommandLineArgs = true; } #if !NETCOREAPP @@ -82,6 +83,12 @@ static CefSharpSettings() /// public static bool FocusedNodeChangedEnabled { get; set; } + /// + /// Any enable-features/disable-features command line arguments will be automatically merged with existing values if supplied. + /// This currently defaults to true. + /// + public static bool MergeFeaturesCommandLineArgs { get; set; } + /// /// CefSharp.WinForms and CefSharp.Wpf.HwndHost ONLY! /// The default is to create