cef/patch/patches/mac_chrome_locale_3623.patch

147 lines
6.1 KiB
Diff

diff --git chrome/browser/chrome_resource_bundle_helper.cc chrome/browser/chrome_resource_bundle_helper.cc
index 0cfc966050b60..bbc20cffaee1a 100644
--- chrome/browser/chrome_resource_bundle_helper.cc
+++ chrome/browser/chrome_resource_bundle_helper.cc
@@ -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
- std::string preferred_locale;
-#if BUILDFLAG(IS_MAC)
- // TODO(markusheintz): Read preference pref::kApplicationLocale in order
- // to enforce the application locale.
- // Tests always get en-US.
- preferred_locale = is_running_tests ? "en-US" : std::string();
-#else
- preferred_locale =
+ std::string preferred_locale =
local_state->GetString(language::prefs::kApplicationLocale);
-#endif
#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 <string>
+#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
+++ components/language/core/browser/locale_util.cc
@@ -17,11 +17,11 @@ std::string GetApplicationLocale(PrefService* local_state) {
// LoadLocaleResources(), which is how the global locale is set.
// TODO(asvitkine): We should try to refactor things so that the logic is not
// duplicated in multiple files.
-#if !BUILDFLAG(IS_APPLE)
+
// The pref isn't always registered in unit tests.
if (local_state->HasPrefPath(prefs::kApplicationLocale))
preferred_locale = local_state->GetString(prefs::kApplicationLocale);
-#endif
+
// Note: The call below is necessary even if |preferred_locale| is empty, as
// it will get the locale that should be used potentially from other sources,
// depending on the platform (e.g. the OS locale on Mac).
diff --git ui/base/l10n/l10n_util.cc ui/base/l10n/l10n_util.cc
index efb5dd2cfe061..965106e026fa3 100644
--- ui/base/l10n/l10n_util.cc
+++ ui/base/l10n/l10n_util.cc
@@ -501,25 +501,7 @@ bool CheckAndResolveLocale(const std::string& locale,
return CheckAndResolveLocale(locale, resolved_locale, /*perform_io=*/true);
}
-#if BUILDFLAG(IS_APPLE)
-std::string GetApplicationLocaleInternalMac(const std::string& pref_locale) {
- // Use any override (Cocoa for the browser), otherwise use the preference
- // passed to the function.
- std::string app_locale = l10n_util::GetLocaleOverride();
- if (app_locale.empty())
- app_locale = pref_locale;
-
- // The above should handle all of the cases Chrome normally hits, but for some
- // unit tests, we need something to fall back too.
- if (app_locale.empty())
- app_locale = "en-US";
-
- return app_locale;
-}
-#endif
-
-#if !BUILDFLAG(IS_APPLE)
-std::string GetApplicationLocaleInternalNonMac(const std::string& pref_locale) {
+std::string GetApplicationLocaleInternal(const std::string& pref_locale) {
std::string resolved_locale;
std::vector<std::string> candidates;
@@ -584,15 +566,6 @@ std::string GetApplicationLocaleInternalNonMac(const std::string& pref_locale) {
return std::string();
}
-#endif // !BUILDFLAG(IS_APPLE)
-
-std::string GetApplicationLocaleInternal(const std::string& pref_locale) {
-#if BUILDFLAG(IS_APPLE)
- return GetApplicationLocaleInternalMac(pref_locale);
-#else
- return GetApplicationLocaleInternalNonMac(pref_locale);
-#endif
-}
std::string GetApplicationLocale(const std::string& pref_locale,
bool set_icu_locale) {