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

Side by Side Diff: google_apis/gaia/ubertoken_fetcher.cc

Issue 136723009: Move UbertokenFetcher from //chrome to //google_apis. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 "google_apis/gaia/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"
11 #include "chrome/browser/signin/profile_oauth2_token_service.h"
12 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
13 #include "google_apis/gaia/gaia_auth_fetcher.h" 10 #include "google_apis/gaia/gaia_auth_fetcher.h"
14 #include "google_apis/gaia/gaia_constants.h" 11 #include "google_apis/gaia/gaia_constants.h"
15 #include "google_apis/gaia/gaia_urls.h" 12 #include "google_apis/gaia/gaia_urls.h"
16 #include "google_apis/gaia/google_service_auth_error.h" 13 #include "google_apis/gaia/google_service_auth_error.h"
17 #include "google_apis/gaia/oauth2_token_service.h" 14 #include "google_apis/gaia/oauth2_token_service.h"
18 15
19 UbertokenFetcher::UbertokenFetcher(Profile* profile, 16 UbertokenFetcher::UbertokenFetcher(
20 UbertokenConsumer* consumer) 17 OAuth2TokenService* token_service,
18 UbertokenConsumer* consumer,
19 net::URLRequestContextGetter* request_context)
21 : OAuth2TokenService::Consumer("uber_token_fetcher"), 20 : OAuth2TokenService::Consumer("uber_token_fetcher"),
22 profile_(profile), consumer_(consumer) { 21 token_service_(token_service),
23 DCHECK(profile); 22 consumer_(consumer),
23 request_context_(request_context) {
24 DCHECK(token_service);
24 DCHECK(consumer); 25 DCHECK(consumer);
26 DCHECK(request_context);
25 } 27 }
26 28
27 UbertokenFetcher::~UbertokenFetcher() { 29 UbertokenFetcher::~UbertokenFetcher() {
28 } 30 }
29 31
30 void UbertokenFetcher::StartFetchingToken(const std::string& account_id) { 32 void UbertokenFetcher::StartFetchingToken(const std::string& account_id) {
31 OAuth2TokenService::ScopeSet scopes; 33 OAuth2TokenService::ScopeSet scopes;
32 scopes.insert(GaiaUrls::GetInstance()->oauth1_login_scope()); 34 scopes.insert(GaiaUrls::GetInstance()->oauth1_login_scope());
33 OAuth2TokenService* token_service = 35 DCHECK(&account_id);
Roger Tawa OOO till Jul 10th 2014/01/15 14:41:19 Did you mean: DCHECK(!account_id.empty()) ?
blundell 2014/01/15 14:46:00 Oops, this is just crud that can go away. On 2014
blundell 2014/01/16 16:01:37 Done.
34 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); 36 access_token_request_ =
35 access_token_request_ = token_service->StartRequest(account_id, scopes, this); 37 token_service_->StartRequest(account_id, scopes, this);
36 } 38 }
37 39
38 void UbertokenFetcher::OnUberAuthTokenSuccess(const std::string& token) { 40 void UbertokenFetcher::OnUberAuthTokenSuccess(const std::string& token) {
39 consumer_->OnUbertokenSuccess(token); 41 consumer_->OnUbertokenSuccess(token);
40 } 42 }
41 43
42 void UbertokenFetcher::OnUberAuthTokenFailure( 44 void UbertokenFetcher::OnUberAuthTokenFailure(
43 const GoogleServiceAuthError& error) { 45 const GoogleServiceAuthError& error) {
44 consumer_->OnUbertokenFailure(error); 46 consumer_->OnUbertokenFailure(error);
45 } 47 }
46 48
47 void UbertokenFetcher::OnGetTokenSuccess( 49 void UbertokenFetcher::OnGetTokenSuccess(
48 const OAuth2TokenService::Request* request, 50 const OAuth2TokenService::Request* request,
49 const std::string& access_token, 51 const std::string& access_token,
50 const base::Time& expiration_time) { 52 const base::Time& expiration_time) {
51 access_token_request_.reset(); 53 access_token_request_.reset();
52 gaia_auth_fetcher_.reset(new GaiaAuthFetcher(this, 54 gaia_auth_fetcher_.reset(new GaiaAuthFetcher(this,
53 GaiaConstants::kChromeSource, 55 GaiaConstants::kChromeSource,
54 profile_->GetRequestContext())); 56 request_context_));
55 gaia_auth_fetcher_->StartTokenFetchForUberAuthExchange(access_token); 57 gaia_auth_fetcher_->StartTokenFetchForUberAuthExchange(access_token);
56 } 58 }
57 59
58 void UbertokenFetcher::OnGetTokenFailure( 60 void UbertokenFetcher::OnGetTokenFailure(
59 const OAuth2TokenService::Request* request, 61 const OAuth2TokenService::Request* request,
60 const GoogleServiceAuthError& error) { 62 const GoogleServiceAuthError& error) {
61 access_token_request_.reset(); 63 access_token_request_.reset();
62 consumer_->OnUbertokenFailure(error); 64 consumer_->OnUbertokenFailure(error);
63 } 65 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698