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

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

Issue 131973004: Eliminate usage of PO2TS::GetPrimaryAccountID() in UbertokenFetcher. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile failure Created 6 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/ubertoken_fetcher.h" 5 #include "chrome/browser/signin/ubertoken_fetcher.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/signin/profile_oauth2_token_service.h" 11 #include "chrome/browser/signin/profile_oauth2_token_service.h"
12 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 12 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
13 #include "google_apis/gaia/gaia_auth_fetcher.h" 13 #include "google_apis/gaia/gaia_auth_fetcher.h"
14 #include "google_apis/gaia/gaia_constants.h" 14 #include "google_apis/gaia/gaia_constants.h"
15 #include "google_apis/gaia/gaia_urls.h" 15 #include "google_apis/gaia/gaia_urls.h"
16 #include "google_apis/gaia/google_service_auth_error.h" 16 #include "google_apis/gaia/google_service_auth_error.h"
17 #include "google_apis/gaia/oauth2_token_service.h"
17 18
18 UbertokenFetcher::UbertokenFetcher(Profile* profile, 19 UbertokenFetcher::UbertokenFetcher(Profile* profile,
19 UbertokenConsumer* consumer) 20 UbertokenConsumer* consumer)
20 : OAuth2TokenService::Consumer("uber_token_fetcher"), 21 : OAuth2TokenService::Consumer("uber_token_fetcher"),
21 profile_(profile), consumer_(consumer) { 22 profile_(profile), consumer_(consumer) {
22 DCHECK(profile); 23 DCHECK(profile);
23 DCHECK(consumer); 24 DCHECK(consumer);
24 } 25 }
25 26
26 UbertokenFetcher::~UbertokenFetcher() { 27 UbertokenFetcher::~UbertokenFetcher() {
27 } 28 }
28 29
29 void UbertokenFetcher::StartFetchingToken() {
30 ProfileOAuth2TokenService* token_service =
31 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
32 StartFetchingToken(token_service->GetPrimaryAccountId());
33 }
34
35 void UbertokenFetcher::StartFetchingToken(const std::string& account_id) { 30 void UbertokenFetcher::StartFetchingToken(const std::string& account_id) {
36 OAuth2TokenService::ScopeSet scopes; 31 OAuth2TokenService::ScopeSet scopes;
37 scopes.insert(GaiaUrls::GetInstance()->oauth1_login_scope()); 32 scopes.insert(GaiaUrls::GetInstance()->oauth1_login_scope());
38 ProfileOAuth2TokenService* token_service = 33 OAuth2TokenService* token_service =
39 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); 34 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
40 access_token_request_ = token_service->StartRequest(account_id, scopes, this); 35 access_token_request_ = token_service->StartRequest(account_id, scopes, this);
41 } 36 }
42 37
43 void UbertokenFetcher::OnUberAuthTokenSuccess(const std::string& token) { 38 void UbertokenFetcher::OnUberAuthTokenSuccess(const std::string& token) {
44 consumer_->OnUbertokenSuccess(token); 39 consumer_->OnUbertokenSuccess(token);
45 } 40 }
46 41
47 void UbertokenFetcher::OnUberAuthTokenFailure( 42 void UbertokenFetcher::OnUberAuthTokenFailure(
48 const GoogleServiceAuthError& error) { 43 const GoogleServiceAuthError& error) {
(...skipping 10 matching lines...) Expand all
59 profile_->GetRequestContext())); 54 profile_->GetRequestContext()));
60 gaia_auth_fetcher_->StartTokenFetchForUberAuthExchange(access_token); 55 gaia_auth_fetcher_->StartTokenFetchForUberAuthExchange(access_token);
61 } 56 }
62 57
63 void UbertokenFetcher::OnGetTokenFailure( 58 void UbertokenFetcher::OnGetTokenFailure(
64 const OAuth2TokenService::Request* request, 59 const OAuth2TokenService::Request* request,
65 const GoogleServiceAuthError& error) { 60 const GoogleServiceAuthError& error) {
66 access_token_request_.reset(); 61 access_token_request_.reset();
67 consumer_->OnUbertokenFailure(error); 62 consumer_->OnUbertokenFailure(error);
68 } 63 }
OLDNEW
« no previous file with comments | « chrome/browser/signin/ubertoken_fetcher.h ('k') | chrome/browser/signin/ubertoken_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698