ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / chrome / browser / chromeos / login / lock / webui_screen_locker.h
blobc3c1878bff5ef88acf0bde6a8d2446c17b93ed4f
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_LOCK_WEBUI_SCREEN_LOCKER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_LOCK_WEBUI_SCREEN_LOCKER_H_
8 #include <string>
10 #include "ash/shell_delegate.h"
11 #include "ash/wm/lock_state_observer.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h"
15 #include "base/time/time.h"
16 #include "chrome/browser/chromeos/login/lock/screen_locker_delegate.h"
17 #include "chrome/browser/chromeos/login/signin_screen_controller.h"
18 #include "chrome/browser/chromeos/login/signin_specifics.h"
19 #include "chrome/browser/chromeos/login/ui/lock_window.h"
20 #include "chrome/browser/chromeos/login/ui/login_display.h"
21 #include "chrome/browser/chromeos/login/ui/webui_login_view.h"
22 #include "chromeos/dbus/power_manager_client.h"
23 #include "ui/gfx/display_observer.h"
24 #include "ui/keyboard/keyboard_controller_observer.h"
25 #include "ui/views/widget/widget.h"
26 #include "ui/views/widget/widget_observer.h"
28 namespace content {
29 class WebUI;
32 namespace chromeos {
34 class OobeUI;
35 class ScreenLocker;
36 class WebUILoginDisplay;
38 namespace login {
39 class NetworkStateHelper;
42 namespace test {
43 class WebUIScreenLockerTester;
46 // This version of ScreenLockerDelegate displays a WebUI lock screen based on
47 // the Oobe account picker screen.
48 class WebUIScreenLocker : public WebUILoginView,
49 public LoginDisplay::Delegate,
50 public ScreenLockerDelegate,
51 public LockWindow::Observer,
52 public ash::LockStateObserver,
53 public views::WidgetObserver,
54 public PowerManagerClient::Observer,
55 public ash::VirtualKeyboardStateObserver,
56 public keyboard::KeyboardControllerObserver,
57 public gfx::DisplayObserver {
58 public:
59 explicit WebUIScreenLocker(ScreenLocker* screen_locker);
61 // ScreenLockerDelegate:
62 void LockScreen() override;
63 void ScreenLockReady() override;
64 void OnAuthenticate() override;
65 void SetInputEnabled(bool enabled) override;
66 void ShowErrorMessage(int error_msg_id,
67 HelpAppLauncher::HelpTopic help_topic_id) override;
68 void ClearErrors() override;
69 void AnimateAuthenticationSuccess() override;
70 gfx::NativeWindow GetNativeWindow() const override;
71 content::WebUI* GetAssociatedWebUI() override;
72 void OnLockWebUIReady() override;
73 void OnLockBackgroundDisplayed() override;
74 void OnHeaderBarVisible() override;
76 // LoginDisplay::Delegate:
77 void CancelPasswordChangedFlow() override;
78 void CreateAccount() override;
79 void CompleteLogin(const UserContext& user_context) override;
80 base::string16 GetConnectedNetworkName() override;
81 bool IsSigninInProgress() const override;
82 void Login(const UserContext& user_context,
83 const SigninSpecifics& specifics) override;
84 void MigrateUserData(const std::string& old_password) override;
85 void OnSigninScreenReady() override;
86 void OnStartEnterpriseEnrollment() override;
87 void OnStartEnableDebuggingScreen() override;
88 void OnStartKioskEnableScreen() override;
89 void OnStartKioskAutolaunchScreen() override;
90 void ShowWrongHWIDScreen() override;
91 void ResetPublicSessionAutoLoginTimer() override;
92 void ResyncUserData() override;
93 void SetDisplayEmail(const std::string& email) override;
94 void Signout() override;
96 // LockWindow::Observer:
97 void OnLockWindowReady() override;
99 // LockStateObserver:
100 void OnLockStateEvent(ash::LockStateObserver::EventType event) override;
102 // WidgetObserver:
103 void OnWidgetDestroying(views::Widget* widget) override;
105 // PowerManagerClient::Observer:
106 void SuspendImminent() override;
107 void SuspendDone(const base::TimeDelta& sleep_duration) override;
108 void LidEventReceived(bool open, const base::TimeTicks& time) override;
110 // content::WebContentsObserver:
111 void RenderProcessGone(base::TerminationStatus status) override;
113 // ash::KeyboardStateObserver:
114 void OnVirtualKeyboardStateChanged(bool activated) override;
116 // keyboard::KeyboardControllerObserver:
117 void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) override;
119 // gfx::DisplayObserver:
120 void OnDisplayAdded(const gfx::Display& new_display) override;
121 void OnDisplayRemoved(const gfx::Display& old_display) override;
122 void OnDisplayMetricsChanged(const gfx::Display& display,
123 uint32_t changed_metrics) override;
125 // Returns instance of the OOBE WebUI.
126 OobeUI* GetOobeUI();
128 private:
129 friend class test::WebUIScreenLockerTester;
131 ~WebUIScreenLocker() override;
133 // Ensures that user pod is focused.
134 void FocusUserPod();
136 // Reset user pod and ensures that user pod is focused.
137 void ResetAndFocusUserPod();
139 // The screen locker window.
140 views::Widget* lock_window_;
142 // Sign-in Screen controller instance (owns login screens).
143 scoped_ptr<SignInScreenController> signin_screen_controller_;
145 // Login UI implementation instance.
146 scoped_ptr<WebUILoginDisplay> login_display_;
148 // Tracks when the lock window is displayed and ready.
149 bool lock_ready_;
151 // Tracks when the WebUI finishes loading.
152 bool webui_ready_;
154 // Time when lock was initiated, required for metrics.
155 base::TimeTicks lock_time_;
157 scoped_ptr<login::NetworkStateHelper> network_state_helper_;
159 // True is subscribed as keyboard controller observer.
160 bool is_observing_keyboard_;
162 // The bounds of the virtual keyboard.
163 gfx::Rect keyboard_bounds_;
165 base::WeakPtrFactory<WebUIScreenLocker> weak_factory_;
167 DISALLOW_COPY_AND_ASSIGN(WebUIScreenLocker);
170 } // namespace chromeos
172 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOCK_WEBUI_SCREEN_LOCKER_H_