| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_IDENTITY_WEB_AUTH_FLOW_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_IDENTITY_WEB_AUTH_FLOW_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_IDENTITY_WEB_AUTH_FLOW_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_IDENTITY_WEB_AUTH_FLOW_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "apps/shell_window_registry.h" | 10 #include "apps/app_window_registry.h" |
| 11 #include "content/public/browser/notification_observer.h" | 11 #include "content/public/browser/notification_observer.h" |
| 12 #include "content/public/browser/notification_registrar.h" | 12 #include "content/public/browser/notification_registrar.h" |
| 13 #include "content/public/browser/web_contents_observer.h" | 13 #include "content/public/browser/web_contents_observer.h" |
| 14 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.h" |
| 15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 16 | 16 |
| 17 class Profile; | 17 class Profile; |
| 18 class WebAuthFlowTest; | 18 class WebAuthFlowTest; |
| 19 | 19 |
| 20 namespace content { | 20 namespace content { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 38 // | 38 // |
| 39 // The window is not displayed until the first page load | 39 // The window is not displayed until the first page load |
| 40 // completes. This allows the flow to complete without flashing a | 40 // completes. This allows the flow to complete without flashing a |
| 41 // window on screen if the provider immediately redirects to the | 41 // window on screen if the provider immediately redirects to the |
| 42 // target URL. | 42 // target URL. |
| 43 // | 43 // |
| 44 // A WebAuthFlow can be started in Mode::SILENT, which never displays | 44 // A WebAuthFlow can be started in Mode::SILENT, which never displays |
| 45 // a window. If a window would be required, the flow fails. | 45 // a window. If a window would be required, the flow fails. |
| 46 class WebAuthFlow : public content::NotificationObserver, | 46 class WebAuthFlow : public content::NotificationObserver, |
| 47 public content::WebContentsObserver, | 47 public content::WebContentsObserver, |
| 48 public apps::ShellWindowRegistry::Observer { | 48 public apps::AppWindowRegistry::Observer { |
| 49 public: | 49 public: |
| 50 enum Mode { | 50 enum Mode { |
| 51 INTERACTIVE, // Show UI to the user if necessary. | 51 INTERACTIVE, // Show UI to the user if necessary. |
| 52 SILENT // No UI should be shown. | 52 SILENT // No UI should be shown. |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 enum Failure { | 55 enum Failure { |
| 56 WINDOW_CLOSED, // Window closed by user. | 56 WINDOW_CLOSED, // Window closed by user. |
| 57 INTERACTION_REQUIRED, // Non-redirect page load in silent mode. | 57 INTERACTION_REQUIRED, // Non-redirect page load in silent mode. |
| 58 LOAD_FAILED | 58 LOAD_FAILED |
| (...skipping 25 matching lines...) Expand all Loading... |
| 84 | 84 |
| 85 // Starts the flow. | 85 // Starts the flow. |
| 86 virtual void Start(); | 86 virtual void Start(); |
| 87 | 87 |
| 88 // Prevents further calls to the delegate and deletes the flow. | 88 // Prevents further calls to the delegate and deletes the flow. |
| 89 void DetachDelegateAndDelete(); | 89 void DetachDelegateAndDelete(); |
| 90 | 90 |
| 91 private: | 91 private: |
| 92 friend class ::WebAuthFlowTest; | 92 friend class ::WebAuthFlowTest; |
| 93 | 93 |
| 94 // ::ShellWindowRegistry::Observer implementation. | 94 // ::AppWindowRegistry::Observer implementation. |
| 95 virtual void OnShellWindowAdded(apps::ShellWindow* shell_window) OVERRIDE; | 95 virtual void OnAppWindowAdded(apps::AppWindow* app_window) OVERRIDE; |
| 96 virtual void OnShellWindowIconChanged(apps::ShellWindow* shell_window) | 96 virtual void OnAppWindowIconChanged(apps::AppWindow* app_window) OVERRIDE; |
| 97 OVERRIDE; | 97 virtual void OnAppWindowRemoved(apps::AppWindow* app_window) OVERRIDE; |
| 98 virtual void OnShellWindowRemoved(apps::ShellWindow* shell_window) OVERRIDE; | |
| 99 | 98 |
| 100 // NotificationObserver implementation. | 99 // NotificationObserver implementation. |
| 101 virtual void Observe(int type, | 100 virtual void Observe(int type, |
| 102 const content::NotificationSource& source, | 101 const content::NotificationSource& source, |
| 103 const content::NotificationDetails& details) OVERRIDE; | 102 const content::NotificationDetails& details) OVERRIDE; |
| 104 | 103 |
| 105 // WebContentsObserver implementation. | 104 // WebContentsObserver implementation. |
| 106 virtual void DidStopLoading(content::RenderViewHost* render_view_host) | 105 virtual void DidStopLoading(content::RenderViewHost* render_view_host) |
| 107 OVERRIDE; | 106 OVERRIDE; |
| 108 virtual void DidNavigateMainFrame( | 107 virtual void DidNavigateMainFrame( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 127 OVERRIDE; | 126 OVERRIDE; |
| 128 | 127 |
| 129 void BeforeUrlLoaded(const GURL& url); | 128 void BeforeUrlLoaded(const GURL& url); |
| 130 void AfterUrlLoaded(); | 129 void AfterUrlLoaded(); |
| 131 | 130 |
| 132 Delegate* delegate_; | 131 Delegate* delegate_; |
| 133 Profile* profile_; | 132 Profile* profile_; |
| 134 GURL provider_url_; | 133 GURL provider_url_; |
| 135 Mode mode_; | 134 Mode mode_; |
| 136 | 135 |
| 137 apps::ShellWindow* shell_window_; | 136 apps::AppWindow* app_window_; |
| 138 std::string shell_window_key_; | 137 std::string app_window_key_; |
| 139 bool embedded_window_created_; | 138 bool embedded_window_created_; |
| 140 | 139 |
| 141 content::NotificationRegistrar registrar_; | 140 content::NotificationRegistrar registrar_; |
| 142 | 141 |
| 143 DISALLOW_COPY_AND_ASSIGN(WebAuthFlow); | 142 DISALLOW_COPY_AND_ASSIGN(WebAuthFlow); |
| 144 }; | 143 }; |
| 145 | 144 |
| 146 } // namespace extensions | 145 } // namespace extensions |
| 147 | 146 |
| 148 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_WEB_AUTH_FLOW_H_ | 147 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_WEB_AUTH_FLOW_H_ |
| OLD | NEW |