| 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_CHROMEOS_LOGIN_WEBUI_LOGIN_VIEW_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_WEBUI_LOGIN_VIEW_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_WEBUI_LOGIN_VIEW_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_WEBUI_LOGIN_VIEW_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "chrome/browser/chromeos/login/login_html_dialog.h" | 12 #include "chrome/browser/chromeos/login/login_html_dialog.h" |
| 13 #include "chrome/browser/chromeos/status/status_area_button.h" | |
| 14 #include "chrome/browser/chromeos/status/status_area_view_chromeos.h" | |
| 15 #include "chrome/browser/tab_render_watcher.h" | 13 #include "chrome/browser/tab_render_watcher.h" |
| 16 #include "chrome/browser/ui/views/unhandled_keyboard_event_handler.h" | 14 #include "chrome/browser/ui/views/unhandled_keyboard_event_handler.h" |
| 17 #include "content/public/browser/notification_observer.h" | 15 #include "content/public/browser/notification_observer.h" |
| 18 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/notification_registrar.h" |
| 19 #include "content/public/browser/web_contents_delegate.h" | 17 #include "content/public/browser/web_contents_delegate.h" |
| 20 #include "ui/views/widget/widget.h" | 18 #include "ui/views/widget/widget.h" |
| 21 #include "ui/views/widget/widget_delegate.h" | 19 #include "ui/views/widget/widget_delegate.h" |
| 22 | 20 |
| 23 class DOMView; | 21 class DOMView; |
| 24 class GURL; | 22 class GURL; |
| 25 class StatusAreaView; | |
| 26 | 23 |
| 27 namespace content { | 24 namespace content { |
| 28 class WebUI; | 25 class WebUI; |
| 29 } | 26 } |
| 30 | 27 |
| 31 namespace views { | 28 namespace views { |
| 32 class View; | 29 class View; |
| 33 class Widget; | 30 class Widget; |
| 34 } | 31 } |
| 35 | 32 |
| 36 namespace chromeos { | 33 namespace chromeos { |
| 37 | 34 |
| 38 // View used to render a WebUI supporting Widget. This widget is used for the | 35 // 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 StatusAreaView and | 36 // WebUI based start up and lock screens. It contains a DOMView. |
| 40 // DOMView. | |
| 41 class WebUILoginView : public views::WidgetDelegateView, | 37 class WebUILoginView : public views::WidgetDelegateView, |
| 42 public StatusAreaButton::Delegate, | |
| 43 public content::WebContentsDelegate, | 38 public content::WebContentsDelegate, |
| 44 public content::NotificationObserver, | 39 public content::NotificationObserver, |
| 45 public TabRenderWatcher::Delegate { | 40 public TabRenderWatcher::Delegate { |
| 46 public: | 41 public: |
| 47 static const int kStatusAreaCornerPadding; | |
| 48 | |
| 49 WebUILoginView(); | 42 WebUILoginView(); |
| 50 virtual ~WebUILoginView(); | 43 virtual ~WebUILoginView(); |
| 51 | 44 |
| 52 // Initializes the webui login view. | 45 // Initializes the webui login view. |
| 53 virtual void Init(views::Widget* login_window); | 46 virtual void Init(views::Widget* login_window); |
| 54 | 47 |
| 55 // Overridden from views::Views: | 48 // Overridden from views::Views: |
| 56 virtual bool AcceleratorPressed( | 49 virtual bool AcceleratorPressed( |
| 57 const ui::Accelerator& accelerator) OVERRIDE; | 50 const ui::Accelerator& accelerator) OVERRIDE; |
| 58 virtual std::string GetClassName() const OVERRIDE; | 51 virtual std::string GetClassName() const OVERRIDE; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 69 | 62 |
| 70 // Loads given page. Should be called after Init() has been called. | 63 // Loads given page. Should be called after Init() has been called. |
| 71 void LoadURL(const GURL& url); | 64 void LoadURL(const GURL& url); |
| 72 | 65 |
| 73 // Returns current WebUI. | 66 // Returns current WebUI. |
| 74 content::WebUI* GetWebUI(); | 67 content::WebUI* GetWebUI(); |
| 75 | 68 |
| 76 // Opens proxy settings dialog. | 69 // Opens proxy settings dialog. |
| 77 void OpenProxySettings(); | 70 void OpenProxySettings(); |
| 78 | 71 |
| 79 // Toggles whether status area is enabled. | |
| 80 void SetStatusAreaEnabled(bool enable); | |
| 81 | |
| 82 // Toggles status area visibility. | 72 // Toggles status area visibility. |
| 83 void SetStatusAreaVisible(bool visible); | 73 void SetStatusAreaVisible(bool visible); |
| 84 | 74 |
| 85 protected: | 75 protected: |
| 86 // Let non-login derived classes suppress emission of this signal. | 76 // Let non-login derived classes suppress emission of this signal. |
| 87 void set_should_emit_login_prompt_visible(bool emit) { | 77 void set_should_emit_login_prompt_visible(bool emit) { |
| 88 should_emit_login_prompt_visible_ = emit; | 78 should_emit_login_prompt_visible_ = emit; |
| 89 } | 79 } |
| 90 | 80 |
| 91 // Overridden from views::View: | 81 // Overridden from views::View: |
| 92 virtual void Layout() OVERRIDE; | 82 virtual void Layout() OVERRIDE; |
| 93 virtual void OnLocaleChanged() OVERRIDE; | 83 virtual void OnLocaleChanged() OVERRIDE; |
| 94 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE; | 84 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE; |
| 95 virtual void AboutToRequestFocusFromTabTraversal(bool reverse) OVERRIDE; | 85 virtual void AboutToRequestFocusFromTabTraversal(bool reverse) OVERRIDE; |
| 96 | 86 |
| 97 // Overridden from StatusAreaButton::Delegate: | |
| 98 virtual bool ShouldExecuteStatusAreaCommand( | |
| 99 const views::View* button_view, int command_id) const OVERRIDE; | |
| 100 virtual void ExecuteStatusAreaCommand( | |
| 101 const views::View* button_view, int command_id) OVERRIDE; | |
| 102 virtual StatusAreaButton::TextStyle GetStatusAreaTextStyle() const OVERRIDE; | |
| 103 virtual void ButtonVisibilityChanged(views::View* button_view) OVERRIDE; | |
| 104 | |
| 105 // TabRenderWatcher::Delegate implementation. | 87 // TabRenderWatcher::Delegate implementation. |
| 106 virtual void OnRenderHostCreated(content::RenderViewHost* host) OVERRIDE; | 88 virtual void OnRenderHostCreated(content::RenderViewHost* host) OVERRIDE; |
| 107 virtual void OnTabMainFrameLoaded() OVERRIDE; | 89 virtual void OnTabMainFrameLoaded() OVERRIDE; |
| 108 virtual void OnTabMainFrameRender() OVERRIDE; | 90 virtual void OnTabMainFrameRender() OVERRIDE; |
| 109 | 91 |
| 110 // Creates and adds the status area (separate window). | |
| 111 virtual void InitStatusArea(); | |
| 112 | |
| 113 // Returns the screen mode to set on the status area view. | |
| 114 virtual StatusAreaViewChromeos::ScreenMode GetScreenMode(); | |
| 115 | |
| 116 // Returns the type to use for the status area widget. | |
| 117 virtual views::Widget::InitParams::Type GetStatusAreaWidgetType(); | |
| 118 | |
| 119 // Overridden from content::NotificationObserver. | 92 // Overridden from content::NotificationObserver. |
| 120 virtual void Observe(int type, | 93 virtual void Observe(int type, |
| 121 const content::NotificationSource& source, | 94 const content::NotificationSource& source, |
| 122 const content::NotificationDetails& details) OVERRIDE; | 95 const content::NotificationDetails& details) OVERRIDE; |
| 123 | 96 |
| 124 StatusAreaView* status_area_; | |
| 125 | |
| 126 // DOMView for rendering a webpage as a webui login. | 97 // DOMView for rendering a webpage as a webui login. |
| 127 DOMView* webui_login_; | 98 DOMView* webui_login_; |
| 128 | 99 |
| 129 private: | 100 private: |
| 130 // Map type for the accelerator-to-identifier map. | 101 // Map type for the accelerator-to-identifier map. |
| 131 typedef std::map<ui::Accelerator, std::string> AccelMap; | 102 typedef std::map<ui::Accelerator, std::string> AccelMap; |
| 132 | 103 |
| 133 // Overridden from content::WebContentsDelegate. | 104 // Overridden from content::WebContentsDelegate. |
| 134 virtual bool HandleContextMenu( | 105 virtual bool HandleContextMenu( |
| 135 const content::ContextMenuParams& params) OVERRIDE; | 106 const content::ContextMenuParams& params) OVERRIDE; |
| 136 virtual void HandleKeyboardEvent( | 107 virtual void HandleKeyboardEvent( |
| 137 const NativeWebKeyboardEvent& event) OVERRIDE; | 108 const NativeWebKeyboardEvent& event) OVERRIDE; |
| 138 virtual bool IsPopupOrPanel( | 109 virtual bool IsPopupOrPanel( |
| 139 const content::WebContents* source) const OVERRIDE; | 110 const content::WebContents* source) const OVERRIDE; |
| 140 virtual bool TakeFocus(bool reverse) OVERRIDE; | 111 virtual bool TakeFocus(bool reverse) OVERRIDE; |
| 141 | 112 |
| 142 // Called when focus is returned from status area. | 113 // Called when focus is returned from status area. |
| 143 // |reverse| is true when focus is traversed backwards (using Shift-Tab). | 114 // |reverse| is true when focus is traversed backwards (using Shift-Tab). |
| 144 void ReturnFocus(bool reverse); | 115 void ReturnFocus(bool reverse); |
| 145 | 116 |
| 146 content::NotificationRegistrar registrar_; | 117 content::NotificationRegistrar registrar_; |
| 147 | 118 |
| 148 // Login window which shows the view. | 119 // Login window which shows the view. |
| 149 views::Widget* login_window_; | 120 views::Widget* login_window_; |
| 150 | 121 |
| 151 // Window that contains status area. | |
| 152 // TODO(nkostylev): Temporary solution till we have | |
| 153 // RenderWidgetHostViewViews working. | |
| 154 views::Widget* status_window_; | |
| 155 | |
| 156 // Converts keyboard events on the TabContents to accelerators. | 122 // Converts keyboard events on the TabContents to accelerators. |
| 157 UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_; | 123 UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_; |
| 158 | 124 |
| 159 // Maps installed accelerators to OOBE webui accelerator identifiers. | 125 // Maps installed accelerators to OOBE webui accelerator identifiers. |
| 160 AccelMap accel_map_; | 126 AccelMap accel_map_; |
| 161 | 127 |
| 162 // Watches webui_login_'s TabContents rendering. | 128 // Watches webui_login_'s TabContents rendering. |
| 163 scoped_ptr<TabRenderWatcher> tab_watcher_; | 129 scoped_ptr<TabRenderWatcher> tab_watcher_; |
| 164 | 130 |
| 165 // Whether the host window is frozen. | 131 // Whether the host window is frozen. |
| 166 bool host_window_frozen_; | 132 bool host_window_frozen_; |
| 167 | 133 |
| 168 // Caches StatusArea visibility setting before it has been initialized. | |
| 169 bool status_area_visibility_on_init_; | |
| 170 | |
| 171 // Has the login page told us that it's ready? This is triggered by either | 134 // Has the login page told us that it's ready? This is triggered by either |
| 172 // all of the user images or the GAIA prompt being loaded, whichever comes | 135 // all of the user images or the GAIA prompt being loaded, whichever comes |
| 173 // first. | 136 // first. |
| 174 bool login_page_is_loaded_; | 137 bool login_page_is_loaded_; |
| 175 | 138 |
| 176 // Should we emit the login-prompt-visible signal when the login page is | 139 // Should we emit the login-prompt-visible signal when the login page is |
| 177 // displayed? | 140 // displayed? |
| 178 bool should_emit_login_prompt_visible_; | 141 bool should_emit_login_prompt_visible_; |
| 179 | 142 |
| 180 DISALLOW_COPY_AND_ASSIGN(WebUILoginView); | 143 DISALLOW_COPY_AND_ASSIGN(WebUILoginView); |
| 181 }; | 144 }; |
| 182 | 145 |
| 183 } // namespace chromeos | 146 } // namespace chromeos |
| 184 | 147 |
| 185 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WEBUI_LOGIN_VIEW_H_ | 148 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WEBUI_LOGIN_VIEW_H_ |
| OLD | NEW |