OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_REGULAR_H_ | 5 #ifndef CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_REGULAR_H_ |
6 #define CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_REGULAR_H_ | 6 #define CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_REGULAR_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/prefs/pref_change_registrar.h" | 13 #include "base/prefs/pref_change_registrar.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "chrome/browser/signin/easy_unlock_service.h" | 15 #include "chrome/browser/signin/easy_unlock_service.h" |
16 #include "components/proximity_auth/screenlock_bridge.h" | 16 #include "components/proximity_auth/screenlock_bridge.h" |
| 17 #include "google_apis/gaia/oauth2_token_service.h" |
17 | 18 |
18 #if defined(OS_CHROMEOS) | 19 #if defined(OS_CHROMEOS) |
19 #include "chrome/browser/chromeos/login/easy_unlock/short_lived_user_context.h" | 20 #include "chrome/browser/chromeos/login/easy_unlock/short_lived_user_context.h" |
20 #endif | 21 #endif |
21 | 22 |
22 namespace base { | 23 namespace base { |
23 class DictionaryValue; | 24 class DictionaryValue; |
24 class ListValue; | 25 class ListValue; |
25 } | 26 } |
26 | 27 |
27 namespace cryptauth { | 28 namespace cryptauth { |
28 class ToggleEasyUnlockResponse; | 29 class ToggleEasyUnlockResponse; |
29 } | 30 } |
30 | 31 |
31 namespace proximity_auth { | 32 namespace proximity_auth { |
32 class CryptAuthClient; | 33 class CryptAuthClient; |
| 34 class CryptAuthGCMManager; |
| 35 class CryptAuthEnrollmentManager; |
| 36 class CryptAuthDeviceManager; |
33 } | 37 } |
34 | 38 |
35 class EasyUnlockAppManager; | 39 class EasyUnlockAppManager; |
36 class EasyUnlockToggleFlow; | 40 class EasyUnlockToggleFlow; |
37 class Profile; | 41 class Profile; |
38 | 42 |
39 // EasyUnlockService instance that should be used for regular, non-signin | 43 // EasyUnlockService instance that should be used for regular, non-signin |
40 // profiles. | 44 // profiles. |
41 class EasyUnlockServiceRegular | 45 class EasyUnlockServiceRegular |
42 : public EasyUnlockService, | 46 : public EasyUnlockService, |
43 public proximity_auth::ScreenlockBridge::Observer { | 47 public proximity_auth::ScreenlockBridge::Observer, |
| 48 public OAuth2TokenService::Observer { |
44 public: | 49 public: |
45 explicit EasyUnlockServiceRegular(Profile* profile); | 50 explicit EasyUnlockServiceRegular(Profile* profile); |
46 ~EasyUnlockServiceRegular() override; | 51 ~EasyUnlockServiceRegular() override; |
47 | 52 |
| 53 // Returns the CryptAuthEnrollmentManager, which manages the profile's |
| 54 // CryptAuth enrollment. |
| 55 proximity_auth::CryptAuthEnrollmentManager* GetCryptAuthEnrollmentManager(); |
| 56 |
| 57 // Returns the CryptAuthEnrollmentManager, which manages the profile's |
| 58 // synced devices from CryptAuth. |
| 59 proximity_auth::CryptAuthDeviceManager* GetCryptAuthDeviceManager(); |
| 60 |
48 private: | 61 private: |
49 // EasyUnlockService implementation: | 62 // EasyUnlockService implementation: |
50 EasyUnlockService::Type GetType() const override; | 63 EasyUnlockService::Type GetType() const override; |
51 std::string GetUserEmail() const override; | 64 std::string GetUserEmail() const override; |
52 void LaunchSetup() override; | 65 void LaunchSetup() override; |
53 const base::DictionaryValue* GetPermitAccess() const override; | 66 const base::DictionaryValue* GetPermitAccess() const override; |
54 void SetPermitAccess(const base::DictionaryValue& permit) override; | 67 void SetPermitAccess(const base::DictionaryValue& permit) override; |
55 void ClearPermitAccess() override; | 68 void ClearPermitAccess() override; |
56 const base::ListValue* GetRemoteDevices() const override; | 69 const base::ListValue* GetRemoteDevices() const override; |
57 void SetRemoteDevices(const base::ListValue& devices) override; | 70 void SetRemoteDevices(const base::ListValue& devices) override; |
58 void RunTurnOffFlow() override; | 71 void RunTurnOffFlow() override; |
59 void ResetTurnOffFlow() override; | 72 void ResetTurnOffFlow() override; |
60 TurnOffFlowStatus GetTurnOffFlowStatus() const override; | 73 TurnOffFlowStatus GetTurnOffFlowStatus() const override; |
61 std::string GetChallenge() const override; | 74 std::string GetChallenge() const override; |
62 std::string GetWrappedSecret() const override; | 75 std::string GetWrappedSecret() const override; |
63 void RecordEasySignInOutcome(const std::string& user_id, | 76 void RecordEasySignInOutcome(const std::string& user_id, |
64 bool success) const override; | 77 bool success) const override; |
65 void RecordPasswordLoginEvent(const std::string& user_id) const override; | 78 void RecordPasswordLoginEvent(const std::string& user_id) const override; |
66 void StartAutoPairing(const AutoPairingResultCallback& callback) override; | 79 void StartAutoPairing(const AutoPairingResultCallback& callback) override; |
67 void SetAutoPairingResult(bool success, const std::string& error) override; | 80 void SetAutoPairingResult(bool success, const std::string& error) override; |
68 void InitializeInternal() override; | 81 void InitializeInternal() override; |
69 void ShutdownInternal() override; | 82 void ShutdownInternal() override; |
70 bool IsAllowedInternal() const override; | 83 bool IsAllowedInternal() const override; |
71 void OnWillFinalizeUnlock(bool success) override; | 84 void OnWillFinalizeUnlock(bool success) override; |
72 void OnSuspendDone() override; | 85 void OnSuspendDone() override; |
73 | 86 |
| 87 // OAuth2TokenService::Observer: |
| 88 void OnRefreshTokenAvailable(const std::string& account_id) override; |
| 89 |
74 // proximity_auth::ScreenlockBridge::Observer implementation: | 90 // proximity_auth::ScreenlockBridge::Observer implementation: |
75 void OnScreenDidLock(proximity_auth::ScreenlockBridge::LockHandler::ScreenType | 91 void OnScreenDidLock(proximity_auth::ScreenlockBridge::LockHandler::ScreenType |
76 screen_type) override; | 92 screen_type) override; |
77 void OnScreenDidUnlock( | 93 void OnScreenDidUnlock( |
78 proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type) | 94 proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type) |
79 override; | 95 override; |
80 void OnFocusedUserChanged(const std::string& user_id) override; | 96 void OnFocusedUserChanged(const std::string& user_id) override; |
81 | 97 |
82 | 98 |
83 // Callback when the controlling pref changes. | 99 // Callback when the controlling pref changes. |
(...skipping 11 matching lines...) Expand all Loading... |
95 // Called with the user's credentials (e.g. username and password) after the | 111 // Called with the user's credentials (e.g. username and password) after the |
96 // user reauthenticates to begin setup. | 112 // user reauthenticates to begin setup. |
97 void OnUserContextFromReauth(const chromeos::UserContext& user_context); | 113 void OnUserContextFromReauth(const chromeos::UserContext& user_context); |
98 | 114 |
99 // Called after a cryptohome RemoveKey or RefreshKey operation to set the | 115 // Called after a cryptohome RemoveKey or RefreshKey operation to set the |
100 // proper hardlock state if the operation is successful. | 116 // proper hardlock state if the operation is successful. |
101 void SetHardlockAfterKeyOperation( | 117 void SetHardlockAfterKeyOperation( |
102 EasyUnlockScreenlockStateHandler::HardlockState state_on_success, | 118 EasyUnlockScreenlockStateHandler::HardlockState state_on_success, |
103 bool success); | 119 bool success); |
104 | 120 |
| 121 // Initializes the managers that communicate with CryptAuth. |
| 122 void InitializeCryptAuth(); |
| 123 |
105 scoped_ptr<chromeos::ShortLivedUserContext> short_lived_user_context_; | 124 scoped_ptr<chromeos::ShortLivedUserContext> short_lived_user_context_; |
106 #endif | 125 #endif |
107 | 126 |
108 // Updates local state with the preference from the user's profile, so they | 127 // Updates local state with the preference from the user's profile, so they |
109 // can be accessed on the sign-in screen. | 128 // can be accessed on the sign-in screen. |
110 void SyncProfilePrefsToLocalState(); | 129 void SyncProfilePrefsToLocalState(); |
111 | 130 |
| 131 // Returns the base GcmDeviceInfo proto containing the device's platform and |
| 132 // version information. |
| 133 cryptauth::GcmDeviceInfo GetGcmDeviceInfo(); |
| 134 |
112 PrefChangeRegistrar registrar_; | 135 PrefChangeRegistrar registrar_; |
113 | 136 |
114 TurnOffFlowStatus turn_off_flow_status_; | 137 TurnOffFlowStatus turn_off_flow_status_; |
115 scoped_ptr<proximity_auth::CryptAuthClient> cryptauth_client_; | 138 scoped_ptr<proximity_auth::CryptAuthClient> cryptauth_client_; |
116 | 139 |
117 AutoPairingResultCallback auto_pairing_callback_; | 140 AutoPairingResultCallback auto_pairing_callback_; |
118 | 141 |
119 // True if the user just unlocked the screen using Easy Unlock. Reset once | 142 // 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 | 143 // the screen unlocks. Used to distinguish Easy Unlock-powered unlocks from |
121 // password-based unlocks for metrics. | 144 // password-based unlocks for metrics. |
122 bool will_unlock_using_easy_unlock_; | 145 bool will_unlock_using_easy_unlock_; |
123 | 146 |
124 // The timestamp for the most recent time when the lock screen was shown. The | 147 // 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 | 148 // 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 | 149 // 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. | 150 // locked but the computer does not go to sleep. |
128 base::TimeTicks lock_screen_last_shown_timestamp_; | 151 base::TimeTicks lock_screen_last_shown_timestamp_; |
129 | 152 |
| 153 // Managers responsible for handling syncing and communications with |
| 154 // CryptAuth. |
| 155 scoped_ptr<proximity_auth::CryptAuthGCMManager> gcm_manager_; |
| 156 scoped_ptr<proximity_auth::CryptAuthEnrollmentManager> enrollment_manager_; |
| 157 scoped_ptr<proximity_auth::CryptAuthDeviceManager> device_manager_; |
| 158 |
130 base::WeakPtrFactory<EasyUnlockServiceRegular> weak_ptr_factory_; | 159 base::WeakPtrFactory<EasyUnlockServiceRegular> weak_ptr_factory_; |
131 | 160 |
132 DISALLOW_COPY_AND_ASSIGN(EasyUnlockServiceRegular); | 161 DISALLOW_COPY_AND_ASSIGN(EasyUnlockServiceRegular); |
133 }; | 162 }; |
134 | 163 |
135 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_REGULAR_H_ | 164 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_REGULAR_H_ |
OLD | NEW |