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

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

Issue 136723009: Move UbertokenFetcher from //chrome to //google_apis. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/signin/ubertoken_fetcher.h"
6
7 #include <vector>
8
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"
14 #include "google_apis/gaia/gaia_constants.h"
15 #include "google_apis/gaia/gaia_urls.h"
16 #include "google_apis/gaia/google_service_auth_error.h"
17 #include "google_apis/gaia/oauth2_token_service.h"
18
19 UbertokenFetcher::UbertokenFetcher(Profile* profile,
20 UbertokenConsumer* consumer)
21 : OAuth2TokenService::Consumer("uber_token_fetcher"),
22 profile_(profile), consumer_(consumer) {
23 DCHECK(profile);
24 DCHECK(consumer);
25 }
26
27 UbertokenFetcher::~UbertokenFetcher() {
28 }
29
30 void UbertokenFetcher::StartFetchingToken(const std::string& account_id) {
31 OAuth2TokenService::ScopeSet scopes;
32 scopes.insert(GaiaUrls::GetInstance()->oauth1_login_scope());
33 OAuth2TokenService* token_service =
34 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
35 access_token_request_ = token_service->StartRequest(account_id, scopes, this);
36 }
37
38 void UbertokenFetcher::OnUberAuthTokenSuccess(const std::string& token) {
39 consumer_->OnUbertokenSuccess(token);
40 }
41
42 void UbertokenFetcher::OnUberAuthTokenFailure(
43 const GoogleServiceAuthError& error) {
44 consumer_->OnUbertokenFailure(error);
45 }
46
47 void UbertokenFetcher::OnGetTokenSuccess(
48 const OAuth2TokenService::Request* request,
49 const std::string& access_token,
50 const base::Time& expiration_time) {
51 access_token_request_.reset();
52 gaia_auth_fetcher_.reset(new GaiaAuthFetcher(this,
53 GaiaConstants::kChromeSource,
54 profile_->GetRequestContext()));
55 gaia_auth_fetcher_->StartTokenFetchForUberAuthExchange(access_token);
56 }
57
58 void UbertokenFetcher::OnGetTokenFailure(
59 const OAuth2TokenService::Request* request,
60 const GoogleServiceAuthError& error) {
61 access_token_request_.reset();
62 consumer_->OnUbertokenFailure(error);
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