• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1diff --git chrome/app/chrome_main_delegate.cc chrome/app/chrome_main_delegate.cc
2index 132735e3a1200..0d392976799a4 100644
3--- chrome/app/chrome_main_delegate.cc
4+++ chrome/app/chrome_main_delegate.cc
5@@ -31,6 +31,7 @@
6 #include "base/trace_event/trace_event_impl.h"
7 #include "build/build_config.h"
8 #include "build/chromeos_buildflags.h"
9+#include "cef/libcef/features/runtime.h"
10 #include "chrome/browser/chrome_content_browser_client.h"
11 #include "chrome/browser/chrome_resource_bundle_helper.h"
12 #include "chrome/browser/defaults.h"
13@@ -390,6 +391,8 @@ struct MainFunction {
14
15 // Initializes the user data dir. Must be called before InitializeLocalState().
16 void InitializeUserDataDir(base::CommandLine* command_line) {
17+  if (cef::IsChromeRuntimeEnabled())
18+    return;
19 #if BUILDFLAG(IS_WIN)
20   // Reach out to chrome_elf for the truth on the user data directory.
21   // Note that in tests, this links to chrome_elf_test_stubs.
22@@ -712,7 +715,9 @@ void ChromeMainDelegate::PostFieldTrialInitialization() {
23   }
24
25 #if BUILDFLAG(IS_WIN)
26+  if (!cef::IsChromeRuntimeEnabled()) {
27   SetUpExtendedCrashReporting(is_browser_process);
28+  }
29   base::sequence_manager::internal::ThreadControllerPowerMonitor::
30       InitializeOnMainThread();
31 #endif
32@@ -1010,6 +1015,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
33   std::string process_type =
34       command_line.GetSwitchValueASCII(switches::kProcessType);
35
36+  if (!cef::IsChromeRuntimeEnabled()) {
37   crash_reporter::InitializeCrashKeys();
38
39 #if BUILDFLAG(IS_POSIX)
40@@ -1020,6 +1026,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
41   InitMacCrashReporter(command_line, process_type);
42   SetUpInstallerPreferences(command_line);
43 #endif
44+  }  // !cef::IsChromeRuntimeEnabled()
45
46 #if BUILDFLAG(IS_WIN)
47   child_process_logging::Init();
48@@ -1146,6 +1153,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
49         locale;
50   }
51
52+  if (!cef::IsChromeRuntimeEnabled()) {
53 #if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
54   // Zygote needs to call InitCrashReporter() in RunZygote().
55   if (process_type != switches::kZygoteProcess) {
56@@ -1178,6 +1186,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
57   // After all the platform Breakpads have been initialized, store the command
58   // line for crash reporting.
59   crash_keys::SetCrashKeysFromCommandLine(command_line);
60+  }  // !cef::IsChromeRuntimeEnabled()
61
62 #if BUILDFLAG(ENABLE_PDF)
63   MaybePatchGdiGetFontData();
64@@ -1269,6 +1278,7 @@ void ChromeMainDelegate::ZygoteForked() {
65     SetUpProfilingShutdownHandler();
66   }
67
68+  if (!cef::IsChromeRuntimeEnabled()) {
69   // Needs to be called after we have chrome::DIR_USER_DATA.  BrowserMain sets
70   // this up for the browser process in a different manner.
71   const base::CommandLine* command_line =
72@@ -1285,6 +1295,7 @@ void ChromeMainDelegate::ZygoteForked() {
73
74   // Reset the command line for the newly spawned process.
75   crash_keys::SetCrashKeysFromCommandLine(*command_line);
76+  }  // !cef::IsChromeRuntimeEnabled()
77 }
78
79 #endif  // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
80diff --git chrome/browser/chrome_browser_main.cc chrome/browser/chrome_browser_main.cc
81index 4e9969d9c5b0b..e599b114f021d 100644
82--- chrome/browser/chrome_browser_main.cc
83+++ chrome/browser/chrome_browser_main.cc
84@@ -52,6 +52,7 @@
85 #include "build/build_config.h"
86 #include "build/chromeos_buildflags.h"
87 #include "cc/base/switches.h"
88+#include "cef/libcef/features/runtime.h"
89 #include "chrome/browser/about_flags.h"
90 #include "chrome/browser/active_use_util.h"
91 #include "chrome/browser/after_startup_task_utils.h"
92@@ -1530,11 +1531,13 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
93         browser_process_->local_state());
94   }
95
96+#if !BUILDFLAG(ENABLE_CEF)
97   // Needs to be done before PostProfileInit, since login manager on CrOS is
98   // called inside PostProfileInit.
99   content::WebUIControllerFactory::RegisterFactory(
100       ChromeWebUIControllerFactory::GetInstance());
101   ChromeUntrustedWebUIControllerFactory::RegisterInstance();
102+#endif
103
104 #if BUILDFLAG(IS_ANDROID)
105   page_info::SetPageInfoClient(new ChromePageInfoClient());
106@@ -1757,11 +1760,14 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
107   // This step is costly and is already measured in
108   // Startup.StartupBrowserCreator_Start.
109   // See the comment above for an explanation of |process_command_line|.
110+  // Bypass StartupBrowserCreator with CEF where |GetMainRunLoopInstance()| is
111+  // nullptr.
112   const bool started =
113+      !GetMainRunLoopInstance() ||
114       !process_command_line ||
115       browser_creator_->Start(parsed_command_line(), base::FilePath(),
116                               profile_info, last_opened_profiles);
117-  if (started) {
118+  if (started && GetMainRunLoopInstance()) {
119 // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch
120 // of lacros-chrome is complete.
121 #if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS))
122@@ -1789,8 +1795,10 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
123
124     // Create the RunLoop for MainMessageLoopRun() to use and transfer
125     // ownership of the browser's lifetime to the BrowserProcess.
126+    // CEF with the Chrome runtime will create and manage its own RunLoop.
127     DCHECK(!GetMainRunLoopInstance());
128-    GetMainRunLoopInstance() = std::make_unique<base::RunLoop>();
129+    if (!cef::IsChromeRuntimeEnabled())
130+      GetMainRunLoopInstance() = std::make_unique<base::RunLoop>();
131     browser_process_->SetQuitClosure(
132         GetMainRunLoopInstance()->QuitWhenIdleClosure());
133   }
134diff --git chrome/browser/chrome_browser_main_mac.mm chrome/browser/chrome_browser_main_mac.mm
135index 8bf722c61c059..ac755279227f2 100644
136--- chrome/browser/chrome_browser_main_mac.mm
137+++ chrome/browser/chrome_browser_main_mac.mm
138@@ -16,6 +16,7 @@
139 #include "base/path_service.h"
140 #include "base/strings/sys_string_conversions.h"
141 #include "build/branding_buildflags.h"
142+#include "cef/libcef/features/features.h"
143 #import "chrome/browser/app_controller_mac.h"
144 #include "chrome/browser/apps/app_shim/app_shim_listener.h"
145 #include "chrome/browser/browser_process.h"
146@@ -112,6 +113,7 @@ void ChromeBrowserMainPartsMac::PreCreateMainMessageLoop() {
147     }
148   }
149
150+#if !BUILDFLAG(ENABLE_CEF)
151   // Create the app delegate. This object is intentionally leaked as a global
152   // singleton. It is accessed through -[NSApp delegate].
153   AppController* app_controller = [[AppController alloc] init];
154@@ -120,6 +122,7 @@ void ChromeBrowserMainPartsMac::PreCreateMainMessageLoop() {
155   chrome::BuildMainMenu(NSApp, app_controller,
156                         l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), false);
157   [app_controller mainMenuCreated];
158+#endif  // BUILDFLAG(ENABLE_CEF)
159
160   chrome::DeveloperIDCertificateReauthorizeInApp();
161   chrome::PurgeStaleScreenCapturePermission();
162@@ -182,7 +185,9 @@ void ChromeBrowserMainPartsMac::PostProfileInit(Profile* profile,
163 }
164
165 void ChromeBrowserMainPartsMac::DidEndMainMessageLoop() {
166+#if !BUILDFLAG(ENABLE_CEF)
167   AppController* appController =
168       base::mac::ObjCCastStrict<AppController>([NSApp delegate]);
169   [appController didEndMainMessageLoop];
170+#endif
171 }
172diff --git chrome/browser/chrome_content_browser_client.cc chrome/browser/chrome_content_browser_client.cc
173index db9c606e0ebc3..e08f55ee85c61 100644
174--- chrome/browser/chrome_content_browser_client.cc
175+++ chrome/browser/chrome_content_browser_client.cc
176@@ -28,6 +28,7 @@
177 #include "base/strings/stringprintf.h"
178 #include "build/build_config.h"
179 #include "build/chromeos_buildflags.h"
180+#include "cef/libcef/features/features.h"
181 #include "chrome/browser/accessibility/accessibility_labels_service.h"
182 #include "chrome/browser/accessibility/accessibility_labels_service_factory.h"
183 #include "chrome/browser/after_startup_task_utils.h"
184@@ -3684,9 +3685,11 @@ void ChromeContentBrowserClient::BrowserURLHandlerCreated(
185                           &search::HandleNewTabURLReverseRewrite);
186 #endif  // BUILDFLAG(IS_ANDROID)
187
188+#if !BUILDFLAG(ENABLE_CEF)
189   // chrome: & friends.
190   handler->AddHandlerPair(&ChromeContentBrowserClient::HandleWebUI,
191                           &ChromeContentBrowserClient::HandleWebUIReverse);
192+#endif
193 }
194
195 base::FilePath ChromeContentBrowserClient::GetDefaultDownloadDirectory() {
196@@ -5338,7 +5341,7 @@ void ChromeContentBrowserClient::OnNetworkServiceCreated(
197       network_service);
198 }
199
200-void ChromeContentBrowserClient::ConfigureNetworkContextParams(
201+bool ChromeContentBrowserClient::ConfigureNetworkContextParams(
202     content::BrowserContext* context,
203     bool in_memory,
204     const base::FilePath& relative_partition_path,
205@@ -5356,6 +5359,8 @@ void ChromeContentBrowserClient::ConfigureNetworkContextParams(
206     network_context_params->user_agent = GetUserAgentBasedOnPolicy(context);
207     network_context_params->accept_language = GetApplicationLocale();
208   }
209+
210+  return true;
211 }
212
213 std::vector<base::FilePath>
214diff --git chrome/browser/chrome_content_browser_client.h chrome/browser/chrome_content_browser_client.h
215index 87f0af8fb00cf..87332d3120c1a 100644
216--- chrome/browser/chrome_content_browser_client.h
217+++ chrome/browser/chrome_content_browser_client.h
218@@ -550,7 +550,7 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient {
219       override;
220   void OnNetworkServiceCreated(
221       network::mojom::NetworkService* network_service) override;
222-  void ConfigureNetworkContextParams(
223+  bool ConfigureNetworkContextParams(
224       content::BrowserContext* context,
225       bool in_memory,
226       const base::FilePath& relative_partition_path,
227diff --git chrome/browser/prefs/browser_prefs.cc chrome/browser/prefs/browser_prefs.cc
228index 3ae5f0a699de3..d66d193121be5 100644
229--- chrome/browser/prefs/browser_prefs.cc
230+++ chrome/browser/prefs/browser_prefs.cc
231@@ -11,6 +11,7 @@
232 #include "build/build_config.h"
233 #include "build/chromecast_buildflags.h"
234 #include "build/chromeos_buildflags.h"
235+#include "cef/libcef/features/features.h"
236 #include "chrome/browser/about_flags.h"
237 #include "chrome/browser/accessibility/accessibility_labels_service.h"
238 #include "chrome/browser/accessibility/accessibility_ui.h"
239@@ -164,6 +165,10 @@
240 #include "chrome/browser/background/background_mode_manager.h"
241 #endif
242
243+#if BUILDFLAG(ENABLE_CEF)
244+#include "cef/libcef/browser/prefs/browser_prefs.h"
245+#endif
246+
247 #if BUILDFLAG(ENABLE_EXTENSIONS)
248 #include "chrome/browser/accessibility/animation_policy_prefs.h"
249 #include "chrome/browser/apps/platform_apps/shortcut_manager.h"
250@@ -1267,6 +1272,10 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry,
251   SessionDataService::RegisterProfilePrefs(registry);
252 #endif
253
254+#if BUILDFLAG(ENABLE_CEF)
255+  browser_prefs::RegisterProfilePrefs(registry);
256+#endif
257+
258 #if BUILDFLAG(ENABLE_EXTENSIONS)
259   ExtensionWebUI::RegisterProfilePrefs(registry);
260   RegisterAnimationPolicyPrefs(registry);
261