summaryrefslogtreecommitdiffstats
path: root/chrome/browser/web_resource
diff options
context:
space:
mode:
authormirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-07 00:00:12 +0000
committermirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-07 00:00:12 +0000
commit6401e9a9d7552331beac22aca0dfa69532ea4b38 (patch)
tree25d717b46b6895178ab9a2acacdfdca513368ca1 /chrome/browser/web_resource
parent7dbcfc1c4bd26dacd41130910d8cc2b5a1375b49 (diff)
downloadchromium_src-6401e9a9d7552331beac22aca0dfa69532ea4b38.zip
chromium_src-6401e9a9d7552331beac22aca0dfa69532ea4b38.tar.gz
chromium_src-6401e9a9d7552331beac22aca0dfa69532ea4b38.tar.bz2
Fix tips in OS X to respect system language settings instead of locale.
BUG= http://crbug.com/22727 TEST= Set preferred language to a different setting from the locale in the OS X system settings. Make sure that the language of the tips matches the language setting (which should be the same as that of the Chrome UI). If tips are not available in the Chrome UI language, no tips should be shown. Review URL: http://codereview.chromium.org/258037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28193 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/web_resource')
-rw-r--r--chrome/browser/web_resource/web_resource_service.cc21
-rw-r--r--chrome/browser/web_resource/web_resource_service.h3
2 files changed, 21 insertions, 3 deletions
diff --git a/chrome/browser/web_resource/web_resource_service.cc b/chrome/browser/web_resource/web_resource_service.cc
index f401807..b056822 100644
--- a/chrome/browser/web_resource/web_resource_service.cc
+++ b/chrome/browser/web_resource/web_resource_service.cc
@@ -205,19 +205,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 locale = ASCIIToWide(g_browser_process->GetApplicationLocale());
+ std::wstring language = WebResourceService::GetWebResourceLanguage(prefs_);
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_, locale, false))
+ if (EndsWith(web_resource_server_, language, 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(locale);
+ web_resource_server_.append(language);
prefs_->SetString(prefs::kNTPTipsCacheUpdate, L"");
}
@@ -296,3 +296,18 @@ 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 caf9d90..41f75f1 100644
--- a/chrome/browser/web_resource/web_resource_service.h
+++ b/chrome/browser/web_resource/web_resource_service.h
@@ -28,6 +28,9 @@ 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;