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/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" |
(...skipping 10 matching lines...) Expand all Loading... |
21 DCHECK(profile); | 21 DCHECK(profile); |
22 DCHECK(consumer); | 22 DCHECK(consumer); |
23 } | 23 } |
24 | 24 |
25 UbertokenFetcher::~UbertokenFetcher() { | 25 UbertokenFetcher::~UbertokenFetcher() { |
26 } | 26 } |
27 | 27 |
28 void UbertokenFetcher::StartFetchingToken() { | 28 void UbertokenFetcher::StartFetchingToken() { |
29 OAuth2TokenService::ScopeSet scopes; | 29 OAuth2TokenService::ScopeSet scopes; |
30 scopes.insert(GaiaUrls::GetInstance()->oauth1_login_scope()); | 30 scopes.insert(GaiaUrls::GetInstance()->oauth1_login_scope()); |
31 access_token_request_ = | 31 ProfileOAuth2TokenService* token_service = |
32 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)-> | 32 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); |
33 StartRequest(scopes, this); | 33 access_token_request_ = token_service->StartRequest( |
| 34 token_service->GetPrimaryAccountId(), scopes, this); |
34 } | 35 } |
35 | 36 |
36 void UbertokenFetcher::OnUberAuthTokenSuccess(const std::string& token) { | 37 void UbertokenFetcher::OnUberAuthTokenSuccess(const std::string& token) { |
37 consumer_->OnUbertokenSuccess(token); | 38 consumer_->OnUbertokenSuccess(token); |
38 } | 39 } |
39 | 40 |
40 void UbertokenFetcher::OnUberAuthTokenFailure( | 41 void UbertokenFetcher::OnUberAuthTokenFailure( |
41 const GoogleServiceAuthError& error) { | 42 const GoogleServiceAuthError& error) { |
42 consumer_->OnUbertokenFailure(error); | 43 consumer_->OnUbertokenFailure(error); |
43 } | 44 } |
44 | 45 |
45 void UbertokenFetcher::OnGetTokenSuccess( | 46 void UbertokenFetcher::OnGetTokenSuccess( |
46 const OAuth2TokenService::Request* request, | 47 const OAuth2TokenService::Request* request, |
47 const std::string& access_token, | 48 const std::string& access_token, |
48 const base::Time& expiration_time) { | 49 const base::Time& expiration_time) { |
49 access_token_request_.reset(); | 50 access_token_request_.reset(); |
50 gaia_auth_fetcher_.reset(new GaiaAuthFetcher(this, | 51 gaia_auth_fetcher_.reset(new GaiaAuthFetcher(this, |
51 GaiaConstants::kChromeSource, | 52 GaiaConstants::kChromeSource, |
52 profile_->GetRequestContext())); | 53 profile_->GetRequestContext())); |
53 gaia_auth_fetcher_->StartTokenFetchForUberAuthExchange(access_token); | 54 gaia_auth_fetcher_->StartTokenFetchForUberAuthExchange(access_token); |
54 } | 55 } |
55 | 56 |
56 void UbertokenFetcher::OnGetTokenFailure( | 57 void UbertokenFetcher::OnGetTokenFailure( |
57 const OAuth2TokenService::Request* request, | 58 const OAuth2TokenService::Request* request, |
58 const GoogleServiceAuthError& error) { | 59 const GoogleServiceAuthError& error) { |
59 access_token_request_.reset(); | 60 access_token_request_.reset(); |
60 consumer_->OnUbertokenFailure(error); | 61 consumer_->OnUbertokenFailure(error); |
61 } | 62 } |
OLD | NEW |