OLD | NEW |
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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 void ExperimentalIdentityGetAuthTokenFunction::StartLoginAccessTokenRequest() { | 228 void ExperimentalIdentityGetAuthTokenFunction::StartLoginAccessTokenRequest() { |
229 ProfileOAuth2TokenService* service = | 229 ProfileOAuth2TokenService* service = |
230 ProfileOAuth2TokenServiceFactory::GetForProfile(profile()); | 230 ProfileOAuth2TokenServiceFactory::GetForProfile(profile()); |
231 #if defined(OS_CHROMEOS) | 231 #if defined(OS_CHROMEOS) |
232 if (chrome::IsRunningInForcedAppMode()) { | 232 if (chrome::IsRunningInForcedAppMode()) { |
233 std::string app_client_id; | 233 std::string app_client_id; |
234 std::string app_client_secret; | 234 std::string app_client_secret; |
235 if (chromeos::UserManager::Get()->GetAppModeChromeClientOAuthInfo( | 235 if (chromeos::UserManager::Get()->GetAppModeChromeClientOAuthInfo( |
236 &app_client_id, &app_client_secret)) { | 236 &app_client_id, &app_client_secret)) { |
237 login_token_request_ = | 237 login_token_request_ = |
238 service->StartRequestForClient(app_client_id, | 238 service->StartRequestForClient(service->GetPrimaryAccountId(), |
| 239 app_client_id, |
239 app_client_secret, | 240 app_client_secret, |
240 OAuth2TokenService::ScopeSet(), | 241 OAuth2TokenService::ScopeSet(), |
241 this); | 242 this); |
242 return; | 243 return; |
243 } | 244 } |
244 } | 245 } |
245 #endif | 246 #endif |
246 login_token_request_ = service->StartRequest(OAuth2TokenService::ScopeSet(), | 247 login_token_request_ = service->StartRequest( |
247 this); | 248 service->GetPrimaryAccountId(), OAuth2TokenService::ScopeSet(), this); |
248 } | 249 } |
249 | 250 |
250 void ExperimentalIdentityGetAuthTokenFunction::StartGaiaRequest( | 251 void ExperimentalIdentityGetAuthTokenFunction::StartGaiaRequest( |
251 const std::string& login_access_token) { | 252 const std::string& login_access_token) { |
252 DCHECK(!login_access_token.empty()); | 253 DCHECK(!login_access_token.empty()); |
253 mint_token_flow_.reset(CreateMintTokenFlow(login_access_token)); | 254 mint_token_flow_.reset(CreateMintTokenFlow(login_access_token)); |
254 mint_token_flow_->Start(); | 255 mint_token_flow_->Start(); |
255 } | 256 } |
256 | 257 |
257 void ExperimentalIdentityGetAuthTokenFunction::ShowLoginPopup() { | 258 void ExperimentalIdentityGetAuthTokenFunction::ShowLoginPopup() { |
(...skipping 23 matching lines...) Expand all Loading... |
281 OAuth2MintTokenFlow::Parameters( | 282 OAuth2MintTokenFlow::Parameters( |
282 login_access_token, | 283 login_access_token, |
283 GetExtension()->id(), | 284 GetExtension()->id(), |
284 oauth2_info.client_id, | 285 oauth2_info.client_id, |
285 oauth2_info.scopes, | 286 oauth2_info.scopes, |
286 gaia_mint_token_mode_)); | 287 gaia_mint_token_mode_)); |
287 return mint_token_flow; | 288 return mint_token_flow; |
288 } | 289 } |
289 | 290 |
290 bool ExperimentalIdentityGetAuthTokenFunction::HasLoginToken() const { | 291 bool ExperimentalIdentityGetAuthTokenFunction::HasLoginToken() const { |
291 return ProfileOAuth2TokenServiceFactory::GetForProfile(profile())-> | 292 ProfileOAuth2TokenService* token_service = |
292 RefreshTokenIsAvailable(); | 293 ProfileOAuth2TokenServiceFactory::GetForProfile(profile()); |
| 294 return token_service->RefreshTokenIsAvailable( |
| 295 token_service->GetPrimaryAccountId()); |
293 } | 296 } |
294 | 297 |
295 ExperimentalIdentityLaunchWebAuthFlowFunction:: | 298 ExperimentalIdentityLaunchWebAuthFlowFunction:: |
296 ExperimentalIdentityLaunchWebAuthFlowFunction() {} | 299 ExperimentalIdentityLaunchWebAuthFlowFunction() {} |
297 | 300 |
298 ExperimentalIdentityLaunchWebAuthFlowFunction:: | 301 ExperimentalIdentityLaunchWebAuthFlowFunction:: |
299 ~ExperimentalIdentityLaunchWebAuthFlowFunction() { | 302 ~ExperimentalIdentityLaunchWebAuthFlowFunction() { |
300 if (auth_flow_) | 303 if (auth_flow_) |
301 auth_flow_.release()->DetachDelegateAndDelete(); | 304 auth_flow_.release()->DetachDelegateAndDelete(); |
302 } | 305 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 } | 393 } |
391 } | 394 } |
392 | 395 |
393 void ExperimentalIdentityLaunchWebAuthFlowFunction:: | 396 void ExperimentalIdentityLaunchWebAuthFlowFunction:: |
394 InitFinalRedirectURLPrefixesForTest(const std::string& extension_id) { | 397 InitFinalRedirectURLPrefixesForTest(const std::string& extension_id) { |
395 final_prefixes_.clear(); | 398 final_prefixes_.clear(); |
396 InitFinalRedirectURLPrefixes(extension_id); | 399 InitFinalRedirectURLPrefixes(extension_id); |
397 } | 400 } |
398 | 401 |
399 } // namespace extensions | 402 } // namespace extensions |
OLD | NEW |