@@ -184,10 +184,20 @@ void OverrideAppLogsPath() {
184
184
}
185
185
#endif
186
186
187
- void BrowserMainParts::PreEarlyInitialization () {
187
+ void BrowserMainParts::InitializeFeatureList () {
188
+ auto * cmd_line = base::CommandLine::ForCurrentProcess ();
189
+ const auto enable_features =
190
+ cmd_line->GetSwitchValueASCII (switches::kEnableFeatures );
191
+ const auto disable_features =
192
+ cmd_line->GetSwitchValueASCII (switches::kDisableFeatures );
193
+
188
194
std::unique_ptr<base::FeatureList> feature_list (new base::FeatureList);
189
- feature_list->InitializeFromCommandLine (" " , " " );
195
+ feature_list->InitializeFromCommandLine (enable_features, disable_features );
190
196
base::FeatureList::SetInstance (std::move (feature_list));
197
+ }
198
+
199
+ void BrowserMainParts::PreEarlyInitialization () {
200
+ InitializeFeatureList ();
191
201
OverrideAppLogsPath ();
192
202
#if defined(USE_X11)
193
203
views::LinuxUI::SetInstance (BuildGtkUi ());
@@ -256,6 +266,16 @@ void BrowserMainParts::PreMainMessageLoopStart() {
256
266
}
257
267
258
268
void BrowserMainParts::PreMainMessageLoopRun () {
269
+ // We already initialized feature list in PreEarlyInitialization(), but
270
+ // the user JS script would not have had a chance to alter the command-line
271
+ // switches at that point. Lets reinitialize it here to pick up the
272
+ // command-line changes. Note that some Chromium code (e.g.
273
+ // gpu_process_host.cc) queries the feature list between
274
+ // PreEarlyInitialization() and here so the user script may not have
275
+ // control over all features. Better than nothing though!
276
+ base::FeatureList::ClearInstanceForTesting ();
277
+ InitializeFeatureList ();
278
+
259
279
content::WebUIControllerFactory::RegisterFactory (
260
280
WebUIControllerFactory::GetInstance ());
261
281
0 commit comments