OLD | NEW |
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/bind.h" | 10 #include "base/bind.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 #include "chrome/browser/extensions/extension_service.h" | 49 #include "chrome/browser/extensions/extension_service.h" |
50 #include "chrome/browser/first_run/first_run.h" | 50 #include "chrome/browser/first_run/first_run.h" |
51 #include "chrome/browser/google/google_util_chromeos.h" | 51 #include "chrome/browser/google/google_util_chromeos.h" |
52 #include "chrome/browser/lifetime/application_lifetime.h" | 52 #include "chrome/browser/lifetime/application_lifetime.h" |
53 #include "chrome/browser/pref_service_flags_storage.h" | 53 #include "chrome/browser/pref_service_flags_storage.h" |
54 #include "chrome/browser/profiles/profile.h" | 54 #include "chrome/browser/profiles/profile.h" |
55 #include "chrome/browser/profiles/profile_manager.h" | 55 #include "chrome/browser/profiles/profile_manager.h" |
56 #include "chrome/browser/rlz/rlz.h" | 56 #include "chrome/browser/rlz/rlz.h" |
57 #include "chrome/browser/signin/signin_manager.h" | 57 #include "chrome/browser/signin/signin_manager.h" |
58 #include "chrome/browser/signin/signin_manager_factory.h" | 58 #include "chrome/browser/signin/signin_manager_factory.h" |
59 #include "chrome/browser/signin/token_service.h" | |
60 #include "chrome/browser/signin/token_service_factory.h" | |
61 #include "chrome/browser/sync/profile_sync_service.h" | 59 #include "chrome/browser/sync/profile_sync_service.h" |
62 #include "chrome/browser/sync/profile_sync_service_factory.h" | 60 #include "chrome/browser/sync/profile_sync_service_factory.h" |
63 #include "chrome/browser/ui/app_list/start_page_service.h" | 61 #include "chrome/browser/ui/app_list/start_page_service.h" |
64 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 62 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
65 #include "chrome/common/chrome_paths.h" | 63 #include "chrome/common/chrome_paths.h" |
66 #include "chrome/common/chrome_switches.h" | 64 #include "chrome/common/chrome_switches.h" |
67 #include "chrome/common/logging_chrome.h" | 65 #include "chrome/common/logging_chrome.h" |
68 #include "chrome/common/pref_names.h" | 66 #include "chrome/common/pref_names.h" |
69 #include "chromeos/chromeos_switches.h" | 67 #include "chromeos/chromeos_switches.h" |
70 #include "chromeos/cryptohome/cryptohome_util.h" | 68 #include "chromeos/cryptohome/cryptohome_util.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 // OAuthLoginManager. | 191 // OAuthLoginManager. |
194 void InitSessionRestoreStrategy(); | 192 void InitSessionRestoreStrategy(); |
195 | 193 |
196 // Restores GAIA auth cookies for the created user profile from OAuth2 token. | 194 // Restores GAIA auth cookies for the created user profile from OAuth2 token. |
197 void RestoreAuthSession(Profile* user_profile, | 195 void RestoreAuthSession(Profile* user_profile, |
198 bool restore_from_auth_cookies); | 196 bool restore_from_auth_cookies); |
199 | 197 |
200 // Initializes RLZ. If |disabled| is true, RLZ pings are disabled. | 198 // Initializes RLZ. If |disabled| is true, RLZ pings are disabled. |
201 void InitRlz(Profile* user_profile, bool disabled); | 199 void InitRlz(Profile* user_profile, bool disabled); |
202 | 200 |
203 // Starts signing related services. Initiates TokenService token retrieval. | 201 // Starts signing related services. Initiates token retrieval. |
204 void StartSignedInServices(Profile* profile); | 202 void StartSignedInServices(Profile* profile); |
205 | 203 |
206 // Attempts exiting browser process and esures this does not happen | 204 // Attempts exiting browser process and esures this does not happen |
207 // while we are still fetching new OAuth refresh tokens. | 205 // while we are still fetching new OAuth refresh tokens. |
208 void AttemptExit(Profile* profile); | 206 void AttemptExit(Profile* profile); |
209 | 207 |
210 UserContext user_context_; | 208 UserContext user_context_; |
211 | 209 |
212 // True if the authentication profile's cookie jar should contain | 210 // True if the authentication profile's cookie jar should contain |
213 // authentication cookies from the authentication extension log in flow. | 211 // authentication cookies from the authentication extension log in flow. |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 CHECK((authenticator_.get() && authenticator_->authentication_profile()) || | 543 CHECK((authenticator_.get() && authenticator_->authentication_profile()) || |
546 !restore_from_auth_cookies); | 544 !restore_from_auth_cookies); |
547 | 545 |
548 if (chrome::IsRunningInForcedAppMode() || | 546 if (chrome::IsRunningInForcedAppMode() || |
549 CommandLine::ForCurrentProcess()->HasSwitch( | 547 CommandLine::ForCurrentProcess()->HasSwitch( |
550 chromeos::switches::kOobeSkipPostLogin)) | 548 chromeos::switches::kOobeSkipPostLogin)) |
551 return; | 549 return; |
552 | 550 |
553 exit_after_session_restore_ = false; | 551 exit_after_session_restore_ = false; |
554 // Remove legacy OAuth1 token if we have one. If it's valid, we should already | 552 // Remove legacy OAuth1 token if we have one. If it's valid, we should already |
555 // have OAuth2 refresh token in TokenService that could be used to retrieve | 553 // have OAuth2 refresh token in OAuth2TokenService that could be used to |
556 // all other tokens and user_context. | 554 // retrieve all other tokens and user_context. |
557 OAuth2LoginManager* login_manager = | 555 OAuth2LoginManager* login_manager = |
558 OAuth2LoginManagerFactory::GetInstance()->GetForProfile(user_profile); | 556 OAuth2LoginManagerFactory::GetInstance()->GetForProfile(user_profile); |
559 login_manager->AddObserver(this); | 557 login_manager->AddObserver(this); |
560 login_manager->RestoreSession( | 558 login_manager->RestoreSession( |
561 authenticator_.get() && authenticator_->authentication_profile() | 559 authenticator_.get() && authenticator_->authentication_profile() |
562 ? authenticator_->authentication_profile()->GetRequestContext() | 560 ? authenticator_->authentication_profile()->GetRequestContext() |
563 : NULL, | 561 : NULL, |
564 session_restore_strategy_, | 562 session_restore_strategy_, |
565 oauth2_refresh_token_, | 563 oauth2_refresh_token_, |
566 user_context_.auth_code); | 564 user_context_.auth_code); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 // recorded. | 638 // recorded. |
641 RLZTracker::InitRlzFromProfileDelayed( | 639 RLZTracker::InitRlzFromProfileDelayed( |
642 user_profile, UserManager::Get()->IsCurrentUserNew(), | 640 user_profile, UserManager::Get()->IsCurrentUserNew(), |
643 ping_delay < 0, base::TimeDelta::FromMilliseconds(abs(ping_delay))); | 641 ping_delay < 0, base::TimeDelta::FromMilliseconds(abs(ping_delay))); |
644 if (delegate_) | 642 if (delegate_) |
645 delegate_->OnRlzInitialized(user_profile); | 643 delegate_->OnRlzInitialized(user_profile); |
646 #endif | 644 #endif |
647 } | 645 } |
648 | 646 |
649 void LoginUtilsImpl::StartSignedInServices(Profile* user_profile) { | 647 void LoginUtilsImpl::StartSignedInServices(Profile* user_profile) { |
650 // Fetch/Create the SigninManager - this will cause the TokenService to load | |
651 // tokens for the currently signed-in user if the SigninManager hasn't | |
652 // already been initialized. | |
653 SigninManagerBase* signin = | 648 SigninManagerBase* signin = |
654 SigninManagerFactory::GetForProfile(user_profile); | 649 SigninManagerFactory::GetForProfile(user_profile); |
655 DCHECK(signin); | 650 DCHECK(signin); |
656 // Make sure SigninManager is connected to our current user (this should | 651 // Make sure SigninManager is connected to our current user (this should |
657 // happen automatically because we set kGoogleServicesUsername in | 652 // happen automatically because we set kGoogleServicesUsername in |
658 // OnProfileCreated()). | 653 // OnProfileCreated()). |
659 DCHECK_EQ(UserManager::Get()->GetLoggedInUser()->display_email(), | 654 DCHECK_EQ(UserManager::Get()->GetLoggedInUser()->display_email(), |
660 signin->GetAuthenticatedUsername()); | 655 signin->GetAuthenticatedUsername()); |
661 static bool initialized = false; | 656 static bool initialized = false; |
662 if (!initialized) { | 657 if (!initialized) { |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 bool LoginUtils::IsWhitelisted(const std::string& username) { | 900 bool LoginUtils::IsWhitelisted(const std::string& username) { |
906 CrosSettings* cros_settings = CrosSettings::Get(); | 901 CrosSettings* cros_settings = CrosSettings::Get(); |
907 bool allow_new_user = false; | 902 bool allow_new_user = false; |
908 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); | 903 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); |
909 if (allow_new_user) | 904 if (allow_new_user) |
910 return true; | 905 return true; |
911 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); | 906 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); |
912 } | 907 } |
913 | 908 |
914 } // namespace chromeos | 909 } // namespace chromeos |
OLD | NEW |