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

Side by Side Diff: chrome/browser/chromeos/login/login_utils.cc

Issue 59883010: This is the fourth CL of several that will eventually replace TokenService with (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix condition in ProfileSyncService::TryStart() Created 7 years, 1 month 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) 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/command_line.h" 10 #include "base/command_line.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "chrome/browser/extensions/extension_service.h" 47 #include "chrome/browser/extensions/extension_service.h"
48 #include "chrome/browser/first_run/first_run.h" 48 #include "chrome/browser/first_run/first_run.h"
49 #include "chrome/browser/google/google_util_chromeos.h" 49 #include "chrome/browser/google/google_util_chromeos.h"
50 #include "chrome/browser/lifetime/application_lifetime.h" 50 #include "chrome/browser/lifetime/application_lifetime.h"
51 #include "chrome/browser/pref_service_flags_storage.h" 51 #include "chrome/browser/pref_service_flags_storage.h"
52 #include "chrome/browser/profiles/profile.h" 52 #include "chrome/browser/profiles/profile.h"
53 #include "chrome/browser/profiles/profile_manager.h" 53 #include "chrome/browser/profiles/profile_manager.h"
54 #include "chrome/browser/rlz/rlz.h" 54 #include "chrome/browser/rlz/rlz.h"
55 #include "chrome/browser/signin/signin_manager.h" 55 #include "chrome/browser/signin/signin_manager.h"
56 #include "chrome/browser/signin/signin_manager_factory.h" 56 #include "chrome/browser/signin/signin_manager_factory.h"
57 #include "chrome/browser/signin/token_service.h"
58 #include "chrome/browser/signin/token_service_factory.h"
59 #include "chrome/browser/sync/profile_sync_service.h" 57 #include "chrome/browser/sync/profile_sync_service.h"
60 #include "chrome/browser/sync/profile_sync_service_factory.h" 58 #include "chrome/browser/sync/profile_sync_service_factory.h"
61 #include "chrome/browser/ui/app_list/start_page_service.h" 59 #include "chrome/browser/ui/app_list/start_page_service.h"
62 #include "chrome/browser/ui/startup/startup_browser_creator.h" 60 #include "chrome/browser/ui/startup/startup_browser_creator.h"
63 #include "chrome/common/chrome_paths.h" 61 #include "chrome/common/chrome_paths.h"
64 #include "chrome/common/chrome_switches.h" 62 #include "chrome/common/chrome_switches.h"
65 #include "chrome/common/logging_chrome.h" 63 #include "chrome/common/logging_chrome.h"
66 #include "chrome/common/pref_names.h" 64 #include "chrome/common/pref_names.h"
67 #include "chromeos/chromeos_switches.h" 65 #include "chromeos/chromeos_switches.h"
68 #include "chromeos/cryptohome/cryptohome_util.h" 66 #include "chromeos/cryptohome/cryptohome_util.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 // OAuthLoginManager. 175 // OAuthLoginManager.
178 void InitSessionRestoreStrategy(); 176 void InitSessionRestoreStrategy();
179 177
180 // Restores GAIA auth cookies for the created user profile from OAuth2 token. 178 // Restores GAIA auth cookies for the created user profile from OAuth2 token.
181 void RestoreAuthSession(Profile* user_profile, 179 void RestoreAuthSession(Profile* user_profile,
182 bool restore_from_auth_cookies); 180 bool restore_from_auth_cookies);
183 181
184 // Initializes RLZ. If |disabled| is true, RLZ pings are disabled. 182 // Initializes RLZ. If |disabled| is true, RLZ pings are disabled.
185 void InitRlz(Profile* user_profile, bool disabled); 183 void InitRlz(Profile* user_profile, bool disabled);
186 184
187 // Starts signing related services. Initiates TokenService token retrieval. 185 // Starts signing related services. Initiates token retrieval.
188 void StartSignedInServices(Profile* profile); 186 void StartSignedInServices(Profile* profile);
189 187
190 // Attempts exiting browser process and esures this does not happen 188 // Attempts exiting browser process and esures this does not happen
191 // while we are still fetching new OAuth refresh tokens. 189 // while we are still fetching new OAuth refresh tokens.
192 void AttemptExit(Profile* profile); 190 void AttemptExit(Profile* profile);
193 191
194 UserContext user_context_; 192 UserContext user_context_;
195 193
196 // True if the authentication profile's cookie jar should contain 194 // True if the authentication profile's cookie jar should contain
197 // authentication cookies from the authentication extension log in flow. 195 // authentication cookies from the authentication extension log in flow.
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 CHECK((authenticator_.get() && authenticator_->authentication_profile()) || 485 CHECK((authenticator_.get() && authenticator_->authentication_profile()) ||
488 !restore_from_auth_cookies); 486 !restore_from_auth_cookies);
489 487
490 if (chrome::IsRunningInForcedAppMode() || 488 if (chrome::IsRunningInForcedAppMode() ||
491 CommandLine::ForCurrentProcess()->HasSwitch( 489 CommandLine::ForCurrentProcess()->HasSwitch(
492 chromeos::switches::kOobeSkipPostLogin)) 490 chromeos::switches::kOobeSkipPostLogin))
493 return; 491 return;
494 492
495 exit_after_session_restore_ = false; 493 exit_after_session_restore_ = false;
496 // Remove legacy OAuth1 token if we have one. If it's valid, we should already 494 // Remove legacy OAuth1 token if we have one. If it's valid, we should already
497 // have OAuth2 refresh token in TokenService that could be used to retrieve 495 // have OAuth2 refresh token in OAuth2TokenService that could be used to
498 // all other tokens and user_context. 496 // retrieve all other tokens and user_context.
499 OAuth2LoginManager* login_manager = 497 OAuth2LoginManager* login_manager =
500 OAuth2LoginManagerFactory::GetInstance()->GetForProfile(user_profile); 498 OAuth2LoginManagerFactory::GetInstance()->GetForProfile(user_profile);
501 login_manager->AddObserver(this); 499 login_manager->AddObserver(this);
502 login_manager->RestoreSession( 500 login_manager->RestoreSession(
503 authenticator_.get() && authenticator_->authentication_profile() 501 authenticator_.get() && authenticator_->authentication_profile()
504 ? authenticator_->authentication_profile()->GetRequestContext() 502 ? authenticator_->authentication_profile()->GetRequestContext()
505 : NULL, 503 : NULL,
506 session_restore_strategy_, 504 session_restore_strategy_,
507 oauth2_refresh_token_, 505 oauth2_refresh_token_,
508 user_context_.auth_code); 506 user_context_.auth_code);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 // recorded. 580 // recorded.
583 RLZTracker::InitRlzFromProfileDelayed( 581 RLZTracker::InitRlzFromProfileDelayed(
584 user_profile, UserManager::Get()->IsCurrentUserNew(), 582 user_profile, UserManager::Get()->IsCurrentUserNew(),
585 ping_delay < 0, base::TimeDelta::FromMilliseconds(abs(ping_delay))); 583 ping_delay < 0, base::TimeDelta::FromMilliseconds(abs(ping_delay)));
586 if (delegate_) 584 if (delegate_)
587 delegate_->OnRlzInitialized(user_profile); 585 delegate_->OnRlzInitialized(user_profile);
588 #endif 586 #endif
589 } 587 }
590 588
591 void LoginUtilsImpl::StartSignedInServices(Profile* user_profile) { 589 void LoginUtilsImpl::StartSignedInServices(Profile* user_profile) {
592 // Fetch/Create the SigninManager - this will cause the TokenService to load
593 // tokens for the currently signed-in user if the SigninManager hasn't
594 // already been initialized.
595 SigninManagerBase* signin = 590 SigninManagerBase* signin =
596 SigninManagerFactory::GetForProfile(user_profile); 591 SigninManagerFactory::GetForProfile(user_profile);
597 DCHECK(signin); 592 DCHECK(signin);
598 // Make sure SigninManager is connected to our current user (this should 593 // Make sure SigninManager is connected to our current user (this should
599 // happen automatically because we set kGoogleServicesUsername in 594 // happen automatically because we set kGoogleServicesUsername in
600 // OnProfileCreated()). 595 // OnProfileCreated()).
601 DCHECK_EQ(UserManager::Get()->GetLoggedInUser()->display_email(), 596 DCHECK_EQ(UserManager::Get()->GetLoggedInUser()->display_email(),
602 signin->GetAuthenticatedUsername()); 597 signin->GetAuthenticatedUsername());
603 static bool initialized = false; 598 static bool initialized = false;
604 if (!initialized) { 599 if (!initialized) {
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 bool LoginUtils::IsWhitelisted(const std::string& username) { 842 bool LoginUtils::IsWhitelisted(const std::string& username) {
848 CrosSettings* cros_settings = CrosSettings::Get(); 843 CrosSettings* cros_settings = CrosSettings::Get();
849 bool allow_new_user = false; 844 bool allow_new_user = false;
850 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); 845 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user);
851 if (allow_new_user) 846 if (allow_new_user)
852 return true; 847 return true;
853 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); 848 return cros_settings->FindEmailInList(kAccountsPrefUsers, username);
854 } 849 }
855 850
856 } // namespace chromeos 851 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/login/oauth2_login_manager.h » ('j') | chrome/browser/sync/profile_sync_service.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698