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

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

Issue 2630023002: Do not fetch tokens for telemetry tests. (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <memory> 7 #include <memory>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h"
11 #include "base/logging.h" 12 #include "base/logging.h"
12 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
13 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "chromeos/chromeos_switches.h"
14 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
15 #include "google_apis/gaia/gaia_auth_fetcher.h" 17 #include "google_apis/gaia/gaia_auth_fetcher.h"
16 #include "google_apis/gaia/gaia_constants.h" 18 #include "google_apis/gaia/gaia_constants.h"
17 #include "google_apis/gaia/gaia_urls.h" 19 #include "google_apis/gaia/gaia_urls.h"
18 #include "google_apis/gaia/google_service_auth_error.h" 20 #include "google_apis/gaia/google_service_auth_error.h"
19 #include "google_apis/gaia/oauth2_access_token_fetcher_impl.h" 21 #include "google_apis/gaia/oauth2_access_token_fetcher_impl.h"
20 #include "net/url_request/url_request_context_getter.h" 22 #include "net/url_request/url_request_context_getter.h"
21 23
22 using content::BrowserThread; 24 using content::BrowserThread;
23 25
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 const TokenCallback& callback) { 159 const TokenCallback& callback) {
158 DCHECK(!refresh_token_fetcher_ && !access_token_fetcher_); 160 DCHECK(!refresh_token_fetcher_ && !access_token_fetcher_);
159 161
160 oauth2_refresh_token_ = oauth2_refresh_token; 162 oauth2_refresh_token_ = oauth2_refresh_token;
161 system_context_getter_ = system_context_getter; 163 system_context_getter_ = system_context_getter;
162 callback_ = callback; 164 callback_ = callback;
163 StartFetchingAccessToken(); 165 StartFetchingAccessToken();
164 } 166 }
165 167
166 void PolicyOAuth2TokenFetcherImpl::StartFetchingRefreshToken() { 168 void PolicyOAuth2TokenFetcherImpl::StartFetchingRefreshToken() {
169 // Don't fetch tokens for test.
170 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
171 chromeos::switches::kDisableGaiaServices)) {
172 failed_ = true;
173 ForwardPolicyToken(
174 std::string(),
175 GoogleServiceAuthError(GoogleServiceAuthError::CONNECTION_FAILED));
176 return;
177 }
178
167 if (auth_code_.empty()) { 179 if (auth_code_.empty()) {
168 refresh_token_fetcher_.reset(new GaiaAuthFetcher( 180 refresh_token_fetcher_.reset(new GaiaAuthFetcher(
169 this, GaiaConstants::kChromeSource, auth_context_getter_.get())); 181 this, GaiaConstants::kChromeSource, auth_context_getter_.get()));
170 refresh_token_fetcher_->StartCookieForOAuthLoginTokenExchange( 182 refresh_token_fetcher_->StartCookieForOAuthLoginTokenExchange(
171 std::string()); 183 std::string());
172 } else { 184 } else {
173 refresh_token_fetcher_.reset(new GaiaAuthFetcher( 185 refresh_token_fetcher_.reset(new GaiaAuthFetcher(
174 this, GaiaConstants::kChromeSource, system_context_getter_.get())); 186 this, GaiaConstants::kChromeSource, system_context_getter_.get()));
175 refresh_token_fetcher_->StartAuthCodeForOAuth2TokenExchange(auth_code_); 187 refresh_token_fetcher_->StartAuthCodeForOAuth2TokenExchange(auth_code_);
176 } 188 }
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 if (use_fake_tokens_for_testing_) 325 if (use_fake_tokens_for_testing_)
314 return new PolicyOAuth2TokenFetcherFake(); 326 return new PolicyOAuth2TokenFetcherFake();
315 return new PolicyOAuth2TokenFetcherImpl(); 327 return new PolicyOAuth2TokenFetcherImpl();
316 } 328 }
317 329
318 PolicyOAuth2TokenFetcher::PolicyOAuth2TokenFetcher() {} 330 PolicyOAuth2TokenFetcher::PolicyOAuth2TokenFetcher() {}
319 331
320 PolicyOAuth2TokenFetcher::~PolicyOAuth2TokenFetcher() {} 332 PolicyOAuth2TokenFetcher::~PolicyOAuth2TokenFetcher() {}
321 333
322 } // namespace policy 334 } // namespace policy
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698