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

Side by Side Diff: chrome/browser/signin/signin_manager.cc

Issue 11991002: Merge 176800 (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1364/src/
Patch Set: Created 7 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) 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/signin/signin_manager.h" 5 #include "chrome/browser/signin/signin_manager.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 profile->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername); 120 profile->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername);
121 121
122 std::string user = profile_->GetPrefs()->GetString( 122 std::string user = profile_->GetPrefs()->GetString(
123 prefs::kGoogleServicesUsername); 123 prefs::kGoogleServicesUsername);
124 if (!user.empty()) 124 if (!user.empty())
125 SetAuthenticatedUsername(user); 125 SetAuthenticatedUsername(user);
126 // TokenService can be null for unit tests. 126 // TokenService can be null for unit tests.
127 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); 127 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_);
128 if (token_service) { 128 if (token_service) {
129 token_service->Initialize(GaiaConstants::kChromeSource, profile_); 129 token_service->Initialize(GaiaConstants::kChromeSource, profile_);
130 // ChromeOS will kick off TokenService::LoadTokensFromDB from
131 // OAuthLoginManager once the rest of the Profile is fully initialized.
132 // Starting it from here would cause OAuthLoginManager mismatch the origin
133 // of OAuth2 tokens.
134 #if !defined(OS_CHROMEOS)
130 if (!authenticated_username_.empty()) { 135 if (!authenticated_username_.empty()) {
131 token_service->LoadTokensFromDB(); 136 token_service->LoadTokensFromDB();
132 } 137 }
138 #endif
133 } 139 }
134 if (!user.empty() && !IsAllowedUsername(user)) { 140 if (!user.empty() && !IsAllowedUsername(user)) {
135 // User is signed in, but the username is invalid - the administrator must 141 // User is signed in, but the username is invalid - the administrator must
136 // have changed the policy since the last signin, so sign out the user. 142 // have changed the policy since the last signin, so sign out the user.
137 SignOut(); 143 SignOut();
138 } 144 }
139 } 145 }
140 146
141 bool SigninManager::IsInitialized() const { 147 bool SigninManager::IsInitialized() const {
142 return profile_ != NULL; 148 return profile_ != NULL;
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 DisableOneClickSignIn(profile_); // Don't ever offer again. 510 DisableOneClickSignIn(profile_); // Don't ever offer again.
505 511
506 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); 512 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_);
507 token_service->UpdateCredentials(last_result_); 513 token_service->UpdateCredentials(last_result_);
508 DCHECK(token_service->AreCredentialsValid()); 514 DCHECK(token_service->AreCredentialsValid());
509 token_service->StartFetchingTokens(); 515 token_service->StartFetchingTokens();
510 516
511 // If we have oauth2 tokens, tell token service about them so it does not 517 // If we have oauth2 tokens, tell token service about them so it does not
512 // need to fetch them again. 518 // need to fetch them again.
513 if (!temp_oauth_login_tokens_.refresh_token.empty()) { 519 if (!temp_oauth_login_tokens_.refresh_token.empty()) {
514 token_service->OnClientOAuthSuccess(temp_oauth_login_tokens_); 520 token_service->UpdateCredentialsWithOAuth2(temp_oauth_login_tokens_);
515 temp_oauth_login_tokens_ = ClientOAuthResult(); 521 temp_oauth_login_tokens_ = ClientOAuthResult();
516 } 522 }
517 } 523 }
518 524
519 void SigninManager::OnGetUserInfoFailure(const GoogleServiceAuthError& error) { 525 void SigninManager::OnGetUserInfoFailure(const GoogleServiceAuthError& error) {
520 LOG(ERROR) << "Unable to retreive the canonical email address. Login failed."; 526 LOG(ERROR) << "Unable to retreive the canonical email address. Login failed.";
521 // REVIEW: why does this call OnClientLoginFailure? 527 // REVIEW: why does this call OnClientLoginFailure?
522 OnClientLoginFailure(error); 528 OnClientLoginFailure(error);
523 } 529 }
524 530
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 !IsAllowedUsername(authenticated_username_)) { 566 !IsAllowedUsername(authenticated_username_)) {
561 // Signed in user is invalid according to the current policy so sign 567 // Signed in user is invalid according to the current policy so sign
562 // the user out. 568 // the user out.
563 SignOut(); 569 SignOut();
564 } 570 }
565 } 571 }
566 572
567 AboutSigninInternals* SigninManager::about_signin_internals() { 573 AboutSigninInternals* SigninManager::about_signin_internals() {
568 return &about_signin_internals_; 574 return &about_signin_internals_;
569 } 575 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/chromeos/login/user_pod_row.js ('k') | chrome/browser/signin/token_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698