From bfbd4a2540b054314532877ed1a47926ba53ccb9 Mon Sep 17 00:00:00 2001 From: "trop[bot]" Date: Fri, 3 Aug 2018 13:08:27 +1000 Subject: [PATCH] fix: Improve --enable-features/--disable-features handling (#13923) As it turns out, we can reinitialize the feature list directly after the user JS script has been executed instead of much later. This allows modifications to `--enable-features`/`--disable-features` to work with a greater set of features. --- atom/browser/atom_browser_main_parts.cc | 8 ++++++++ brightray/browser/browser_main_parts.cc | 10 ---------- brightray/browser/browser_main_parts.h | 4 ++-- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/atom/browser/atom_browser_main_parts.cc b/atom/browser/atom_browser_main_parts.cc index 13db661a2e65..5229b19ca9af 100644 --- a/atom/browser/atom_browser_main_parts.cc +++ b/atom/browser/atom_browser_main_parts.cc @@ -154,6 +154,14 @@ void AtomBrowserMainParts::PostEarlyInitialization() { // Wrap the uv loop with global env. node_bindings_->set_uv_env(env); + + // We already initialized the feature list in + // brightray::BrowserMainParts::PreEarlyInitialization(), but + // the user JS script would not have had a chance to alter the command-line + // switches at that point. Lets reinitialize it here to pick up the + // command-line changes. + base::FeatureList::ClearInstanceForTesting(); + brightray::BrowserMainParts::InitializeFeatureList(); } int AtomBrowserMainParts::PreCreateThreads() { diff --git a/brightray/browser/browser_main_parts.cc b/brightray/browser/browser_main_parts.cc index 9349a95ea222..8fc4c1adc99c 100644 --- a/brightray/browser/browser_main_parts.cc +++ b/brightray/browser/browser_main_parts.cc @@ -268,16 +268,6 @@ void BrowserMainParts::PreMainMessageLoopStart() { } void BrowserMainParts::PreMainMessageLoopRun() { - // We already initialized the feature list in PreEarlyInitialization(), but - // the user JS script would not have had a chance to alter the command-line - // switches at that point. Lets force re-initialization here to pick up the - // command-line changes. Note that some Chromium code (e.g. - // gpu_process_host.cc) queries the feature list between - // PreEarlyInitialization() and here so the user script may not have - // control over all features. Better than nothing though! - base::FeatureList::ClearInstanceForTesting(); - InitializeFeatureList(); - content::WebUIControllerFactory::RegisterFactory( WebUIControllerFactory::GetInstance()); diff --git a/brightray/browser/browser_main_parts.h b/brightray/browser/browser_main_parts.h index f8d758d0ab0c..cf8e0296585b 100644 --- a/brightray/browser/browser_main_parts.h +++ b/brightray/browser/browser_main_parts.h @@ -43,14 +43,14 @@ class BrowserMainParts : public content::BrowserMainParts { int PreCreateThreads() override; void PostDestroyThreads() override; + void InitializeFeatureList(); + private: #if defined(OS_MACOSX) void InitializeMainNib(); void OverrideAppLogsPath(); #endif - void InitializeFeatureList(); - std::unique_ptr io_thread_; #if defined(USE_AURA)