| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_CHROMEOS_LOGIN_UI_WEBUI_LOGIN_VIEW_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_UI_WEBUI_LOGIN_VIEW_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_UI_WEBUI_LOGIN_VIEW_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_UI_WEBUI_LOGIN_VIEW_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" |
| 12 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
| 13 #include "chrome/browser/ui/chrome_web_modal_dialog_manager_delegate.h" | 14 #include "chrome/browser/ui/chrome_web_modal_dialog_manager_delegate.h" |
| 14 #include "components/web_modal/web_contents_modal_dialog_host.h" | 15 #include "components/web_modal/web_contents_modal_dialog_host.h" |
| 15 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
| 16 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
| 17 #include "content/public/browser/web_contents_delegate.h" | 18 #include "content/public/browser/web_contents_delegate.h" |
| 18 #include "ui/views/controls/webview/unhandled_keyboard_event_handler.h" | 19 #include "ui/views/controls/webview/unhandled_keyboard_event_handler.h" |
| 19 #include "ui/views/widget/widget.h" | 20 #include "ui/views/widget/widget.h" |
| 20 #include "ui/views/widget/widget_delegate.h" | 21 #include "ui/views/widget/widget_delegate.h" |
| 21 | 22 #include "url/gurl.h" |
| 22 class GURL; | |
| 23 | 23 |
| 24 namespace content { | 24 namespace content { |
| 25 class WebUI; | 25 class WebUI; |
| 26 } | 26 } |
| 27 | 27 |
| 28 namespace views { | 28 namespace views { |
| 29 class View; | 29 class View; |
| 30 class WebView; | 30 class WebView; |
| 31 class Widget; | 31 class Widget; |
| 32 } | 32 } |
| 33 | 33 |
| 34 namespace chromeos { | 34 namespace chromeos { |
| 35 | 35 |
| 36 class OobeUI; | 36 class OobeUI; |
| 37 class WebViewHandle; |
| 37 | 38 |
| 38 // View used to render a WebUI supporting Widget. This widget is used for the | 39 // View used to render a WebUI supporting Widget. This widget is used for the |
| 39 // WebUI based start up and lock screens. It contains a WebView. | 40 // WebUI based start up and lock screens. It contains a WebView. |
| 40 class WebUILoginView : public views::View, | 41 class WebUILoginView : public views::View, |
| 41 public content::WebContentsDelegate, | 42 public content::WebContentsDelegate, |
| 42 public content::NotificationObserver, | 43 public content::NotificationObserver, |
| 43 public ChromeWebModalDialogManagerDelegate, | 44 public ChromeWebModalDialogManagerDelegate, |
| 44 public web_modal::WebContentsModalDialogHost { | 45 public web_modal::WebContentsModalDialogHost { |
| 45 public: | 46 public: |
| 47 struct WebViewSettings { |
| 48 // URL of the WebView to preload and reuse across WebUILoginView instances. |
| 49 GURL preloaded_url; |
| 50 }; |
| 51 |
| 46 // Internal class name. | 52 // Internal class name. |
| 47 static const char kViewClassName[]; | 53 static const char kViewClassName[]; |
| 48 | 54 |
| 49 WebUILoginView(); | 55 explicit WebUILoginView(const WebViewSettings& settings); |
| 50 ~WebUILoginView() override; | 56 ~WebUILoginView() override; |
| 51 | 57 |
| 52 // Initializes the webui login view. | 58 // Initializes the webui login view. |
| 53 virtual void Init(); | 59 virtual void Init(); |
| 54 | 60 |
| 55 // Overridden from views::View: | 61 // Overridden from views::View: |
| 56 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; | 62 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; |
| 57 const char* GetClassName() const override; | 63 const char* GetClassName() const override; |
| 58 void RequestFocus() override; | 64 void RequestFocus() override; |
| 59 | 65 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 void set_is_hidden(bool hidden) { is_hidden_ = hidden; } | 104 void set_is_hidden(bool hidden) { is_hidden_ = hidden; } |
| 99 | 105 |
| 100 bool webui_visible() const { return webui_visible_; } | 106 bool webui_visible() const { return webui_visible_; } |
| 101 | 107 |
| 102 // Let suppress emission of this signal. | 108 // Let suppress emission of this signal. |
| 103 void set_should_emit_login_prompt_visible(bool emit) { | 109 void set_should_emit_login_prompt_visible(bool emit) { |
| 104 should_emit_login_prompt_visible_ = emit; | 110 should_emit_login_prompt_visible_ = emit; |
| 105 } | 111 } |
| 106 | 112 |
| 107 protected: | 113 protected: |
| 114 static void InitializeWebView(views::WebView* web_view); |
| 115 |
| 108 // Overridden from views::View: | 116 // Overridden from views::View: |
| 109 void Layout() override; | 117 void Layout() override; |
| 110 void OnLocaleChanged() override; | 118 void OnLocaleChanged() override; |
| 111 void ChildPreferredSizeChanged(View* child) override; | 119 void ChildPreferredSizeChanged(View* child) override; |
| 112 void AboutToRequestFocusFromTabTraversal(bool reverse) override; | 120 void AboutToRequestFocusFromTabTraversal(bool reverse) override; |
| 113 | 121 |
| 114 // Overridden from content::NotificationObserver. | 122 // Overridden from content::NotificationObserver. |
| 115 void Observe(int type, | 123 void Observe(int type, |
| 116 const content::NotificationSource& source, | 124 const content::NotificationSource& source, |
| 117 const content::NotificationDetails& details) override; | 125 const content::NotificationDetails& details) override; |
| 118 | 126 |
| 119 // WebView for rendering a webpage as a webui login. | 127 views::WebView* web_view(); |
| 120 views::WebView* webui_login_ = nullptr; | |
| 121 | 128 |
| 122 private: | 129 private: |
| 123 // Map type for the accelerator-to-identifier map. | 130 // Map type for the accelerator-to-identifier map. |
| 124 typedef std::map<ui::Accelerator, std::string> AccelMap; | 131 typedef std::map<ui::Accelerator, std::string> AccelMap; |
| 125 | 132 |
| 126 // Overridden from content::WebContentsDelegate. | 133 // Overridden from content::WebContentsDelegate. |
| 127 bool HandleContextMenu(const content::ContextMenuParams& params) override; | 134 bool HandleContextMenu(const content::ContextMenuParams& params) override; |
| 128 void HandleKeyboardEvent( | 135 void HandleKeyboardEvent( |
| 129 content::WebContents* source, | 136 content::WebContents* source, |
| 130 const content::NativeWebKeyboardEvent& event) override; | 137 const content::NativeWebKeyboardEvent& event) override; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 141 const blink::WebGestureEvent& event) override; | 148 const blink::WebGestureEvent& event) override; |
| 142 | 149 |
| 143 // Performs series of actions when login prompt is considered | 150 // Performs series of actions when login prompt is considered |
| 144 // to be ready and visible. | 151 // to be ready and visible. |
| 145 // 1. Emits LoginPromptVisible signal if needed | 152 // 1. Emits LoginPromptVisible signal if needed |
| 146 // 2. Notifies OOBE/sign classes. | 153 // 2. Notifies OOBE/sign classes. |
| 147 void OnLoginPromptVisible(); | 154 void OnLoginPromptVisible(); |
| 148 | 155 |
| 149 content::NotificationRegistrar registrar_; | 156 content::NotificationRegistrar registrar_; |
| 150 | 157 |
| 158 // WebView configuration options. |
| 159 const WebViewSettings settings_; |
| 160 |
| 161 // WebView for rendering a webpage as a webui login. |
| 162 scoped_refptr<WebViewHandle> webui_login_; |
| 163 |
| 164 // True if the current webview instance (ie, GetWebUI()) has been reused. |
| 165 bool is_reusing_webview_ = false; |
| 166 |
| 151 // Converts keyboard events on the WebContents to accelerators. | 167 // Converts keyboard events on the WebContents to accelerators. |
| 152 views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_; | 168 views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_; |
| 153 | 169 |
| 154 // Maps installed accelerators to OOBE webui accelerator identifiers. | 170 // Maps installed accelerators to OOBE webui accelerator identifiers. |
| 155 AccelMap accel_map_; | 171 AccelMap accel_map_; |
| 156 | 172 |
| 157 // True when WebUI is being initialized hidden. | 173 // True when WebUI is being initialized hidden. |
| 158 bool is_hidden_ = false; | 174 bool is_hidden_ = false; |
| 159 | 175 |
| 160 // True when the WebUI has finished initializing and is visible. | 176 // True when the WebUI has finished initializing and is visible. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 179 std::unique_ptr<CycleFocusTraversable> cycle_focus_traversable_; | 195 std::unique_ptr<CycleFocusTraversable> cycle_focus_traversable_; |
| 180 | 196 |
| 181 base::ObserverList<web_modal::ModalDialogHostObserver> observer_list_; | 197 base::ObserverList<web_modal::ModalDialogHostObserver> observer_list_; |
| 182 | 198 |
| 183 DISALLOW_COPY_AND_ASSIGN(WebUILoginView); | 199 DISALLOW_COPY_AND_ASSIGN(WebUILoginView); |
| 184 }; | 200 }; |
| 185 | 201 |
| 186 } // namespace chromeos | 202 } // namespace chromeos |
| 187 | 203 |
| 188 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_UI_WEBUI_LOGIN_VIEW_H_ | 204 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_UI_WEBUI_LOGIN_VIEW_H_ |
| OLD | NEW |