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_
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"
36 class WebUILoginDisplay
;
39 class NetworkStateHelper
;
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
{
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
;
95 bool IsUserWhitelisted(const std::string
& user_id
) override
;
97 // LockWindow::Observer:
98 void OnLockWindowReady() override
;
100 // LockStateObserver:
101 void OnLockStateEvent(ash::LockStateObserver::EventType event
) override
;
104 void OnWidgetDestroying(views::Widget
* widget
) override
;
106 // PowerManagerClient::Observer:
107 void SuspendImminent() override
;
108 void SuspendDone(const base::TimeDelta
& sleep_duration
) override
;
109 void LidEventReceived(bool open
, const base::TimeTicks
& time
) override
;
111 // content::WebContentsObserver:
112 void RenderProcessGone(base::TerminationStatus status
) override
;
114 // ash::KeyboardStateObserver:
115 void OnVirtualKeyboardStateChanged(bool activated
) override
;
117 // keyboard::KeyboardControllerObserver:
118 void OnKeyboardBoundsChanging(const gfx::Rect
& new_bounds
) override
;
120 // gfx::DisplayObserver:
121 void OnDisplayAdded(const gfx::Display
& new_display
) override
;
122 void OnDisplayRemoved(const gfx::Display
& old_display
) override
;
123 void OnDisplayMetricsChanged(const gfx::Display
& display
,
124 uint32_t changed_metrics
) override
;
126 // Returns instance of the OOBE WebUI.
130 friend class test::WebUIScreenLockerTester
;
132 ~WebUIScreenLocker() override
;
134 // Ensures that user pod is focused.
137 // Reset user pod and ensures that user pod is focused.
138 void ResetAndFocusUserPod();
140 // The screen locker window.
141 views::Widget
* lock_window_
;
143 // Sign-in Screen controller instance (owns login screens).
144 scoped_ptr
<SignInScreenController
> signin_screen_controller_
;
146 // Login UI implementation instance.
147 scoped_ptr
<WebUILoginDisplay
> login_display_
;
149 // Tracks when the lock window is displayed and ready.
152 // Tracks when the WebUI finishes loading.
155 // Time when lock was initiated, required for metrics.
156 base::TimeTicks lock_time_
;
158 scoped_ptr
<login::NetworkStateHelper
> network_state_helper_
;
160 // True is subscribed as keyboard controller observer.
161 bool is_observing_keyboard_
;
163 base::WeakPtrFactory
<WebUIScreenLocker
> weak_factory_
;
165 DISALLOW_COPY_AND_ASSIGN(WebUIScreenLocker
);
168 } // namespace chromeos
170 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOCK_WEBUI_SCREEN_LOCKER_H_