[ChromeOS] WebUILoginView returns true for IsPopupOrPanel.
[chromium-blink-merge.git] / chrome / browser / chromeos / login / webui_login_view.h
blob72b7b64fc7a6a15985a8af041a1a8cd913cdbaed
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_WEBUI_LOGIN_VIEW_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_WEBUI_LOGIN_VIEW_H_
7 #pragma once
9 #include "chrome/browser/chromeos/login/login_html_dialog.h"
10 #include "chrome/browser/chromeos/status/status_area_host.h"
11 #include "chrome/browser/chromeos/tab_first_render_watcher.h"
12 #include "chrome/browser/ui/views/unhandled_keyboard_event_handler.h"
13 #include "content/browser/tab_contents/tab_contents_delegate.h"
14 #include "views/view.h"
16 class DOMView;
17 class GURL;
18 class Profile;
19 class WebUI;
21 namespace views {
22 class Widget;
25 namespace chromeos {
27 class StatusAreaView;
28 class TabFirstRenderWatcher;
30 // View used to render a WebUI supporting Widget. This widget is used for the
31 // WebUI based start up and lock screens. It contains a StatusAreaView and
32 // DOMView.
33 class WebUILoginView : public views::View,
34 public StatusAreaHost,
35 public TabContentsDelegate,
36 public chromeos::LoginHtmlDialog::Delegate,
37 public TabFirstRenderWatcher::Delegate {
38 public:
39 static const int kStatusAreaCornerPadding;
41 WebUILoginView();
42 virtual ~WebUILoginView();
44 // Initializes the webui login view.
45 virtual void Init();
47 // Overridden from views::Views:
48 virtual bool AcceleratorPressed(
49 const views::Accelerator& accelerator) OVERRIDE;
50 virtual std::string GetClassName() const OVERRIDE;
52 // Overridden from StatusAreaHost:
53 virtual gfx::NativeWindow GetNativeWindow() const;
55 // Called when WebUI window is created.
56 virtual void OnWindowCreated();
58 // Invokes SetWindowType for the window. This is invoked during startup and
59 // after we've painted.
60 void UpdateWindowType();
62 // Loads given page. Should be called after Init() has been called.
63 void LoadURL(const GURL& url);
65 // Returns current WebUI.
66 WebUI* GetWebUI();
68 // Toggles whether status area is enabled.
69 void SetStatusAreaEnabled(bool enable);
71 // Toggles status area visibility.
72 void SetStatusAreaVisible(bool visible);
74 protected:
75 // Overridden from views::View:
76 virtual void Layout() OVERRIDE;
77 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE;
79 // Overridden from StatusAreaHost:
80 virtual Profile* GetProfile() const OVERRIDE;
81 virtual void ExecuteBrowserCommand(int id) const OVERRIDE;
82 virtual bool ShouldOpenButtonOptions(
83 const views::View* button_view) const OVERRIDE;
84 virtual void OpenButtonOptions(const views::View* button_view) OVERRIDE;
85 virtual ScreenMode GetScreenMode() const OVERRIDE;
86 virtual TextStyle GetTextStyle() const OVERRIDE;
87 virtual void ButtonVisibilityChanged(views::View* button_view) OVERRIDE;
89 // Overridden from LoginHtmlDialog::Delegate:
90 virtual void OnDialogClosed() OVERRIDE;
91 virtual void OnLocaleChanged() OVERRIDE;
93 // TabFirstRenderWatcher::Delegate implementation.
94 virtual void OnTabMainFrameLoaded() OVERRIDE;
95 virtual void OnTabMainFrameFirstRender() OVERRIDE;
97 // Creates and adds the status area (separate window).
98 virtual void InitStatusArea();
100 StatusAreaView* status_area_;
102 Profile* profile_;
104 // DOMView for rendering a webpage as a webui login.
105 DOMView* webui_login_;
107 private:
108 // Map type for the accelerator-to-identifier map.
109 typedef std::map<views::Accelerator, std::string> AccelMap;
111 // Overridden from TabContentsDelegate.
112 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE;
113 virtual void HandleKeyboardEvent(
114 const NativeWebKeyboardEvent& event) OVERRIDE;
115 virtual bool IsPopupOrPanel(const TabContents* source) const OVERRIDE;
116 virtual bool TakeFocus(bool reverse) OVERRIDE;
118 // Window that contains status area.
119 // TODO(nkostylev): Temporary solution till we have
120 // RenderWidgetHostViewViews working.
121 views::Widget* status_window_;
123 // Converts keyboard events on the TabContents to accelerators.
124 UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_;
126 // Maps installed accelerators to OOBE webui accelerator identifiers.
127 AccelMap accel_map_;
129 // Proxy settings dialog that can be invoked from network menu.
130 scoped_ptr<LoginHtmlDialog> proxy_settings_dialog_;
132 // Watches webui_login_'s TabContents rendering.
133 scoped_ptr<TabFirstRenderWatcher> tab_watcher_;
135 // Whether the host window is frozen.
136 bool host_window_frozen_;
138 DISALLOW_COPY_AND_ASSIGN(WebUILoginView);
141 } // namespace chromeos
143 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WEBUI_LOGIN_VIEW_H_