Add method to get filters for a bookmark in Enhanced bookmark bridge
[chromium-blink-merge.git] / chrome / browser / signin / easy_unlock_screenlock_state_handler.h
blob228aaa12f9b3cd63874eda7e01e7df82da03f7b7
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_
8 #include <string>
10 #include "base/strings/string16.h"
11 #include "chrome/browser/signin/screenlock_bridge.h"
13 class PrefService;
15 // Profile specific class responsible for updating screenlock UI for the user
16 // associated with the profile when their Easy Unlock state changes.
17 class EasyUnlockScreenlockStateHandler : public ScreenlockBridge::Observer {
18 public:
19 // Available Easy Unlock states.
20 enum State {
21 // Easy Unlock is not enabled, or the screen is not locked.
22 STATE_INACTIVE,
23 // Bluetooth is not on.
24 STATE_NO_BLUETOOTH,
25 // Easy Unlock is in process of turning on Bluetooth.
26 STATE_BLUETOOTH_CONNECTING,
27 // No phones eligible to unlock the device can be found.
28 STATE_NO_PHONE,
29 // A phone eligible to unlock the device is found, but cannot be
30 // authenticated.
31 STATE_PHONE_NOT_AUTHENTICATED,
32 // A phone eligible to unlock the device is found, but it's locked.
33 STATE_PHONE_LOCKED,
34 // A phone eligible to unlock the device is found, but does not have lock
35 // screen enabled.
36 STATE_PHONE_UNLOCKABLE,
37 // A phone eligible to unlock the device is found, but it's not close enough
38 // to be allowed to unlock the device.
39 STATE_PHONE_NOT_NEARBY,
40 // An Easy Unlock enabled phone is found, but it is not allowed to unlock
41 // the device because it does not support reporting it's lock screen state.
42 STATE_PHONE_UNSUPPORTED,
43 // The device can be unlocked using Easy Unlock.
44 STATE_AUTHENTICATED
47 // Hard lock states.
48 enum HardlockState {
49 NO_HARDLOCK = 0, // Hard lock is not enforced. This is default.
50 USER_HARDLOCK = 1 << 0, // Hard lock is requested by user.
51 PAIRING_CHANGED = 1 << 1, // Hard lock because pairing data is changed.
52 NO_PAIRING = 1 << 2, // Hard lock because there is no pairing data.
53 LOGIN_FAILED = 1 << 3 // Transient hard lock caused by login attempt
54 // failure. Reset when screen is unlocked.
57 // |user_email|: The email for the user associated with the profile to which
58 // this class is attached.
59 // |initial_hardlock_state|: The initial hardlock state.
60 // |screenlock_bridge|: The screenlock bridge used to update the screen lock
61 // state.
62 EasyUnlockScreenlockStateHandler(const std::string& user_email,
63 HardlockState initial_hardlock_state,
64 ScreenlockBridge* screenlock_bridge);
65 ~EasyUnlockScreenlockStateHandler() override;
67 // Returns true if handler is not in INACTIVE state.
68 bool IsActive() const;
70 // Whether the handler is in state that is allowed just after auth failure
71 // (i.e. the state that would cause auth failure rather than one caused by an
72 // auth failure).
73 bool InStateValidOnRemoteAuthFailure() const;
75 // Changes internal state to |new_state| and updates the user's screenlock
76 // accordingly.
77 void ChangeState(State new_state);
79 // Updates the screenlock state.
80 void SetHardlockState(HardlockState new_state);
82 // Shows the hardlock UI if the hardlock_state_ is not NO_HARDLOCK.
83 void MaybeShowHardlockUI();
85 // Marks the current screenlock state as the one for trial Easy Unlock run.
86 void SetTrialRun();
88 State state() const { return state_; }
90 private:
91 // ScreenlockBridge::Observer:
92 void OnScreenDidLock() override;
93 void OnScreenDidUnlock() override;
94 void OnFocusedUserChanged(const std::string& user_id) override;
96 // Forces refresh of the Easy Unlock screenlock UI.
97 void RefreshScreenlockState();
99 void ShowHardlockUI();
101 // Updates icon's tooltip options.
102 // |trial_run|: Whether the trial Easy Unlock run is in progress.
103 void UpdateTooltipOptions(
104 bool trial_run,
105 ScreenlockBridge::UserPodCustomIconOptions* icon_options);
107 // Gets the name to be used for the device. The name depends on the device
108 // type (example values: Chromebook and Chromebox).
109 base::string16 GetDeviceName();
111 // Updates the screenlock auth type if it has to be changed.
112 void UpdateScreenlockAuthType();
114 State state_;
115 std::string user_email_;
116 ScreenlockBridge* screenlock_bridge_;
118 // State of hardlock.
119 HardlockState hardlock_state_;
120 bool hardlock_ui_shown_;
122 // Whether this is the trial Easy Unlock run. If this is the case, a
123 // tutorial message should be shown and hard-locking be disabled. The trial
124 // run should be set if the screen was locked by the Easy Unlock setup app.
125 bool is_trial_run_;
127 DISALLOW_COPY_AND_ASSIGN(EasyUnlockScreenlockStateHandler);
130 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SCREENLOCK_STATE_HANDLER_H_