Index: chrome/browser/extensions/api/identity/identity_api.cc |
=================================================================== |
--- chrome/browser/extensions/api/identity/identity_api.cc (revision 134959) |
+++ chrome/browser/extensions/api/identity/identity_api.cc (working copy) |
@@ -13,12 +13,17 @@ |
#include "chrome/common/extensions/extension.h" |
#include "googleurl/src/gurl.h" |
+using content::WebContents; |
Mihai Parparita -not on Chrome
2012/05/08 21:33:30
These two using statements can be removed.
Munjal (Google)
2012/05/11 18:53:33
Done.
|
+using content::WebContentsDelegate; |
+ |
namespace extensions { |
namespace { |
const char kInvalidClientId[] = "Invalid OAuth2 Client ID."; |
const char kInvalidScopes[] = "Invalid OAuth2 scopes."; |
+const char kUrlFieldRequired[] = "Missing required field: url"; |
+const char kInvalidRedirect[] = "Did not redirect to the right URL."; |
} // namespace |
@@ -70,4 +75,39 @@ |
Release(); // Balanced in RunImpl. |
} |
+LaunchAuthFlowFunction::LaunchAuthFlowFunction() {} |
+LaunchAuthFlowFunction::~LaunchAuthFlowFunction() {} |
+ |
+bool LaunchAuthFlowFunction::RunImpl() { |
+ DictionaryValue* arg1 = NULL; |
+ std::string url; |
+ |
+ if (!args_.get() || |
+ !args_->GetDictionary(0, &arg1) || |
+ !arg1->GetString("url", &url)) { |
+ error_ = kUrlFieldRequired; |
+ return false; |
+ } |
+ |
+ AddRef(); // Balanced in OnAuthFlowSuccess/Failed. |
+ GURL auth_url(url); |
+ auth_flow_.reset(new ExtensionAuthFlow( |
+ this, profile(), GetExtension()->id(), auth_url)); |
+ auth_flow_->Start(); |
+ return true; |
+} |
+ |
+void LaunchAuthFlowFunction::OnAuthFlowSuccess( |
+ const std::string& redirect_url) { |
+ result_.reset(Value::CreateStringValue(redirect_url)); |
+ SendResponse(true); |
+ Release(); // Balanced in RunImpl. |
+} |
+ |
+void LaunchAuthFlowFunction::OnAuthFlowFailure() { |
+ error_ = kInvalidRedirect; |
+ SendResponse(false); |
+ Release(); // Balanced in RunImpl. |
+} |
+ |
} // namespace extensions |