OLD | NEW |
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_SIGNIN_EASY_UNLOCK_SCREENLOCK_STATE_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SCREENLOCK_STATE_HANDLER_H_ |
6 #define CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SCREENLOCK_STATE_HANDLER_H_ | 6 #define CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SCREENLOCK_STATE_HANDLER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
11 #include "components/proximity_auth/screenlock_bridge.h" | 11 #include "components/proximity_auth/screenlock_bridge.h" |
12 #include "components/proximity_auth/screenlock_state.h" | 12 #include "components/proximity_auth/screenlock_state.h" |
| 13 #include "components/signin/core/account_id/account_id.h" |
13 | 14 |
14 class PrefService; | 15 class PrefService; |
15 | 16 |
16 // Profile specific class responsible for updating screenlock UI for the user | 17 // Profile specific class responsible for updating screenlock UI for the user |
17 // associated with the profile when their Easy Unlock state changes. | 18 // associated with the profile when their Easy Unlock state changes. |
18 class EasyUnlockScreenlockStateHandler | 19 class EasyUnlockScreenlockStateHandler |
19 : public proximity_auth::ScreenlockBridge::Observer { | 20 : public proximity_auth::ScreenlockBridge::Observer { |
20 public: | 21 public: |
21 // Hard lock states. | 22 // Hard lock states. |
22 enum HardlockState { | 23 enum HardlockState { |
23 NO_HARDLOCK = 0, // Hard lock is not enforced. This is default. | 24 NO_HARDLOCK = 0, // Hard lock is not enforced. This is default. |
24 USER_HARDLOCK = 1 << 0, // Hard lock is requested by user. | 25 USER_HARDLOCK = 1 << 0, // Hard lock is requested by user. |
25 PAIRING_CHANGED = 1 << 1, // Hard lock because pairing data is changed. | 26 PAIRING_CHANGED = 1 << 1, // Hard lock because pairing data is changed. |
26 NO_PAIRING = 1 << 2, // Hard lock because there is no pairing data. | 27 NO_PAIRING = 1 << 2, // Hard lock because there is no pairing data. |
27 LOGIN_FAILED = 1 << 3, // Transient hard lock caused by login attempt | 28 LOGIN_FAILED = 1 << 3, // Transient hard lock caused by login attempt |
28 // failure. Reset when screen is unlocked. | 29 // failure. Reset when screen is unlocked. |
29 PAIRING_ADDED = 1 << 4, // Similar to PAIRING_CHANGED when it happens | 30 PAIRING_ADDED = 1 << 4, // Similar to PAIRING_CHANGED when it happens |
30 // on a new Chromebook. | 31 // on a new Chromebook. |
31 }; | 32 }; |
32 | 33 |
33 // |user_email|: The email for the user associated with the profile to which | 34 // |account_id|: The account id of the user associated with the profile to |
34 // this class is attached. | 35 // which this class is attached. |
35 // |initial_hardlock_state|: The initial hardlock state. | 36 // |initial_hardlock_state|: The initial hardlock state. |
36 // |screenlock_bridge|: The screenlock bridge used to update the screen lock | 37 // |screenlock_bridge|: The screenlock bridge used to update the screen lock |
37 // state. | 38 // state. |
38 EasyUnlockScreenlockStateHandler( | 39 EasyUnlockScreenlockStateHandler( |
39 const std::string& user_email, | 40 const AccountId& account_id, |
40 HardlockState initial_hardlock_state, | 41 HardlockState initial_hardlock_state, |
41 proximity_auth::ScreenlockBridge* screenlock_bridge); | 42 proximity_auth::ScreenlockBridge* screenlock_bridge); |
42 ~EasyUnlockScreenlockStateHandler() override; | 43 ~EasyUnlockScreenlockStateHandler() override; |
43 | 44 |
44 // Returns true if handler is not in INACTIVE state. | 45 // Returns true if handler is not in INACTIVE state. |
45 bool IsActive() const; | 46 bool IsActive() const; |
46 | 47 |
47 // Whether the handler is in state that is allowed just after auth failure | 48 // Whether the handler is in state that is allowed just after auth failure |
48 // (i.e. the state that would cause auth failure rather than one caused by an | 49 // (i.e. the state that would cause auth failure rather than one caused by an |
49 // auth failure). | 50 // auth failure). |
(...skipping 18 matching lines...) Expand all Loading... |
68 | 69 |
69 proximity_auth::ScreenlockState state() const { return state_; } | 70 proximity_auth::ScreenlockState state() const { return state_; } |
70 | 71 |
71 private: | 72 private: |
72 // proximity_auth::ScreenlockBridge::Observer: | 73 // proximity_auth::ScreenlockBridge::Observer: |
73 void OnScreenDidLock(proximity_auth::ScreenlockBridge::LockHandler::ScreenType | 74 void OnScreenDidLock(proximity_auth::ScreenlockBridge::LockHandler::ScreenType |
74 screen_type) override; | 75 screen_type) override; |
75 void OnScreenDidUnlock( | 76 void OnScreenDidUnlock( |
76 proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type) | 77 proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type) |
77 override; | 78 override; |
78 void OnFocusedUserChanged(const std::string& user_id) override; | 79 void OnFocusedUserChanged(const AccountId& account_id) override; |
79 | 80 |
80 // Forces refresh of the Easy Unlock screenlock UI. | 81 // Forces refresh of the Easy Unlock screenlock UI. |
81 void RefreshScreenlockState(); | 82 void RefreshScreenlockState(); |
82 | 83 |
83 void ShowHardlockUI(); | 84 void ShowHardlockUI(); |
84 | 85 |
85 // Updates icon's tooltip options. | 86 // Updates icon's tooltip options. |
86 void UpdateTooltipOptions( | 87 void UpdateTooltipOptions( |
87 proximity_auth::ScreenlockBridge::UserPodCustomIconOptions* icon_options); | 88 proximity_auth::ScreenlockBridge::UserPodCustomIconOptions* icon_options); |
88 | 89 |
89 // Gets the name to be used for the device. The name depends on the device | 90 // Gets the name to be used for the device. The name depends on the device |
90 // type (example values: Chromebook and Chromebox). | 91 // type (example values: Chromebook and Chromebox). |
91 base::string16 GetDeviceName(); | 92 base::string16 GetDeviceName(); |
92 | 93 |
93 // Updates the screenlock auth type if it has to be changed. | 94 // Updates the screenlock auth type if it has to be changed. |
94 void UpdateScreenlockAuthType(); | 95 void UpdateScreenlockAuthType(); |
95 | 96 |
96 proximity_auth::ScreenlockState state_; | 97 proximity_auth::ScreenlockState state_; |
97 std::string user_email_; | 98 const AccountId account_id_; |
98 proximity_auth::ScreenlockBridge* screenlock_bridge_; | 99 proximity_auth::ScreenlockBridge* screenlock_bridge_; |
99 | 100 |
100 // State of hardlock. | 101 // State of hardlock. |
101 HardlockState hardlock_state_; | 102 HardlockState hardlock_state_; |
102 bool hardlock_ui_shown_; | 103 bool hardlock_ui_shown_ = false; |
103 | 104 |
104 // Whether this is the trial Easy Unlock run. If this is the case, a | 105 // Whether this is the trial Easy Unlock run. If this is the case, a |
105 // tutorial message should be shown and hard-locking be disabled. The trial | 106 // tutorial message should be shown and hard-locking be disabled. The trial |
106 // run should be set if the screen was locked by the Easy Unlock setup app. | 107 // run should be set if the screen was locked by the Easy Unlock setup app. |
107 bool is_trial_run_; | 108 bool is_trial_run_ = false; |
108 | 109 |
109 // Whether the user's phone was ever locked while on the current lock screen. | 110 // Whether the user's phone was ever locked while on the current lock screen. |
110 bool did_see_locked_phone_; | 111 bool did_see_locked_phone_ = false; |
111 | 112 |
112 DISALLOW_COPY_AND_ASSIGN(EasyUnlockScreenlockStateHandler); | 113 DISALLOW_COPY_AND_ASSIGN(EasyUnlockScreenlockStateHandler); |
113 }; | 114 }; |
114 | 115 |
115 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SCREENLOCK_STATE_HANDLER_H_ | 116 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SCREENLOCK_STATE_HANDLER_H_ |
OLD | NEW |