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

Unified Diff: chrome/browser/profiles/profile_impl.cc

Issue 6248017: Do not use local override for language settings: always sync. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: bs removed 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
« no previous file with comments | « chrome/browser/profiles/profile_impl.h ('k') | chrome/browser/sync/glue/preference_model_associator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profiles/profile_impl.cc
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index e0d342941cbdf49c93f320fd970f1d3610e040e9..67191443fc325f1d2e21113d6b31aca32eac2adb 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -1366,28 +1366,75 @@ PromoCounter* ProfileImpl::GetInstantPromoCounter() {
}
#if defined(OS_CHROMEOS)
-void ProfileImpl::ChangeApplicationLocale(
- const std::string& locale, bool keep_local) {
- if (locale.empty()) {
+void ProfileImpl::ChangeAppLocale(
+ const std::string& new_locale, AppLocaleChangedVia via) {
+ if (new_locale.empty()) {
NOTREACHED();
return;
}
- if (keep_local) {
- GetPrefs()->SetString(prefs::kApplicationLocaleOverride, locale);
- } else {
- GetPrefs()->SetString(prefs::kApplicationLocale, locale);
- GetPrefs()->ClearPref(prefs::kApplicationLocaleOverride);
+ std::string pref_locale = GetPrefs()->GetString(prefs::kApplicationLocale);
+ bool do_update_pref = true;
+ switch (via) {
+ case APP_LOCALE_CHANGED_VIA_SETTINGS:
+ case APP_LOCALE_CHANGED_VIA_REVERT: {
+ // We keep kApplicationLocaleBackup value as a reference. In case value
+ // of kApplicationLocale preference would change due to sync from other
+ // device then kApplicationLocaleBackup value will trigger and allow us to
+ // show notification about automatic locale change in LocaleChangeGuard.
+ GetPrefs()->SetString(prefs::kApplicationLocaleBackup, new_locale);
+ GetPrefs()->ClearPref(prefs::kApplicationLocaleAccepted);
+ // We maintain kApplicationLocale property in both a global storage
+ // and user's profile. Global property determines locale of login screen,
+ // while user's profile determines his personal locale preference.
+ // In case of APP_LOCALE_CHANGED_VIA_LOGIN we won't touch local state
+ // because login screen code is active and takes care of it.
+ g_browser_process->local_state()->SetString(
+ prefs::kApplicationLocale, new_locale);
+ break;
+ }
+ case APP_LOCALE_CHANGED_VIA_LOGIN: {
+ if (!pref_locale.empty()) {
+ DCHECK(pref_locale == new_locale);
+ std::string accepted_locale =
+ GetPrefs()->GetString(prefs::kApplicationLocaleAccepted);
+ if (accepted_locale == new_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.
+ GetPrefs()->SetString(prefs::kApplicationLocaleBackup, new_locale);
+ } else {
+ // Back up locale of login screen.
+ GetPrefs()->SetString(prefs::kApplicationLocaleBackup,
+ g_browser_process->GetApplicationLocale());
+ }
+ } else {
+ std::string cur_locale = g_browser_process->GetApplicationLocale();
+ std::string backup_locale =
+ GetPrefs()->GetString(prefs::kApplicationLocaleBackup);
+ // 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.
+ GetPrefs()->SetString(prefs::kApplicationLocaleBackup, cur_locale);
+ if (!backup_locale.empty())
+ GetPrefs()->SetString(prefs::kApplicationLocale, backup_locale);
+ do_update_pref = false;
+ }
+ break;
+ }
+ case APP_LOCALE_CHANGED_VIA_UNKNOWN:
+ default: {
+ NOTREACHED();
+ break;
+ }
}
- GetPrefs()->SetString(prefs::kApplicationLocaleBackup, locale);
- GetPrefs()->ClearPref(prefs::kApplicationLocaleAccepted);
- // We maintain kApplicationLocale property in both a global storage
- // and user's profile. Global property determines locale of login screen,
- // while user's profile determines his personal locale preference.
- g_browser_process->local_state()->SetString(
- prefs::kApplicationLocale, locale);
-
- GetPrefs()->SavePersistentPrefs();
- g_browser_process->local_state()->SavePersistentPrefs();
+ if (do_update_pref)
+ GetPrefs()->SetString(prefs::kApplicationLocale, new_locale);
+
+ GetPrefs()->ScheduleSavePersistentPrefs();
+ g_browser_process->local_state()->ScheduleSavePersistentPrefs();
}
chromeos::ProxyConfigServiceImpl*
« no previous file with comments | « chrome/browser/profiles/profile_impl.h ('k') | chrome/browser/sync/glue/preference_model_associator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698