Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Side by Side Diff: chrome/browser/chromeos/login/lock/screen_locker.h

Issue 2859363003: cros: Initial structure for views-based lock. (Closed)
Patch Set: Update session state in chrome Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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_LOCK_SCREEN_LOCKER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_LOCK_SCREEN_LOCKER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_LOCK_SCREEN_LOCKER_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_LOCK_SCREEN_LOCKER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/sequenced_task_runner_helpers.h" 15 #include "base/sequenced_task_runner_helpers.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "chrome/browser/chromeos/login/help_app_launcher.h" 17 #include "chrome/browser/chromeos/login/help_app_launcher.h"
18 #include "chrome/browser/chromeos/login/ui/login_display.h" 18 #include "chrome/browser/chromeos/login/ui/login_display.h"
19 #include "chromeos/login/auth/auth_status_consumer.h" 19 #include "chromeos/login/auth/auth_status_consumer.h"
20 #include "chromeos/login/auth/user_context.h" 20 #include "chromeos/login/auth/user_context.h"
21 #include "components/user_manager/user.h" 21 #include "components/user_manager/user.h"
22 #include "mojo/public/cpp/bindings/binding.h" 22 #include "mojo/public/cpp/bindings/binding.h"
23 #include "services/device/public/interfaces/fingerprint.mojom.h" 23 #include "services/device/public/interfaces/fingerprint.mojom.h"
24 #include "ui/base/accelerators/accelerator.h" 24 #include "ui/base/accelerators/accelerator.h"
25 #include "ui/base/ime/chromeos/input_method_manager.h" 25 #include "ui/base/ime/chromeos/input_method_manager.h"
26 26
27 namespace content {
28 class WebContents;
29 }
30
27 namespace chromeos { 31 namespace chromeos {
28 32
29 class Authenticator; 33 class Authenticator;
30 class ExtendedAuthenticator; 34 class ExtendedAuthenticator;
31 class AuthFailure; 35 class AuthFailure;
32 class ScreenlockIconProvider; 36 class ScreenlockIconProvider;
33 class WebUIScreenLocker; 37 class WebUIScreenLocker;
34 38
35 namespace test { 39 namespace test {
36 class ScreenLockerTester; 40 class ScreenLockerTester;
37 class ScreenLockerViewsTester; 41 class ScreenLockerViewsTester;
38 class WebUIScreenLockerTester; 42 class WebUIScreenLockerTester;
39 } // namespace test 43 } // namespace test
40 44
41 // ScreenLocker creates a WebUIScreenLocker which will display the lock UI. 45 // ScreenLocker creates a WebUIScreenLocker which will display the lock UI.
42 // As well, it takes care of authenticating the user and managing a global 46 // As well, it takes care of authenticating the user and managing a global
43 // instance of itself which will be deleted when the system is unlocked. 47 // instance of itself which will be deleted when the system is unlocked.
44 class ScreenLocker : public AuthStatusConsumer, 48 class ScreenLocker : public AuthStatusConsumer,
45 public device::mojom::FingerprintObserver { 49 public device::mojom::FingerprintObserver {
46 public: 50 public:
51 enum class FingerprintState {
52 kHidden,
53 kDefault,
54 kSignin,
55 kFailed,
56 kRemoved,
57 };
58
59 // Delegate used to send internal state changes back to the UI.
60 class Delegate {
61 public:
62 Delegate();
63 virtual ~Delegate();
64
65 // Enable/disable password input.
66 virtual void SetInputEnabled(bool enabled) = 0;
James Cook 2017/05/08 22:04:21 nit: SetPasswordEnabled() or SetPasswordInputEnabl
jdufault 2017/05/08 23:02:35 Done.
67
68 // Show the given error message.
69 virtual void ShowErrorMessage(int error_msg_id,
70 HelpAppLauncher::HelpTopic help_topic_id) = 0;
71
72 // Close any displayed error messages.
73 virtual void ClearErrors() = 0;
74
75 // Run any visual effects after authentication is successful. This must call
76 // ScreenLocker::UnlockOnLoginSuccess() after all effects are done.
77 virtual void AnimateAuthenticationSuccess() = 0;
78
79 // Called when the webui lock screen is ready. This gets invoked by a
80 // chrome.send from the embedded webui.
81 virtual void OnLockWebUIReady() = 0;
82
83 // Called when webui lock screen wallpaper is loaded and displayed.
84 virtual void OnLockBackgroundDisplayed() = 0;
85
86 // Called when the webui header bar becomes visible.
87 virtual void OnHeaderBarVisible() = 0;
88
89 // Called by ScreenLocker to notify that ash lock animation finishes.
90 virtual void OnAshLockAnimationFinished() = 0;
91
92 // Called when fingerprint state has changed.
93 virtual void SetFingerprintState(const AccountId& account_id,
94 FingerprintState state) = 0;
95
96 // Returns the web contents used to back the lock screen.
97 // TODO(jdufault): Remove this function when we remove WebUIScreenLocker.
98 virtual content::WebContents* GetWebContents() = 0;
99
100 private:
101 DISALLOW_COPY_AND_ASSIGN(Delegate);
102 };
James Cook 2017/05/08 22:04:21 nice method docs, by the way
jdufault 2017/05/08 23:02:35 FYI: This section is mostly copied from webui_scre
103
47 explicit ScreenLocker(const user_manager::UserList& users); 104 explicit ScreenLocker(const user_manager::UserList& users);
48 105
49 // Returns the default instance if it has been created. 106 // Returns the default instance if it has been created.
50 static ScreenLocker* default_screen_locker() { 107 static ScreenLocker* default_screen_locker() {
51 return screen_locker_; 108 return screen_locker_;
52 } 109 }
53 110
54 bool locked() const { return locked_; } 111 bool locked() const { return locked_; }
55 112
56 // Initialize and show the screen locker. 113 // Initialize and show the screen locker.
(...skipping 23 matching lines...) Expand all
80 // (Re)enable input field. 137 // (Re)enable input field.
81 void EnableInput(); 138 void EnableInput();
82 139
83 // Disables all UI needed and shows error bubble with |message|. 140 // Disables all UI needed and shows error bubble with |message|.
84 // If |sign_out_only| is true then all other input except "Sign Out" 141 // If |sign_out_only| is true then all other input except "Sign Out"
85 // button is blocked. 142 // button is blocked.
86 void ShowErrorMessage(int error_msg_id, 143 void ShowErrorMessage(int error_msg_id,
87 HelpAppLauncher::HelpTopic help_topic_id, 144 HelpAppLauncher::HelpTopic help_topic_id,
88 bool sign_out_only); 145 bool sign_out_only);
89 146
90 // Returns the WebUIScreenLocker used to lock the screen. 147 // Returns the WebUIScreenLocker instance. This should only be used in tests.
91 WebUIScreenLocker* web_ui() { return web_ui_.get(); } 148 // When using views-based lock this will be a nullptr.
149 // TODO(jdufault): Remove this function, make tests agnostic to ui impl.
150 WebUIScreenLocker* web_ui_for_testing() { return web_ui_.get(); }
151
152 // Returns delegate that can be used to talk to the view-layer.
153 Delegate* delegate() { return delegate_; }
92 154
93 // Returns the users to authenticate. 155 // Returns the users to authenticate.
94 const user_manager::UserList& users() const { return users_; } 156 const user_manager::UserList& users() const { return users_; }
95 157
96 // Allow a AuthStatusConsumer to listen for 158 // Allow a AuthStatusConsumer to listen for
97 // the same login events that ScreenLocker does. 159 // the same login events that ScreenLocker does.
98 void SetLoginStatusConsumer(chromeos::AuthStatusConsumer* consumer); 160 void SetLoginStatusConsumer(chromeos::AuthStatusConsumer* consumer);
99 161
100 // Initialize or uninitialize the ScreenLocker class. It listens to 162 // Initialize or uninitialize the ScreenLocker class. It listens to
101 // NOTIFICATION_SESSION_STARTED so that the screen locker accepts lock 163 // NOTIFICATION_SESSION_STARTED so that the screen locker accepts lock
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 const user_manager::User* FindUnlockUser(const AccountId& account_id); 223 const user_manager::User* FindUnlockUser(const AccountId& account_id);
162 224
163 // Callback to be invoked for ash start lock request. |locked| is true when 225 // Callback to be invoked for ash start lock request. |locked| is true when
164 // ash is fully locked and post lock animation finishes. Otherwise, the start 226 // ash is fully locked and post lock animation finishes. Otherwise, the start
165 // lock request is failed. 227 // lock request is failed.
166 void OnStartLockCallback(bool locked); 228 void OnStartLockCallback(bool locked);
167 229
168 // WebUIScreenLocker instance in use. 230 // WebUIScreenLocker instance in use.
169 std::unique_ptr<WebUIScreenLocker> web_ui_; 231 std::unique_ptr<WebUIScreenLocker> web_ui_;
170 232
233 // Delegate used to talk to the view.
234 Delegate* delegate_ = nullptr;
235 bool owns_delegate_ = false;
236
171 // Users that can unlock the device. 237 // Users that can unlock the device.
172 user_manager::UserList users_; 238 user_manager::UserList users_;
173 239
174 // Used to authenticate the user to unlock. 240 // Used to authenticate the user to unlock.
175 scoped_refptr<Authenticator> authenticator_; 241 scoped_refptr<Authenticator> authenticator_;
176 242
177 // Used to authenticate the user to unlock supervised users. 243 // Used to authenticate the user to unlock supervised users.
178 scoped_refptr<ExtendedAuthenticator> extended_authenticator_; 244 scoped_refptr<ExtendedAuthenticator> extended_authenticator_;
179 245
180 // True if the screen is locked, or false otherwise. This changes 246 // True if the screen is locked, or false otherwise. This changes
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 mojo::Binding<device::mojom::FingerprintObserver> binding_; 280 mojo::Binding<device::mojom::FingerprintObserver> binding_;
215 281
216 base::WeakPtrFactory<ScreenLocker> weak_factory_; 282 base::WeakPtrFactory<ScreenLocker> weak_factory_;
217 283
218 DISALLOW_COPY_AND_ASSIGN(ScreenLocker); 284 DISALLOW_COPY_AND_ASSIGN(ScreenLocker);
219 }; 285 };
220 286
221 } // namespace chromeos 287 } // namespace chromeos
222 288
223 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOCK_SCREEN_LOCKER_H_ 289 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOCK_SCREEN_LOCKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698