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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SCREENLOCK_STATE_HANDLER_H_
6 #define CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SCREENLOCK_STATE_HANDLER_H_
10 #include "base/strings/string16.h"
11 #include "base/timer/timer.h"
12 #include "chrome/browser/signin/screenlock_bridge.h"
16 // Profile specific class responsible for updating screenlock UI for the user
17 // associated with the profile when their Easy Unlock state changes.
18 class EasyUnlockScreenlockStateHandler
: public ScreenlockBridge::Observer
{
20 // Available Easy Unlock states.
22 // Easy Unlock is not enabled, or the screen is not locked.
24 // Bluetooth is not on.
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.
30 // A phone eligible to unlock the device is found, but cannot be
32 STATE_PHONE_NOT_AUTHENTICATED
,
33 // A phone eligible to unlock the device is found, but it's locked.
35 // A phone eligible to unlock the device is found, but does not have lock
37 STATE_PHONE_UNLOCKABLE
,
38 // A phone eligible to unlock the device is found, but it's not close enough
39 // to be allowed to unlock the device.
40 STATE_PHONE_NOT_NEARBY
,
41 // An Easy Unlock enabled phone is found, but it is not allowed to unlock
42 // the device because it does not support reporting it's lock screen state.
43 STATE_PHONE_UNSUPPORTED
,
44 // The device can be unlocked using Easy Unlock.
50 NO_HARDLOCK
= 0, // Hard lock is not enforced. This is default.
51 USER_HARDLOCK
= 1 << 0, // Hard lock is requested by user.
52 PAIRING_CHANGED
= 1 << 1, // Hard lock because pairing data is changed.
53 NO_PAIRING
= 1 << 2 // Hard lock because there is no pairing data.
56 // |user_email|: The email for the user associated with the profile to which
57 // this class is attached.
58 // |initial_hardlock_state|: The initial hardlock state.
59 // |screenlock_bridge|: The screenlock bridge used to update the screen lock
61 EasyUnlockScreenlockStateHandler(const std::string
& user_email
,
62 HardlockState initial_hardlock_state
,
63 ScreenlockBridge
* screenlock_bridge
);
64 virtual ~EasyUnlockScreenlockStateHandler();
66 // Returns true if handler is not in INACTIVE state.
67 bool IsActive() const;
69 // Changes internal state to |new_state| and updates the user's screenlock
71 void ChangeState(State new_state
);
73 // Updates the screenlock state.
74 void SetHardlockState(HardlockState new_state
);
76 // Shows the hardlock UI if the hardlock_state_ is not NO_HARDLOCK.
77 void MaybeShowHardlockUI();
79 // Marks the current screenlock state as the one for trial Easy Unlock run.
83 // ScreenlockBridge::Observer:
84 virtual void OnScreenDidLock() override
;
85 virtual void OnScreenDidUnlock() override
;
86 virtual void OnFocusedUserChanged(const std::string
& user_id
) override
;
88 // Forces refresh of the Easy Unlock screenlock UI.
89 void RefreshScreenlockState();
91 void ShowHardlockUI();
93 // Updates icon's tooltip options.
94 // |trial_run|: Whether the trial Easy Unlock run is in progress.
95 void UpdateTooltipOptions(
97 ScreenlockBridge::UserPodCustomIconOptions
* icon_options
);
99 // Gets the name to be used for the device. The name depends on the device
100 // type (example values: Chromebook and Chromebox).
101 base::string16
GetDeviceName();
103 // Updates the screenlock auth type if it has to be changed.
104 void UpdateScreenlockAuthType();
107 std::string user_email_
;
108 ScreenlockBridge
* screenlock_bridge_
;
110 // State of hardlock.
111 HardlockState hardlock_state_
;
112 bool hardlock_ui_shown_
;
114 // Whether this is the trial Easy Unlock run. If this is the case, a
115 // tutorial message should be shown and hard-locking be disabled. The trial
116 // run should be set if the screen was locked by the Easy Unlock setup app.
119 DISALLOW_COPY_AND_ASSIGN(EasyUnlockScreenlockStateHandler
);
122 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SCREENLOCK_STATE_HANDLER_H_