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

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

Issue 14081014: Identity API: Change WebAuthFlow to use <webview> instead of a normal browser pop-up. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: chrome.identity side-by-side with chrome.experimental.identity Created 7 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/web_auth_flow.h
diff --git a/chrome/browser/extensions/api/identity/web_auth_flow.h b/chrome/browser/extensions/api/identity/web_auth_flow.h
index dd5eed8dfac79af15b929de1a9f3e1fb65bc4ae8..352a73f39d5b2f3f744ca8ee7bc8b05e62d51ff2 100644
--- a/chrome/browser/extensions/api/identity/web_auth_flow.h
+++ b/chrome/browser/extensions/api/identity/web_auth_flow.h
@@ -5,7 +5,9 @@
#ifndef CHROME_BROWSER_EXTENSIONS_API_IDENTITY_WEB_AUTH_FLOW_H_
#define CHROME_BROWSER_EXTENSIONS_API_IDENTITY_WEB_AUTH_FLOW_H_
-#include "chrome/browser/ui/host_desktop.h"
+#include <string>
+
+#include "chrome/browser/extensions/shell_window_registry.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/web_contents_observer.h"
@@ -38,7 +40,8 @@ namespace extensions {
// A WebAuthFlow can be started in Mode::SILENT, which never displays
// a window. If a window would be required, the flow fails.
class WebAuthFlow : public content::NotificationObserver,
- public content::WebContentsObserver {
+ public content::WebContentsObserver,
+ public ShellWindowRegistry::Observer {
public:
enum Mode {
INTERACTIVE, // Show UI to the user if necessary.
@@ -47,9 +50,12 @@ class WebAuthFlow : public content::NotificationObserver,
enum Failure {
WINDOW_CLOSED, // Window closed by user.
- INTERACTION_REQUIRED // Non-redirect page load in silent mode.
+ INTERACTION_REQUIRED, // Non-redirect page load in silent mode.
+ LOAD_FAILED // A page failed to load.
};
+ // Clients of the WebAuthFlow implement this interface to learn the
+ // outcome of the flow.
class Delegate {
public:
// Called when the auth flow fails. This means that the flow did not result
@@ -58,6 +64,9 @@ class WebAuthFlow : public content::NotificationObserver,
// Called on redirects and other navigations to see if the URL should stop
// the flow.
virtual void OnAuthFlowURLChange(const GURL& redirect_url) = 0;
+ // Called when the flow has been completely closed and it is safe to
+ // delete the object.
+ virtual void OnAuthFlowClosed() = 0;
protected:
virtual ~Delegate() {}
@@ -68,18 +77,16 @@ class WebAuthFlow : public content::NotificationObserver,
WebAuthFlow(Delegate* delegate,
Profile* profile,
const GURL& provider_url,
- Mode mode,
- const gfx::Rect& initial_bounds,
- chrome::HostDesktopType host_desktop_type);
+ Mode mode);
virtual ~WebAuthFlow();
// Starts the flow.
virtual void Start();
- protected:
- // Overridable for testing.
- virtual content::WebContents* CreateWebContents();
- virtual void ShowAuthFlowPopup();
+ // Stops the flow and closes the window. After this function returns, the
+ // delegate will not be called again, except for a final call to
+ // OnAuthFlowClosed.
+ virtual void Close();
private:
friend class ::WebAuthFlowTest;
@@ -90,26 +97,50 @@ class WebAuthFlow : public content::NotificationObserver,
const content::NotificationDetails& details) OVERRIDE;
// WebContentsObserver implementation.
- virtual void ProvisionalChangeToMainFrameUrl(
- const GURL& url,
+ virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
+ virtual void DidStartProvisionalLoadForFrame(
+ int64 frame_id,
+ int64 parent_frame_id,
+ bool is_main_frame,
+ const GURL& validated_url,
+ bool is_error_page,
+ bool is_iframe_srcdoc,
+ content::RenderViewHost* render_view_host) OVERRIDE;
+ virtual void DidFailProvisionalLoad(
+ int64 frame_id,
+ bool is_main_frame,
+ const GURL& validated_url,
+ int error_code,
+ const string16& error_description,
content::RenderViewHost* render_view_host) OVERRIDE;
+ virtual void DidFailLoad(int64 frame_id,
+ const GURL& validated_url,
+ bool is_main_frame,
+ int error_code,
+ const string16& error_description,
+ content::RenderViewHost* render_view_host) OVERRIDE;
virtual void DidStopLoading(
content::RenderViewHost* render_view_host) OVERRIDE;
- virtual void WebContentsDestroyed(
- content::WebContents* web_contents) OVERRIDE;
+
+ // ShellWindowRegistry::Observer implementation.
+ virtual void OnShellWindowAdded(ShellWindow* shell_window) OVERRIDE;
+ virtual void OnShellWindowIconChanged(ShellWindow* shell_window) OVERRIDE {}
+ virtual void OnShellWindowRemoved(ShellWindow* shell_window) OVERRIDE;
void BeforeUrlLoaded(const GURL& url);
void AfterUrlLoaded();
+ void DeferredClose();
Delegate* delegate_;
+ bool closed_;
Profile* profile_;
GURL provider_url_;
Mode mode_;
- gfx::Rect initial_bounds_;
- chrome::HostDesktopType host_desktop_type_;
- bool popup_shown_;
+ bool shell_window_loaded_;
+
+ ShellWindow* shell_window_;
+ std::string shell_window_key_;
- content::WebContents* contents_;
content::NotificationRegistrar registrar_;
DISALLOW_COPY_AND_ASSIGN(WebAuthFlow);
« no previous file with comments | « chrome/browser/extensions/api/identity/identity_apitest.cc ('k') | chrome/browser/extensions/api/identity/web_auth_flow.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698