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

Side by Side Diff: chrome/browser/chromeos/login/login_utils.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/login/login_utils.h" 5 #include "chrome/browser/chromeos/login/login_utils.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 const GaiaAuthConsumer::ClientLoginResult& credentials); 148 const GaiaAuthConsumer::ClientLoginResult& credentials);
149 149
150 // Sets the current background view. 150 // Sets the current background view.
151 virtual void SetBackgroundView(chromeos::BackgroundView* background_view); 151 virtual void SetBackgroundView(chromeos::BackgroundView* background_view);
152 152
153 // Gets the current background view. 153 // Gets the current background view.
154 virtual chromeos::BackgroundView* GetBackgroundView(); 154 virtual chromeos::BackgroundView* GetBackgroundView();
155 155
156 private: 156 private:
157 // Check user's profile for kApplicationLocale setting. 157 // Check user's profile for kApplicationLocale setting.
158 void RespectLocalePreference(PrefService* pref); 158 void RespectLocalePreference(Profile* pref);
159 159
160 // Indicates if DoBrowserLaunch will actually launch the browser or not. 160 // Indicates if DoBrowserLaunch will actually launch the browser or not.
161 bool browser_launch_enabled_; 161 bool browser_launch_enabled_;
162 162
163 // The current background view. 163 // The current background view.
164 chromeos::BackgroundView* background_view_; 164 chromeos::BackgroundView* background_view_;
165 165
166 DISALLOW_COPY_AND_ASSIGN(LoginUtilsImpl); 166 DISALLOW_COPY_AND_ASSIGN(LoginUtilsImpl);
167 }; 167 };
168 168
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 if (cryptohome->TpmIsEnabled() && !cryptohome->TpmIsBeingOwned()) { 302 if (cryptohome->TpmIsEnabled() && !cryptohome->TpmIsBeingOwned()) {
303 if (cryptohome->TpmIsOwned()) { 303 if (cryptohome->TpmIsOwned()) {
304 cryptohome->TpmClearStoredPassword(); 304 cryptohome->TpmClearStoredPassword();
305 } else { 305 } else {
306 cryptohome->TpmCanAttemptOwnership(); 306 cryptohome->TpmCanAttemptOwnership();
307 } 307 }
308 } 308 }
309 } 309 }
310 btl->AddLoginTimeMarker("TPMOwned", false); 310 btl->AddLoginTimeMarker("TPMOwned", false);
311 311
312 RespectLocalePreference(profile->GetPrefs()); 312 RespectLocalePreference(profile);
313 313
314 if (first_login) { 314 if (first_login) {
315 SetFirstLoginPrefs(profile->GetPrefs()); 315 SetFirstLoginPrefs(profile->GetPrefs());
316 } 316 }
317 317
318 // Enable/disable plugins based on user preferences. 318 // Enable/disable plugins based on user preferences.
319 PluginUpdater::GetInstance()->DisablePluginGroupsFromPrefs(profile); 319 PluginUpdater::GetInstance()->DisablePluginGroupsFromPrefs(profile);
320 btl->AddLoginTimeMarker("PluginsStateUpdated", false); 320 btl->AddLoginTimeMarker("PluginsStateUpdated", false);
321 321
322 // We suck. This is a hack since we do not have the enterprise feature 322 // We suck. This is a hack since we do not have the enterprise feature
(...skipping 24 matching lines...) Expand all
347 void LoginUtilsImpl::FetchTokens( 347 void LoginUtilsImpl::FetchTokens(
348 Profile* profile, 348 Profile* profile,
349 const GaiaAuthConsumer::ClientLoginResult& credentials) { 349 const GaiaAuthConsumer::ClientLoginResult& credentials) {
350 TokenService* token_service = profile->GetTokenService(); 350 TokenService* token_service = profile->GetTokenService();
351 token_service->UpdateCredentials(credentials); 351 token_service->UpdateCredentials(credentials);
352 if (token_service->AreCredentialsValid()) { 352 if (token_service->AreCredentialsValid()) {
353 token_service->StartFetchingTokens(); 353 token_service->StartFetchingTokens();
354 } 354 }
355 } 355 }
356 356
357 void LoginUtilsImpl::RespectLocalePreference(PrefService* prefs) { 357 void LoginUtilsImpl::RespectLocalePreference(Profile* profile) {
358 DCHECK(profile != NULL);
359 PrefService* prefs = profile->GetPrefs();
358 DCHECK(prefs != NULL); 360 DCHECK(prefs != NULL);
359 std::string pref_locale_override =
360 prefs->GetString(prefs::kApplicationLocaleOverride);
361 if (!pref_locale_override.empty()) {
362 LanguageSwitchMenu::SwitchLanguage(pref_locale_override);
363 return;
364 }
365
366 if (g_browser_process == NULL) 361 if (g_browser_process == NULL)
367 return; 362 return;
368 std::string cur_locale = g_browser_process->GetApplicationLocale();
369 363
370 std::string pref_locale = prefs->GetString(prefs::kApplicationLocale); 364 std::string pref_locale = prefs->GetString(prefs::kApplicationLocale);
371 if (!pref_locale.empty()) { 365 if (pref_locale.empty())
372 if (prefs->GetString(prefs::kApplicationLocaleAccepted) == pref_locale) { 366 pref_locale = prefs->GetString(prefs::kApplicationLocaleBackup);
373 // If locale is accepted then we do not want to show LocaleChange 367 if (pref_locale.empty())
374 // notification. This notification is triggered by different values of 368 pref_locale = g_browser_process->GetApplicationLocale();
375 // kApplicationLocaleBackup and kApplicationLocale preferences, 369 DCHECK(!pref_locale.empty());
376 // so make them identical. 370 profile->ChangeAppLocale(pref_locale, Profile::APP_LOCALE_CHANGED_VIA_LOGIN);
377 prefs->SetString(prefs::kApplicationLocaleBackup, pref_locale); 371 LanguageSwitchMenu::SwitchLanguage(pref_locale);
378 } else {
379 std::string pref_locale_backup =
380 prefs->GetString(prefs::kApplicationLocaleBackup);
381 if (pref_locale_backup != cur_locale) {
382 if (pref_locale_backup == pref_locale || pref_locale_backup.empty()) {
383 prefs->SetString(prefs::kApplicationLocaleBackup, cur_locale);
384 }
385 }
386 }
387 LanguageSwitchMenu::SwitchLanguage(pref_locale);
388 return;
389 }
390 // Profile synchronization takes time and is not completed at that moment
391 // at first login. So we initialize locale preference in steps:
392 // (1) first save it to temporary backup;
393 // (2) on next login we assume that synchronization is already completed
394 // and we may finalize initialization.
395 std::string pref_locale_backup =
396 prefs->GetString(prefs::kApplicationLocaleBackup);
397 prefs->SetString(prefs::kApplicationLocaleBackup, cur_locale);
398 prefs->ScheduleSavePersistentPrefs();
399 if (!pref_locale_backup.empty()) {
400 prefs->SetString(prefs::kApplicationLocale, pref_locale_backup);
401 prefs->ScheduleSavePersistentPrefs();
402 LanguageSwitchMenu::SwitchLanguage(pref_locale_backup);
403 }
404 } 372 }
405 373
406 void LoginUtilsImpl::CompleteOffTheRecordLogin(const GURL& start_url) { 374 void LoginUtilsImpl::CompleteOffTheRecordLogin(const GURL& start_url) {
407 VLOG(1) << "Completing off the record login"; 375 VLOG(1) << "Completing off the record login";
408 376
409 UserManager::Get()->OffTheRecordUserLoggedIn(); 377 UserManager::Get()->OffTheRecordUserLoggedIn();
410 378
411 if (CrosLibrary::Get()->EnsureLoaded()) { 379 if (CrosLibrary::Get()->EnsureLoaded()) {
412 // For guest session we ask session manager to restart Chrome with --bwsi 380 // For guest session we ask session manager to restart Chrome with --bwsi
413 // flag. We keep only some of the arguments of this process. 381 // flag. We keep only some of the arguments of this process.
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 BrowserInit browser_init; 554 BrowserInit browser_init;
587 int return_code; 555 int return_code;
588 browser_init.LaunchBrowser(*CommandLine::ForCurrentProcess(), 556 browser_init.LaunchBrowser(*CommandLine::ForCurrentProcess(),
589 profile, 557 profile,
590 FilePath(), 558 FilePath(),
591 true, 559 true,
592 &return_code); 560 &return_code);
593 } 561 }
594 562
595 } // namespace chromeos 563 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/locale_change_guard.cc ('k') | chrome/browser/dom_ui/options/language_options_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698