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_install_prompt.h" | 8 #include "chrome/browser/extensions/extension_install_prompt.h" |
9 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 9 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 OAuth2MintTokenFlow::MODE_MINT_TOKEN_FORCE : | 45 OAuth2MintTokenFlow::MODE_MINT_TOKEN_FORCE : |
46 OAuth2MintTokenFlow::MODE_MINT_TOKEN_NO_FORCE)) { | 46 OAuth2MintTokenFlow::MODE_MINT_TOKEN_NO_FORCE)) { |
47 return true; | 47 return true; |
48 } else { | 48 } else { |
49 Release(); | 49 Release(); |
50 return false; | 50 return false; |
51 } | 51 } |
52 } | 52 } |
53 | 53 |
54 void GetAuthTokenFunction::OnMintTokenSuccess(const std::string& access_token) { | 54 void GetAuthTokenFunction::OnMintTokenSuccess(const std::string& access_token) { |
55 result_.reset(Value::CreateStringValue(access_token)); | 55 SetResult(Value::CreateStringValue(access_token)); |
56 SendResponse(true); | 56 SendResponse(true); |
57 Release(); // Balanced in RunImpl. | 57 Release(); // Balanced in RunImpl. |
58 } | 58 } |
59 | 59 |
60 void GetAuthTokenFunction::OnMintTokenFailure( | 60 void GetAuthTokenFunction::OnMintTokenFailure( |
61 const GoogleServiceAuthError& error) { | 61 const GoogleServiceAuthError& error) { |
62 error_ = std::string(kAuthFailure) + error.ToString(); | 62 error_ = std::string(kAuthFailure) + error.ToString(); |
63 SendResponse(false); | 63 SendResponse(false); |
64 Release(); // Balanced in RunImpl. | 64 Release(); // Balanced in RunImpl. |
65 } | 65 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 AddRef(); // Balanced in OnAuthFlowSuccess/Failure. | 140 AddRef(); // Balanced in OnAuthFlowSuccess/Failure. |
141 GURL auth_url(url); | 141 GURL auth_url(url); |
142 auth_flow_.reset(new WebAuthFlow( | 142 auth_flow_.reset(new WebAuthFlow( |
143 this, profile(), GetExtension()->id(), auth_url, mode)); | 143 this, profile(), GetExtension()->id(), auth_url, mode)); |
144 auth_flow_->Start(); | 144 auth_flow_->Start(); |
145 return true; | 145 return true; |
146 } | 146 } |
147 | 147 |
148 void LaunchWebAuthFlowFunction::OnAuthFlowSuccess( | 148 void LaunchWebAuthFlowFunction::OnAuthFlowSuccess( |
149 const std::string& redirect_url) { | 149 const std::string& redirect_url) { |
150 result_.reset(Value::CreateStringValue(redirect_url)); | 150 SetResult(Value::CreateStringValue(redirect_url)); |
151 SendResponse(true); | 151 SendResponse(true); |
152 Release(); // Balanced in RunImpl. | 152 Release(); // Balanced in RunImpl. |
153 } | 153 } |
154 | 154 |
155 void LaunchWebAuthFlowFunction::OnAuthFlowFailure() { | 155 void LaunchWebAuthFlowFunction::OnAuthFlowFailure() { |
156 error_ = kInvalidRedirect; | 156 error_ = kInvalidRedirect; |
157 SendResponse(false); | 157 SendResponse(false); |
158 Release(); // Balanced in RunImpl. | 158 Release(); // Balanced in RunImpl. |
159 } | 159 } |
160 | 160 |
161 } // namespace extensions | 161 } // namespace extensions |
OLD | NEW |