| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_WEBUI_SCREEN_LOCKER_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_WEBUI_SCREEN_LOCKER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "ash/wm/lock_state_observer.h" | |
| 11 #include "base/compiler_specific.h" | |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "base/memory/weak_ptr.h" | |
| 14 #include "base/time/time.h" | |
| 15 #include "chrome/browser/chromeos/login/lock_window.h" | |
| 16 #include "chrome/browser/chromeos/login/login_display.h" | |
| 17 #include "chrome/browser/chromeos/login/screen_locker_delegate.h" | |
| 18 #include "chrome/browser/chromeos/login/webui_login_view.h" | |
| 19 #include "chromeos/dbus/power_manager_client.h" | |
| 20 #include "content/public/browser/notification_observer.h" | |
| 21 #include "content/public/browser/notification_registrar.h" | |
| 22 #include "ui/views/widget/widget.h" | |
| 23 #include "ui/views/widget/widget_observer.h" | |
| 24 | |
| 25 namespace content { | |
| 26 class WebUI; | |
| 27 } | |
| 28 | |
| 29 namespace chromeos { | |
| 30 | |
| 31 class ScreenLocker; | |
| 32 class WebUILoginDisplay; | |
| 33 class UserContext; | |
| 34 | |
| 35 namespace login { | |
| 36 class NetworkStateHelper; | |
| 37 } | |
| 38 | |
| 39 namespace test { | |
| 40 class WebUIScreenLockerTester; | |
| 41 } | |
| 42 | |
| 43 // This version of ScreenLockerDelegate displays a WebUI lock screen based on | |
| 44 // the Oobe account picker screen. | |
| 45 class WebUIScreenLocker : public WebUILoginView, | |
| 46 public LoginDisplay::Delegate, | |
| 47 public ScreenLockerDelegate, | |
| 48 public LockWindow::Observer, | |
| 49 public ash::LockStateObserver, | |
| 50 public views::WidgetObserver, | |
| 51 public PowerManagerClient::Observer { | |
| 52 public: | |
| 53 explicit WebUIScreenLocker(ScreenLocker* screen_locker); | |
| 54 | |
| 55 // ScreenLockerDelegate implementation. | |
| 56 virtual void LockScreen() OVERRIDE; | |
| 57 virtual void ScreenLockReady() OVERRIDE; | |
| 58 virtual void OnAuthenticate() OVERRIDE; | |
| 59 virtual void SetInputEnabled(bool enabled) OVERRIDE; | |
| 60 virtual void ShowBannerMessage(const std::string& message) OVERRIDE; | |
| 61 virtual void ShowUserPodButton(const std::string& username, | |
| 62 const std::string& iconURL, | |
| 63 const base::Closure& click_callback) OVERRIDE; | |
| 64 virtual void HideUserPodButton(const std::string& username) OVERRIDE; | |
| 65 virtual void SetAuthType(const std::string& username, | |
| 66 LoginDisplay::AuthType auth_type, | |
| 67 const std::string& initial_value) OVERRIDE; | |
| 68 virtual LoginDisplay::AuthType GetAuthType(const std::string& username) | |
| 69 const OVERRIDE; | |
| 70 virtual void ShowErrorMessage( | |
| 71 int error_msg_id, | |
| 72 HelpAppLauncher::HelpTopic help_topic_id) OVERRIDE; | |
| 73 virtual void ClearErrors() OVERRIDE; | |
| 74 virtual void AnimateAuthenticationSuccess() OVERRIDE; | |
| 75 virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE; | |
| 76 virtual content::WebUI* GetAssociatedWebUI() OVERRIDE; | |
| 77 virtual void OnLockWebUIReady() OVERRIDE; | |
| 78 virtual void OnLockBackgroundDisplayed() OVERRIDE; | |
| 79 | |
| 80 // LoginDisplay::Delegate: implementation | |
| 81 virtual void CancelPasswordChangedFlow() OVERRIDE; | |
| 82 virtual void CreateAccount() OVERRIDE; | |
| 83 virtual void CompleteLogin(const UserContext& user_context) OVERRIDE; | |
| 84 virtual base::string16 GetConnectedNetworkName() OVERRIDE; | |
| 85 virtual bool IsSigninInProgress() const OVERRIDE; | |
| 86 virtual void Login(const UserContext& user_context) OVERRIDE; | |
| 87 virtual void LoginAsRetailModeUser() OVERRIDE; | |
| 88 virtual void LoginAsGuest() OVERRIDE; | |
| 89 virtual void MigrateUserData(const std::string& old_password) OVERRIDE; | |
| 90 virtual void LoginAsPublicAccount(const std::string& username) OVERRIDE; | |
| 91 virtual void OnSigninScreenReady() OVERRIDE; | |
| 92 virtual void OnUserSelected(const std::string& username) OVERRIDE; | |
| 93 virtual void OnStartEnterpriseEnrollment() OVERRIDE; | |
| 94 virtual void OnStartKioskEnableScreen() OVERRIDE; | |
| 95 virtual void OnStartKioskAutolaunchScreen() OVERRIDE; | |
| 96 virtual void ShowWrongHWIDScreen() OVERRIDE; | |
| 97 virtual void ResetPublicSessionAutoLoginTimer() OVERRIDE; | |
| 98 virtual void ResyncUserData() OVERRIDE; | |
| 99 virtual void SetDisplayEmail(const std::string& email) OVERRIDE; | |
| 100 virtual void Signout() OVERRIDE; | |
| 101 virtual void LoginAsKioskApp(const std::string& app_id, | |
| 102 bool diagnostic_mode) OVERRIDE; | |
| 103 | |
| 104 // content::NotificationObserver (via WebUILoginView) implementation. | |
| 105 virtual void Observe(int type, | |
| 106 const content::NotificationSource& source, | |
| 107 const content::NotificationDetails& details) OVERRIDE; | |
| 108 | |
| 109 // LockWindow::Observer implementation. | |
| 110 virtual void OnLockWindowReady() OVERRIDE; | |
| 111 | |
| 112 // LockStateObserver override. | |
| 113 virtual void OnLockStateEvent( | |
| 114 ash::LockStateObserver::EventType event) OVERRIDE; | |
| 115 | |
| 116 // WidgetObserver override. | |
| 117 virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE; | |
| 118 | |
| 119 // PowerManagerClient::Observer overrides: | |
| 120 virtual void SuspendDone(const base::TimeDelta& sleep_duration) OVERRIDE; | |
| 121 virtual void LidEventReceived(bool open, | |
| 122 const base::TimeTicks& time) OVERRIDE; | |
| 123 | |
| 124 // Overridden from content::WebContentsObserver: | |
| 125 virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE; | |
| 126 | |
| 127 private: | |
| 128 friend class test::WebUIScreenLockerTester; | |
| 129 | |
| 130 virtual ~WebUIScreenLocker(); | |
| 131 | |
| 132 // Ensures that user pod is focused. | |
| 133 void FocusUserPod(); | |
| 134 | |
| 135 // The screen locker window. | |
| 136 views::Widget* lock_window_; | |
| 137 | |
| 138 // Login UI implementation instance. | |
| 139 scoped_ptr<WebUILoginDisplay> login_display_; | |
| 140 | |
| 141 // Used for user image changed notifications. | |
| 142 content::NotificationRegistrar registrar_; | |
| 143 | |
| 144 // Tracks when the lock window is displayed and ready. | |
| 145 bool lock_ready_; | |
| 146 | |
| 147 // Tracks when the WebUI finishes loading. | |
| 148 bool webui_ready_; | |
| 149 | |
| 150 // Time when lock was initiated, required for metrics. | |
| 151 base::TimeTicks lock_time_; | |
| 152 | |
| 153 scoped_ptr<login::NetworkStateHelper> network_state_helper_; | |
| 154 | |
| 155 base::WeakPtrFactory<WebUIScreenLocker> weak_factory_; | |
| 156 | |
| 157 DISALLOW_COPY_AND_ASSIGN(WebUIScreenLocker); | |
| 158 }; | |
| 159 | |
| 160 } // namespace chromeos | |
| 161 | |
| 162 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WEBUI_SCREEN_LOCKER_H_ | |
| OLD | NEW |