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

Unified Diff: chrome/browser/chromeos/login/login_utils.cc

Issue 5976005: show notification on locale change (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment Created 9 years, 11 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
Index: chrome/browser/chromeos/login/login_utils.cc
diff --git a/chrome/browser/chromeos/login/login_utils.cc b/chrome/browser/chromeos/login/login_utils.cc
index 708f2e4ba98b9ca6235ca34bf02197bcad872a6c..7eb48ba3bdebdf80688058ff4b3d50ad3a6a9b6b 100644
--- a/chrome/browser/chromeos/login/login_utils.cc
+++ b/chrome/browser/chromeos/login/login_utils.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -329,26 +329,53 @@ void LoginUtilsImpl::FetchTokens(
}
}
-void LoginUtilsImpl::RespectLocalePreference(PrefService* pref) {
- std::string pref_locale = pref->GetString(prefs::kApplicationLocale);
- if (pref_locale.empty()) {
- // Profile synchronization takes time and is not completed at that moment
- // at first login. So we initialize locale preference in steps:
- // (1) first save it to temporary backup;
- // (2) on next login we assume that synchronization is already completed
- // and we may finalize initialization.
- std::string pref_locale_backup =
- pref->GetString(prefs::kApplicationLocaleBackup);
- if (pref_locale_backup.empty()) {
- pref->SetString(prefs::kApplicationLocaleBackup,
- g_browser_process->GetApplicationLocale());
- return;
+void LoginUtilsImpl::RespectLocalePreference(PrefService* prefs) {
+ DCHECK(prefs != NULL);
+ std::string pref_locale_override =
+ prefs->GetString(prefs::kApplicationLocaleOverride);
+ if (!pref_locale_override.empty()) {
+ LanguageSwitchMenu::SwitchLanguage(pref_locale_override);
+ return;
+ }
+
+ if (g_browser_process == NULL)
+ return;
+ std::string cur_locale = g_browser_process->GetApplicationLocale();
+
+ std::string pref_locale = prefs->GetString(prefs::kApplicationLocale);
+ if (!pref_locale.empty()) {
+ if (prefs->GetString(prefs::kApplicationLocaleAccepted) == pref_locale) {
+ // If locale is accepted then we do not want to show LocaleChange
+ // notification. This notification is triggered by different values of
+ // kApplicationLocaleBackup and kApplicationLocale preferences,
+ // so make them identical.
+ prefs->SetString(prefs::kApplicationLocaleBackup, pref_locale);
} else {
- pref_locale.swap(pref_locale_backup);
- pref->SetString(prefs::kApplicationLocale, pref_locale);
+ std::string pref_locale_backup =
+ prefs->GetString(prefs::kApplicationLocaleBackup);
+ if (pref_locale_backup != cur_locale) {
+ if (pref_locale_backup == pref_locale || pref_locale_backup.empty()) {
+ prefs->SetString(prefs::kApplicationLocaleBackup, cur_locale);
+ }
+ }
}
+ LanguageSwitchMenu::SwitchLanguage(pref_locale);
+ return;
+ }
+ // Profile synchronization takes time and is not completed at that moment
+ // at first login. So we initialize locale preference in steps:
+ // (1) first save it to temporary backup;
+ // (2) on next login we assume that synchronization is already completed
+ // and we may finalize initialization.
+ std::string pref_locale_backup =
+ prefs->GetString(prefs::kApplicationLocaleBackup);
+ prefs->SetString(prefs::kApplicationLocaleBackup, cur_locale);
+ prefs->ScheduleSavePersistentPrefs();
+ if (!pref_locale_backup.empty()) {
+ prefs->SetString(prefs::kApplicationLocale, pref_locale_backup);
+ prefs->ScheduleSavePersistentPrefs();
+ LanguageSwitchMenu::SwitchLanguage(pref_locale_backup);
}
- LanguageSwitchMenu::SwitchLanguage(pref_locale);
}
void LoginUtilsImpl::CompleteOffTheRecordLogin(const GURL& start_url) {

Powered by Google App Engine
This is Rietveld 408576698