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

Side by Side Diff: chrome/browser/chromeos/login/ui/webui_login_view.h

Issue 2512473004: cros: Enable WebUILoginView reuse. (Closed)
Patch Set: Initial upload Created 4 years 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
OLDNEW
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
(...skipping 16 matching lines...) Expand all
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 SharedWebViewUsageHandle;
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;
xiyuan 2016/12/09 22:37:30 nit: #include "url/gurl.h" and get rid of forward
jdufault 2016/12/12 18:23:09 Done.
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
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);
xiyuan 2016/12/09 22:37:30 nit: no need to expose this in header, put it in t
jdufault 2016/12/12 18:23:09 This is needed for preloading the webview (done in
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;
(...skipping 23 matching lines...) Expand all
141 const blink::WebGestureEvent& event) override; 149 const blink::WebGestureEvent& event) override;
142 150
143 // Performs series of actions when login prompt is considered 151 // Performs series of actions when login prompt is considered
144 // to be ready and visible. 152 // to be ready and visible.
145 // 1. Emits LoginPromptVisible signal if needed 153 // 1. Emits LoginPromptVisible signal if needed
146 // 2. Notifies OOBE/sign classes. 154 // 2. Notifies OOBE/sign classes.
147 void OnLoginPromptVisible(); 155 void OnLoginPromptVisible();
148 156
149 content::NotificationRegistrar registrar_; 157 content::NotificationRegistrar registrar_;
150 158
159 // WebView configuration options.
160 WebViewSettings settings_;
xiyuan 2016/12/09 22:37:30 nit: const WebViewSettings if we don't need to cha
jdufault 2016/12/12 18:23:09 Done.
161
162 // True if the current webview instance (ie, GetWebUI()) has been reused.
163 bool is_reusing_webview_ = false;
164
165 // Prevents the webview from being destroyed while it is in use.
166 std::unique_ptr<SharedWebViewUsageHandle> webview_usage_handle_;
167
151 // Converts keyboard events on the WebContents to accelerators. 168 // Converts keyboard events on the WebContents to accelerators.
152 views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_; 169 views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_;
153 170
154 // Maps installed accelerators to OOBE webui accelerator identifiers. 171 // Maps installed accelerators to OOBE webui accelerator identifiers.
155 AccelMap accel_map_; 172 AccelMap accel_map_;
156 173
157 // True when WebUI is being initialized hidden. 174 // True when WebUI is being initialized hidden.
158 bool is_hidden_ = false; 175 bool is_hidden_ = false;
159 176
160 // True when the WebUI has finished initializing and is visible. 177 // True when the WebUI has finished initializing and is visible.
(...skipping 18 matching lines...) Expand all
179 std::unique_ptr<CycleFocusTraversable> cycle_focus_traversable_; 196 std::unique_ptr<CycleFocusTraversable> cycle_focus_traversable_;
180 197
181 base::ObserverList<web_modal::ModalDialogHostObserver> observer_list_; 198 base::ObserverList<web_modal::ModalDialogHostObserver> observer_list_;
182 199
183 DISALLOW_COPY_AND_ASSIGN(WebUILoginView); 200 DISALLOW_COPY_AND_ASSIGN(WebUILoginView);
184 }; 201 };
185 202
186 } // namespace chromeos 203 } // namespace chromeos
187 204
188 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_UI_WEBUI_LOGIN_VIEW_H_ 205 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_UI_WEBUI_LOGIN_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698