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

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

Issue 13599003: revoke unused OAuth2 tokens on signout and re-signin (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Created 7 years, 8 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
« no previous file with comments | « chrome/browser/signin/signin_manager.h ('k') | google_apis/gaia/gaia_auth_consumer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 HandleAuthError(GoogleServiceAuthError( 321 HandleAuthError(GoogleServiceAuthError(
322 GoogleServiceAuthError::ACCOUNT_DISABLED), true); 322 GoogleServiceAuthError::ACCOUNT_DISABLED), true);
323 return false; 323 return false;
324 } 324 }
325 325
326 // This attempt is either 1) the user trying to establish initial sync, or 326 // This attempt is either 1) the user trying to establish initial sync, or
327 // 2) trying to refresh credentials for an existing username. If it is 2, we 327 // 2) trying to refresh credentials for an existing username. If it is 2, we
328 // need to try again, but take care to leave state around tracking that the 328 // need to try again, but take care to leave state around tracking that the
329 // user has successfully signed in once before with this username, so that on 329 // user has successfully signed in once before with this username, so that on
330 // restart we don't think sync setup has never completed. 330 // restart we don't think sync setup has never completed.
331 RevokeOAuthLoginToken();
331 ClearTransientSigninData(); 332 ClearTransientSigninData();
332 type_ = type; 333 type_ = type;
333 possibly_invalid_username_.assign(username); 334 possibly_invalid_username_.assign(username);
334 password_.assign(password); 335 password_.assign(password);
335 336
336 client_login_.reset(new GaiaAuthFetcher(this, 337 client_login_.reset(new GaiaAuthFetcher(this,
337 GaiaConstants::kChromeSource, 338 GaiaConstants::kChromeSource,
338 profile_->GetRequestContext())); 339 profile_->GetRequestContext()));
339 340
340 NotifyDiagnosticsObservers(SIGNIN_TYPE, SigninTypeToString(type)); 341 NotifyDiagnosticsObservers(SIGNIN_TYPE, SigninTypeToString(type));
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 NotifyDiagnosticsObservers(USERNAME, ""); 552 NotifyDiagnosticsObservers(USERNAME, "");
552 NotifyDiagnosticsObservers(LSID, ""); 553 NotifyDiagnosticsObservers(LSID, "");
553 NotifyDiagnosticsObservers( 554 NotifyDiagnosticsObservers(
554 signin_internals_util::SID, ""); 555 signin_internals_util::SID, "");
555 556
556 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); 557 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_);
557 content::NotificationService::current()->Notify( 558 content::NotificationService::current()->Notify(
558 chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, 559 chrome::NOTIFICATION_GOOGLE_SIGNED_OUT,
559 content::Source<Profile>(profile_), 560 content::Source<Profile>(profile_),
560 content::Details<const GoogleServiceSignoutDetails>(&details)); 561 content::Details<const GoogleServiceSignoutDetails>(&details));
562 RevokeOAuthLoginToken();
561 token_service->ResetCredentialsInMemory(); 563 token_service->ResetCredentialsInMemory();
562 token_service->EraseTokensFromDB(); 564 token_service->EraseTokensFromDB();
563 } 565 }
564 566
567 void SigninManager::RevokeOAuthLoginToken() {
568 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_);
569 if (token_service->HasOAuthLoginToken()) {
570 revoke_token_fetcher_.reset(
571 new GaiaAuthFetcher(this,
572 GaiaConstants::kChromeSource,
573 profile_->GetRequestContext()));
574 revoke_token_fetcher_->StartRevokeOAuth2Token(
575 token_service->GetOAuth2LoginRefreshToken());
576 }
577 }
578
579 void SigninManager::OnOAuth2RevokeTokenCompleted() {
580 revoke_token_fetcher_.reset(NULL);
581 }
582
565 bool SigninManager::AuthInProgress() const { 583 bool SigninManager::AuthInProgress() const {
566 return !possibly_invalid_username_.empty(); 584 return !possibly_invalid_username_.empty();
567 } 585 }
568 586
569 void SigninManager::OnGetUserInfoKeyNotFound(const std::string& key) { 587 void SigninManager::OnGetUserInfoKeyNotFound(const std::string& key) {
570 DCHECK(key == kGetInfoDisplayEmailKey || key == kGetInfoEmailKey); 588 DCHECK(key == kGetInfoDisplayEmailKey || key == kGetInfoEmailKey);
571 LOG(ERROR) << "Account is not associated with a valid email address. " 589 LOG(ERROR) << "Account is not associated with a valid email address. "
572 << "Login failed."; 590 << "Login failed.";
573 OnClientLoginFailure(GoogleServiceAuthError( 591 OnClientLoginFailure(GoogleServiceAuthError(
574 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS)); 592 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS));
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 NotifySigninValueChanged(field, value)); 954 NotifySigninValueChanged(field, value));
937 } 955 }
938 956
939 void SigninManager::NotifyDiagnosticsObservers( 957 void SigninManager::NotifyDiagnosticsObservers(
940 const TimedSigninStatusField& field, 958 const TimedSigninStatusField& field,
941 const std::string& value) { 959 const std::string& value) {
942 FOR_EACH_OBSERVER(SigninDiagnosticsObserver, 960 FOR_EACH_OBSERVER(SigninDiagnosticsObserver,
943 signin_diagnostics_observers_, 961 signin_diagnostics_observers_,
944 NotifySigninValueChanged(field, value)); 962 NotifySigninValueChanged(field, value));
945 } 963 }
OLDNEW
« no previous file with comments | « chrome/browser/signin/signin_manager.h ('k') | google_apis/gaia/gaia_auth_consumer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698