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

Side by Side Diff: chrome/browser/signin/easy_unlock_screenlock_state_handler.h

Issue 1113043004: [Smart Lock] Extract the screenlock state to the proximity_auth component. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit tests compile Created 5 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_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 13
13 class PrefService; 14 class PrefService;
14 15
15 // Profile specific class responsible for updating screenlock UI for the user 16 // Profile specific class responsible for updating screenlock UI for the user
16 // associated with the profile when their Easy Unlock state changes. 17 // associated with the profile when their Easy Unlock state changes.
17 class EasyUnlockScreenlockStateHandler 18 class EasyUnlockScreenlockStateHandler
18 : public proximity_auth::ScreenlockBridge::Observer { 19 : public proximity_auth::ScreenlockBridge::Observer {
19 public: 20 public:
20 // Available Easy Unlock states.
21 enum State {
22 // Easy Unlock is not enabled, or the screen is not locked.
23 STATE_INACTIVE,
24 // Bluetooth is not on.
25 STATE_NO_BLUETOOTH,
26 // Easy Unlock is in process of turning on Bluetooth.
27 STATE_BLUETOOTH_CONNECTING,
28 // No phones eligible to unlock the device can be found.
29 STATE_NO_PHONE,
30 // A phone eligible to unlock the device is found, but cannot be
31 // authenticated.
32 STATE_PHONE_NOT_AUTHENTICATED,
33 // A phone eligible to unlock the device is found, but it's locked.
34 STATE_PHONE_LOCKED,
35 // A phone eligible to unlock the device is found, but does not have lock
36 // screen enabled.
37 STATE_PHONE_UNLOCKABLE,
38 // An Easy Unlock enabled phone is found, but it is not allowed to unlock
39 // the device because it does not support reporting it's lock screen state.
40 STATE_PHONE_UNSUPPORTED,
41 // A phone eligible to unlock the device is found, but its received signal
42 // strength is too low, i.e. the phone is roughly more than 30 feet away,
43 // and therefore is not allowed to unlock the device.
44 STATE_RSSI_TOO_LOW,
45 // A phone eligible to unlock the device is found, but the local device's
46 // transmission power is too high, indicating that the phone is (probably)
47 // more than 1 foot away, and therefore is not allowed to unlock the device.
48 STATE_TX_POWER_TOO_HIGH,
49 // A phone eligible to unlock the device is found; but (a) the phone is
50 // locked, and (b) the local device's transmission power is too high,
51 // indicating that the phone is (probably) more than 1 foot away, and
52 // therefore is not allowed to unlock the device.
53 STATE_PHONE_LOCKED_AND_TX_POWER_TOO_HIGH,
54 // The device can be unlocked using Easy Unlock.
55 STATE_AUTHENTICATED
56 };
57
58 // Hard lock states. 21 // Hard lock states.
59 enum HardlockState { 22 enum HardlockState {
60 NO_HARDLOCK = 0, // Hard lock is not enforced. This is default. 23 NO_HARDLOCK = 0, // Hard lock is not enforced. This is default.
61 USER_HARDLOCK = 1 << 0, // Hard lock is requested by user. 24 USER_HARDLOCK = 1 << 0, // Hard lock is requested by user.
62 PAIRING_CHANGED = 1 << 1, // Hard lock because pairing data is changed. 25 PAIRING_CHANGED = 1 << 1, // Hard lock because pairing data is changed.
63 NO_PAIRING = 1 << 2, // Hard lock because there is no pairing data. 26 NO_PAIRING = 1 << 2, // Hard lock because there is no pairing data.
64 LOGIN_FAILED = 1 << 3, // Transient hard lock caused by login attempt 27 LOGIN_FAILED = 1 << 3, // Transient hard lock caused by login attempt
65 // failure. Reset when screen is unlocked. 28 // failure. Reset when screen is unlocked.
66 PAIRING_ADDED = 1 << 4, // Similar to PAIRING_CHANGED when it happens 29 PAIRING_ADDED = 1 << 4, // Similar to PAIRING_CHANGED when it happens
67 // on a new Chromebook. 30 // on a new Chromebook.
(...skipping 13 matching lines...) Expand all
81 // Returns true if handler is not in INACTIVE state. 44 // Returns true if handler is not in INACTIVE state.
82 bool IsActive() const; 45 bool IsActive() const;
83 46
84 // Whether the handler is in state that is allowed just after auth failure 47 // Whether the handler is in state that is allowed just after auth failure
85 // (i.e. the state that would cause auth failure rather than one caused by an 48 // (i.e. the state that would cause auth failure rather than one caused by an
86 // auth failure). 49 // auth failure).
87 bool InStateValidOnRemoteAuthFailure() const; 50 bool InStateValidOnRemoteAuthFailure() const;
88 51
89 // Changes internal state to |new_state| and updates the user's screenlock 52 // Changes internal state to |new_state| and updates the user's screenlock
90 // accordingly. 53 // accordingly.
91 void ChangeState(State new_state); 54 void ChangeState(proximity_auth::ScreenlockState new_state);
92 55
93 // Updates the screenlock state. 56 // Updates the screenlock state.
94 void SetHardlockState(HardlockState new_state); 57 void SetHardlockState(HardlockState new_state);
95 58
96 // Shows the hardlock UI if the hardlock_state_ is not NO_HARDLOCK. 59 // Shows the hardlock UI if the hardlock_state_ is not NO_HARDLOCK.
97 void MaybeShowHardlockUI(); 60 void MaybeShowHardlockUI();
98 61
99 // Marks the current screenlock state as the one for trial Easy Unlock run. 62 // Marks the current screenlock state as the one for trial Easy Unlock run.
100 void SetTrialRun(); 63 void SetTrialRun();
101 64
102 // Records that the user clicked on the lock icon during the trial run 65 // Records that the user clicked on the lock icon during the trial run
103 // initiated by the Easy Unlock app. 66 // initiated by the Easy Unlock app.
104 void RecordClickOnLockIcon(); 67 void RecordClickOnLockIcon();
105 68
106 State state() const { return state_; } 69 proximity_auth::ScreenlockState state() const { return state_; }
107 70
108 private: 71 private:
109 // proximity_auth::ScreenlockBridge::Observer: 72 // proximity_auth::ScreenlockBridge::Observer:
110 void OnScreenDidLock(proximity_auth::ScreenlockBridge::LockHandler::ScreenType 73 void OnScreenDidLock(proximity_auth::ScreenlockBridge::LockHandler::ScreenType
111 screen_type) override; 74 screen_type) override;
112 void OnScreenDidUnlock( 75 void OnScreenDidUnlock(
113 proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type) 76 proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type)
114 override; 77 override;
115 void OnFocusedUserChanged(const std::string& user_id) override; 78 void OnFocusedUserChanged(const std::string& user_id) override;
116 79
117 // Forces refresh of the Easy Unlock screenlock UI. 80 // Forces refresh of the Easy Unlock screenlock UI.
118 void RefreshScreenlockState(); 81 void RefreshScreenlockState();
119 82
120 void ShowHardlockUI(); 83 void ShowHardlockUI();
121 84
122 // Updates icon's tooltip options. 85 // Updates icon's tooltip options.
123 void UpdateTooltipOptions( 86 void UpdateTooltipOptions(
124 proximity_auth::ScreenlockBridge::UserPodCustomIconOptions* icon_options); 87 proximity_auth::ScreenlockBridge::UserPodCustomIconOptions* icon_options);
125 88
126 // Gets the name to be used for the device. The name depends on the device 89 // Gets the name to be used for the device. The name depends on the device
127 // type (example values: Chromebook and Chromebox). 90 // type (example values: Chromebook and Chromebox).
128 base::string16 GetDeviceName(); 91 base::string16 GetDeviceName();
129 92
130 // Updates the screenlock auth type if it has to be changed. 93 // Updates the screenlock auth type if it has to be changed.
131 void UpdateScreenlockAuthType(); 94 void UpdateScreenlockAuthType();
132 95
133 State state_; 96 proximity_auth::ScreenlockState state_;
134 std::string user_email_; 97 std::string user_email_;
135 proximity_auth::ScreenlockBridge* screenlock_bridge_; 98 proximity_auth::ScreenlockBridge* screenlock_bridge_;
136 99
137 // State of hardlock. 100 // State of hardlock.
138 HardlockState hardlock_state_; 101 HardlockState hardlock_state_;
139 bool hardlock_ui_shown_; 102 bool hardlock_ui_shown_;
140 103
141 // Whether this is the trial Easy Unlock run. If this is the case, a 104 // Whether this is the trial Easy Unlock run. If this is the case, a
142 // tutorial message should be shown and hard-locking be disabled. The trial 105 // tutorial message should be shown and hard-locking be disabled. The trial
143 // run should be set if the screen was locked by the Easy Unlock setup app. 106 // run should be set if the screen was locked by the Easy Unlock setup app.
144 bool is_trial_run_; 107 bool is_trial_run_;
145 108
146 // Whether the user's phone was ever locked while on the current lock screen. 109 // Whether the user's phone was ever locked while on the current lock screen.
147 bool did_see_locked_phone_; 110 bool did_see_locked_phone_;
148 111
149 DISALLOW_COPY_AND_ASSIGN(EasyUnlockScreenlockStateHandler); 112 DISALLOW_COPY_AND_ASSIGN(EasyUnlockScreenlockStateHandler);
150 }; 113 };
151 114
152 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SCREENLOCK_STATE_HANDLER_H_ 115 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SCREENLOCK_STATE_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698