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) |
@@ -8,17 +8,28 @@ |
#include "chrome/browser/extensions/extension_function_dispatcher.h" |
#include "chrome/browser/signin/token_service.h" |
#include "chrome/browser/signin/token_service_factory.h" |
+#include "chrome/browser/tab_contents/tab_util.h" |
Mihai Parparita -not on Chrome
2012/05/04 22:37:18
All of these #includes that got added seem to be u
|
#include "chrome/browser/ui/browser.h" |
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
#include "chrome/common/extensions/extension.h" |
+#include "content/public/browser/web_contents.h" |
+#include "content/public/browser/web_contents_delegate.h" |
#include "googleurl/src/gurl.h" |
+#include "ui/views/controls/webview/webview.h" |
+#include "ui/views/widget/widget.h" |
+#include "ui/views/widget/widget_delegate.h" |
+using content::WebContents; |
+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 +81,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; |
+ } |
+ |
+ GURL auth_url(url); |
+ auth_flow_.reset(new ExtensionAuthFlow( |
+ this, profile(), GetExtension()->id(), auth_url)); |
+ auth_flow_->Start(); |
+ AddRef(); |
Mihai Parparita -not on Chrome
2012/05/04 22:37:18
Add comments about this being balanced in OnAuthFl
Munjal (Google)
2012/05/08 19:26:35
Done.
|
+ return true; |
+} |
+ |
+void LaunchAuthFlowFunction::OnAuthFlowCompleted( |
Mihai Parparita -not on Chrome
2012/05/04 22:37:18
Nit: The token minting delegate uses the names On*
Munjal (Google)
2012/05/08 19:26:35
Done.
|
+ const std::string& redirect_url) { |
+ result_.reset(Value::CreateStringValue(redirect_url)); |
+ SendResponse(true); |
+ Release(); |
+} |
+ |
+void LaunchAuthFlowFunction::OnAuthFlowFailed() { |
+ error_ = kInvalidRedirect; |
+ SendResponse(false); |
+ Release(); |
+} |
+ |
} // namespace extensions |