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

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

Issue 16998003: Update CrOS to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 void PolicyOAuth2TokenFetcher::Start() { 56 void PolicyOAuth2TokenFetcher::Start() {
57 retry_count_ = 0; 57 retry_count_ = 0;
58 if (oauth2_refresh_token_.empty()) { 58 if (oauth2_refresh_token_.empty()) {
59 StartFetchingRefreshToken(); 59 StartFetchingRefreshToken();
60 } else { 60 } else {
61 StartFetchingAccessToken(); 61 StartFetchingAccessToken();
62 } 62 }
63 } 63 }
64 64
65 void PolicyOAuth2TokenFetcher::StartFetchingRefreshToken() { 65 void PolicyOAuth2TokenFetcher::StartFetchingRefreshToken() {
66 refresh_token_fetcher_.reset( 66 refresh_token_fetcher_.reset(new GaiaAuthFetcher(
67 new GaiaAuthFetcher(this, 67 this, GaiaConstants::kChromeSource, auth_context_getter_.get()));
68 GaiaConstants::kChromeSource,
69 auth_context_getter_));
70 refresh_token_fetcher_->StartCookieForOAuthLoginTokenExchange(EmptyString()); 68 refresh_token_fetcher_->StartCookieForOAuthLoginTokenExchange(EmptyString());
71 } 69 }
72 70
73 void PolicyOAuth2TokenFetcher::StartFetchingAccessToken() { 71 void PolicyOAuth2TokenFetcher::StartFetchingAccessToken() {
74 std::vector<std::string> scopes; 72 std::vector<std::string> scopes;
75 scopes.push_back(GaiaConstants::kDeviceManagementServiceOAuth); 73 scopes.push_back(GaiaConstants::kDeviceManagementServiceOAuth);
76 access_token_fetcher_.reset( 74 access_token_fetcher_.reset(
77 new OAuth2AccessTokenFetcher(this, system_context_getter_)); 75 new OAuth2AccessTokenFetcher(this, system_context_getter_.get()));
78 access_token_fetcher_->Start( 76 access_token_fetcher_->Start(
79 GaiaUrls::GetInstance()->oauth2_chrome_client_id(), 77 GaiaUrls::GetInstance()->oauth2_chrome_client_id(),
80 GaiaUrls::GetInstance()->oauth2_chrome_client_secret(), 78 GaiaUrls::GetInstance()->oauth2_chrome_client_secret(),
81 oauth2_refresh_token_, 79 oauth2_refresh_token_,
82 scopes); 80 scopes);
83 } 81 }
84 82
85 void PolicyOAuth2TokenFetcher::OnClientOAuthSuccess( 83 void PolicyOAuth2TokenFetcher::OnClientOAuthSuccess(
86 const GaiaAuthConsumer::ClientOAuthResult& oauth2_tokens) { 84 const GaiaAuthConsumer::ClientOAuthResult& oauth2_tokens) {
87 LOG(INFO) << "OAuth2 tokens for policy fetching succeeded."; 85 LOG(INFO) << "OAuth2 tokens for policy fetching succeeded.";
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // So don't rely on |this| still being valid after ForwardPolicyToken() 132 // So don't rely on |this| still being valid after ForwardPolicyToken()
135 // returns i.e. don't write to |failed_| or other fields. 133 // returns i.e. don't write to |failed_| or other fields.
136 ForwardPolicyToken(EmptyString()); 134 ForwardPolicyToken(EmptyString());
137 } 135 }
138 136
139 void PolicyOAuth2TokenFetcher::ForwardPolicyToken(const std::string& token) { 137 void PolicyOAuth2TokenFetcher::ForwardPolicyToken(const std::string& token) {
140 callback_.Run(token); 138 callback_.Run(token);
141 } 139 }
142 140
143 } // namespace policy 141 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698