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 // The device can be unlocked using Easy Unlock.
45 // |user_email|: The email for the user associated with the profile to which
46 // this class is attached.
47 // |pref_service|: The profile preferences.
48 // |screenlock_bridge|: The screenlock bridge used to update the screen lock
50 EasyUnlockScreenlockStateHandler(const std::string& user_email,
51 PrefService* pref_service,
52 ScreenlockBridge* screenlock_bridge);
53 virtual ~EasyUnlockScreenlockStateHandler();
55 // Changes internal state to |new_state| and updates the user's screenlock
57 void ChangeState(State new_state);
60 // ScreenlockBridge::Observer:
61 virtual void OnScreenDidLock() OVERRIDE;
62 virtual void OnScreenDidUnlock() OVERRIDE;
64 void UpdateTooltipOptions(
65 ScreenlockBridge::UserPodCustomIconOptions* icon_options);
67 // Whether the tutorial message should be shown to the user. The message is
68 // shown only once, when the user encounters STATE_AUTHENTICATED for the first
69 // time (across sessions). After the tutorial message is shown,
70 // |MarkTutorialShown| should be called to prevent further tutorial message.
71 bool ShouldShowTutorial();
73 // Sets user preference that prevents showing of tutorial messages.
74 void MarkTutorialShown();
76 // Gets the name to be used for the device. The name depends on the device
77 // type (example values: Chromebook and Chromebox).
78 base::string16 GetDeviceName();
80 // Updates the screenlock auth type if it has to be changed.
81 void UpdateScreenlockAuthType();
84 std::string user_email_;
85 PrefService* pref_service_;
86 ScreenlockBridge* screenlock_bridge_;
88 DISALLOW_COPY_AND_ASSIGN(EasyUnlockScreenlockStateHandler);
91 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SCREENLOCK_STATE_HANDLER_H_