Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6470)

Unified Diff: chrome/browser/ui/webui/about_ui.cc

Issue 14990003: CrOS online EULA: support localization, change timeout (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Nits, added Hebrew mapping Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/app/chromeos_strings.grdp ('k') | chrome/common/url_constants.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/about_ui.cc
diff --git a/chrome/browser/ui/webui/about_ui.cc b/chrome/browser/ui/webui/about_ui.cc
index 5e5c545e8c504c1cc0b0534a60aeb15705d5ddd7..50a597dc3363671a9d00403bdf7ff9024ea5f621 100644
--- a/chrome/browser/ui/webui/about_ui.cc
+++ b/chrome/browser/ui/webui/about_ui.cc
@@ -103,7 +103,7 @@ const char kMemoryCssPath[] = "about_memory.css";
const char kStatsJsPath[] = "stats.js";
const char kStringsJsPath[] = "strings.js";
// chrome://terms falls back to offline page after kOnlineTermsTimeoutSec.
-const int kOnlineTermsTimeoutSec = 10;
+const int kOnlineTermsTimeoutSec = 7;
// When you type about:memory, it actually loads this intermediate URL that
// redirects you to the final page. This avoids the problem where typing
@@ -145,18 +145,56 @@ class AboutMemoryHandler : public MemoryDetails {
};
#if defined(OS_CHROMEOS)
+
+// Contains pairs of corresponding locales for Chrome and Google URLs.
+struct Chrome2GoogleLocaleMapping {
+ const char* chrome_locale;
+ const char* google_locale;
+};
+
+// List of locales constant which are different for Google URL
+const Chrome2GoogleLocaleMapping locale_mapping[] = {
Evan Stade 2013/05/06 18:06:05 When I launch (desktop) Chrome in a foreign locale
Nikita (slow) 2013/05/06 18:10:15 Evan, per my understanding it seems to be that thi
+ {"de-AT", "de"},
+ {"de-CH", "de"},
+ {"de-DE", "de"},
+ {"en-GB", "en_uk"},
+ {"fr-CA", "fr"},
+ {"fr-CH", "fr"},
+ {"fr-FR", "fr"},
+ {"he", "iw"},
+ {"it-CH", "it"},
+ {"it-IT", "it"}
+};
+
+// Returns server side locale if it's different from the Chrome one.
+// Otherwise, returns NULL.
+const char* TranslateChromeLangToGoogle(const char* chrome_locale) {
+ for (std::size_t i = 0; i < arraysize(locale_mapping); ++i) {
+ if (LowerCaseEqualsASCII(chrome_locale,
+ locale_mapping[i].chrome_locale)) {
+ return locale_mapping[i].google_locale;
+ }
+ }
+ return NULL;
+}
+
// Helper class that fetches the online Chrome OS terms. Empty string is
// returned once fetching failed or exceeded |kOnlineTermsTimeoutSec|.
class ChromeOSOnlineTermsHandler : public net::URLFetcherDelegate {
public:
typedef base::Callback<void (ChromeOSOnlineTermsHandler*)> FetchCallback;
- explicit ChromeOSOnlineTermsHandler(const FetchCallback& callback)
+ explicit ChromeOSOnlineTermsHandler(const FetchCallback& callback,
+ const std::string& locale)
: fetch_callback_(callback) {
- eula_fetcher_.reset(net::URLFetcher::Create(
- GURL(l10n_util::GetStringUTF16(IDS_EULA_POLICY_URL)),
- net::URLFetcher::GET,
- this));
+ const char* google_lang = TranslateChromeLangToGoogle(locale.c_str());
+ if (!google_lang)
+ google_lang = locale.c_str();
+ std::string eula_URL = base::StringPrintf(chrome::kOnlineEulaURLPath,
+ google_lang);
+ eula_fetcher_.reset(net::URLFetcher::Create(GURL(eula_URL),
+ net::URLFetcher::GET,
+ this));
eula_fetcher_->SetRequestContext(
g_browser_process->system_request_context());
eula_fetcher_->AddExtraRequestHeader("Accept: text/html");
@@ -257,7 +295,8 @@ class ChromeOSTermsHandler
// Try to load online version of ChromeOS terms first.
// ChromeOSOnlineTermsHandler object destroys itself.
new ChromeOSOnlineTermsHandler(
- base::Bind(&ChromeOSTermsHandler::OnOnlineEULAFetched, this));
+ base::Bind(&ChromeOSTermsHandler::OnOnlineEULAFetched, this),
+ locale_);
}
}
« no previous file with comments | « chrome/app/chromeos_strings.grdp ('k') | chrome/common/url_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698