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

Side by Side Diff: chrome/browser/chromeos/login/login_utils.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: Added comment on "list of preferred languages". Created 7 years, 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/chromeos/chromeos_version.h" 10 #include "base/chromeos/chromeos_version.h"
(...skipping 17 matching lines...) Expand all
28 #include "base/threading/worker_pool.h" 28 #include "base/threading/worker_pool.h"
29 #include "base/time/time.h" 29 #include "base/time/time.h"
30 #include "chrome/browser/about_flags.h" 30 #include "chrome/browser/about_flags.h"
31 #include "chrome/browser/app_mode/app_mode_utils.h" 31 #include "chrome/browser/app_mode/app_mode_utils.h"
32 #include "chrome/browser/browser_process.h" 32 #include "chrome/browser/browser_process.h"
33 #include "chrome/browser/browser_shutdown.h" 33 #include "chrome/browser/browser_shutdown.h"
34 #include "chrome/browser/chrome_notification_types.h" 34 #include "chrome/browser/chrome_notification_types.h"
35 #include "chrome/browser/chromeos/boot_times_loader.h" 35 #include "chrome/browser/chromeos/boot_times_loader.h"
36 #include "chrome/browser/chromeos/input_method/input_method_util.h" 36 #include "chrome/browser/chromeos/input_method/input_method_util.h"
37 #include "chrome/browser/chromeos/login/chrome_restart_request.h" 37 #include "chrome/browser/chromeos/login/chrome_restart_request.h"
38 #include "chrome/browser/chromeos/login/language_switch_menu.h"
39 #include "chrome/browser/chromeos/login/login_display_host.h" 38 #include "chrome/browser/chromeos/login/login_display_host.h"
40 #include "chrome/browser/chromeos/login/oauth_login_manager.h" 39 #include "chrome/browser/chromeos/login/oauth_login_manager.h"
41 #include "chrome/browser/chromeos/login/parallel_authenticator.h" 40 #include "chrome/browser/chromeos/login/parallel_authenticator.h"
42 #include "chrome/browser/chromeos/login/profile_auth_data.h" 41 #include "chrome/browser/chromeos/login/profile_auth_data.h"
43 #include "chrome/browser/chromeos/login/screen_locker.h" 42 #include "chrome/browser/chromeos/login/screen_locker.h"
44 #include "chrome/browser/chromeos/login/user_manager.h" 43 #include "chrome/browser/chromeos/login/user_manager.h"
45 #include "chrome/browser/chromeos/settings/cros_settings.h" 44 #include "chrome/browser/chromeos/settings/cros_settings.h"
46 #include "chrome/browser/chromeos/settings/cros_settings_names.h" 45 #include "chrome/browser/chromeos/settings/cros_settings_names.h"
47 #include "chrome/browser/extensions/extension_service.h" 46 #include "chrome/browser/extensions/extension_service.h"
48 #include "chrome/browser/first_run/first_run.h" 47 #include "chrome/browser/first_run/first_run.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 virtual void OnFoundStoredTokens() OVERRIDE; 139 virtual void OnFoundStoredTokens() OVERRIDE;
141 140
142 // net::NetworkChangeNotifier::ConnectionTypeObserver overrides. 141 // net::NetworkChangeNotifier::ConnectionTypeObserver overrides.
143 virtual void OnConnectionTypeChanged( 142 virtual void OnConnectionTypeChanged(
144 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; 143 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE;
145 144
146 private: 145 private:
147 // Restarts OAuth session authentication check. 146 // Restarts OAuth session authentication check.
148 void KickStartAuthentication(Profile* profile); 147 void KickStartAuthentication(Profile* profile);
149 148
150 // Check user's profile for kApplicationLocale setting.
151 void RespectLocalePreference(Profile* pref);
152
153 // Callback for Profile::CREATE_STATUS_CREATED profile state. 149 // Callback for Profile::CREATE_STATUS_CREATED profile state.
154 // Initializes basic preferences for newly created profile. Any other 150 // Initializes basic preferences for newly created profile. Any other
155 // early profile initialization that needs to happen before 151 // early profile initialization that needs to happen before
156 // ProfileManager::DoFinalInit() gets called is done here. 152 // ProfileManager::DoFinalInit() gets called is done here.
157 void InitProfilePreferences(Profile* user_profile); 153 void InitProfilePreferences(Profile* user_profile);
158 154
159 // Callback for asynchronous profile creation. 155 // Callback for asynchronous profile creation.
160 void OnProfileCreated(Profile* profile, 156 void OnProfileCreated(Profile* profile,
161 Profile::CreateStatus status); 157 Profile::CreateStatus status);
162 158
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 } else { 349 } else {
354 // Make sure that the google service username is properly set (we do this 350 // Make sure that the google service username is properly set (we do this
355 // on every sign in, not just the first login, to deal with existing 351 // on every sign in, not just the first login, to deal with existing
356 // profiles that might not have it set yet). 352 // profiles that might not have it set yet).
357 StringPrefMember google_services_username; 353 StringPrefMember google_services_username;
358 google_services_username.Init(prefs::kGoogleServicesUsername, 354 google_services_username.Init(prefs::kGoogleServicesUsername,
359 user_profile->GetPrefs()); 355 user_profile->GetPrefs());
360 google_services_username.SetValue( 356 google_services_username.SetValue(
361 UserManager::Get()->GetLoggedInUser()->display_email()); 357 UserManager::Get()->GetLoggedInUser()->display_email());
362 } 358 }
363
364 RespectLocalePreference(user_profile);
365 } 359 }
366 360
367 void LoginUtilsImpl::InitSessionRestoreStrategy() { 361 void LoginUtilsImpl::InitSessionRestoreStrategy() {
368 CommandLine* command_line = CommandLine::ForCurrentProcess(); 362 CommandLine* command_line = CommandLine::ForCurrentProcess();
369 bool in_app_mode = chrome::IsRunningInForcedAppMode(); 363 bool in_app_mode = chrome::IsRunningInForcedAppMode();
370 364
371 // Are we in kiosk app mode? 365 // Are we in kiosk app mode?
372 if (in_app_mode) { 366 if (in_app_mode) {
373 if (command_line->HasSwitch(::switches::kAppModeOAuth2Token)) { 367 if (command_line->HasSwitch(::switches::kAppModeOAuth2Token)) {
374 oauth2_refresh_token_ = command_line->GetSwitchValueASCII( 368 oauth2_refresh_token_ = command_line->GetSwitchValueASCII(
(...skipping 28 matching lines...) Expand all
403 } 397 }
404 } 398 }
405 399
406 400
407 void LoginUtilsImpl::OnProfileCreated( 401 void LoginUtilsImpl::OnProfileCreated(
408 Profile* user_profile, 402 Profile* user_profile,
409 Profile::CreateStatus status) { 403 Profile::CreateStatus status) {
410 CHECK(user_profile); 404 CHECK(user_profile);
411 405
412 switch (status) { 406 switch (status) {
407 case Profile::CREATE_STATUS_CREATED:
408 InitProfilePreferences(user_profile);
409 break;
413 case Profile::CREATE_STATUS_INITIALIZED: 410 case Profile::CREATE_STATUS_INITIALIZED:
414 UserProfileInitialized(user_profile); 411 UserProfileInitialized(user_profile);
415 break; 412 break;
416 case Profile::CREATE_STATUS_CREATED:
417 InitProfilePreferences(user_profile);
418 break;
419 case Profile::CREATE_STATUS_LOCAL_FAIL: 413 case Profile::CREATE_STATUS_LOCAL_FAIL:
420 case Profile::CREATE_STATUS_REMOTE_FAIL: 414 case Profile::CREATE_STATUS_REMOTE_FAIL:
421 case Profile::CREATE_STATUS_CANCELED: 415 case Profile::CREATE_STATUS_CANCELED:
422 case Profile::MAX_CREATE_STATUS: 416 case Profile::MAX_CREATE_STATUS:
423 NOTREACHED(); 417 NOTREACHED();
424 break; 418 break;
425 } 419 }
426 } 420 }
427 421
428 void LoginUtilsImpl::UserProfileInitialized(Profile* user_profile) { 422 void LoginUtilsImpl::UserProfileInitialized(Profile* user_profile) {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 content::NotificationService::current()->Notify( 581 content::NotificationService::current()->Notify(
588 chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL, 582 chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL,
589 content::Source<Profile>(user_profile), 583 content::Source<Profile>(user_profile),
590 content::Details<const GoogleServiceSigninSuccessDetails>(&details)); 584 content::Details<const GoogleServiceSigninSuccessDetails>(&details));
591 } 585 }
592 } 586 }
593 user_context_.password.clear(); 587 user_context_.password.clear();
594 user_context_.auth_code.clear(); 588 user_context_.auth_code.clear();
595 } 589 }
596 590
597 void LoginUtilsImpl::RespectLocalePreference(Profile* profile) {
598 DCHECK(profile != NULL);
599 PrefService* prefs = profile->GetPrefs();
600 DCHECK(prefs != NULL);
601 if (g_browser_process == NULL)
602 return;
603
604 std::string pref_locale = prefs->GetString(prefs::kApplicationLocale);
605 if (pref_locale.empty())
606 pref_locale = prefs->GetString(prefs::kApplicationLocaleBackup);
607 if (pref_locale.empty())
608 pref_locale = g_browser_process->GetApplicationLocale();
609 DCHECK(!pref_locale.empty());
610 profile->ChangeAppLocale(pref_locale, Profile::APP_LOCALE_CHANGED_VIA_LOGIN);
611 // Here we don't enable keyboard layouts. Input methods are set up when
612 // the user first logs in. Then the user may customize the input methods.
613 // Hence changing input methods here, just because the user's UI language
614 // is different from the login screen UI language, is not desirable. Note
615 // that input method preferences are synced, so users can use their
616 // farovite input methods as soon as the preferences are synced.
617 LanguageSwitchMenu::SwitchLanguage(pref_locale);
618 }
619
620 void LoginUtilsImpl::CompleteOffTheRecordLogin(const GURL& start_url) { 591 void LoginUtilsImpl::CompleteOffTheRecordLogin(const GURL& start_url) {
621 VLOG(1) << "Completing incognito login"; 592 VLOG(1) << "Completing incognito login";
622 593
623 // For guest session we ask session manager to restart Chrome with --bwsi 594 // For guest session we ask session manager to restart Chrome with --bwsi
624 // flag. We keep only some of the arguments of this process. 595 // flag. We keep only some of the arguments of this process.
625 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); 596 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
626 CommandLine command_line(browser_command_line.GetProgram()); 597 CommandLine command_line(browser_command_line.GetProgram());
627 std::string cmd_line_str = GetOffTheRecordCommandLine(start_url, 598 std::string cmd_line_str = GetOffTheRecordCommandLine(start_url,
628 browser_command_line, 599 browser_command_line,
629 &command_line); 600 &command_line);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 bool LoginUtils::IsWhitelisted(const std::string& username) { 748 bool LoginUtils::IsWhitelisted(const std::string& username) {
778 CrosSettings* cros_settings = CrosSettings::Get(); 749 CrosSettings* cros_settings = CrosSettings::Get();
779 bool allow_new_user = false; 750 bool allow_new_user = false;
780 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); 751 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user);
781 if (allow_new_user) 752 if (allow_new_user)
782 return true; 753 return true;
783 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); 754 return cros_settings->FindEmailInList(kAccountsPrefUsers, username);
784 } 755 }
785 756
786 } // namespace chromeos 757 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/login/mock_user_manager.h » ('j') | chrome/browser/chromeos/login/user.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698