Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Unified Diff: chrome/browser/extensions/api/identity/identity_api.cc

Issue 10178020: Start implementing an auth flow for platform apps to be able to do auth (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/identity/identity_api.cc
===================================================================
--- chrome/browser/extensions/api/identity/identity_api.cc (revision 137883)
+++ chrome/browser/extensions/api/identity/identity_api.cc (working copy)
@@ -19,6 +19,8 @@
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 +72,39 @@
Release(); // Balanced in RunImpl.
}
+LaunchWebAuthFlowFunction::LaunchWebAuthFlowFunction() {}
+LaunchWebAuthFlowFunction::~LaunchWebAuthFlowFunction() {}
+
+bool LaunchWebAuthFlowFunction::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/Failure.
+ GURL auth_url(url);
+ auth_flow_.reset(new WebAuthFlow(
+ this, profile(), GetExtension()->id(), auth_url));
+ auth_flow_->Start();
+ return true;
+}
+
+void LaunchWebAuthFlowFunction::OnAuthFlowSuccess(
+ const std::string& redirect_url) {
+ result_.reset(Value::CreateStringValue(redirect_url));
+ SendResponse(true);
+ Release(); // Balanced in RunImpl.
+}
+
+void LaunchWebAuthFlowFunction::OnAuthFlowFailure() {
+ error_ = kInvalidRedirect;
+ SendResponse(false);
+ Release(); // Balanced in RunImpl.
+}
+
} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/api/identity/identity_api.h ('k') | chrome/browser/extensions/api/identity/identity_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698