@@ -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))
0 commit comments