2012-04-03 03:34:16 +02:00
|
|
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "cef/libcef/browser/alloy/alloy_browser_main.h"
|
2012-05-18 22:32:28 +02:00
|
|
|
|
2016-01-06 20:20:54 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2024-01-20 23:48:57 +01:00
|
|
|
#include <memory>
|
2012-05-18 22:32:28 +02:00
|
|
|
#include <string>
|
|
|
|
|
2022-06-02 11:49:50 +02:00
|
|
|
#include "base/feature_list.h"
|
2023-01-30 18:43:54 +01:00
|
|
|
#include "base/functional/bind.h"
|
2013-06-22 04:06:32 +02:00
|
|
|
#include "base/strings/string_number_conversions.h"
|
2021-04-21 00:52:34 +02:00
|
|
|
#include "base/task/thread_pool.h"
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "cef/libcef/browser/alloy/devtools/devtools_manager_delegate.h"
|
|
|
|
#include "cef/libcef/browser/alloy/dialogs/alloy_constrained_window_views_client.h"
|
|
|
|
#include "cef/libcef/browser/browser_context.h"
|
|
|
|
#include "cef/libcef/browser/browser_context_keyed_service_factories.h"
|
|
|
|
#include "cef/libcef/browser/context.h"
|
|
|
|
#include "cef/libcef/browser/extensions/extension_system_factory.h"
|
|
|
|
#include "cef/libcef/browser/file_dialog_runner.h"
|
|
|
|
#include "cef/libcef/browser/net/chrome_scheme_handler.h"
|
|
|
|
#include "cef/libcef/browser/permission_prompt.h"
|
|
|
|
#include "cef/libcef/browser/thread_util.h"
|
|
|
|
#include "cef/libcef/common/app_manager.h"
|
|
|
|
#include "cef/libcef/common/command_line_impl.h"
|
|
|
|
#include "cef/libcef/common/extensions/extensions_util.h"
|
|
|
|
#include "cef/libcef/common/net/net_resource_provider.h"
|
2019-05-02 18:16:44 +02:00
|
|
|
#include "chrome/browser/browser_process.h"
|
2023-12-05 00:45:54 +01:00
|
|
|
#include "chrome/browser/chrome_process_singleton.h"
|
2020-10-08 21:54:42 +02:00
|
|
|
#include "chrome/browser/media/router/chrome_media_router_factory.h"
|
2019-05-02 18:16:44 +02:00
|
|
|
#include "chrome/browser/net/system_network_context_manager.h"
|
2023-04-11 20:08:21 +02:00
|
|
|
#include "chrome/browser/ui/color/chrome_color_mixers.h"
|
2022-06-02 11:49:50 +02:00
|
|
|
#include "chrome/browser/ui/javascript_dialogs/chrome_javascript_app_modal_dialog_view_factory.h"
|
|
|
|
#include "chrome/browser/ui/ui_features.h"
|
2023-06-06 16:41:53 +02:00
|
|
|
#include "chrome/common/chrome_paths.h"
|
2021-08-09 23:18:43 +02:00
|
|
|
#include "chrome/common/chrome_switches.h"
|
2024-03-23 00:51:00 +01:00
|
|
|
#include "components/color/color_mixers.h"
|
2019-07-17 20:47:27 +02:00
|
|
|
#include "components/constrained_window/constrained_window_views.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "content/public/browser/gpu_data_manager.h"
|
2020-04-14 21:31:00 +02:00
|
|
|
#include "content/public/browser/network_service_instance.h"
|
2020-10-08 21:54:42 +02:00
|
|
|
#include "content/public/common/result_codes.h"
|
2022-01-28 22:16:29 +01:00
|
|
|
#include "extensions/browser/extensions_browser_client.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "extensions/common/constants.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "net/base/net_module.h"
|
2021-08-09 23:18:43 +02:00
|
|
|
#include "third_party/widevine/cdm/buildflags.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "ui/base/resource/resource_bundle.h"
|
2023-07-21 00:11:34 +02:00
|
|
|
#include "ui/color/color_provider_manager.h"
|
2023-02-22 23:10:25 +01:00
|
|
|
#include "ui/native_theme/native_theme.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2022-01-24 18:58:02 +01:00
|
|
|
#if BUILDFLAG(IS_LINUX)
|
2024-01-26 03:12:43 +01:00
|
|
|
#include "ui/base/ozone_buildflags.h"
|
|
|
|
#if defined(USE_AURA) && BUILDFLAG(IS_OZONE_X11)
|
2019-02-27 20:17:21 +01:00
|
|
|
#include "ui/events/devices/x11/touch_factory_x11.h"
|
|
|
|
#endif
|
2024-03-29 17:48:33 +01:00
|
|
|
#if defined(USE_DBUS)
|
|
|
|
#include "chrome/browser/ui/views/dark_mode_manager_linux.h"
|
|
|
|
#endif
|
2021-12-16 23:35:54 +01:00
|
|
|
#endif
|
2019-02-27 20:17:21 +01:00
|
|
|
|
2013-12-07 02:55:22 +01:00
|
|
|
#if defined(USE_AURA)
|
|
|
|
#include "ui/aura/env.h"
|
|
|
|
#include "ui/views/widget/desktop_aura/desktop_screen.h"
|
2017-04-26 18:49:30 +02:00
|
|
|
#include "ui/wm/core/wm_state.h"
|
2014-05-06 19:20:43 +02:00
|
|
|
|
2022-01-24 18:58:02 +01:00
|
|
|
#if BUILDFLAG(IS_WIN)
|
2022-06-23 12:59:09 +02:00
|
|
|
#include "base/enterprise_util.h"
|
2023-06-06 16:41:53 +02:00
|
|
|
#include "base/files/file_util.h"
|
2020-03-19 16:34:15 +01:00
|
|
|
#include "chrome/browser/chrome_browser_main_win.h"
|
2020-04-16 03:26:27 +02:00
|
|
|
#include "chrome/browser/win/parental_controls.h"
|
2014-05-06 19:20:43 +02:00
|
|
|
#endif
|
2013-12-07 02:55:22 +01:00
|
|
|
#endif // defined(USE_AURA)
|
|
|
|
|
2022-01-24 18:58:02 +01:00
|
|
|
#if BUILDFLAG(IS_MAC)
|
2019-10-15 13:11:59 +02:00
|
|
|
#include "chrome/browser/ui/views/chrome_layout_provider.h"
|
|
|
|
#include "chrome/browser/ui/views/chrome_views_delegate.h"
|
|
|
|
#else
|
|
|
|
#include "ui/views/test/desktop_test_views_delegate.h"
|
|
|
|
#endif
|
|
|
|
|
2022-01-24 18:58:02 +01:00
|
|
|
#if defined(USE_AURA) && BUILDFLAG(IS_LINUX)
|
2019-06-05 16:15:45 +02:00
|
|
|
#include "ui/base/ime/init/input_method_initializer.h"
|
2014-05-22 23:01:22 +02:00
|
|
|
#endif
|
|
|
|
|
2022-01-25 21:26:51 +01:00
|
|
|
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX)
|
2023-04-04 20:00:13 +02:00
|
|
|
#include "components/os_crypt/sync/os_crypt.h"
|
2022-01-25 21:26:51 +01:00
|
|
|
#endif
|
|
|
|
|
2022-01-24 18:58:02 +01:00
|
|
|
#if BUILDFLAG(IS_LINUX)
|
2022-01-25 21:26:51 +01:00
|
|
|
#include "base/path_service.h"
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "cef/libcef/browser/printing/print_dialog_linux.h"
|
2022-04-15 21:55:23 +02:00
|
|
|
#include "chrome/browser/themes/theme_service_aura_linux.h"
|
|
|
|
#include "chrome/browser/ui/views/theme_profile_key.h"
|
2023-10-19 20:08:48 +02:00
|
|
|
#include "chrome/grit/branded_strings.h"
|
2023-04-04 20:00:13 +02:00
|
|
|
#include "components/os_crypt/sync/key_storage_config_linux.h"
|
2022-04-15 21:55:23 +02:00
|
|
|
#include "ui/base/cursor/cursor_factory.h"
|
|
|
|
#include "ui/base/ime/input_method.h"
|
2022-01-25 21:26:51 +01:00
|
|
|
#include "ui/base/l10n/l10n_util.h"
|
2022-07-25 19:49:32 +02:00
|
|
|
#include "ui/linux/linux_ui.h"
|
|
|
|
#include "ui/linux/linux_ui_delegate.h"
|
|
|
|
#include "ui/linux/linux_ui_factory.h"
|
2022-09-26 21:30:45 +02:00
|
|
|
#include "ui/linux/linux_ui_getter.h"
|
2022-04-15 21:55:23 +02:00
|
|
|
#include "ui/ozone/public/ozone_platform.h"
|
2022-01-25 21:26:51 +01:00
|
|
|
#endif // BUILDFLAG(IS_LINUX)
|
2014-07-10 17:41:30 +02:00
|
|
|
|
2021-08-09 23:18:43 +02:00
|
|
|
#if BUILDFLAG(ENABLE_MEDIA_FOUNDATION_WIDEVINE_CDM)
|
|
|
|
#include "chrome/browser/component_updater/media_foundation_widevine_cdm_component_installer.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT)
|
|
|
|
#include "chrome/browser/component_updater/widevine_cdm_component_installer.h"
|
|
|
|
#endif
|
|
|
|
|
2022-04-15 21:55:23 +02:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
#if BUILDFLAG(IS_LINUX)
|
|
|
|
|
2022-09-26 21:30:45 +02:00
|
|
|
class LinuxUiGetterImpl : public ui::LinuxUiGetter {
|
|
|
|
public:
|
|
|
|
LinuxUiGetterImpl() = default;
|
|
|
|
~LinuxUiGetterImpl() override = default;
|
|
|
|
ui::LinuxUiTheme* GetForWindow(aura::Window* window) override {
|
|
|
|
return window ? GetForProfile(GetThemeProfileForWindow(window)) : nullptr;
|
|
|
|
}
|
|
|
|
ui::LinuxUiTheme* GetForProfile(Profile* profile) override {
|
|
|
|
return ui::GetLinuxUiTheme(
|
|
|
|
ThemeServiceAuraLinux::GetSystemThemeForProfile(profile));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-04-15 21:55:23 +02:00
|
|
|
#endif // BUILDFLAG(IS_LINUX)
|
|
|
|
|
2023-12-05 00:45:54 +01:00
|
|
|
void ProcessSingletonNotificationCallbackImpl(
|
2024-03-19 22:11:42 +01:00
|
|
|
base::CommandLine command_line,
|
2023-12-05 00:45:54 +01:00
|
|
|
const base::FilePath& current_directory) {
|
|
|
|
// Drop the request if the browser process is already shutting down.
|
|
|
|
if (!CONTEXT_STATE_VALID()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool handled = false;
|
|
|
|
|
|
|
|
if (auto app = CefAppManager::Get()->GetApplication()) {
|
|
|
|
if (auto handler = app->GetBrowserProcessHandler()) {
|
|
|
|
CefRefPtr<CefCommandLineImpl> commandLinePtr(
|
|
|
|
new CefCommandLineImpl(command_line));
|
|
|
|
handled = handler->OnAlreadyRunningAppRelaunch(commandLinePtr.get(),
|
|
|
|
current_directory.value());
|
|
|
|
std::ignore = commandLinePtr->Detach(nullptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!handled) {
|
|
|
|
LOG(WARNING) << "Unhandled app relaunch; implement "
|
|
|
|
"CefBrowserProcessHandler::OnAlreadyRunningAppRelaunch.";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Based on ChromeBrowserMainParts::ProcessSingletonNotificationCallback.
|
|
|
|
bool ProcessSingletonNotificationCallback(
|
2024-03-19 22:11:42 +01:00
|
|
|
base::CommandLine command_line,
|
2023-12-05 00:45:54 +01:00
|
|
|
const base::FilePath& current_directory) {
|
|
|
|
// Drop the request if the browser process is already shutting down.
|
|
|
|
// Note that we're going to post an async task below. Even if the browser
|
|
|
|
// process isn't shutting down right now, it could be by the time the task
|
|
|
|
// starts running. So, an additional check needs to happen when it starts.
|
|
|
|
// But regardless of any future check, there is no reason to post the task
|
|
|
|
// now if we know we're already shutting down.
|
|
|
|
if (!CONTEXT_STATE_VALID()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// In order to handle this request on Windows, there is platform specific
|
|
|
|
// code in browser_finder.cc that requires making outbound COM calls to
|
|
|
|
// cross-apartment shell objects (via IVirtualDesktopManager). That is not
|
|
|
|
// allowed within a SendMessage handler, which this function is a part of.
|
|
|
|
// So, we post a task to asynchronously finish the command line processing.
|
|
|
|
return base::SingleThreadTaskRunner::GetCurrentDefault()->PostTask(
|
|
|
|
FROM_HERE, base::BindOnce(&ProcessSingletonNotificationCallbackImpl,
|
2024-03-19 22:11:42 +01:00
|
|
|
std::move(command_line), current_directory));
|
2023-12-05 00:45:54 +01:00
|
|
|
}
|
|
|
|
|
2022-04-15 21:55:23 +02:00
|
|
|
} // namespace
|
|
|
|
|
2022-05-19 12:28:44 +02:00
|
|
|
AlloyBrowserMainParts::AlloyBrowserMainParts() = default;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
AlloyBrowserMainParts::~AlloyBrowserMainParts() {
|
2019-07-17 20:47:27 +02:00
|
|
|
constrained_window::SetConstrainedWindowViewsClient(nullptr);
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
void AlloyBrowserMainParts::ToolkitInitialized() {
|
2024-04-17 18:01:26 +02:00
|
|
|
SetConstrainedWindowViewsClient(
|
|
|
|
CreateAlloyConstrainedWindowViewsClient(nullptr));
|
2013-12-07 02:55:22 +01:00
|
|
|
#if defined(USE_AURA)
|
2014-05-29 19:15:34 +02:00
|
|
|
CHECK(aura::Env::GetInstance());
|
2013-12-07 02:55:22 +01:00
|
|
|
|
2024-01-20 23:48:57 +01:00
|
|
|
wm_state_ = std::make_unique<wm::WMState>();
|
2014-05-06 19:20:43 +02:00
|
|
|
#endif // defined(USE_AURA)
|
2019-10-15 13:11:59 +02:00
|
|
|
|
2022-01-24 18:58:02 +01:00
|
|
|
#if BUILDFLAG(IS_MAC)
|
2019-10-15 13:11:59 +02:00
|
|
|
views_delegate_ = std::make_unique<ChromeViewsDelegate>();
|
|
|
|
layout_provider_ = ChromeLayoutProvider::CreateLayoutProvider();
|
|
|
|
#else
|
|
|
|
views_delegate_ = std::make_unique<views::DesktopTestViewsDelegate>();
|
|
|
|
#endif
|
2022-04-15 21:55:23 +02:00
|
|
|
|
|
|
|
#if BUILDFLAG(IS_LINUX)
|
2022-09-26 21:30:45 +02:00
|
|
|
// Based on chrome_browser_main_extra_parts_views_linux.cc
|
2024-03-29 17:48:33 +01:00
|
|
|
// |linux_ui| will be nullptr with multi-threaded-message-loop. See
|
|
|
|
// CefUiThread::InitializeBrowserRunner.
|
|
|
|
if (auto linux_ui = ui::GetDefaultLinuxUi()) {
|
2022-09-26 21:30:45 +02:00
|
|
|
linux_ui_getter_ = std::make_unique<LinuxUiGetterImpl>();
|
|
|
|
ui::LinuxUi::SetInstance(linux_ui);
|
|
|
|
|
|
|
|
// Cursor theme changes are tracked by LinuxUI (via a CursorThemeManager
|
|
|
|
// implementation). Start observing them once it's initialized.
|
|
|
|
ui::CursorFactory::GetInstance()->ObserveThemeChanges();
|
|
|
|
}
|
|
|
|
|
2024-03-29 17:48:33 +01:00
|
|
|
#if defined(USE_DBUS)
|
|
|
|
if (!ui::NativeTheme::IsForcedDarkMode() &&
|
|
|
|
!ui::NativeTheme::IsForcedLightMode()) {
|
|
|
|
dark_mode_manager_ = std::make_unique<ui::DarkModeManagerLinux>();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2022-09-26 21:30:45 +02:00
|
|
|
auto printing_delegate = new CefPrintingContextLinuxDelegate();
|
|
|
|
auto default_delegate =
|
2023-01-12 17:49:21 +01:00
|
|
|
ui::PrintingContextLinuxDelegate::SetInstance(printing_delegate);
|
2022-09-26 21:30:45 +02:00
|
|
|
printing_delegate->SetDefaultDelegate(default_delegate);
|
|
|
|
#endif // BUILDFLAG(IS_LINUX)
|
2022-06-02 11:49:50 +02:00
|
|
|
|
|
|
|
#if BUILDFLAG(IS_MAC)
|
2023-01-02 23:59:03 +01:00
|
|
|
if (base::FeatureList::IsEnabled(features::kViewsJSAppModalDialog)) {
|
2022-06-02 11:49:50 +02:00
|
|
|
InstallChromeJavaScriptAppModalDialogViewFactory();
|
2023-01-02 23:59:03 +01:00
|
|
|
} else {
|
2022-06-02 11:49:50 +02:00
|
|
|
InstallChromeJavaScriptAppModalDialogViewCocoaFactory();
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2022-06-02 11:49:50 +02:00
|
|
|
#else
|
|
|
|
InstallChromeJavaScriptAppModalDialogViewFactory();
|
|
|
|
#endif
|
2023-04-11 20:08:21 +02:00
|
|
|
|
|
|
|
// On GTK that builds the native theme that, in turn, adds the GTK core color
|
|
|
|
// mixer; core mixers should all be added before we add chrome mixers.
|
2024-03-23 00:51:00 +01:00
|
|
|
ui::ColorProviderManager::Get().AppendColorProviderInitializer(
|
|
|
|
base::BindRepeating(color::AddComponentsColorMixers));
|
2023-04-11 20:08:21 +02:00
|
|
|
ui::ColorProviderManager::Get().AppendColorProviderInitializer(
|
|
|
|
base::BindRepeating(AddChromeColorMixers));
|
2018-03-20 21:15:08 +01:00
|
|
|
}
|
|
|
|
|
2021-06-04 03:34:56 +02:00
|
|
|
void AlloyBrowserMainParts::PreCreateMainMessageLoop() {
|
2022-01-24 18:58:02 +01:00
|
|
|
#if BUILDFLAG(IS_LINUX)
|
2024-01-26 03:12:43 +01:00
|
|
|
#if defined(USE_AURA) && BUILDFLAG(IS_OZONE_X11)
|
2019-02-27 20:17:21 +01:00
|
|
|
ui::TouchFactory::SetTouchDeviceListFromCommandLine();
|
|
|
|
#endif
|
2021-12-16 23:35:54 +01:00
|
|
|
#endif
|
2019-02-27 20:17:21 +01:00
|
|
|
|
2022-01-24 18:58:02 +01:00
|
|
|
#if BUILDFLAG(IS_WIN)
|
2019-07-29 23:27:12 +02:00
|
|
|
// Initialize the OSCrypt.
|
|
|
|
PrefService* local_state = g_browser_process->local_state();
|
|
|
|
DCHECK(local_state);
|
2020-03-04 01:29:39 +01:00
|
|
|
bool os_crypt_init = OSCrypt::Init(local_state);
|
|
|
|
DCHECK(os_crypt_init);
|
2020-03-19 16:34:15 +01:00
|
|
|
|
|
|
|
// installer_util references strings that are normally compiled into
|
|
|
|
// setup.exe. In Chrome, these strings are in the locale files.
|
|
|
|
ChromeBrowserMainPartsWin::SetupInstallerUtilStrings();
|
2022-01-24 18:58:02 +01:00
|
|
|
#endif // BUILDFLAG(IS_WIN)
|
2020-10-08 21:54:42 +02:00
|
|
|
|
|
|
|
media_router::ChromeMediaRouterFactory::DoPlatformInit();
|
2013-12-07 02:55:22 +01:00
|
|
|
}
|
|
|
|
|
2021-06-04 03:34:56 +02:00
|
|
|
void AlloyBrowserMainParts::PostCreateMainMessageLoop() {
|
2022-01-24 18:58:02 +01:00
|
|
|
#if BUILDFLAG(IS_LINUX)
|
2022-01-25 21:26:51 +01:00
|
|
|
const base::CommandLine* command_line =
|
|
|
|
base::CommandLine::ForCurrentProcess();
|
|
|
|
|
|
|
|
// Set up crypt config. This needs to be done before anything starts the
|
|
|
|
// network service, as the raw encryption key needs to be shared with the
|
|
|
|
// network service for encrypted cookie storage.
|
|
|
|
// Based on ChromeBrowserMainPartsLinux::PostCreateMainMessageLoop.
|
|
|
|
std::unique_ptr<os_crypt::Config> config =
|
|
|
|
std::make_unique<os_crypt::Config>();
|
|
|
|
// Forward to os_crypt the flag to use a specific password store.
|
|
|
|
config->store = command_line->GetSwitchValueASCII(switches::kPasswordStore);
|
|
|
|
// Forward the product name (defaults to "Chromium").
|
|
|
|
config->product_name = l10n_util::GetStringUTF8(IDS_PRODUCT_NAME);
|
|
|
|
// OSCrypt can be disabled in a special settings file.
|
|
|
|
config->should_use_preference =
|
|
|
|
command_line->HasSwitch(switches::kEnableEncryptionSelection);
|
|
|
|
base::PathService::Get(chrome::DIR_USER_DATA, &config->user_data_path);
|
|
|
|
DCHECK(!config->user_data_path.empty());
|
|
|
|
OSCrypt::SetConfig(std::move(config));
|
|
|
|
#endif // BUILDFLAG(IS_LINUX)
|
2023-06-06 16:41:53 +02:00
|
|
|
|
|
|
|
#if BUILDFLAG(IS_WIN)
|
|
|
|
base::SetExtraNoExecuteAllowedPath(chrome::DIR_USER_DATA);
|
|
|
|
#endif
|
2013-03-12 21:23:24 +01:00
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
int AlloyBrowserMainParts::PreCreateThreads() {
|
2022-01-24 18:58:02 +01:00
|
|
|
#if BUILDFLAG(IS_WIN)
|
2012-06-28 19:21:18 +02:00
|
|
|
PlatformInitialize();
|
2015-06-12 00:08:33 +02:00
|
|
|
#endif
|
|
|
|
|
2013-06-24 20:57:05 +02:00
|
|
|
net::NetModule::SetResourceProvider(&NetResourceProvider);
|
2012-06-28 19:21:18 +02:00
|
|
|
|
2019-05-02 18:16:44 +02:00
|
|
|
// Initialize these objects before IO access restrictions are applied and
|
2012-06-28 19:21:18 +02:00
|
|
|
// before the IO thread is started.
|
|
|
|
content::GpuDataManager::GetInstance();
|
2019-07-29 23:27:12 +02:00
|
|
|
SystemNetworkContextManager::CreateInstance(g_browser_process->local_state());
|
2012-06-28 19:21:18 +02:00
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-12-05 00:45:54 +01:00
|
|
|
void AlloyBrowserMainParts::PostCreateThreads() {
|
|
|
|
ChromeProcessSingleton::GetInstance()->StartWatching();
|
|
|
|
}
|
|
|
|
|
2021-04-21 00:52:34 +02:00
|
|
|
int AlloyBrowserMainParts::PreMainMessageLoopRun() {
|
2017-09-06 23:40:58 +02:00
|
|
|
#if defined(USE_AURA)
|
2021-06-04 03:34:56 +02:00
|
|
|
screen_ = views::CreateDesktopScreen();
|
2022-06-17 15:28:55 +02:00
|
|
|
#endif
|
|
|
|
#if BUILDFLAG(IS_MAC)
|
|
|
|
screen_ = std::make_unique<display::ScopedNativeScreen>();
|
2017-09-06 23:40:58 +02:00
|
|
|
#endif
|
|
|
|
|
2015-07-16 23:40:01 +02:00
|
|
|
if (extensions::ExtensionsEnabled()) {
|
2022-01-28 22:16:29 +01:00
|
|
|
// This should be set in ChromeBrowserProcessAlloy::Initialize.
|
|
|
|
DCHECK(extensions::ExtensionsBrowserClient::Get());
|
2015-07-16 23:40:01 +02:00
|
|
|
// Initialize extension global objects before creating the global
|
|
|
|
// BrowserContext.
|
|
|
|
extensions::CefExtensionSystemFactory::GetInstance();
|
|
|
|
}
|
|
|
|
|
2018-02-02 23:43:33 +01:00
|
|
|
// Register additional KeyedService factories here. See
|
|
|
|
// ChromeBrowserMainExtraPartsProfiles for details.
|
|
|
|
cef::EnsureBrowserContextKeyedServiceFactoriesBuilt();
|
|
|
|
|
2021-04-21 00:52:34 +02:00
|
|
|
background_task_runner_ = base::ThreadPool::CreateSingleThreadTaskRunner(
|
|
|
|
{base::TaskPriority::BEST_EFFORT,
|
2018-03-20 21:15:08 +01:00
|
|
|
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
|
2021-04-21 00:52:34 +02:00
|
|
|
user_visible_task_runner_ = base::ThreadPool::CreateSingleThreadTaskRunner(
|
|
|
|
{base::TaskPriority::USER_VISIBLE,
|
2018-03-20 21:15:08 +01:00
|
|
|
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
|
2021-04-21 00:52:34 +02:00
|
|
|
user_blocking_task_runner_ = base::ThreadPool::CreateSingleThreadTaskRunner(
|
|
|
|
{base::TaskPriority::USER_BLOCKING,
|
2018-03-20 21:15:08 +01:00
|
|
|
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
|
|
|
|
|
2015-03-02 21:25:14 +01:00
|
|
|
CefRequestContextSettings settings;
|
2020-04-23 23:45:04 +02:00
|
|
|
CefContext::Get()->PopulateGlobalRequestContextSettings(&settings);
|
2015-03-02 21:25:14 +01:00
|
|
|
|
2017-05-04 23:53:27 +02:00
|
|
|
// Create the global RequestContext.
|
|
|
|
global_request_context_ =
|
|
|
|
CefRequestContextImpl::CreateGlobalRequestContext(settings);
|
2022-08-23 18:20:45 +02:00
|
|
|
auto browser_context =
|
|
|
|
global_request_context_->GetBrowserContext()->AsBrowserContext();
|
|
|
|
|
|
|
|
CefDevToolsManagerDelegate::StartHttpHandler(browser_context);
|
2015-06-12 00:08:33 +02:00
|
|
|
|
2022-01-24 18:58:02 +01:00
|
|
|
#if BUILDFLAG(IS_WIN)
|
2020-04-16 03:26:27 +02:00
|
|
|
// Windows parental controls calls can be slow, so we do an early init here
|
|
|
|
// that calculates this value off of the UI thread.
|
|
|
|
InitializeWinParentalControls();
|
2022-06-23 12:59:09 +02:00
|
|
|
|
|
|
|
// These methods may call LoadLibrary and could trigger
|
|
|
|
// AssertBlockingAllowed() failures if executed at a later time on the UI
|
|
|
|
// thread.
|
|
|
|
base::IsManagedDevice();
|
|
|
|
base::IsEnterpriseDevice();
|
|
|
|
#endif // BUILDFLAG(IS_WIN)
|
2020-04-14 21:31:00 +02:00
|
|
|
|
2016-11-07 20:14:09 +01:00
|
|
|
scheme::RegisterWebUIControllerFactory();
|
2022-04-15 21:55:23 +02:00
|
|
|
file_dialog_runner::RegisterFactory();
|
2022-07-07 12:01:24 +02:00
|
|
|
permission_prompt::RegisterCreateCallback();
|
2021-04-21 00:52:34 +02:00
|
|
|
|
2023-02-22 23:10:25 +01:00
|
|
|
// Initialize theme configuration (high contrast, dark mode, etc).
|
|
|
|
ui::NativeTheme::GetInstanceForNativeUi();
|
|
|
|
|
2021-08-10 18:05:10 +02:00
|
|
|
#if BUILDFLAG(ENABLE_MEDIA_FOUNDATION_WIDEVINE_CDM) || \
|
|
|
|
BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT)
|
2021-08-09 23:18:43 +02:00
|
|
|
const base::CommandLine* command_line =
|
|
|
|
base::CommandLine::ForCurrentProcess();
|
|
|
|
if (!command_line->HasSwitch(switches::kDisableComponentUpdate)) {
|
|
|
|
auto* const cus = g_browser_process->component_updater();
|
|
|
|
|
|
|
|
#if BUILDFLAG(ENABLE_MEDIA_FOUNDATION_WIDEVINE_CDM)
|
|
|
|
RegisterMediaFoundationWidevineCdmComponent(cus);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT)
|
|
|
|
RegisterWidevineCdmComponent(cus);
|
|
|
|
#endif
|
|
|
|
}
|
2021-08-10 18:05:10 +02:00
|
|
|
#endif
|
2021-08-09 23:18:43 +02:00
|
|
|
|
2023-12-05 00:45:54 +01:00
|
|
|
// Allow ProcessSingleton to process messages.
|
|
|
|
// This is done here instead of just relying on the main message loop's start
|
|
|
|
// to avoid rendezvous in RunLoops that may precede MainMessageLoopRun.
|
|
|
|
ChromeProcessSingleton::GetInstance()->Unlock(
|
|
|
|
base::BindRepeating(&ProcessSingletonNotificationCallback));
|
|
|
|
|
2021-04-21 00:52:34 +02:00
|
|
|
return content::RESULT_CODE_NORMAL_EXIT;
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
void AlloyBrowserMainParts::PostMainMessageLoopRun() {
|
2016-10-17 20:14:44 +02:00
|
|
|
// NOTE: Destroy objects in reverse order of creation.
|
|
|
|
CefDevToolsManagerDelegate::StopHttpHandler();
|
|
|
|
|
2023-12-05 00:45:54 +01:00
|
|
|
ChromeProcessSingleton::GetInstance()->Cleanup();
|
|
|
|
|
2017-08-04 00:55:19 +02:00
|
|
|
// There should be no additional references to the global CefRequestContext
|
|
|
|
// during shutdown. Did you forget to release a CefBrowser reference?
|
|
|
|
DCHECK(global_request_context_->HasOneRef());
|
2020-01-15 14:36:24 +01:00
|
|
|
global_request_context_ = nullptr;
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
void AlloyBrowserMainParts::PostDestroyThreads() {
|
2019-10-15 13:11:59 +02:00
|
|
|
views_delegate_.reset();
|
2022-01-24 18:58:02 +01:00
|
|
|
#if BUILDFLAG(IS_MAC)
|
2019-10-15 13:11:59 +02:00
|
|
|
layout_provider_.reset();
|
2013-12-07 02:55:22 +01:00
|
|
|
#endif
|
2013-09-03 18:43:31 +02:00
|
|
|
}
|