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.
48 // |user_email|: The email for the user associated with the profile to which
49 // this class is attached.
50 // |pref_service|: The profile preferences.
51 // |screenlock_bridge|: The screenlock bridge used to update the screen lock
53 EasyUnlockScreenlockStateHandler(const std::string& user_email,
54 PrefService* pref_service,
55 ScreenlockBridge* screenlock_bridge);
56 virtual ~EasyUnlockScreenlockStateHandler();
58 // Changes internal state to |new_state| and updates the user's screenlock
60 void ChangeState(State new_state);
63 // ScreenlockBridge::Observer:
64 virtual void OnScreenDidLock() OVERRIDE;
65 virtual void OnScreenDidUnlock() OVERRIDE;
66 virtual void OnFocusedUserChanged(const std::string& user_id) OVERRIDE;
68 // Updates icon's tooltip options.
69 // |trial_run|: Whether the trial Easy Unlock run is in progress.
70 void UpdateTooltipOptions(
72 ScreenlockBridge::UserPodCustomIconOptions* icon_options);
74 // Whether this is the first, trial Easy Unlock run. If this is the case, a
75 // tutorial message should be shown and hard-locking be disabled in
76 // Authenticated state. The trial run will be active if Easy Unlock never
77 // entered Authenticated state (across sessions).
80 // Sets user preference that marks trial run completed.
81 void MarkTrialRunComplete();
83 // Gets the name to be used for the device. The name depends on the device
84 // type (example values: Chromebook and Chromebox).
85 base::string16 GetDeviceName();
87 // Updates the screenlock auth type if it has to be changed.
88 void UpdateScreenlockAuthType();
91 std::string user_email_;
92 PrefService* pref_service_;
93 ScreenlockBridge* screenlock_bridge_;
95 DISALLOW_COPY_AND_ASSIGN(EasyUnlockScreenlockStateHandler);
98 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SCREENLOCK_STATE_HANDLER_H_