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 "components/proximity_auth/screenlock_bridge.h"
12 #include "components/proximity_auth/screenlock_state.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
19 : public proximity_auth::ScreenlockBridge::Observer
{
23 NO_HARDLOCK
= 0, // Hard lock is not enforced. This is default.
24 USER_HARDLOCK
= 1 << 0, // Hard lock is requested by user.
25 PAIRING_CHANGED
= 1 << 1, // Hard lock because pairing data is changed.
26 NO_PAIRING
= 1 << 2, // Hard lock because there is no pairing data.
27 LOGIN_FAILED
= 1 << 3, // Transient hard lock caused by login attempt
28 // failure. Reset when screen is unlocked.
29 PAIRING_ADDED
= 1 << 4, // Similar to PAIRING_CHANGED when it happens
30 // on a new Chromebook.
33 // |user_email|: The email for the user associated with the profile to which
34 // this class is attached.
35 // |initial_hardlock_state|: The initial hardlock state.
36 // |screenlock_bridge|: The screenlock bridge used to update the screen lock
38 EasyUnlockScreenlockStateHandler(
39 const std::string
& user_email
,
40 HardlockState initial_hardlock_state
,
41 proximity_auth::ScreenlockBridge
* screenlock_bridge
);
42 ~EasyUnlockScreenlockStateHandler() override
;
44 // Returns true if handler is not in INACTIVE state.
45 bool IsActive() const;
47 // Whether the handler is in state that is allowed just after auth failure
48 // (i.e. the state that would cause auth failure rather than one caused by an
50 bool InStateValidOnRemoteAuthFailure() const;
52 // Changes internal state to |new_state| and updates the user's screenlock
54 void ChangeState(proximity_auth::ScreenlockState new_state
);
56 // Updates the screenlock state.
57 void SetHardlockState(HardlockState new_state
);
59 // Shows the hardlock UI if the hardlock_state_ is not NO_HARDLOCK.
60 void MaybeShowHardlockUI();
62 // Marks the current screenlock state as the one for trial Easy Unlock run.
65 // Records that the user clicked on the lock icon during the trial run
66 // initiated by the Easy Unlock app.
67 void RecordClickOnLockIcon();
69 proximity_auth::ScreenlockState
state() const { return state_
; }
72 // proximity_auth::ScreenlockBridge::Observer:
73 void OnScreenDidLock(proximity_auth::ScreenlockBridge::LockHandler::ScreenType
74 screen_type
) override
;
75 void OnScreenDidUnlock(
76 proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type
)
78 void OnFocusedUserChanged(const std::string
& user_id
) override
;
80 // Forces refresh of the Easy Unlock screenlock UI.
81 void RefreshScreenlockState();
83 void ShowHardlockUI();
85 // Updates icon's tooltip options.
86 void UpdateTooltipOptions(
87 proximity_auth::ScreenlockBridge::UserPodCustomIconOptions
* icon_options
);
89 // Gets the name to be used for the device. The name depends on the device
90 // type (example values: Chromebook and Chromebox).
91 base::string16
GetDeviceName();
93 // Updates the screenlock auth type if it has to be changed.
94 void UpdateScreenlockAuthType();
96 proximity_auth::ScreenlockState state_
;
97 std::string user_email_
;
98 proximity_auth::ScreenlockBridge
* screenlock_bridge_
;
100 // State of hardlock.
101 HardlockState hardlock_state_
;
102 bool hardlock_ui_shown_
;
104 // Whether this is the trial Easy Unlock run. If this is the case, a
105 // tutorial message should be shown and hard-locking be disabled. The trial
106 // run should be set if the screen was locked by the Easy Unlock setup app.
109 // Whether the user's phone was ever locked while on the current lock screen.
110 bool did_see_locked_phone_
;
112 DISALLOW_COPY_AND_ASSIGN(EasyUnlockScreenlockStateHandler
);
115 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SCREENLOCK_STATE_HANDLER_H_