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

Side by Side 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, 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/extensions/api/identity/extension_auth_flow.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_IDENTITY_EXTENSION_AUTH_FLOW_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_IDENTITY_EXTENSION_AUTH_FLOW_H_
7 #pragma once
8
9 #include <string>
10
11 #include "base/memory/scoped_ptr.h"
12 #include "content/public/browser/web_contents.h"
13 #include "content/public/browser/web_contents_delegate.h"
14 #include "googleurl/src/gurl.h"
15 #include "ui/views/controls/webview/webview.h"
16 #include "ui/views/widget/widget.h"
17 #include "ui/views/widget/widget_delegate.h"
18
19 namespace content {
20 class BrowserContext;
21 }
22
23 namespace extensions {
24
25 // Controller class to perform an auth flow with a provider.
26 // This is the class to start the auth flow and it takes care of all the
27 // details. It behaves the following way:
28 // Given a provider URL, load the URL and perform usual web protocol steps
29 // until the redirect back to the given URL happens. The provider can show
30 // a web page to the user if needed before redirecting it to an appropriate
31 // URL.
32 class ExtensionAuthFlow
33 : public content::WebContentsDelegate,
34 public views::WidgetDelegate {
35 public:
36 class Delegate {
37 public:
38 // Called when the auth flow is completely (with success or failure).
39 // |redirect_url| is the full URL the provider redirected to at the end
40 // of the flow.
41 virtual void OnAuthFlowCompleted(const std::string& redirect_url) = 0;
42 };
43
44 // Creates an instance with the given parameters.
45 ExtensionAuthFlow(Delegate* delegate,
46 content::BrowserContext* browser_context,
47 const std::string& extension_id,
48 const GURL& provider_url);
49
50 // Starts the flow.
51 // Delegate will be called with callbacks.
52 void Start();
53
54 private:
55 // WebContentsDelegate implementation.
56 virtual void LoadingStateChanged(content::WebContents* source) OVERRIDE;
57
58 // WidgetDelegate implementation.
59 virtual views::View* GetContentsView() OVERRIDE;
60 virtual views::Widget* GetWidget() OVERRIDE;
61 virtual const views::Widget* GetWidget() const OVERRIDE;
62 virtual void WindowClosing() OVERRIDE;
63
64 void OnProviderUrlLoaded();
65 // Reports the results back to the delegate.
66 void ReportResult();
67
68 Delegate* delegate_;
69 content::BrowserContext* browser_context_;
70 GURL provider_url_;
71 std::string extension_id_;
72 GURL result_;
73
74 scoped_ptr<content::WebContents> contents_;
75 scoped_ptr<views::WebView> web_view_;
sky 2012/04/27 18:27:38 Views are normally owned by their parent. So, as l
76 scoped_ptr<views::Widget> widget_;
sky 2012/04/27 18:27:38 If you want to own the widget like this you need t
77
78 DISALLOW_COPY_AND_ASSIGN(ExtensionAuthFlow);
79 };
80
81 } // namespace extensions
82
83 #endif CHROME_BROWSER_EXTENSIONS_API_IDENTITY_EXTENSION_AUTH_FLOW_H_
OLDNEW
« 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