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/identity_api.h" | 5 #include "chrome/browser/extensions/api/identity/identity_api.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 8 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
9 #include "chrome/browser/signin/token_service.h" | 9 #include "chrome/browser/signin/token_service.h" |
10 #include "chrome/browser/signin/token_service_factory.h" | 10 #include "chrome/browser/signin/token_service_factory.h" |
(...skipping 26 matching lines...) Expand all Loading... | |
37 if (oauth2_info.scopes.size() == 0) { | 37 if (oauth2_info.scopes.size() == 0) { |
38 error_ = kInvalidScopes; | 38 error_ = kInvalidScopes; |
39 return false; | 39 return false; |
40 } | 40 } |
41 | 41 |
42 AddRef(); // Balanced in OnMintTokenSuccess|Failure. | 42 AddRef(); // Balanced in OnMintTokenSuccess|Failure. |
43 | 43 |
44 TokenService* token_service = TokenServiceFactory::GetForProfile(profile()); | 44 TokenService* token_service = TokenServiceFactory::GetForProfile(profile()); |
45 | 45 |
46 flow_.reset( | 46 flow_.reset( |
47 new OAuth2MintTokenFlow(profile()->GetRequestContext(), this)); | 47 new OAuth2MintTokenFlow( |
asargent_no_longer_on_chrome
2012/04/10 22:47:25
nit: this could go on the preceding line just afte
Munjal (Google)
2012/04/10 23:15:35
Done.
| |
48 flow_->Start(token_service->GetOAuth2LoginRefreshToken(), | 48 profile()->GetRequestContext(), |
49 extension->id(), oauth2_info.client_id, oauth2_info.scopes); | 49 this, |
50 OAuth2MintTokenFlow::Parameters( | |
51 token_service->GetOAuth2LoginRefreshToken(), | |
52 extension->id(), | |
53 oauth2_info.client_id, | |
54 oauth2_info.scopes, | |
55 OAuth2MintTokenFlow::MODE_MINT_TOKEN_FORCE))); | |
56 flow_->Start(); | |
50 | 57 |
51 return true; | 58 return true; |
52 } | 59 } |
53 | 60 |
54 void GetAuthTokenFunction::OnMintTokenSuccess(const std::string& access_token) { | 61 void GetAuthTokenFunction::OnMintTokenSuccess(const std::string& access_token) { |
55 result_.reset(Value::CreateStringValue(access_token)); | 62 result_.reset(Value::CreateStringValue(access_token)); |
56 SendResponse(true); | 63 SendResponse(true); |
57 Release(); // Balanced in RunImpl. | 64 Release(); // Balanced in RunImpl. |
58 } | 65 } |
59 | 66 |
60 void GetAuthTokenFunction::OnMintTokenFailure( | 67 void GetAuthTokenFunction::OnMintTokenFailure( |
61 const GoogleServiceAuthError& error) { | 68 const GoogleServiceAuthError& error) { |
62 error_ = error.ToString(); | 69 error_ = error.ToString(); |
63 SendResponse(false); | 70 SendResponse(false); |
64 Release(); // Balanced in RunImpl. | 71 Release(); // Balanced in RunImpl. |
65 } | 72 } |
66 | 73 |
67 } // namespace extensions | 74 } // namespace extensions |
OLD | NEW |