Index: chrome/browser/extensions/api/identity/identity_api.cc |
diff --git a/chrome/browser/extensions/api/identity/identity_api.cc b/chrome/browser/extensions/api/identity/identity_api.cc |
index 485711e8be8eebae06df1ae73b4a274d067a56d3..58b61d376ff1fa3fead6e082ec4b4d841df56ac2 100644 |
--- a/chrome/browser/extensions/api/identity/identity_api.cc |
+++ b/chrome/browser/extensions/api/identity/identity_api.cc |
@@ -393,8 +393,17 @@ void IdentityGetAuthTokenFunction::OnGetTokenFailure( |
#if defined(OS_CHROMEOS) |
void IdentityGetAuthTokenFunction::StartDeviceLoginAccessTokenRequest() { |
- chromeos::DeviceOAuth2TokenService* service = |
- chromeos::DeviceOAuth2TokenServiceFactory::Get(); |
+ chromeos::DeviceOAuth2TokenServiceFactory::Get( |
+ base::Bind(&IdentityGetAuthTokenFunction::DidGetTokenService, |
+ this)); |
+} |
+ |
+void IdentityGetAuthTokenFunction::DidGetTokenService( |
+ chromeos::DeviceOAuth2TokenService* service) { |
+ if (!service) { |
+ CompleteFunctionWithError(identity_constants::kUserNotSignedIn); |
+ return; |
+ } |
// Since robot account refresh tokens are scoped down to [any-api] only, |
// request access token for [any-api] instead of login. |
OAuth2TokenService::ScopeSet scopes; |