[Media Router] Add integration tests and e2e tests for media router and presentation...
[chromium-blink-merge.git] / chrome / browser / signin / easy_unlock_service_regular.h
blob1f4ff9d605b060a5c6d5f7bcde9b2063de153511
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_SERVICE_REGULAR_H_
6 #define CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_REGULAR_H_
8 #include <string>
10 #include "base/callback.h"
11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/prefs/pref_change_registrar.h"
14 #include "base/time/time.h"
15 #include "chrome/browser/signin/easy_unlock_service.h"
16 #include "components/proximity_auth/screenlock_bridge.h"
18 #if defined(OS_CHROMEOS)
19 #include "chrome/browser/chromeos/login/easy_unlock/short_lived_user_context.h"
20 #endif
22 namespace base {
23 class DictionaryValue;
24 class ListValue;
27 namespace cryptauth {
28 class ToggleEasyUnlockResponse;
31 namespace proximity_auth {
32 class CryptAuthClient;
35 class EasyUnlockAppManager;
36 class EasyUnlockToggleFlow;
37 class Profile;
39 // EasyUnlockService instance that should be used for regular, non-signin
40 // profiles.
41 class EasyUnlockServiceRegular
42 : public EasyUnlockService,
43 public proximity_auth::ScreenlockBridge::Observer {
44 public:
45 explicit EasyUnlockServiceRegular(Profile* profile);
46 ~EasyUnlockServiceRegular() override;
48 private:
49 // EasyUnlockService implementation:
50 EasyUnlockService::Type GetType() const override;
51 std::string GetUserEmail() const override;
52 void LaunchSetup() override;
53 const base::DictionaryValue* GetPermitAccess() const override;
54 void SetPermitAccess(const base::DictionaryValue& permit) override;
55 void ClearPermitAccess() override;
56 const base::ListValue* GetRemoteDevices() const override;
57 void SetRemoteDevices(const base::ListValue& devices) override;
58 void RunTurnOffFlow() override;
59 void ResetTurnOffFlow() override;
60 TurnOffFlowStatus GetTurnOffFlowStatus() const override;
61 std::string GetChallenge() const override;
62 std::string GetWrappedSecret() const override;
63 void RecordEasySignInOutcome(const std::string& user_id,
64 bool success) const override;
65 void RecordPasswordLoginEvent(const std::string& user_id) const override;
66 void StartAutoPairing(const AutoPairingResultCallback& callback) override;
67 void SetAutoPairingResult(bool success, const std::string& error) override;
68 void InitializeInternal() override;
69 void ShutdownInternal() override;
70 bool IsAllowedInternal() const override;
71 void OnWillFinalizeUnlock(bool success) override;
72 void OnSuspendDone() override;
74 // proximity_auth::ScreenlockBridge::Observer implementation:
75 void OnScreenDidLock(proximity_auth::ScreenlockBridge::LockHandler::ScreenType
76 screen_type) override;
77 void OnScreenDidUnlock(
78 proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type)
79 override;
80 void OnFocusedUserChanged(const std::string& user_id) override;
83 // Callback when the controlling pref changes.
84 void OnPrefsChanged();
86 // Sets the new turn-off flow status.
87 void SetTurnOffFlowStatus(TurnOffFlowStatus status);
89 // Callback for ToggleEasyUnlock CryptAuth API.
90 void OnToggleEasyUnlockApiComplete(
91 const cryptauth::ToggleEasyUnlockResponse& response);
92 void OnToggleEasyUnlockApiFailed(const std::string& error_message);
94 #if defined(OS_CHROMEOS)
95 // Called with the user's credentials (e.g. username and password) after the
96 // user reauthenticates to begin setup.
97 void OnUserContextFromReauth(const chromeos::UserContext& user_context);
99 // Called after a cryptohome RemoveKey or RefreshKey operation to set the
100 // proper hardlock state if the operation is successful.
101 void SetHardlockAfterKeyOperation(
102 EasyUnlockScreenlockStateHandler::HardlockState state_on_success,
103 bool success);
105 scoped_ptr<chromeos::ShortLivedUserContext> short_lived_user_context_;
106 #endif
108 // Updates local state with the preference from the user's profile, so they
109 // can be accessed on the sign-in screen.
110 void SyncProfilePrefsToLocalState();
112 PrefChangeRegistrar registrar_;
114 TurnOffFlowStatus turn_off_flow_status_;
115 scoped_ptr<proximity_auth::CryptAuthClient> cryptauth_client_;
117 AutoPairingResultCallback auto_pairing_callback_;
119 // True if the user just unlocked the screen using Easy Unlock. Reset once
120 // the screen unlocks. Used to distinguish Easy Unlock-powered unlocks from
121 // password-based unlocks for metrics.
122 bool will_unlock_using_easy_unlock_;
124 // The timestamp for the most recent time when the lock screen was shown. The
125 // lock screen is typically shown when the user awakens her computer from
126 // sleep -- e.g. by opening the lid -- but can also be shown if the screen is
127 // locked but the computer does not go to sleep.
128 base::TimeTicks lock_screen_last_shown_timestamp_;
130 base::WeakPtrFactory<EasyUnlockServiceRegular> weak_ptr_factory_;
132 DISALLOW_COPY_AND_ASSIGN(EasyUnlockServiceRegular);
135 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_REGULAR_H_