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 <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); | 223 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); |
224 } | 224 } |
225 | 225 |
226 IdentityGetAuthTokenFunction::IdentityGetAuthTokenFunction() | 226 IdentityGetAuthTokenFunction::IdentityGetAuthTokenFunction() |
227 : OAuth2TokenService::Consumer("extensions_identity_api"), | 227 : OAuth2TokenService::Consumer("extensions_identity_api"), |
228 should_prompt_for_scopes_(false), | 228 should_prompt_for_scopes_(false), |
229 should_prompt_for_signin_(false) {} | 229 should_prompt_for_signin_(false) {} |
230 | 230 |
231 IdentityGetAuthTokenFunction::~IdentityGetAuthTokenFunction() {} | 231 IdentityGetAuthTokenFunction::~IdentityGetAuthTokenFunction() {} |
232 | 232 |
233 bool IdentityGetAuthTokenFunction::RunImpl() { | 233 bool IdentityGetAuthTokenFunction::RunAsync() { |
234 if (GetProfile()->IsOffTheRecord()) { | 234 if (GetProfile()->IsOffTheRecord()) { |
235 error_ = identity_constants::kOffTheRecord; | 235 error_ = identity_constants::kOffTheRecord; |
236 return false; | 236 return false; |
237 } | 237 } |
238 | 238 |
239 scoped_ptr<identity::GetAuthToken::Params> params( | 239 scoped_ptr<identity::GetAuthToken::Params> params( |
240 identity::GetAuthToken::Params::Create(*args_)); | 240 identity::GetAuthToken::Params::Create(*args_)); |
241 EXTENSION_FUNCTION_VALIDATE(params.get()); | 241 EXTENSION_FUNCTION_VALIDATE(params.get()); |
242 bool interactive = params->details.get() && | 242 bool interactive = params->details.get() && |
243 params->details->interactive.get() && | 243 params->details->interactive.get() && |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 return true; | 703 return true; |
704 } | 704 } |
705 | 705 |
706 IdentityLaunchWebAuthFlowFunction::IdentityLaunchWebAuthFlowFunction() {} | 706 IdentityLaunchWebAuthFlowFunction::IdentityLaunchWebAuthFlowFunction() {} |
707 | 707 |
708 IdentityLaunchWebAuthFlowFunction::~IdentityLaunchWebAuthFlowFunction() { | 708 IdentityLaunchWebAuthFlowFunction::~IdentityLaunchWebAuthFlowFunction() { |
709 if (auth_flow_) | 709 if (auth_flow_) |
710 auth_flow_.release()->DetachDelegateAndDelete(); | 710 auth_flow_.release()->DetachDelegateAndDelete(); |
711 } | 711 } |
712 | 712 |
713 bool IdentityLaunchWebAuthFlowFunction::RunImpl() { | 713 bool IdentityLaunchWebAuthFlowFunction::RunAsync() { |
714 if (GetProfile()->IsOffTheRecord()) { | 714 if (GetProfile()->IsOffTheRecord()) { |
715 error_ = identity_constants::kOffTheRecord; | 715 error_ = identity_constants::kOffTheRecord; |
716 return false; | 716 return false; |
717 } | 717 } |
718 | 718 |
719 scoped_ptr<identity::LaunchWebAuthFlow::Params> params( | 719 scoped_ptr<identity::LaunchWebAuthFlow::Params> params( |
720 identity::LaunchWebAuthFlow::Params::Create(*args_)); | 720 identity::LaunchWebAuthFlow::Params::Create(*args_)); |
721 EXTENSION_FUNCTION_VALIDATE(params.get()); | 721 EXTENSION_FUNCTION_VALIDATE(params.get()); |
722 | 722 |
723 GURL auth_url(params->details.url); | 723 GURL auth_url(params->details.url); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 break; | 760 break; |
761 case WebAuthFlow::LOAD_FAILED: | 761 case WebAuthFlow::LOAD_FAILED: |
762 error_ = identity_constants::kPageLoadFailure; | 762 error_ = identity_constants::kPageLoadFailure; |
763 break; | 763 break; |
764 default: | 764 default: |
765 NOTREACHED() << "Unexpected error from web auth flow: " << failure; | 765 NOTREACHED() << "Unexpected error from web auth flow: " << failure; |
766 error_ = identity_constants::kInvalidRedirect; | 766 error_ = identity_constants::kInvalidRedirect; |
767 break; | 767 break; |
768 } | 768 } |
769 SendResponse(false); | 769 SendResponse(false); |
770 Release(); // Balanced in RunImpl. | 770 Release(); // Balanced in RunAsync. |
771 } | 771 } |
772 | 772 |
773 void IdentityLaunchWebAuthFlowFunction::OnAuthFlowURLChange( | 773 void IdentityLaunchWebAuthFlowFunction::OnAuthFlowURLChange( |
774 const GURL& redirect_url) { | 774 const GURL& redirect_url) { |
775 if (redirect_url.GetWithEmptyPath() == final_url_prefix_) { | 775 if (redirect_url.GetWithEmptyPath() == final_url_prefix_) { |
776 SetResult(new base::StringValue(redirect_url.spec())); | 776 SetResult(new base::StringValue(redirect_url.spec())); |
777 SendResponse(true); | 777 SendResponse(true); |
778 Release(); // Balanced in RunImpl. | 778 Release(); // Balanced in RunAsync. |
779 } | 779 } |
780 } | 780 } |
781 | 781 |
782 } // namespace extensions | 782 } // namespace extensions |
OLD | NEW |