diff --git a/libcef/common/chrome/chrome_main_delegate_cef.h b/libcef/common/chrome/chrome_main_delegate_cef.h index 323d6a8f5..1ca1abf15 100644 --- a/libcef/common/chrome/chrome_main_delegate_cef.h +++ b/libcef/common/chrome/chrome_main_delegate_cef.h @@ -12,6 +12,7 @@ #include "libcef/common/app_manager.h" #include "libcef/common/chrome/chrome_content_client_cef.h" #include "libcef/common/main_runner_handler.h" +#include "libcef/common/resource_bundle_delegate.h" #include "libcef/common/task_runner_manager.h" #include "chrome/app/chrome_main_delegate.h" @@ -72,6 +73,11 @@ class ChromeMainDelegateCef : public ChromeMainDelegate, scoped_refptr GetRenderTaskRunner() override; scoped_refptr GetWebWorkerTaskRunner() override; + // ChromeMainDelegate overrides. + ui::ResourceBundle::Delegate* GetResourceBundleDelegate() override { + return &resource_bundle_delegate_; + } + private: ChromeContentBrowserClientCef* content_browser_client() const; ChromeContentRendererClientCef* content_renderer_client() const; @@ -82,6 +88,8 @@ class ChromeMainDelegateCef : public ChromeMainDelegate, // We use this instead of ChromeMainDelegate::chrome_content_client_. ChromeContentClientCef chrome_content_client_cef_; + + CefResourceBundleDelegate resource_bundle_delegate_; }; #endif // CEF_LIBCEF_COMMON_CHROME_CHROME_MAIN_DELEGATE_CEF_ diff --git a/libcef/common/resource_bundle_delegate.cc b/libcef/common/resource_bundle_delegate.cc index 31015e7aa..5cf69aa34 100644 --- a/libcef/common/resource_bundle_delegate.cc +++ b/libcef/common/resource_bundle_delegate.cc @@ -1,6 +1,14 @@ #include "libcef/common/resource_bundle_delegate.h" #include "libcef/common/app_manager.h" +#include "libcef/features/runtime.h" + +CefResourceBundleDelegate::CefResourceBundleDelegate() { + // Alloy bootstrap explicitly enables pack file loading in + // AlloyMainDelegate::InitializeResourceBundle, and it is otherwise disabled + // by default. Chrome bootstrap does not support this. + allow_pack_file_load_ = cef::IsChromeRuntimeEnabled(); +} base::FilePath CefResourceBundleDelegate::GetPathForResourcePack( const base::FilePath& pack_path, diff --git a/libcef/common/resource_bundle_delegate.h b/libcef/common/resource_bundle_delegate.h index c66e38534..3a64610e4 100644 --- a/libcef/common/resource_bundle_delegate.h +++ b/libcef/common/resource_bundle_delegate.h @@ -7,13 +7,16 @@ #define CEF_LIBCEF_COMMON_RESOURCE_BUNDLE_DELEGATE_H_ #pragma once +#include "cef/libcef/features/features.h" #include "ui/base/resource/resource_bundle.h" -class AlloyContentClient; - class CefResourceBundleDelegate : public ui::ResourceBundle::Delegate { public: - CefResourceBundleDelegate() = default; + CefResourceBundleDelegate(); + + CefResourceBundleDelegate(const CefResourceBundleDelegate&) = delete; + CefResourceBundleDelegate& operator=(const CefResourceBundleDelegate&) = + delete; void set_pack_loading_disabled(bool val) { pack_loading_disabled_ = val; } bool pack_loading_disabled() const { return pack_loading_disabled_; } @@ -40,7 +43,7 @@ class CefResourceBundleDelegate : public ui::ResourceBundle::Delegate { private: bool pack_loading_disabled_ = false; - bool allow_pack_file_load_ = false; + bool allow_pack_file_load_; }; #endif // CEF_LIBCEF_COMMON_RESOURCE_BUNDLE_DELEGATE_H_ diff --git a/patch/patch.cfg b/patch/patch.cfg index 31c111342..8a7f939e7 100644 --- a/patch/patch.cfg +++ b/patch/patch.cfg @@ -223,6 +223,9 @@ patches = [ # # Apply dynamic light/dark theme changes to web content. # https://issues.chromium.org/issues/332328864#comment3 + # + # Pass ui::ResourceBundle::Delegate to InitSharedInstanceWithLocale. + # https://github.com/chromiumembedded/cef/issues/3685 'name': 'chrome_runtime', }, { @@ -741,6 +744,9 @@ patches = [ # # mac: Add fallback for unsupported --lang values. # https://github.com/chromiumembedded/cef/issues/3653 + # + # Pass ui::ResourceBundle::Delegate to InitSharedInstanceWithLocale. + # https://github.com/chromiumembedded/cef/issues/3685 'name': 'mac_chrome_locale_3623' }, { diff --git a/patch/patches/chrome_runtime.patch b/patch/patches/chrome_runtime.patch index aac31f6ee..813c319f5 100644 --- a/patch/patches/chrome_runtime.patch +++ b/patch/patches/chrome_runtime.patch @@ -1,5 +1,5 @@ diff --git chrome/app/chrome_main_delegate.cc chrome/app/chrome_main_delegate.cc -index 363f485ce3564..0afa082daf7e7 100644 +index 363f485ce3564..91aa4ec8b2689 100644 --- chrome/app/chrome_main_delegate.cc +++ chrome/app/chrome_main_delegate.cc @@ -37,6 +37,7 @@ @@ -40,7 +40,17 @@ index 363f485ce3564..0afa082daf7e7 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. -@@ -1062,7 +1070,8 @@ std::optional ChromeMainDelegate::PostEarlyInitialization( +@@ -1043,7 +1051,8 @@ std::optional 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(); + +@@ -1062,7 +1071,8 @@ std::optional ChromeMainDelegate::PostEarlyInitialization( if (base::FeatureList::IsEnabled( features::kWriteBasicSystemProfileToPersistentHistogramsFile)) { @@ -50,7 +60,7 @@ index 363f485ce3564..0afa082daf7e7 100644 #if BUILDFLAG(IS_ANDROID) record = base::FeatureList::IsEnabled(chrome::android::kUmaBackgroundSessions); -@@ -1507,6 +1516,7 @@ void ChromeMainDelegate::PreSandboxStartup() { +@@ -1507,6 +1517,7 @@ void ChromeMainDelegate::PreSandboxStartup() { std::string process_type = command_line.GetSwitchValueASCII(switches::kProcessType); @@ -58,7 +68,7 @@ index 363f485ce3564..0afa082daf7e7 100644 crash_reporter::InitializeCrashKeys(); #if BUILDFLAG(IS_CHROMEOS_LACROS) -@@ -1525,6 +1535,7 @@ void ChromeMainDelegate::PreSandboxStartup() { +@@ -1525,6 +1536,7 @@ void ChromeMainDelegate::PreSandboxStartup() { InitMacCrashReporter(command_line, process_type); SetUpInstallerPreferences(command_line); #endif @@ -66,7 +76,17 @@ index 363f485ce3564..0afa082daf7e7 100644 #if BUILDFLAG(IS_WIN) child_process_logging::Init(); -@@ -1735,6 +1746,7 @@ void ChromeMainDelegate::PreSandboxStartup() { +@@ -1705,7 +1717,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); +@@ -1735,6 +1748,7 @@ void ChromeMainDelegate::PreSandboxStartup() { CHECK(!loaded_locale.empty()) << "Locale could not be found for " << locale; } @@ -74,7 +94,7 @@ index 363f485ce3564..0afa082daf7e7 100644 #if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) // Zygote needs to call InitCrashReporter() in RunZygote(). if (process_type != switches::kZygoteProcess) { -@@ -1770,6 +1782,7 @@ void ChromeMainDelegate::PreSandboxStartup() { +@@ -1770,6 +1784,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 363f485ce3564..0afa082daf7e7 100644 #if BUILDFLAG(ENABLE_PDF) MaybePatchGdiGetFontData(); -@@ -1895,6 +1908,7 @@ void ChromeMainDelegate::ZygoteForked() { +@@ -1895,6 +1910,7 @@ void ChromeMainDelegate::ZygoteForked() { SetUpProfilingShutdownHandler(); } @@ -90,7 +110,7 @@ index 363f485ce3564..0afa082daf7e7 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 = -@@ -1907,6 +1921,7 @@ void ChromeMainDelegate::ZygoteForked() { +@@ -1907,6 +1923,7 @@ void ChromeMainDelegate::ZygoteForked() { // Reset the command line for the newly spawned process. crash_keys::SetCrashKeysFromCommandLine(*command_line); @@ -98,7 +118,7 @@ index 363f485ce3564..0afa082daf7e7 100644 } #endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) -@@ -2003,6 +2018,7 @@ void ChromeMainDelegate::InitializeMemorySystem() { +@@ -2003,6 +2020,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 363f485ce3564..0afa082daf7e7 100644 memory_system::Initializer() .SetGwpAsanParameters(gwp_asan_boost_sampling, process_type) .SetProfilingClientParameters(chrome::GetChannel(), -@@ -2012,5 +2028,5 @@ void ChromeMainDelegate::InitializeMemorySystem() { +@@ -2012,5 +2030,5 @@ void ChromeMainDelegate::InitializeMemorySystem() { memory_system::DispatcherParameters:: AllocationTraceRecorderInclusion::kDynamic, process_type) @@ -114,10 +134,18 @@ index 363f485ce3564..0afa082daf7e7 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 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 chrome_content_browser_client_; + std::unique_ptr chrome_content_utility_client_; + std::unique_ptr tracing_sampler_profiler_; ChromeContentClient chrome_content_client_; diff --git a/patch/patches/mac_chrome_locale_3623.patch b/patch/patches/mac_chrome_locale_3623.patch index b05ee81a5..fd742e3fe 100644 --- a/patch/patches/mac_chrome_locale_3623.patch +++ b/patch/patches/mac_chrome_locale_3623.patch @@ -1,8 +1,21 @@ diff --git chrome/browser/chrome_resource_bundle_helper.cc chrome/browser/chrome_resource_bundle_helper.cc -index 0cfc966050b60..8268a8b1f4fcb 100644 +index 0cfc966050b60..bbc20cffaee1a 100644 --- chrome/browser/chrome_resource_bundle_helper.cc +++ chrome/browser/chrome_resource_bundle_helper.cc -@@ -82,16 +82,8 @@ std::string InitResourceBundleAndDetermineLocale(PrefService* local_state, +@@ -68,8 +68,10 @@ extern void InitializeLocalState( + + // Initializes the shared instance of ResourceBundle and returns the application + // locale. An empty |actual_locale| value indicates failure. +-std::string InitResourceBundleAndDetermineLocale(PrefService* local_state, +- bool is_running_tests) { ++std::string InitResourceBundleAndDetermineLocale( ++ PrefService* local_state, ++ ui::ResourceBundle::Delegate* resource_bundle_delegate, ++ bool is_running_tests) { + #if BUILDFLAG(IS_ANDROID) + // In order for SetLoadSecondaryLocalePaks() to work ResourceBundle must + // not have been created yet. +@@ -82,16 +84,8 @@ std::string InitResourceBundleAndDetermineLocale(PrefService* local_state, .empty()); #endif @@ -20,6 +33,52 @@ index 0cfc966050b60..8268a8b1f4fcb 100644 #if BUILDFLAG(IS_CHROMEOS_ASH) ui::ResourceBundle::SetLottieParsingFunctions( +@@ -103,7 +97,8 @@ std::string InitResourceBundleAndDetermineLocale(PrefService* local_state, + // On a POSIX OS other than ChromeOS, the parameter that is passed to the + // method InitSharedInstance is ignored. + std::string actual_locale = ui::ResourceBundle::InitSharedInstanceWithLocale( +- preferred_locale, nullptr, ui::ResourceBundle::LOAD_COMMON_RESOURCES); ++ preferred_locale, resource_bundle_delegate, ++ ui::ResourceBundle::LOAD_COMMON_RESOURCES); + CHECK(!actual_locale.empty()) + << "Locale could not be found for " << preferred_locale; + +@@ -155,6 +150,7 @@ std::string InitResourceBundleAndDetermineLocale(PrefService* local_state, + + std::string LoadLocalState( + ChromeFeatureListCreator* chrome_feature_list_creator, ++ ui::ResourceBundle::Delegate* resource_bundle_delegate, + bool is_running_tests) { + base::FilePath user_data_dir; + if (!base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) +@@ -166,5 +162,6 @@ std::string LoadLocalState( + new ChromeCommandLinePrefStore(base::CommandLine::ForCurrentProcess())); + + return InitResourceBundleAndDetermineLocale( +- chrome_feature_list_creator->local_state(), is_running_tests); ++ chrome_feature_list_creator->local_state(), resource_bundle_delegate, ++ is_running_tests); + } +diff --git chrome/browser/chrome_resource_bundle_helper.h chrome/browser/chrome_resource_bundle_helper.h +index 0b22e445bc3ff..1d7c6b319ba4b 100644 +--- chrome/browser/chrome_resource_bundle_helper.h ++++ chrome/browser/chrome_resource_bundle_helper.h +@@ -7,12 +7,15 @@ + + #include + ++#include "ui/base/resource/resource_bundle.h" ++ + class ChromeFeatureListCreator; + + // Loads the local state, and returns the application locale. An empty return + // value indicates the ResouceBundle couldn't be loaded. + std::string LoadLocalState( + ChromeFeatureListCreator* chrome_feature_list_creator, ++ ui::ResourceBundle::Delegate* resource_bundle_delegate, + bool is_running_tests); + + #endif // CHROME_BROWSER_CHROME_RESOURCE_BUNDLE_HELPER_H_ diff --git components/language/core/browser/locale_util.cc components/language/core/browser/locale_util.cc index aa43742055b04..e84f21ab963cc 100644 --- components/language/core/browser/locale_util.cc