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