chrome: Support CefResourceBundleHandler (see #3685)

This commit is contained in:
Marshall Greenblatt
2024-05-03 12:50:23 -04:00
parent 4e3668f93a
commit ca636bb96e
6 changed files with 169 additions and 21 deletions

View File

@ -1,5 +1,5 @@
diff --git chrome/app/chrome_main_delegate.cc chrome/app/chrome_main_delegate.cc
index c09a805c4ed7b..de89b16690593 100644
index c09a805c4ed7b..3db1403d60ed5 100644
--- chrome/app/chrome_main_delegate.cc
+++ chrome/app/chrome_main_delegate.cc
@@ -37,6 +37,7 @@
@ -40,7 +40,17 @@ index c09a805c4ed7b..de89b16690593 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.
@@ -1069,7 +1077,8 @@ std::optional<int> ChromeMainDelegate::PostEarlyInitialization(
@@ -1050,7 +1058,8 @@ std::optional<int> ChromeMainDelegate::PostEarlyInitialization(
// Initializes the resource bundle and determines the locale.
std::string actual_locale = LoadLocalState(
- chrome_feature_list_creator, invoked_in_browser->is_running_test);
+ chrome_feature_list_creator, GetResourceBundleDelegate(),
+ invoked_in_browser->is_running_test);
chrome_feature_list_creator->SetApplicationLocale(actual_locale);
chrome_feature_list_creator->OverrideCachedUIStrings();
@@ -1069,7 +1078,8 @@ std::optional<int> ChromeMainDelegate::PostEarlyInitialization(
if (base::FeatureList::IsEnabled(
features::kWriteBasicSystemProfileToPersistentHistogramsFile)) {
@ -50,7 +60,7 @@ index c09a805c4ed7b..de89b16690593 100644
#if BUILDFLAG(IS_ANDROID)
record =
base::FeatureList::IsEnabled(chrome::android::kUmaBackgroundSessions);
@@ -1505,6 +1514,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
@@ -1505,6 +1515,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
std::string process_type =
command_line.GetSwitchValueASCII(switches::kProcessType);
@ -58,7 +68,7 @@ index c09a805c4ed7b..de89b16690593 100644
crash_reporter::InitializeCrashKeys();
#if BUILDFLAG(IS_CHROMEOS_LACROS)
@@ -1523,6 +1533,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
@@ -1523,6 +1534,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
InitMacCrashReporter(command_line, process_type);
SetUpInstallerPreferences(command_line);
#endif
@ -66,7 +76,17 @@ index c09a805c4ed7b..de89b16690593 100644
#if BUILDFLAG(IS_WIN)
child_process_logging::Init();
@@ -1733,6 +1744,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
@@ -1703,7 +1715,8 @@ void ChromeMainDelegate::PreSandboxStartup() {
#else
const std::string loaded_locale =
ui::ResourceBundle::InitSharedInstanceWithLocale(
- locale, nullptr, ui::ResourceBundle::LOAD_COMMON_RESOURCES);
+ locale, GetResourceBundleDelegate(),
+ ui::ResourceBundle::LOAD_COMMON_RESOURCES);
base::FilePath resources_pack_path;
base::PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path);
@@ -1733,6 +1746,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
CHECK(!loaded_locale.empty()) << "Locale could not be found for " << locale;
}
@ -74,7 +94,7 @@ index c09a805c4ed7b..de89b16690593 100644
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
// Zygote needs to call InitCrashReporter() in RunZygote().
if (process_type != switches::kZygoteProcess) {
@@ -1768,6 +1780,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
@@ -1768,6 +1782,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
// After all the platform Breakpads have been initialized, store the command
// line for crash reporting.
crash_keys::SetCrashKeysFromCommandLine(command_line);
@ -82,7 +102,7 @@ index c09a805c4ed7b..de89b16690593 100644
#if BUILDFLAG(ENABLE_PDF)
MaybePatchGdiGetFontData();
@@ -1893,6 +1906,7 @@ void ChromeMainDelegate::ZygoteForked() {
@@ -1893,6 +1908,7 @@ void ChromeMainDelegate::ZygoteForked() {
SetUpProfilingShutdownHandler();
}
@ -90,7 +110,7 @@ index c09a805c4ed7b..de89b16690593 100644
// 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 =
@@ -1905,6 +1919,7 @@ void ChromeMainDelegate::ZygoteForked() {
@@ -1905,6 +1921,7 @@ void ChromeMainDelegate::ZygoteForked() {
// Reset the command line for the newly spawned process.
crash_keys::SetCrashKeysFromCommandLine(*command_line);
@ -98,7 +118,7 @@ index c09a805c4ed7b..de89b16690593 100644
}
#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
@@ -2001,6 +2016,7 @@ void ChromeMainDelegate::InitializeMemorySystem() {
@@ -2001,6 +2018,7 @@ void ChromeMainDelegate::InitializeMemorySystem() {
const bool is_browser_process = process_type.empty();
const bool gwp_asan_boost_sampling = is_browser_process || IsCanaryDev();
@ -106,7 +126,7 @@ index c09a805c4ed7b..de89b16690593 100644
memory_system::Initializer()
.SetGwpAsanParameters(gwp_asan_boost_sampling, process_type)
.SetProfilingClientParameters(chrome::GetChannel(),
@@ -2010,5 +2026,5 @@ void ChromeMainDelegate::InitializeMemorySystem() {
@@ -2010,5 +2028,5 @@ void ChromeMainDelegate::InitializeMemorySystem() {
memory_system::DispatcherParameters::
AllocationTraceRecorderInclusion::kDynamic,
process_type)
@ -114,10 +134,18 @@ index c09a805c4ed7b..de89b16690593 100644
+ .Initialize(*memory_system_);
}
diff --git chrome/app/chrome_main_delegate.h chrome/app/chrome_main_delegate.h
index 3553377e96017..5207128b768f2 100644
index 3553377e96017..9f6edc70ef1d4 100644
--- chrome/app/chrome_main_delegate.h
+++ chrome/app/chrome_main_delegate.h
@@ -49,6 +49,8 @@ class ChromeMainDelegate : public content::ContentMainDelegate {
@@ -16,6 +16,7 @@
#include "chrome/common/chrome_content_client.h"
#include "components/memory_system/memory_system.h"
#include "content/public/app/content_main_delegate.h"
+#include "ui/base/resource/resource_bundle.h"
namespace base {
class CommandLine;
@@ -49,6 +50,8 @@ class ChromeMainDelegate : public content::ContentMainDelegate {
~ChromeMainDelegate() override;
@ -126,7 +154,17 @@ index 3553377e96017..5207128b768f2 100644
protected:
// content::ContentMainDelegate:
std::optional<int> BasicStartupComplete() override;
@@ -98,7 +100,7 @@ class ChromeMainDelegate : public content::ContentMainDelegate {
@@ -92,13 +95,17 @@ class ChromeMainDelegate : public content::ContentMainDelegate {
void InitializeMemorySystem();
+ virtual ui::ResourceBundle::Delegate* GetResourceBundleDelegate() {
+ return nullptr;
+ }
+
std::unique_ptr<ChromeContentBrowserClient> chrome_content_browser_client_;
std::unique_ptr<ChromeContentUtilityClient> chrome_content_utility_client_;
std::unique_ptr<tracing::TracingSamplerProfiler> tracing_sampler_profiler_;
ChromeContentClient chrome_content_client_;