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

Side by Side Diff: chrome/browser/chromeos/policy/policy_oauth2_token_fetcher.cc

Issue 182573003: Extract OAuth2AccessTokenFetcher interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add missing file. Created 6 years, 9 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/chromeos/policy/policy_oauth2_token_fetcher.h" 5 #include "chrome/browser/chromeos/policy/policy_oauth2_token_fetcher.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.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_access_token_fetcher.h" 17 #include "google_apis/gaia/oauth2_access_token_fetcher_impl.h"
18 #include "net/url_request/url_request_context_getter.h" 18 #include "net/url_request/url_request_context_getter.h"
19 19
20 using content::BrowserThread; 20 using content::BrowserThread;
21 21
22 namespace policy { 22 namespace policy {
23 23
24 namespace { 24 namespace {
25 25
26 // Max retry count for token fetching requests. 26 // Max retry count for token fetching requests.
27 const int kMaxRequestAttemptCount = 5; 27 const int kMaxRequestAttemptCount = 5;
(...skipping 25 matching lines...) Expand all
53 this, GaiaConstants::kChromeSource, auth_context_getter_.get())); 53 this, GaiaConstants::kChromeSource, auth_context_getter_.get()));
54 refresh_token_fetcher_->StartCookieForOAuthLoginTokenExchange(std::string()); 54 refresh_token_fetcher_->StartCookieForOAuthLoginTokenExchange(std::string());
55 } 55 }
56 56
57 void PolicyOAuth2TokenFetcher::StartFetchingAccessToken() { 57 void PolicyOAuth2TokenFetcher::StartFetchingAccessToken() {
58 std::vector<std::string> scopes; 58 std::vector<std::string> scopes;
59 scopes.push_back(GaiaConstants::kDeviceManagementServiceOAuth); 59 scopes.push_back(GaiaConstants::kDeviceManagementServiceOAuth);
60 scopes.push_back( 60 scopes.push_back(
61 GaiaUrls::GetInstance()->oauth_wrap_bridge_user_info_scope()); 61 GaiaUrls::GetInstance()->oauth_wrap_bridge_user_info_scope());
62 access_token_fetcher_.reset( 62 access_token_fetcher_.reset(
63 new OAuth2AccessTokenFetcher(this, system_context_getter_.get())); 63 new OAuth2AccessTokenFetcherImpl(this, system_context_getter_.get()));
64 access_token_fetcher_->Start( 64 access_token_fetcher_->Start(
65 GaiaUrls::GetInstance()->oauth2_chrome_client_id(), 65 GaiaUrls::GetInstance()->oauth2_chrome_client_id(),
66 GaiaUrls::GetInstance()->oauth2_chrome_client_secret(), 66 GaiaUrls::GetInstance()->oauth2_chrome_client_secret(),
67 oauth2_refresh_token_, 67 oauth2_refresh_token_,
68 scopes); 68 scopes);
69 } 69 }
70 70
71 void PolicyOAuth2TokenFetcher::OnClientOAuthSuccess( 71 void PolicyOAuth2TokenFetcher::OnClientOAuthSuccess(
72 const GaiaAuthConsumer::ClientOAuthResult& oauth2_tokens) { 72 const GaiaAuthConsumer::ClientOAuthResult& oauth2_tokens) {
73 VLOG(1) << "OAuth2 tokens for policy fetching succeeded."; 73 VLOG(1) << "OAuth2 tokens for policy fetching succeeded.";
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 125 }
126 126
127 void PolicyOAuth2TokenFetcher::ForwardPolicyToken( 127 void PolicyOAuth2TokenFetcher::ForwardPolicyToken(
128 const std::string& token, 128 const std::string& token,
129 const GoogleServiceAuthError& error) { 129 const GoogleServiceAuthError& error) {
130 if (!callback_.is_null()) 130 if (!callback_.is_null())
131 callback_.Run(token, error); 131 callback_.Run(token, error);
132 } 132 }
133 133
134 } // namespace policy 134 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698