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

Side by Side Diff: chrome/browser/extensions/api/identity/experimental_identity_api.cc

Issue 23382008: Making OAuth2TokenService multi-login aware, updating callers, minor fixes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updates to AndroidPO2TS and removing the DCHECK(signin_manager) from GetPrimaryAccountId Created 7 years, 3 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
OLDNEW
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/extensions/api/identity/experimental_identity_api.h" 5 #include "chrome/browser/extensions/api/identity/experimental_identity_api.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 void ExperimentalIdentityGetAuthTokenFunction::StartLoginAccessTokenRequest() { 229 void ExperimentalIdentityGetAuthTokenFunction::StartLoginAccessTokenRequest() {
230 ProfileOAuth2TokenService* service = 230 ProfileOAuth2TokenService* service =
231 ProfileOAuth2TokenServiceFactory::GetForProfile(profile()); 231 ProfileOAuth2TokenServiceFactory::GetForProfile(profile());
232 #if defined(OS_CHROMEOS) 232 #if defined(OS_CHROMEOS)
233 if (chrome::IsRunningInForcedAppMode()) { 233 if (chrome::IsRunningInForcedAppMode()) {
234 std::string app_client_id; 234 std::string app_client_id;
235 std::string app_client_secret; 235 std::string app_client_secret;
236 if (chromeos::UserManager::Get()->GetAppModeChromeClientOAuthInfo( 236 if (chromeos::UserManager::Get()->GetAppModeChromeClientOAuthInfo(
237 &app_client_id, &app_client_secret)) { 237 &app_client_id, &app_client_secret)) {
238 login_token_request_ = 238 login_token_request_ =
239 service->StartRequestForClient(app_client_id, 239 service->StartRequestForClient(service->GetPrimaryAccountId(),
240 app_client_id,
240 app_client_secret, 241 app_client_secret,
241 OAuth2TokenService::ScopeSet(), 242 OAuth2TokenService::ScopeSet(),
242 this); 243 this);
243 return; 244 return;
244 } 245 }
245 } 246 }
246 #endif 247 #endif
247 login_token_request_ = service->StartRequest(OAuth2TokenService::ScopeSet(), 248 login_token_request_ = service->StartRequest(
248 this); 249 service->GetPrimaryAccountId(), OAuth2TokenService::ScopeSet(), this);
249 } 250 }
250 251
251 void ExperimentalIdentityGetAuthTokenFunction::StartGaiaRequest( 252 void ExperimentalIdentityGetAuthTokenFunction::StartGaiaRequest(
252 const std::string& login_access_token) { 253 const std::string& login_access_token) {
253 DCHECK(!login_access_token.empty()); 254 DCHECK(!login_access_token.empty());
254 mint_token_flow_.reset(CreateMintTokenFlow(login_access_token)); 255 mint_token_flow_.reset(CreateMintTokenFlow(login_access_token));
255 mint_token_flow_->Start(); 256 mint_token_flow_->Start();
256 } 257 }
257 258
258 void ExperimentalIdentityGetAuthTokenFunction::ShowLoginPopup() { 259 void ExperimentalIdentityGetAuthTokenFunction::ShowLoginPopup() {
(...skipping 23 matching lines...) Expand all
282 OAuth2MintTokenFlow::Parameters( 283 OAuth2MintTokenFlow::Parameters(
283 login_access_token, 284 login_access_token,
284 GetExtension()->id(), 285 GetExtension()->id(),
285 oauth2_info.client_id, 286 oauth2_info.client_id,
286 oauth2_info.scopes, 287 oauth2_info.scopes,
287 gaia_mint_token_mode_)); 288 gaia_mint_token_mode_));
288 return mint_token_flow; 289 return mint_token_flow;
289 } 290 }
290 291
291 bool ExperimentalIdentityGetAuthTokenFunction::HasLoginToken() const { 292 bool ExperimentalIdentityGetAuthTokenFunction::HasLoginToken() const {
292 return ProfileOAuth2TokenServiceFactory::GetForProfile(profile())-> 293 ProfileOAuth2TokenService* token_service =
293 RefreshTokenIsAvailable(); 294 ProfileOAuth2TokenServiceFactory::GetForProfile(profile());
295 return token_service->RefreshTokenIsAvailable(
296 token_service->GetPrimaryAccountId());
294 } 297 }
295 298
296 ExperimentalIdentityLaunchWebAuthFlowFunction:: 299 ExperimentalIdentityLaunchWebAuthFlowFunction::
297 ExperimentalIdentityLaunchWebAuthFlowFunction() {} 300 ExperimentalIdentityLaunchWebAuthFlowFunction() {}
298 301
299 ExperimentalIdentityLaunchWebAuthFlowFunction:: 302 ExperimentalIdentityLaunchWebAuthFlowFunction::
300 ~ExperimentalIdentityLaunchWebAuthFlowFunction() { 303 ~ExperimentalIdentityLaunchWebAuthFlowFunction() {
301 if (auth_flow_) 304 if (auth_flow_)
302 auth_flow_.release()->DetachDelegateAndDelete(); 305 auth_flow_.release()->DetachDelegateAndDelete();
303 } 306 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 } 394 }
392 } 395 }
393 396
394 void ExperimentalIdentityLaunchWebAuthFlowFunction:: 397 void ExperimentalIdentityLaunchWebAuthFlowFunction::
395 InitFinalRedirectURLPrefixesForTest(const std::string& extension_id) { 398 InitFinalRedirectURLPrefixesForTest(const std::string& extension_id) {
396 final_prefixes_.clear(); 399 final_prefixes_.clear();
397 InitFinalRedirectURLPrefixes(extension_id); 400 InitFinalRedirectURLPrefixes(extension_id);
398 } 401 }
399 402
400 } // namespace extensions 403 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698