Skip to content

Commit a76adba

Browse files
authored
Merge pull request electron#13782 from electron/fix-enable-disable-features-2-0-x
fix: Use --enable-features and --disable-features (2.0.x)
2 parents 9667b83 + 6689dce commit a76adba

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

brightray/browser/browser_main_parts.cc

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,20 @@ void OverrideAppLogsPath() {
184184
}
185185
#endif
186186

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+
188194
std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
189-
feature_list->InitializeFromCommandLine("", "");
195+
feature_list->InitializeFromCommandLine(enable_features, disable_features);
190196
base::FeatureList::SetInstance(std::move(feature_list));
197+
}
198+
199+
void BrowserMainParts::PreEarlyInitialization() {
200+
InitializeFeatureList();
191201
OverrideAppLogsPath();
192202
#if defined(USE_X11)
193203
views::LinuxUI::SetInstance(BuildGtkUi());
@@ -256,6 +266,16 @@ void BrowserMainParts::PreMainMessageLoopStart() {
256266
}
257267

258268
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+
259279
content::WebUIControllerFactory::RegisterFactory(
260280
WebUIControllerFactory::GetInstance());
261281

brightray/browser/browser_main_parts.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ class BrowserMainParts : public content::BrowserMainParts {
5252
void OverrideAppLogsPath();
5353
#endif
5454

55+
void InitializeFeatureList();
56+
5557
std::unique_ptr<IOThread> io_thread_;
5658

5759
#if defined(TOOLKIT_VIEWS)

0 commit comments

Comments
 (0)