Remove libcef/features/runtime.h (see #3685)
Use BUILDFLAG(ENABLE_CEF) exclusively in patch files.
This commit is contained in:
parent
0d166c3c90
commit
60ce575e53
1
BUILD.gn
1
BUILD.gn
|
@ -827,7 +827,6 @@ source_set("libcef_static") {
|
|||
"libcef/common/values_impl.h",
|
||||
"libcef/common/waitable_event_impl.cc",
|
||||
"libcef/common/waitable_event_impl.h",
|
||||
"libcef/features/runtime.h",
|
||||
"libcef/renderer/browser_impl.cc",
|
||||
"libcef/renderer/browser_impl.h",
|
||||
"libcef/renderer/chrome/chrome_content_renderer_client_cef.cc",
|
||||
|
|
|
@ -40,8 +40,6 @@
|
|||
|
||||
namespace {
|
||||
|
||||
bool g_initialized = false;
|
||||
|
||||
// Based on components/crash/core/app/run_as_crashpad_handler_win.cc
|
||||
// Remove the "--type=crashpad-handler" command-line flag that will otherwise
|
||||
// confuse the crashpad handler.
|
||||
|
@ -99,7 +97,6 @@ bool CefMainRunner::Initialize(CefSettings* settings,
|
|||
void* windows_sandbox_info,
|
||||
bool* initialized,
|
||||
base::OnceClosure context_initialized) {
|
||||
g_initialized = true;
|
||||
settings_ = settings;
|
||||
application_ = application;
|
||||
|
||||
|
@ -166,8 +163,6 @@ void CefMainRunner::Shutdown(base::OnceClosure shutdown_on_ui_thread,
|
|||
keep_alive_.reset();
|
||||
settings_ = nullptr;
|
||||
application_ = nullptr;
|
||||
|
||||
g_initialized = false;
|
||||
}
|
||||
|
||||
void CefMainRunner::RunMessageLoop() {
|
||||
|
@ -229,8 +224,6 @@ int CefMainRunner::RunAsHelperProcess(const CefMainArgs& args,
|
|||
return -1;
|
||||
}
|
||||
|
||||
g_initialized = true;
|
||||
|
||||
auto main_delegate = std::make_unique<ChromeMainDelegateCef>(
|
||||
/*runner=*/nullptr, /*settings=*/nullptr, application);
|
||||
BeforeMainInitialize(args);
|
||||
|
@ -472,12 +465,3 @@ void CefMainRunner::BeforeUIThreadShutdown() {
|
|||
|
||||
sampling_profiler_.reset();
|
||||
}
|
||||
|
||||
// From libcef/features/runtime.h:
|
||||
namespace cef {
|
||||
|
||||
bool IsChromeRuntimeEnabled() {
|
||||
return g_initialized;
|
||||
}
|
||||
|
||||
} // namespace cef
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#include "base/strings/string_util.h"
|
||||
#include "cef/include/cef_crash_util.h"
|
||||
#include "cef/libcef/common/cef_switches.h"
|
||||
#include "cef/libcef/features/runtime.h"
|
||||
#include "chrome/common/crash_keys.h"
|
||||
#include "components/crash/core/common/crash_key.h"
|
||||
#include "components/crash/core/common/crash_keys.h"
|
||||
|
@ -244,12 +243,3 @@ void CefSetCrashKeyValue(const CefString& key, const CefString& value) {
|
|||
<< " with value: " << value.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
// From libcef/features/runtime.h:
|
||||
namespace cef {
|
||||
|
||||
bool IsCrashReportingEnabled() {
|
||||
return crash_reporting::Enabled();
|
||||
}
|
||||
|
||||
} // namespace cef
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
// Copyright 2020 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_FEATURES_RUNTIME_H_
|
||||
#define CEF_LIBCEF_FEATURES_RUNTIME_H_
|
||||
#pragma once
|
||||
|
||||
#include "cef/libcef/features/features.h"
|
||||
|
||||
namespace cef {
|
||||
|
||||
#if BUILDFLAG(ENABLE_CEF)
|
||||
|
||||
inline bool IsCefBuildEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// True if running as CEF Chrome runtime.
|
||||
bool IsChromeRuntimeEnabled();
|
||||
|
||||
// True if CEF crash reporting is enabled.
|
||||
bool IsCrashReportingEnabled();
|
||||
|
||||
#else // !BUILDFLAG(ENABLE_CEF)
|
||||
|
||||
inline bool IsCefBuildEnabled() {
|
||||
return false;
|
||||
}
|
||||
inline bool IsChromeRuntimeEnabled() {
|
||||
return false;
|
||||
}
|
||||
inline bool IsCrashReportingEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // !BUILDFLAG(ENABLE_CEF)
|
||||
|
||||
} // namespace cef
|
||||
|
||||
#endif // CEF_LIBCEF_FEATURES_RUNTIME_H_
|
|
@ -472,14 +472,14 @@ index 557abfcd71d85..fb64e93157148 100644
|
|||
case TYPE_NORMAL:
|
||||
return NormalBrowserSupportsWindowFeature(feature, check_can_support);
|
||||
diff --git chrome/browser/ui/browser.h chrome/browser/ui/browser.h
|
||||
index 69f2c9c0ff003..3cae24a0e42d2 100644
|
||||
index 69f2c9c0ff003..83d46c6326568 100644
|
||||
--- chrome/browser/ui/browser.h
|
||||
+++ chrome/browser/ui/browser.h
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "base/timer/elapsed_timer.h"
|
||||
#include "build/build_config.h"
|
||||
#include "build/chromeos_buildflags.h"
|
||||
+#include "cef/libcef/features/runtime.h"
|
||||
+#include "cef/libcef/features/features.h"
|
||||
#include "chrome/browser/tab_contents/web_contents_collection.h"
|
||||
#include "chrome/browser/themes/theme_service_observer.h"
|
||||
#include "chrome/browser/ui/bookmarks/bookmark_bar.h"
|
||||
|
|
|
@ -49,14 +49,14 @@ index 2628f1751cd14..cc2c330d8db5d 100644
|
|||
base::BindOnce(&ChromeDownloadManagerDelegate::OnDownloadTargetDetermined,
|
||||
weak_ptr_factory_.GetWeakPtr(), download->GetId(),
|
||||
diff --git chrome/browser/download/chrome_download_manager_delegate.h chrome/browser/download/chrome_download_manager_delegate.h
|
||||
index af7f1d5fac12b..1cb1d01464c11 100644
|
||||
index af7f1d5fac12b..8cd591798ab61 100644
|
||||
--- chrome/browser/download/chrome_download_manager_delegate.h
|
||||
+++ chrome/browser/download/chrome_download_manager_delegate.h
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "base/task/sequenced_task_runner.h"
|
||||
#include "base/unguessable_token.h"
|
||||
#include "build/build_config.h"
|
||||
+#include "cef/libcef/features/runtime.h"
|
||||
+#include "cef/libcef/features/features.h"
|
||||
#include "chrome/browser/download/download_completion_blocker.h"
|
||||
#include "chrome/browser/download/download_target_determiner_delegate.h"
|
||||
#include "components/download/public/common/download_danger_type.h"
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
diff --git chrome/browser/extensions/api/chrome_extensions_api_client.cc chrome/browser/extensions/api/chrome_extensions_api_client.cc
|
||||
index 4007e26f780c3..5f92d74018f9e 100644
|
||||
index 4007e26f780c3..26d0d492cf176 100644
|
||||
--- chrome/browser/extensions/api/chrome_extensions_api_client.cc
|
||||
+++ chrome/browser/extensions/api/chrome_extensions_api_client.cc
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "base/strings/string_util.h"
|
||||
#include "build/build_config.h"
|
||||
#include "build/chromeos_buildflags.h"
|
||||
+#include "cef/libcef/features/runtime.h"
|
||||
+#include "cef/libcef/features/features.h"
|
||||
#include "chrome/browser/extensions/api/automation_internal/chrome_automation_internal_api_delegate.h"
|
||||
#include "chrome/browser/extensions/api/chrome_device_permissions_prompt.h"
|
||||
#include "chrome/browser/extensions/api/declarative_content/chrome_content_rules_registry.h"
|
||||
|
@ -21,18 +21,18 @@ index 4007e26f780c3..5f92d74018f9e 100644
|
|||
#if BUILDFLAG(ENABLE_PRINTING)
|
||||
#include "chrome/browser/printing/printing_init.h"
|
||||
#endif
|
||||
@@ -314,6 +319,11 @@ ChromeExtensionsAPIClient::CreateGuestViewManagerDelegate() const {
|
||||
@@ -314,7 +319,11 @@ ChromeExtensionsAPIClient::CreateGuestViewManagerDelegate() const {
|
||||
std::unique_ptr<MimeHandlerViewGuestDelegate>
|
||||
ChromeExtensionsAPIClient::CreateMimeHandlerViewGuestDelegate(
|
||||
MimeHandlerViewGuest* guest) const {
|
||||
+#if BUILDFLAG(ENABLE_CEF)
|
||||
+ if (cef::IsChromeRuntimeEnabled()) {
|
||||
+ return std::make_unique<ChromeMimeHandlerViewGuestDelegateCef>(guest);
|
||||
+ }
|
||||
+#endif
|
||||
+#else
|
||||
return std::make_unique<ChromeMimeHandlerViewGuestDelegate>();
|
||||
+#endif
|
||||
}
|
||||
|
||||
WebViewGuestDelegate* ChromeExtensionsAPIClient::CreateWebViewGuestDelegate(
|
||||
diff --git chrome/browser/extensions/api/tabs/tabs_api.cc chrome/browser/extensions/api/tabs/tabs_api.cc
|
||||
index 73de5dd73a522..12005b67a6ee9 100644
|
||||
--- chrome/browser/extensions/api/tabs/tabs_api.cc
|
||||
|
|
|
@ -1,26 +1,32 @@
|
|||
diff --git chrome/app/chrome_main_delegate.cc chrome/app/chrome_main_delegate.cc
|
||||
index 2805028bc810c..53154db3326f7 100644
|
||||
index 2805028bc810c..0aef6f992262e 100644
|
||||
--- chrome/app/chrome_main_delegate.cc
|
||||
+++ chrome/app/chrome_main_delegate.cc
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "base/trace_event/trace_event_impl.h"
|
||||
#include "build/build_config.h"
|
||||
#include "build/chromeos_buildflags.h"
|
||||
+#include "cef/libcef/features/runtime.h"
|
||||
+#include "cef/libcef/features/features.h"
|
||||
#include "chrome/browser/buildflags.h"
|
||||
#include "chrome/browser/chrome_content_browser_client.h"
|
||||
#include "chrome/browser/chrome_resource_bundle_helper.h"
|
||||
@@ -610,6 +611,9 @@ struct MainFunction {
|
||||
@@ -608,6 +609,7 @@ struct MainFunction {
|
||||
int (*function)(content::MainFunctionParams);
|
||||
};
|
||||
|
||||
+#if !BUILDFLAG(ENABLE_CEF)
|
||||
// Initializes the user data dir. Must be called before InitializeLocalState().
|
||||
void InitializeUserDataDir(base::CommandLine* command_line) {
|
||||
+ if (cef::IsChromeRuntimeEnabled()) {
|
||||
+ return;
|
||||
+ }
|
||||
#if BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
// In debug builds of Lacros, we keep track of when the user data dir
|
||||
// is initialized, to ensure the cryptohome is not accessed before login
|
||||
@@ -847,6 +851,10 @@ ChromeMainDelegate::~ChromeMainDelegate() {
|
||||
@@ -691,6 +693,7 @@ void InitializeUserDataDir(base::CommandLine* command_line) {
|
||||
command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir);
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
}
|
||||
+#endif // !BUILDFLAG(ENABLE_CEF)
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
// If Lacros was prelaunched at login screen, this method blocks waiting
|
||||
@@ -847,6 +850,10 @@ ChromeMainDelegate::~ChromeMainDelegate() {
|
||||
ChromeMainDelegate::~ChromeMainDelegate() = default;
|
||||
#endif // !BUILDFLAG(IS_ANDROID)
|
||||
|
||||
|
@ -31,7 +37,7 @@ index 2805028bc810c..53154db3326f7 100644
|
|||
std::optional<int> ChromeMainDelegate::PostEarlyInitialization(
|
||||
InvokedIn invoked_in) {
|
||||
DUMP_WILL_BE_CHECK(base::ThreadPoolInstance::Get());
|
||||
@@ -872,7 +880,7 @@ std::optional<int> ChromeMainDelegate::PostEarlyInitialization(
|
||||
@@ -872,7 +879,7 @@ std::optional<int> ChromeMainDelegate::PostEarlyInitialization(
|
||||
// future session's metrics.
|
||||
DeferBrowserMetrics(user_data_dir);
|
||||
|
||||
|
@ -40,7 +46,7 @@ index 2805028bc810c..53154db3326f7 100644
|
|||
// In the case the process is not the singleton process, the uninstall tasks
|
||||
// need to be executed here. A window will be displayed asking to close all
|
||||
// running instances.
|
||||
@@ -1040,7 +1048,8 @@ std::optional<int> ChromeMainDelegate::PostEarlyInitialization(
|
||||
@@ -1040,7 +1047,8 @@ std::optional<int> ChromeMainDelegate::PostEarlyInitialization(
|
||||
|
||||
// Initializes the resource bundle and determines the locale.
|
||||
std::string actual_locale = LoadLocalState(
|
||||
|
@ -50,37 +56,56 @@ index 2805028bc810c..53154db3326f7 100644
|
|||
chrome_feature_list_creator->SetApplicationLocale(actual_locale);
|
||||
chrome_feature_list_creator->OverrideCachedUIStrings();
|
||||
|
||||
@@ -1059,7 +1068,8 @@ std::optional<int> ChromeMainDelegate::PostEarlyInitialization(
|
||||
@@ -1057,6 +1065,8 @@ std::optional<int> ChromeMainDelegate::PostEarlyInitialization(
|
||||
new net::NetworkChangeNotifierFactoryAndroid());
|
||||
#endif
|
||||
|
||||
+#if !BUILDFLAG(ENABLE_CEF)
|
||||
+ // Avoid CEF crash with multi-threaded-message-loop.
|
||||
if (base::FeatureList::IsEnabled(
|
||||
features::kWriteBasicSystemProfileToPersistentHistogramsFile)) {
|
||||
- bool record = true;
|
||||
+ // Avoid CEF crash with multi-threaded-message-loop.
|
||||
+ bool record = !cef::IsChromeRuntimeEnabled();
|
||||
bool record = true;
|
||||
@@ -1067,6 +1077,7 @@ std::optional<int> ChromeMainDelegate::PostEarlyInitialization(
|
||||
if (record)
|
||||
chrome_content_browser_client_->startup_data()->RecordCoreSystemProfile();
|
||||
}
|
||||
+#endif // !BUILDFLAG(ENABLE_CEF)
|
||||
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
record =
|
||||
base::FeatureList::IsEnabled(chrome::android::kUmaBackgroundSessions);
|
||||
@@ -1506,9 +1516,10 @@ void ChromeMainDelegate::PreSandboxStartup() {
|
||||
UmaSessionStats::OnStartup();
|
||||
@@ -1506,6 +1517,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
|
||||
std::string process_type =
|
||||
command_line.GetSwitchValueASCII(switches::kProcessType);
|
||||
|
||||
+ if (!cef::IsChromeRuntimeEnabled()) {
|
||||
+#if !BUILDFLAG(ENABLE_CEF)
|
||||
crash_reporter::InitializeCrashKeys();
|
||||
|
||||
-#if BUILDFLAG(IS_POSIX)
|
||||
+#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(ENABLE_CEF)
|
||||
ChromeCrashReporterClient::Create();
|
||||
#endif
|
||||
|
||||
@@ -1516,6 +1527,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
|
||||
#if BUILDFLAG(IS_POSIX)
|
||||
@@ -1516,6 +1528,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
|
||||
InitMacCrashReporter(command_line, process_type);
|
||||
SetUpInstallerPreferences(command_line);
|
||||
#endif
|
||||
+ } // !cef::IsChromeRuntimeEnabled()
|
||||
+#endif // !BUILDFLAG(ENABLE_CEF)
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
child_process_logging::Init();
|
||||
@@ -1696,7 +1708,8 @@ void ChromeMainDelegate::PreSandboxStartup() {
|
||||
@@ -1527,6 +1540,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
|
||||
base::CPU cpu_info;
|
||||
#endif
|
||||
|
||||
+#if !BUILDFLAG(ENABLE_CEF)
|
||||
// Initialize the user data dir for any process type that needs it.
|
||||
bool initialize_user_data_dir = chrome::ProcessNeedsProfileDir(process_type);
|
||||
#if BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
@@ -1538,6 +1552,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
|
||||
if (initialize_user_data_dir) {
|
||||
InitializeUserDataDir(base::CommandLine::ForCurrentProcess());
|
||||
}
|
||||
+#endif // !BUILDFLAG(ENABLE_CEF)
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
// Generate shared resource file only on browser process. This is to avoid
|
||||
@@ -1696,7 +1711,8 @@ void ChromeMainDelegate::PreSandboxStartup() {
|
||||
#else
|
||||
const std::string loaded_locale =
|
||||
ui::ResourceBundle::InitSharedInstanceWithLocale(
|
||||
|
@ -90,39 +115,39 @@ index 2805028bc810c..53154db3326f7 100644
|
|||
|
||||
base::FilePath resources_pack_path;
|
||||
base::PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path);
|
||||
@@ -1726,6 +1739,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
|
||||
@@ -1726,6 +1742,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
|
||||
CHECK(!loaded_locale.empty()) << "Locale could not be found for " << locale;
|
||||
}
|
||||
|
||||
+ if (!cef::IsChromeRuntimeEnabled()) {
|
||||
+#if !BUILDFLAG(ENABLE_CEF)
|
||||
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
||||
// Zygote needs to call InitCrashReporter() in RunZygote().
|
||||
if (process_type != switches::kZygoteProcess) {
|
||||
@@ -1761,6 +1775,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
|
||||
@@ -1761,6 +1778,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
|
||||
// After all the platform Breakpads have been initialized, store the command
|
||||
// line for crash reporting.
|
||||
crash_keys::SetCrashKeysFromCommandLine(command_line);
|
||||
+ } // !cef::IsChromeRuntimeEnabled()
|
||||
+#endif // !BUILDFLAG(ENABLE_CEF)
|
||||
|
||||
#if BUILDFLAG(ENABLE_PDF)
|
||||
MaybePatchGdiGetFontData();
|
||||
@@ -1888,6 +1903,7 @@ void ChromeMainDelegate::ZygoteForked() {
|
||||
@@ -1888,6 +1906,7 @@ void ChromeMainDelegate::ZygoteForked() {
|
||||
SetUpProfilingShutdownHandler();
|
||||
}
|
||||
|
||||
+ if (!cef::IsChromeRuntimeEnabled()) {
|
||||
+#if !BUILDFLAG(ENABLE_CEF)
|
||||
// Needs to be called after we have chrome::DIR_USER_DATA. BrowserMain sets
|
||||
// this up for the browser process in a different manner.
|
||||
const base::CommandLine* command_line =
|
||||
@@ -1900,6 +1916,7 @@ void ChromeMainDelegate::ZygoteForked() {
|
||||
@@ -1900,6 +1919,7 @@ void ChromeMainDelegate::ZygoteForked() {
|
||||
|
||||
// Reset the command line for the newly spawned process.
|
||||
crash_keys::SetCrashKeysFromCommandLine(*command_line);
|
||||
+ } // !cef::IsChromeRuntimeEnabled()
|
||||
+#endif // !BUILDFLAG(ENABLE_CEF)
|
||||
}
|
||||
|
||||
#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
@@ -2002,6 +2019,7 @@ void ChromeMainDelegate::InitializeMemorySystem() {
|
||||
@@ -2002,6 +2022,7 @@ void ChromeMainDelegate::InitializeMemorySystem() {
|
||||
: memory_system::DispatcherParameters::
|
||||
AllocationTraceRecorderInclusion::kIgnore;
|
||||
|
||||
|
@ -130,7 +155,7 @@ index 2805028bc810c..53154db3326f7 100644
|
|||
memory_system::Initializer()
|
||||
.SetGwpAsanParameters(gwp_asan_boost_sampling, process_type)
|
||||
.SetProfilingClientParameters(chrome::GetChannel(),
|
||||
@@ -2009,5 +2027,5 @@ void ChromeMainDelegate::InitializeMemorySystem() {
|
||||
@@ -2009,5 +2030,5 @@ void ChromeMainDelegate::InitializeMemorySystem() {
|
||||
.SetDispatcherParameters(memory_system::DispatcherParameters::
|
||||
PoissonAllocationSamplerInclusion::kEnforce,
|
||||
allocation_recorder_inclusion, process_type)
|
||||
|
@ -212,14 +237,14 @@ index ac1361bd6bc2e..a303ca169c7f7 100644
|
|||
|
||||
base::PathService::OverrideAndCreateIfNeeded(
|
||||
diff --git chrome/browser/chrome_browser_main.cc chrome/browser/chrome_browser_main.cc
|
||||
index f90f1b8fa54d9..3c1406cc798a7 100644
|
||||
index f90f1b8fa54d9..22fac24f015e1 100644
|
||||
--- chrome/browser/chrome_browser_main.cc
|
||||
+++ chrome/browser/chrome_browser_main.cc
|
||||
@@ -52,6 +52,7 @@
|
||||
#include "build/build_config.h"
|
||||
#include "build/chromeos_buildflags.h"
|
||||
#include "cc/base/switches.h"
|
||||
+#include "cef/libcef/features/runtime.h"
|
||||
+#include "cef/libcef/features/features.h"
|
||||
#include "chrome/browser/about_flags.h"
|
||||
#include "chrome/browser/active_use_util.h"
|
||||
#include "chrome/browser/after_startup_task_utils.h"
|
||||
|
|
Loading…
Reference in New Issue