Index: ui/base/l10n/l10n_util.cc |
diff --git a/ui/base/l10n/l10n_util.cc b/ui/base/l10n/l10n_util.cc |
index 55c4d04c393dfb55068134d728c5b6a790d4574b..54b2848f82ef7e1e9284cb16abc9a716c1ddbfbe 100644 |
--- a/ui/base/l10n/l10n_util.cc |
+++ b/ui/base/l10n/l10n_util.cc |
@@ -311,6 +311,11 @@ std::string GetCanonicalLocale(const std::string& locale) { |
return base::i18n::GetCanonicalLocale(locale.c_str()); |
} |
+std::string GetLanguage(const std::string& locale) { |
+ const std::string::size_type hyphen_pos = locale.find('-'); |
+ return std::string(locale, 0, hyphen_pos); |
+} |
+ |
bool CheckAndResolveLocale(const std::string& locale, |
std::string* resolved_locale) { |
#if defined(OS_MACOSX) |
@@ -334,10 +339,9 @@ bool CheckAndResolveLocale(const std::string& locale, |
// does not support but available on Windows. We fall |
// back to en-US in GetApplicationLocale so that it's a not critical, |
// but we can do better. |
- std::string::size_type hyphen_pos = locale.find('-'); |
- std::string lang(locale, 0, hyphen_pos); |
- if (hyphen_pos != std::string::npos && hyphen_pos > 0) { |
- std::string region(locale, hyphen_pos + 1); |
+ const std::string lang(GetLanguage(locale)); |
+ if (lang.size() < locale.size()) { |
+ std::string region(locale, lang.size() + 1); |
std::string tmp_locale(lang); |
// Map es-RR other than es-ES to es-419 (Chrome's Latin American |
// Spanish locale). |
@@ -877,4 +881,12 @@ int GetLocalizedContentsWidthInPixels(int pixel_resource_id) { |
return width; |
} |
+const char* const* GetAcceptLanguageListForTesting() { |
+ return kAcceptLanguageList; |
+} |
+ |
+size_t GetAcceptLanguageListSizeForTesting() { |
+ return arraysize(kAcceptLanguageList); |
+} |
+ |
} // namespace l10n_util |