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" |
| 6 |
| 7 #include <vector> |
| 8 |
5 #include "base/logging.h" | 9 #include "base/logging.h" |
6 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
7 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/signin/token_service.h" | 12 #include "chrome/browser/signin/token_service.h" |
9 #include "chrome/browser/signin/token_service_factory.h" | 13 #include "chrome/browser/signin/token_service_factory.h" |
10 #include "chrome/browser/signin/ubertoken_fetcher.h" | |
11 #include "chrome/common/chrome_notification_types.h" | 14 #include "chrome/common/chrome_notification_types.h" |
12 #include "google_apis/gaia/gaia_constants.h" | 15 #include "google_apis/gaia/gaia_constants.h" |
13 #include "google_apis/gaia/gaia_urls.h" | 16 #include "google_apis/gaia/gaia_urls.h" |
14 #include "google_apis/gaia/google_service_auth_error.h" | 17 #include "google_apis/gaia/google_service_auth_error.h" |
15 #include "net/base/load_flags.h" | 18 #include "net/base/load_flags.h" |
16 | 19 |
17 UbertokenFetcher::UbertokenFetcher(Profile* profile, | 20 UbertokenFetcher::UbertokenFetcher(Profile* profile, |
18 UbertokenConsumer* consumer) | 21 UbertokenConsumer* consumer) |
19 : profile_(profile), consumer_(consumer) { | 22 : profile_(profile), consumer_(consumer) { |
20 DCHECK(profile); | 23 DCHECK(profile); |
(...skipping 19 matching lines...) Expand all Loading... |
40 } | 43 } |
41 | 44 |
42 void UbertokenFetcher::StartFetchingUbertoken() { | 45 void UbertokenFetcher::StartFetchingUbertoken() { |
43 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); | 46 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); |
44 DCHECK(token_service->HasOAuthLoginToken()); | 47 DCHECK(token_service->HasOAuthLoginToken()); |
45 gaia::OAuthClientInfo client_info; | 48 gaia::OAuthClientInfo client_info; |
46 GaiaUrls* urls = GaiaUrls::GetInstance(); | 49 GaiaUrls* urls = GaiaUrls::GetInstance(); |
47 client_info.client_id = urls->oauth2_chrome_client_id(); | 50 client_info.client_id = urls->oauth2_chrome_client_id(); |
48 client_info.client_secret = urls->oauth2_chrome_client_secret(); | 51 client_info.client_secret = urls->oauth2_chrome_client_secret(); |
49 gaia_oauth_client_.reset(new gaia::GaiaOAuthClient( | 52 gaia_oauth_client_.reset(new gaia::GaiaOAuthClient( |
50 urls->oauth2_token_url(), profile_->GetRequestContext())); | 53 profile_->GetRequestContext())); |
| 54 std::vector<std::string> empty_scope_list; // (Use scope from refresh token.) |
51 gaia_oauth_client_->RefreshToken( | 55 gaia_oauth_client_->RefreshToken( |
52 client_info, token_service->GetOAuth2LoginRefreshToken(), 1, this); | 56 client_info, token_service->GetOAuth2LoginRefreshToken(), |
| 57 empty_scope_list, 1, this); |
53 } | 58 } |
54 | 59 |
55 void UbertokenFetcher::Observe(int type, | 60 void UbertokenFetcher::Observe(int type, |
56 const content::NotificationSource& source, | 61 const content::NotificationSource& source, |
57 const content::NotificationDetails& details) { | 62 const content::NotificationDetails& details) { |
58 DCHECK(type == chrome::NOTIFICATION_TOKEN_AVAILABLE || | 63 DCHECK(type == chrome::NOTIFICATION_TOKEN_AVAILABLE || |
59 type == chrome::NOTIFICATION_TOKEN_REQUEST_FAILED); | 64 type == chrome::NOTIFICATION_TOKEN_REQUEST_FAILED); |
60 | 65 |
61 if (type == chrome::NOTIFICATION_TOKEN_AVAILABLE) { | 66 if (type == chrome::NOTIFICATION_TOKEN_AVAILABLE) { |
62 TokenService::TokenAvailableDetails* token_details = | 67 TokenService::TokenAvailableDetails* token_details = |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 } | 111 } |
107 | 112 |
108 void UbertokenFetcher::OnUberAuthTokenSuccess(const std::string& token) { | 113 void UbertokenFetcher::OnUberAuthTokenSuccess(const std::string& token) { |
109 consumer_->OnUbertokenSuccess(token); | 114 consumer_->OnUbertokenSuccess(token); |
110 } | 115 } |
111 | 116 |
112 void UbertokenFetcher::OnUberAuthTokenFailure( | 117 void UbertokenFetcher::OnUberAuthTokenFailure( |
113 const GoogleServiceAuthError& error) { | 118 const GoogleServiceAuthError& error) { |
114 consumer_->OnUbertokenFailure(error); | 119 consumer_->OnUbertokenFailure(error); |
115 } | 120 } |
OLD | NEW |