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

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

Issue 23095006: If user profile doesn't contain language setting, default to his Google account settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix shared build. Created 7 years, 4 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/profiles/profile_impl.cc
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index c3650e8ba514879259e8d40b907acc558da8e9aa..f07228fcdc7753b966567febee8179cdeb7e8584 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -29,6 +29,7 @@
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
+#include "chrome/browser/chromeos/login/language_switch_menu.h"
#include "chrome/browser/content_settings/cookie_settings.h"
#include "chrome/browser/content_settings/host_content_settings_map.h"
#include "chrome/browser/download/chrome_download_manager_delegate.h"
@@ -361,6 +362,9 @@ ProfileImpl::ProfileImpl(
host_content_settings_map_(NULL),
last_session_exit_type_(EXIT_NORMAL),
start_time_(Time::Now()),
+#if defined(OS_CHROMEOS)
+ is_created_(false),
+#endif
delegate_(delegate),
predictor_(NULL) {
TRACE_EVENT0("browser", "ProfileImpl::ctor")
@@ -987,6 +991,10 @@ void ProfileImpl::EnsureSessionServiceCreated() {
#endif
#if defined(OS_CHROMEOS)
+void ProfileImpl::MarkCreated() {
+ is_created_ = true;
+}
+
void ProfileImpl::ChangeAppLocale(
const std::string& new_locale, AppLocaleChangedVia via) {
if (new_locale.empty()) {
@@ -1042,7 +1050,9 @@ void ProfileImpl::ChangeAppLocale(
// (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())
+ if (!new_locale.empty())
+ GetPrefs()->SetString(prefs::kApplicationLocale, new_locale);
+ else if (!backup_locale.empty())
GetPrefs()->SetString(prefs::kApplicationLocale, backup_locale);
do_update_pref = false;
}
@@ -1062,6 +1072,43 @@ void ProfileImpl::ChangeAppLocale(
local_state->SetString(prefs::kOwnerLocale, new_locale);
}
+void ProfileImpl::SetGPlusProfileLocale(const std::string& gplus_locale) {
+ gplus_locale_.reset(new std::string);
+ // Ignore result
+ l10n_util::CheckAndResolveLocale(gplus_locale, gplus_locale_.get());
jungshik at Google 2013/08/26 16:42:50 This does not take into account the preferred lang
Alexander Alekseev 2013/09/06 19:52:08 I like the idea, but I couldn't find "list of lang
jungshik at Google 2013/09/18 08:50:04 Thanks for digging that up. I've alerted an engine
+ RespectLocalePreference();
+}
+
+void ProfileImpl::RespectLocalePreference() {
+ PrefService* prefs = GetPrefs();
+ DCHECK(prefs != NULL);
+ if (g_browser_process == NULL)
+ return;
+
+ if (!is_created_)
+ return;
+
+ if (gplus_locale_ == NULL)
+ return;
+
+ std::string pref_locale = prefs->GetString(prefs::kApplicationLocale);
+ if (pref_locale.empty())
+ pref_locale = prefs->GetString(prefs::kApplicationLocaleBackup);
+ if (pref_locale.empty())
+ pref_locale = *gplus_locale_;
+ if (pref_locale.empty())
+ pref_locale = g_browser_process->GetApplicationLocale();
+ DCHECK(!pref_locale.empty());
+ ChangeAppLocale(pref_locale, APP_LOCALE_CHANGED_VIA_LOGIN);
+ // Here we don't enable keyboard layouts. Input methods are set up when
+ // the user first logs in. Then the user may customize the input methods.
+ // Hence changing input methods here, just because the user's UI language
+ // is different from the login screen UI language, is not desirable. Note
+ // that input method preferences are synced, so users can use their
+ // farovite input methods as soon as the preferences are synced.
+ chromeos::LanguageSwitchMenu::SwitchLanguage(pref_locale);
+}
+
void ProfileImpl::OnLogin() {
if (locale_change_guard_ == NULL)
locale_change_guard_.reset(new chromeos::LocaleChangeGuard(this));

Powered by Google App Engine
This is Rietveld 408576698