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

Side by Side Diff: chrome/browser/chromeos/login/login_utils.cc

Issue 7574009: Added OAuth support to TokenService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tweaked mock for OnOAuthWrapBridgeFailure. Created 9 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/login/online_attempt.cc » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/login/login_utils.h" 5 #include "chrome/browser/chromeos/login/login_utils.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 149
150 // Verifies OAuth1 access token by performing OAuthLogin. 150 // Verifies OAuth1 access token by performing OAuthLogin.
151 class OAuthLoginVerifier : public GaiaOAuthConsumer { 151 class OAuthLoginVerifier : public GaiaOAuthConsumer {
152 public: 152 public:
153 OAuthLoginVerifier(Profile* user_profile, 153 OAuthLoginVerifier(Profile* user_profile,
154 const std::string& oauth1_token, 154 const std::string& oauth1_token,
155 const std::string& oauth1_secret) 155 const std::string& oauth1_secret)
156 : oauth_fetcher_(this, 156 : oauth_fetcher_(this,
157 user_profile->GetOffTheRecordProfile()->GetRequestContext(), 157 user_profile->GetOffTheRecordProfile()->GetRequestContext(),
158 user_profile->GetOffTheRecordProfile(), 158 user_profile->GetOffTheRecordProfile(),
159 GaiaConstants::kSyncService,
160 kServiceScopeChromeOS), 159 kServiceScopeChromeOS),
161 oauth1_token_(oauth1_token), 160 oauth1_token_(oauth1_token),
162 oauth1_secret_(oauth1_secret) { 161 oauth1_secret_(oauth1_secret) {
163 } 162 }
164 virtual ~OAuthLoginVerifier() {} 163 virtual ~OAuthLoginVerifier() {}
165 164
166 void Start() { 165 void Start() {
167 oauth_fetcher_.StartOAuthLogin(GaiaConstants::kChromeOSSource, 166 oauth_fetcher_.StartOAuthLogin(GaiaConstants::kChromeOSSource,
168 GaiaConstants::kContactsService, 167 GaiaConstants::kContactsService,
169 oauth1_token_, 168 oauth1_token_,
(...skipping 24 matching lines...) Expand all
194 193
195 // Fetches an OAuth token and initializes user policy with it. 194 // Fetches an OAuth token and initializes user policy with it.
196 class PolicyOAuthFetcher : public GaiaOAuthConsumer { 195 class PolicyOAuthFetcher : public GaiaOAuthConsumer {
197 public: 196 public:
198 PolicyOAuthFetcher(Profile* profile, 197 PolicyOAuthFetcher(Profile* profile,
199 const std::string& oauth1_token, 198 const std::string& oauth1_token,
200 const std::string& oauth1_secret) 199 const std::string& oauth1_secret)
201 : oauth_fetcher_(this, 200 : oauth_fetcher_(this,
202 profile->GetRequestContext(), 201 profile->GetRequestContext(),
203 profile, 202 profile,
204 GaiaConstants::kDeviceManagementService,
205 kServiceScopeChromeOSDeviceManagement), 203 kServiceScopeChromeOSDeviceManagement),
206 oauth1_token_(oauth1_token), 204 oauth1_token_(oauth1_token),
207 oauth1_secret_(oauth1_secret) { 205 oauth1_secret_(oauth1_secret) {
208 oauth_fetcher_.SetAutoFetchLimit( 206 oauth_fetcher_.SetAutoFetchLimit(
209 GaiaOAuthFetcher::OAUTH2_SERVICE_ACCESS_TOKEN); 207 GaiaOAuthFetcher::OAUTH2_SERVICE_ACCESS_TOKEN);
210 } 208 }
211 virtual ~PolicyOAuthFetcher() {} 209 virtual ~PolicyOAuthFetcher() {}
212 210
213 void Start() { 211 void Start() {
214 oauth_fetcher_.StartOAuthWrapBridge(oauth1_token_, oauth1_secret_, "3600", 212 oauth_fetcher_.StartOAuthWrapBridge(
215 std::string(GaiaConstants::kDeviceManagementService), 213 oauth1_token_, oauth1_secret_, GaiaConstants::kGaiaOAuthDuration,
216 std::string(kServiceScopeChromeOSDeviceManagement)); 214 std::string(kServiceScopeChromeOSDeviceManagement));
217 } 215 }
218 216
219 // GaiaOAuthConsumer implementation: 217 // GaiaOAuthConsumer implementation:
220 virtual void OnOAuthWrapBridgeSuccess( 218 virtual void OnOAuthWrapBridgeSuccess(
221 const std::string& service_name, 219 const std::string& service_name,
222 const std::string& token, 220 const std::string& token,
223 const std::string& expires_in) OVERRIDE { 221 const std::string& expires_in) OVERRIDE {
224 policy::BrowserPolicyConnector* browser_policy_connector = 222 policy::BrowserPolicyConnector* browser_policy_connector =
225 g_browser_process->browser_policy_connector(); 223 g_browser_process->browser_policy_connector();
226 browser_policy_connector->RegisterForUserPolicy(token); 224 browser_policy_connector->RegisterForUserPolicy(token);
227 } 225 }
228 226
229 virtual void OnOAuthWrapBridgeFailure( 227 virtual void OnOAuthWrapBridgeFailure(
228 const std::string& service_name,
230 const GoogleServiceAuthError& error) OVERRIDE { 229 const GoogleServiceAuthError& error) OVERRIDE {
231 LOG(WARNING) << "Failed to get OAuth access token."; 230 LOG(WARNING) << "Failed to get OAuth access token for " << service_name;
232 } 231 }
233 232
234 private: 233 private:
235 GaiaOAuthFetcher oauth_fetcher_; 234 GaiaOAuthFetcher oauth_fetcher_;
236 std::string oauth1_token_; 235 std::string oauth1_token_;
237 std::string oauth1_secret_; 236 std::string oauth1_secret_;
238 237
239 DISALLOW_COPY_AND_ASSIGN(PolicyOAuthFetcher); 238 DISALLOW_COPY_AND_ASSIGN(PolicyOAuthFetcher);
240 }; 239 };
241 240
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 delegate_->OnProfilePrepared(user_profile); 561 delegate_->OnProfilePrepared(user_profile);
563 562
564 // TODO(altimofeev): Need to sanitize memory used to store password. 563 // TODO(altimofeev): Need to sanitize memory used to store password.
565 credentials_ = GaiaAuthConsumer::ClientLoginResult(); 564 credentials_ = GaiaAuthConsumer::ClientLoginResult();
566 } 565 }
567 566
568 void LoginUtilsImpl::FetchOAuth1AccessToken(Profile* auth_profile) { 567 void LoginUtilsImpl::FetchOAuth1AccessToken(Profile* auth_profile) {
569 oauth_fetcher_.reset(new GaiaOAuthFetcher(this, 568 oauth_fetcher_.reset(new GaiaOAuthFetcher(this,
570 auth_profile->GetRequestContext(), 569 auth_profile->GetRequestContext(),
571 auth_profile, 570 auth_profile,
572 GaiaConstants::kSyncService,
573 kServiceScopeChromeOS)); 571 kServiceScopeChromeOS));
574 // Let's first get the Oauth request token and OAuth1 token+secret. 572 // Let's first get the Oauth request token and OAuth1 token+secret.
575 // One we get that, we will kick off individial requests for OAuth2 tokens for 573 // One we get that, we will kick off individial requests for OAuth2 tokens for
576 // all our services. 574 // all our services.
577 oauth_fetcher_->SetAutoFetchLimit(GaiaOAuthFetcher::OAUTH1_ALL_ACCESS_TOKEN); 575 oauth_fetcher_->SetAutoFetchLimit(GaiaOAuthFetcher::OAUTH1_ALL_ACCESS_TOKEN);
578 oauth_fetcher_->StartGetOAuthTokenRequest(); 576 oauth_fetcher_->StartGetOAuthTokenRequest();
579 } 577 }
580 578
581 void LoginUtilsImpl::FetchCookies( 579 void LoginUtilsImpl::FetchCookies(
582 Profile* profile, 580 Profile* profile,
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 // Mark login host for deletion after browser starts. This 955 // Mark login host for deletion after browser starts. This
958 // guarantees that the message loop will be referenced by the 956 // guarantees that the message loop will be referenced by the
959 // browser before it is dereferenced by the login host. 957 // browser before it is dereferenced by the login host.
960 if (login_host) { 958 if (login_host) {
961 login_host->OnSessionStart(); 959 login_host->OnSessionStart();
962 login_host = NULL; 960 login_host = NULL;
963 } 961 }
964 } 962 }
965 963
966 } // namespace chromeos 964 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/login/online_attempt.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698