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

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: 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 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 359
364 RespectLocalePreference(user_profile); 360 user_profile->RespectLocalePreference();
365 } 361 }
366 362
367 void LoginUtilsImpl::InitSessionRestoreStrategy() { 363 void LoginUtilsImpl::InitSessionRestoreStrategy() {
368 CommandLine* command_line = CommandLine::ForCurrentProcess(); 364 CommandLine* command_line = CommandLine::ForCurrentProcess();
369 bool in_app_mode = chrome::IsRunningInForcedAppMode(); 365 bool in_app_mode = chrome::IsRunningInForcedAppMode();
370 366
371 // Are we in kiosk app mode? 367 // Are we in kiosk app mode?
372 if (in_app_mode) { 368 if (in_app_mode) {
373 if (command_line->HasSwitch(::switches::kAppModeOAuth2Token)) { 369 if (command_line->HasSwitch(::switches::kAppModeOAuth2Token)) {
374 oauth2_refresh_token_ = command_line->GetSwitchValueASCII( 370 oauth2_refresh_token_ = command_line->GetSwitchValueASCII(
(...skipping 28 matching lines...) Expand all
403 } 399 }
404 } 400 }
405 401
406 402
407 void LoginUtilsImpl::OnProfileCreated( 403 void LoginUtilsImpl::OnProfileCreated(
408 Profile* user_profile, 404 Profile* user_profile,
409 Profile::CreateStatus status) { 405 Profile::CreateStatus status) {
410 CHECK(user_profile); 406 CHECK(user_profile);
411 407
412 switch (status) { 408 switch (status) {
409 case Profile::CREATE_STATUS_CREATED:
410 user_profile->MarkCreated();
411 InitProfilePreferences(user_profile);
412 break;
413 case Profile::CREATE_STATUS_INITIALIZED: 413 case Profile::CREATE_STATUS_INITIALIZED:
414 UserProfileInitialized(user_profile); 414 UserProfileInitialized(user_profile);
415 break; 415 break;
416 case Profile::CREATE_STATUS_CREATED:
417 InitProfilePreferences(user_profile);
418 break;
419 case Profile::CREATE_STATUS_LOCAL_FAIL: 416 case Profile::CREATE_STATUS_LOCAL_FAIL:
420 case Profile::CREATE_STATUS_REMOTE_FAIL: 417 case Profile::CREATE_STATUS_REMOTE_FAIL:
421 case Profile::CREATE_STATUS_CANCELED: 418 case Profile::CREATE_STATUS_CANCELED:
422 case Profile::MAX_CREATE_STATUS: 419 case Profile::MAX_CREATE_STATUS:
423 NOTREACHED(); 420 NOTREACHED();
424 break; 421 break;
425 } 422 }
426 } 423 }
427 424
428 void LoginUtilsImpl::UserProfileInitialized(Profile* user_profile) { 425 void LoginUtilsImpl::UserProfileInitialized(Profile* user_profile) {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 content::NotificationService::current()->Notify( 584 content::NotificationService::current()->Notify(
588 chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL, 585 chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL,
589 content::Source<Profile>(user_profile), 586 content::Source<Profile>(user_profile),
590 content::Details<const GoogleServiceSigninSuccessDetails>(&details)); 587 content::Details<const GoogleServiceSigninSuccessDetails>(&details));
591 } 588 }
592 } 589 }
593 user_context_.password.clear(); 590 user_context_.password.clear();
594 user_context_.auth_code.clear(); 591 user_context_.auth_code.clear();
595 } 592 }
596 593
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) { 594 void LoginUtilsImpl::CompleteOffTheRecordLogin(const GURL& start_url) {
621 VLOG(1) << "Completing incognito login"; 595 VLOG(1) << "Completing incognito login";
622 596
623 // For guest session we ask session manager to restart Chrome with --bwsi 597 // For guest session we ask session manager to restart Chrome with --bwsi
624 // flag. We keep only some of the arguments of this process. 598 // flag. We keep only some of the arguments of this process.
625 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); 599 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
626 CommandLine command_line(browser_command_line.GetProgram()); 600 CommandLine command_line(browser_command_line.GetProgram());
627 std::string cmd_line_str = GetOffTheRecordCommandLine(start_url, 601 std::string cmd_line_str = GetOffTheRecordCommandLine(start_url,
628 browser_command_line, 602 browser_command_line,
629 &command_line); 603 &command_line);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 bool LoginUtils::IsWhitelisted(const std::string& username) { 751 bool LoginUtils::IsWhitelisted(const std::string& username) {
778 CrosSettings* cros_settings = CrosSettings::Get(); 752 CrosSettings* cros_settings = CrosSettings::Get();
779 bool allow_new_user = false; 753 bool allow_new_user = false;
780 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); 754 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user);
781 if (allow_new_user) 755 if (allow_new_user)
782 return true; 756 return true;
783 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); 757 return cros_settings->FindEmailInList(kAccountsPrefUsers, username);
784 } 758 }
785 759
786 } // namespace chromeos 760 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698