| 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 "chrome/browser/signin/screenlock_bridge.h" | 11 #include "components/proximity_auth/screenlock_bridge.h" |
| 12 | 12 |
| 13 class PrefService; | 13 class PrefService; |
| 14 | 14 |
| 15 // Profile specific class responsible for updating screenlock UI for the user | 15 // Profile specific class responsible for updating screenlock UI for the user |
| 16 // associated with the profile when their Easy Unlock state changes. | 16 // associated with the profile when their Easy Unlock state changes. |
| 17 class EasyUnlockScreenlockStateHandler : public ScreenlockBridge::Observer { | 17 class EasyUnlockScreenlockStateHandler |
| 18 : public proximity_auth::ScreenlockBridge::Observer { |
| 18 public: | 19 public: |
| 19 // Available Easy Unlock states. | 20 // Available Easy Unlock states. |
| 20 enum State { | 21 enum State { |
| 21 // Easy Unlock is not enabled, or the screen is not locked. | 22 // Easy Unlock is not enabled, or the screen is not locked. |
| 22 STATE_INACTIVE, | 23 STATE_INACTIVE, |
| 23 // Bluetooth is not on. | 24 // Bluetooth is not on. |
| 24 STATE_NO_BLUETOOTH, | 25 STATE_NO_BLUETOOTH, |
| 25 // Easy Unlock is in process of turning on Bluetooth. | 26 // Easy Unlock is in process of turning on Bluetooth. |
| 26 STATE_BLUETOOTH_CONNECTING, | 27 STATE_BLUETOOTH_CONNECTING, |
| 27 // No phones eligible to unlock the device can be found. | 28 // No phones eligible to unlock the device can be found. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 // failure. Reset when screen is unlocked. | 65 // failure. Reset when screen is unlocked. |
| 65 PAIRING_ADDED = 1 << 4, // Similar to PAIRING_CHANGED when it happens | 66 PAIRING_ADDED = 1 << 4, // Similar to PAIRING_CHANGED when it happens |
| 66 // on a new Chromebook. | 67 // on a new Chromebook. |
| 67 }; | 68 }; |
| 68 | 69 |
| 69 // |user_email|: The email for the user associated with the profile to which | 70 // |user_email|: The email for the user associated with the profile to which |
| 70 // this class is attached. | 71 // this class is attached. |
| 71 // |initial_hardlock_state|: The initial hardlock state. | 72 // |initial_hardlock_state|: The initial hardlock state. |
| 72 // |screenlock_bridge|: The screenlock bridge used to update the screen lock | 73 // |screenlock_bridge|: The screenlock bridge used to update the screen lock |
| 73 // state. | 74 // state. |
| 74 EasyUnlockScreenlockStateHandler(const std::string& user_email, | 75 EasyUnlockScreenlockStateHandler( |
| 75 HardlockState initial_hardlock_state, | 76 const std::string& user_email, |
| 76 ScreenlockBridge* screenlock_bridge); | 77 HardlockState initial_hardlock_state, |
| 78 proximity_auth::ScreenlockBridge* screenlock_bridge); |
| 77 ~EasyUnlockScreenlockStateHandler() override; | 79 ~EasyUnlockScreenlockStateHandler() override; |
| 78 | 80 |
| 79 // Returns true if handler is not in INACTIVE state. | 81 // Returns true if handler is not in INACTIVE state. |
| 80 bool IsActive() const; | 82 bool IsActive() const; |
| 81 | 83 |
| 82 // Whether the handler is in state that is allowed just after auth failure | 84 // Whether the handler is in state that is allowed just after auth failure |
| 83 // (i.e. the state that would cause auth failure rather than one caused by an | 85 // (i.e. the state that would cause auth failure rather than one caused by an |
| 84 // auth failure). | 86 // auth failure). |
| 85 bool InStateValidOnRemoteAuthFailure() const; | 87 bool InStateValidOnRemoteAuthFailure() const; |
| 86 | 88 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 97 // Marks the current screenlock state as the one for trial Easy Unlock run. | 99 // Marks the current screenlock state as the one for trial Easy Unlock run. |
| 98 void SetTrialRun(); | 100 void SetTrialRun(); |
| 99 | 101 |
| 100 // Records that the user clicked on the lock icon during the trial run | 102 // Records that the user clicked on the lock icon during the trial run |
| 101 // initiated by the Easy Unlock app. | 103 // initiated by the Easy Unlock app. |
| 102 void RecordClickOnLockIcon(); | 104 void RecordClickOnLockIcon(); |
| 103 | 105 |
| 104 State state() const { return state_; } | 106 State state() const { return state_; } |
| 105 | 107 |
| 106 private: | 108 private: |
| 107 // ScreenlockBridge::Observer: | 109 // proximity_auth::ScreenlockBridge::Observer: |
| 108 void OnScreenDidLock( | 110 void OnScreenDidLock(proximity_auth::ScreenlockBridge::LockHandler::ScreenType |
| 109 ScreenlockBridge::LockHandler::ScreenType screen_type) override; | 111 screen_type) override; |
| 110 void OnScreenDidUnlock( | 112 void OnScreenDidUnlock( |
| 111 ScreenlockBridge::LockHandler::ScreenType screen_type) override; | 113 proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type) |
| 114 override; |
| 112 void OnFocusedUserChanged(const std::string& user_id) override; | 115 void OnFocusedUserChanged(const std::string& user_id) override; |
| 113 | 116 |
| 114 // Forces refresh of the Easy Unlock screenlock UI. | 117 // Forces refresh of the Easy Unlock screenlock UI. |
| 115 void RefreshScreenlockState(); | 118 void RefreshScreenlockState(); |
| 116 | 119 |
| 117 void ShowHardlockUI(); | 120 void ShowHardlockUI(); |
| 118 | 121 |
| 119 // Updates icon's tooltip options. | 122 // Updates icon's tooltip options. |
| 120 void UpdateTooltipOptions( | 123 void UpdateTooltipOptions( |
| 121 ScreenlockBridge::UserPodCustomIconOptions* icon_options); | 124 proximity_auth::ScreenlockBridge::UserPodCustomIconOptions* icon_options); |
| 122 | 125 |
| 123 // Gets the name to be used for the device. The name depends on the device | 126 // Gets the name to be used for the device. The name depends on the device |
| 124 // type (example values: Chromebook and Chromebox). | 127 // type (example values: Chromebook and Chromebox). |
| 125 base::string16 GetDeviceName(); | 128 base::string16 GetDeviceName(); |
| 126 | 129 |
| 127 // Updates the screenlock auth type if it has to be changed. | 130 // Updates the screenlock auth type if it has to be changed. |
| 128 void UpdateScreenlockAuthType(); | 131 void UpdateScreenlockAuthType(); |
| 129 | 132 |
| 130 State state_; | 133 State state_; |
| 131 std::string user_email_; | 134 std::string user_email_; |
| 132 ScreenlockBridge* screenlock_bridge_; | 135 proximity_auth::ScreenlockBridge* screenlock_bridge_; |
| 133 | 136 |
| 134 // State of hardlock. | 137 // State of hardlock. |
| 135 HardlockState hardlock_state_; | 138 HardlockState hardlock_state_; |
| 136 bool hardlock_ui_shown_; | 139 bool hardlock_ui_shown_; |
| 137 | 140 |
| 138 // Whether this is the trial Easy Unlock run. If this is the case, a | 141 // Whether this is the trial Easy Unlock run. If this is the case, a |
| 139 // tutorial message should be shown and hard-locking be disabled. The trial | 142 // tutorial message should be shown and hard-locking be disabled. The trial |
| 140 // run should be set if the screen was locked by the Easy Unlock setup app. | 143 // run should be set if the screen was locked by the Easy Unlock setup app. |
| 141 bool is_trial_run_; | 144 bool is_trial_run_; |
| 142 | 145 |
| 143 // Whether the user's phone was ever locked while on the current lock screen. | 146 // Whether the user's phone was ever locked while on the current lock screen. |
| 144 bool did_see_locked_phone_; | 147 bool did_see_locked_phone_; |
| 145 | 148 |
| 146 DISALLOW_COPY_AND_ASSIGN(EasyUnlockScreenlockStateHandler); | 149 DISALLOW_COPY_AND_ASSIGN(EasyUnlockScreenlockStateHandler); |
| 147 }; | 150 }; |
| 148 | 151 |
| 149 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SCREENLOCK_STATE_HANDLER_H_ | 152 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SCREENLOCK_STATE_HANDLER_H_ |
| OLD | NEW |