diff options
author | thomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-19 16:25:04 +0000 |
---|---|---|
committer | thomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-19 16:25:04 +0000 |
commit | 9986ee16343028edb452fe235ac6a8fca5ee12f5 (patch) | |
tree | 8f173eb25a6e7b8d10370e38e8dd60ea5d16da94 /chrome/browser | |
parent | 877161b02f6703bb5694a395de9e8cd4e8a93a3e (diff) | |
download | chromium_src-9986ee16343028edb452fe235ac6a8fca5ee12f5.zip chromium_src-9986ee16343028edb452fe235ac6a8fca5ee12f5.tar.gz chromium_src-9986ee16343028edb452fe235ac6a8fca5ee12f5.tar.bz2 |
Mac language/locale cleanup
- Effectively revert revision 28193 (http://codereview.chromium.org/258037), this makes Mac match the other platform for what at it's core is used for the chrome concept of locale.
- For the ApplicationLanguage, the browser will end up with what Cocoa picks (same as before)
- All other process types will honor the language they got on the command line when starting up.
- When asked the apps language, have the same side effect as Windows and Linux has of pushing the language through to ICU also (so dates format right, etc.)
- During browser startup, if someone passed a language, bail because Mac can't support that.
TEST=The tips on the NTP and the dates on the history page are in the same language at the UI.
BUG=26856
BUG=22727
Review URL: http://codereview.chromium.org/399086
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32515 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/browser_main_mac.mm | 6 | ||||
-rw-r--r-- | chrome/browser/dom_ui/tips_handler.cc | 6 | ||||
-rw-r--r-- | chrome/browser/web_resource/web_resource_service.cc | 21 | ||||
-rw-r--r-- | chrome/browser/web_resource/web_resource_service.h | 3 |
4 files changed, 12 insertions, 24 deletions
diff --git a/chrome/browser/browser_main_mac.mm b/chrome/browser/browser_main_mac.mm index 65b6970..27024f06 100644 --- a/chrome/browser/browser_main_mac.mm +++ b/chrome/browser/browser_main_mac.mm @@ -6,6 +6,8 @@ #import <Cocoa/Cocoa.h> +#include "app/app_switches.h" +#include "app/l10n_util_mac.h" #include "app/resource_bundle.h" #include "base/command_line.h" #include "base/debug_util.h" @@ -39,6 +41,10 @@ void WillInitializeMainMessageLoop(const MainFunctionParams& parameters) { // Now load the nib. [NSBundle loadNibNamed:@"MainMenu" owner:NSApp]; + // The browser process only wants to support the language Cocoa will use, so + // force the app locale to be overriden with that value. + l10n_util::OverrideLocaleWithCocoaLocale(); + // This is a no-op if the KeystoneRegistration framework is not present. // The framework is only distributed with branded Google Chrome builds. [[KeystoneGlue defaultKeystoneGlue] registerWithKeystone]; diff --git a/chrome/browser/dom_ui/tips_handler.cc b/chrome/browser/dom_ui/tips_handler.cc index 68ce766..35d3cc2 100644 --- a/chrome/browser/dom_ui/tips_handler.cc +++ b/chrome/browser/dom_ui/tips_handler.cc @@ -44,9 +44,9 @@ void TipsHandler::HandleGetTips(const Value* content) { PrefService* current_prefs = dom_ui_->GetProfile()->GetPrefs(); if (current_prefs->HasPrefPath(prefs::kNTPTipsServer)) { std::wstring server = current_prefs->GetString(prefs::kNTPTipsServer); - std::wstring tips_language = WebResourceService::GetWebResourceLanguage( - current_prefs); - if (!EndsWith(server, tips_language, false)) { + std::wstring locale = + ASCIIToWide(g_browser_process->GetApplicationLocale()); + if (!EndsWith(server, locale, false)) { dom_ui_->CallJavascriptFunction(L"tips", list_value); return; } diff --git a/chrome/browser/web_resource/web_resource_service.cc b/chrome/browser/web_resource/web_resource_service.cc index c26c8b1..c4ffa47 100644 --- a/chrome/browser/web_resource/web_resource_service.cc +++ b/chrome/browser/web_resource/web_resource_service.cc @@ -211,19 +211,19 @@ void WebResourceService::Init() { resource_dispatcher_host_ = g_browser_process->resource_dispatcher_host(); web_resource_fetcher_ = new WebResourceFetcher(this); prefs_->RegisterStringPref(prefs::kNTPTipsCacheUpdate, L"0"); - std::wstring language = WebResourceService::GetWebResourceLanguage(prefs_); + std::wstring locale = ASCIIToWide(g_browser_process->GetApplicationLocale()); if (prefs_->HasPrefPath(prefs::kNTPTipsServer)) { web_resource_server_ = prefs_->GetString(prefs::kNTPTipsServer); // If we are in the correct locale, initialization is done. - if (EndsWith(web_resource_server_, language, false)) + if (EndsWith(web_resource_server_, locale, false)) return; } // If we have not yet set a server, or if the tips server is set to the wrong // locale, reset the server and force an immediate update of tips. web_resource_server_ = kDefaultResourceServer; - web_resource_server_.append(language); + web_resource_server_.append(locale); prefs_->SetString(prefs::kNTPTipsCacheUpdate, L""); } @@ -302,18 +302,3 @@ void WebResourceService::UpdateResourceCache(const std::string& json_data) { DoubleToWString(base::Time::Now().ToDoubleT())); prefs_->SetString(prefs::kNTPTipsServer, web_resource_server_); } - -// static -std::wstring WebResourceService::GetWebResourceLanguage(PrefService* prefs) { -#if defined OS_MACOSX - // OS X derives the language for the Chrome UI from the list of accepted - // languages, which can be different from the locale. - std::wstring languageList = prefs->GetString(prefs::kAcceptLanguages); - int pos = languageList.find(L","); - pos = pos >= 0 ? pos : languageList.length(); - return languageList.substr(0, pos); -#else - return ASCIIToWide(g_browser_process->GetApplicationLocale()); -#endif -} - diff --git a/chrome/browser/web_resource/web_resource_service.h b/chrome/browser/web_resource/web_resource_service.h index 86abf1a..a125cdc9 100644 --- a/chrome/browser/web_resource/web_resource_service.h +++ b/chrome/browser/web_resource/web_resource_service.h @@ -26,9 +26,6 @@ class WebResourceService // the process that will parse the JSON, and then update the cache. void UpdateResourceCache(const std::string& json_data); - // Get the language appropriate for delivery of the web resources. - static std::wstring GetWebResourceLanguage(PrefService* prefs); - static const wchar_t* kTipDictionaryPrefName; static const wchar_t* kCurrentTipPrefName; static const wchar_t* kTipCachePrefName; |