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

Unified Diff: chrome/browser/extensions/api/identity/extension_auth_flow.h

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, 8 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
« no previous file with comments | « no previous file | chrome/browser/extensions/api/identity/extension_auth_flow.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/identity/extension_auth_flow.h
===================================================================
--- chrome/browser/extensions/api/identity/extension_auth_flow.h (revision 0)
+++ chrome/browser/extensions/api/identity/extension_auth_flow.h (revision 0)
@@ -0,0 +1,83 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_API_IDENTITY_EXTENSION_AUTH_FLOW_H_
+#define CHROME_BROWSER_EXTENSIONS_API_IDENTITY_EXTENSION_AUTH_FLOW_H_
+#pragma once
+
+#include <string>
+
+#include "base/memory/scoped_ptr.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"
+
+namespace content {
+class BrowserContext;
+}
+
+namespace extensions {
+
+// Controller class to perform an auth flow with a provider.
+// This is the class to start the auth flow and it takes care of all the
+// details. It behaves the following way:
+// Given a provider URL, load the URL and perform usual web protocol steps
+// until the redirect back to the given URL happens. The provider can show
+// a web page to the user if needed before redirecting it to an appropriate
+// URL.
+class ExtensionAuthFlow
+ : public content::WebContentsDelegate,
+ public views::WidgetDelegate {
+ public:
+ class Delegate {
+ public:
+ // Called when the auth flow is completely (with success or failure).
+ // |redirect_url| is the full URL the provider redirected to at the end
+ // of the flow.
+ virtual void OnAuthFlowCompleted(const std::string& redirect_url) = 0;
+ };
+
+ // Creates an instance with the given parameters.
+ ExtensionAuthFlow(Delegate* delegate,
+ content::BrowserContext* browser_context,
+ const std::string& extension_id,
+ const GURL& provider_url);
+
+ // Starts the flow.
+ // Delegate will be called with callbacks.
+ void Start();
+
+ private:
+ // WebContentsDelegate implementation.
+ virtual void LoadingStateChanged(content::WebContents* source) OVERRIDE;
+
+ // WidgetDelegate implementation.
+ virtual views::View* GetContentsView() OVERRIDE;
+ virtual views::Widget* GetWidget() OVERRIDE;
+ virtual const views::Widget* GetWidget() const OVERRIDE;
+ virtual void WindowClosing() OVERRIDE;
+
+ void OnProviderUrlLoaded();
+ // Reports the results back to the delegate.
+ void ReportResult();
+
+ Delegate* delegate_;
+ content::BrowserContext* browser_context_;
+ GURL provider_url_;
+ std::string extension_id_;
+ GURL result_;
+
+ scoped_ptr<content::WebContents> contents_;
+ scoped_ptr<views::WebView> web_view_;
sky 2012/04/27 18:27:38 Views are normally owned by their parent. So, as l
+ scoped_ptr<views::Widget> widget_;
sky 2012/04/27 18:27:38 If you want to own the widget like this you need t
+
+ DISALLOW_COPY_AND_ASSIGN(ExtensionAuthFlow);
+};
+
+} // namespace extensions
+
+#endif CHROME_BROWSER_EXTENSIONS_API_IDENTITY_EXTENSION_AUTH_FLOW_H_
« no previous file with comments | « no previous file | chrome/browser/extensions/api/identity/extension_auth_flow.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698