From 8b447e3a6f8a94b6d190217f6966016a4d8acae2 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Thu, 19 Jan 2023 16:20:29 -0500 Subject: [PATCH] chrome: Don't show the profile picker on startup (fixes issue #3440) --- .../common/chrome/chrome_main_delegate_cef.cc | 23 +++++++++++++++++++ .../common/chrome/chrome_main_delegate_cef.h | 1 + 2 files changed, 24 insertions(+) diff --git a/libcef/common/chrome/chrome_main_delegate_cef.cc b/libcef/common/chrome/chrome_main_delegate_cef.cc index dd6d9483d..de9dbf3e7 100644 --- a/libcef/common/chrome/chrome_main_delegate_cef.cc +++ b/libcef/common/chrome/chrome_main_delegate_cef.cc @@ -19,7 +19,9 @@ #include "base/command_line.h" #include "base/lazy_instance.h" #include "base/threading/threading_features.h" +#include "chrome/browser/metrics/chrome_feature_list_creator.h" #include "chrome/common/chrome_switches.h" +#include "chrome/common/pref_names.h" #include "components/embedder_support/switches.h" #include "content/public/common/content_switches.h" #include "sandbox/policy/switches.h" @@ -204,6 +206,27 @@ absl::optional ChromeMainDelegateCef::PreBrowserMain() { return absl::nullopt; } +absl::optional ChromeMainDelegateCef::PostEarlyInitialization( + InvokedIn invoked_in) { + const auto result = ChromeMainDelegate::PostEarlyInitialization(invoked_in); + if (!result) { + const auto* invoked_in_browser = + absl::get_if(&invoked_in); + if (invoked_in_browser) { + // At this point local_state has been created but ownership has not yet + // been passed to BrowserProcessImpl (g_browser_process is nullptr). + auto* local_state = chrome_content_browser_client_->startup_data() + ->chrome_feature_list_creator() + ->local_state(); + + // Don't show the profile picker on startup (see issue #3440). + local_state->SetBoolean(prefs::kBrowserShowProfilePickerOnStartup, false); + } + } + + return result; +} + absl::variant ChromeMainDelegateCef::RunProcess( const std::string& process_type, diff --git a/libcef/common/chrome/chrome_main_delegate_cef.h b/libcef/common/chrome/chrome_main_delegate_cef.h index 4a4645b97..cfe768f06 100644 --- a/libcef/common/chrome/chrome_main_delegate_cef.h +++ b/libcef/common/chrome/chrome_main_delegate_cef.h @@ -39,6 +39,7 @@ class ChromeMainDelegateCef : public ChromeMainDelegate, absl::optional BasicStartupComplete() override; void PreSandboxStartup() override; absl::optional PreBrowserMain() override; + absl::optional PostEarlyInitialization(InvokedIn invoked_in) override; absl::variant RunProcess( const std::string& process_type, content::MainFunctionParams main_function_params) override;