Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: chrome/browser/signin/easy_unlock_service_regular.h

Issue 1372283002: Hook up ProximityAuthSystem in EasyUnlockService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth_connection
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/cryptauth/cryptauth_device_manager.h"
16 #include "components/proximity_auth/screenlock_bridge.h" 17 #include "components/proximity_auth/screenlock_bridge.h"
17 #include "google_apis/gaia/oauth2_token_service.h" 18 #include "google_apis/gaia/oauth2_token_service.h"
18 19
19 #if defined(OS_CHROMEOS) 20 #if defined(OS_CHROMEOS)
20 #include "chrome/browser/chromeos/login/easy_unlock/short_lived_user_context.h" 21 #include "chrome/browser/chromeos/login/easy_unlock/short_lived_user_context.h"
21 #endif 22 #endif
22 23
23 namespace base { 24 namespace base {
24 class DictionaryValue; 25 class DictionaryValue;
25 class ListValue; 26 class ListValue;
26 } 27 }
27 28
28 namespace cryptauth { 29 namespace cryptauth {
29 class ToggleEasyUnlockResponse; 30 class ToggleEasyUnlockResponse;
30 } 31 }
31 32
32 namespace proximity_auth { 33 namespace proximity_auth {
33 class CryptAuthClient; 34 class CryptAuthClient;
34 class CryptAuthGCMManager; 35 class CryptAuthGCMManager;
35 class CryptAuthEnrollmentManager; 36 class CryptAuthEnrollmentManager;
36 class CryptAuthDeviceManager; 37 class RemoteDeviceLoader;
37 } 38 }
38 39
39 class EasyUnlockAppManager; 40 class EasyUnlockAppManager;
40 class EasyUnlockToggleFlow; 41 class EasyUnlockToggleFlow;
41 class Profile; 42 class Profile;
42 43
43 // EasyUnlockService instance that should be used for regular, non-signin 44 // EasyUnlockService instance that should be used for regular, non-signin
44 // profiles. 45 // profiles.
45 class EasyUnlockServiceRegular 46 class EasyUnlockServiceRegular
46 : public EasyUnlockService, 47 : public EasyUnlockService,
47 public proximity_auth::ScreenlockBridge::Observer, 48 public proximity_auth::ScreenlockBridge::Observer,
49 public proximity_auth::CryptAuthDeviceManager::Observer,
48 public OAuth2TokenService::Observer { 50 public OAuth2TokenService::Observer {
49 public: 51 public:
50 explicit EasyUnlockServiceRegular(Profile* profile); 52 explicit EasyUnlockServiceRegular(Profile* profile);
51 ~EasyUnlockServiceRegular() override; 53 ~EasyUnlockServiceRegular() override;
52 54
53 // Returns the CryptAuthEnrollmentManager, which manages the profile's 55 // Returns the CryptAuthEnrollmentManager, which manages the profile's
54 // CryptAuth enrollment. 56 // CryptAuth enrollment.
55 proximity_auth::CryptAuthEnrollmentManager* GetCryptAuthEnrollmentManager(); 57 proximity_auth::CryptAuthEnrollmentManager* GetCryptAuthEnrollmentManager();
56 58
57 // Returns the CryptAuthEnrollmentManager, which manages the profile's 59 // Returns the CryptAuthEnrollmentManager, which manages the profile's
58 // synced devices from CryptAuth. 60 // synced devices from CryptAuth.
59 proximity_auth::CryptAuthDeviceManager* GetCryptAuthDeviceManager(); 61 proximity_auth::CryptAuthDeviceManager* GetCryptAuthDeviceManager();
60 62
61 private: 63 private:
64 // Loads the RemoteDevice instances that will be supplied to
65 // ProximityAuthSystem.
66 void LoadRemoteDevices();
67
68 // Called when |remote_device_loader_| completes.
69 void OnRemoteDevicesLoaded(
70 const std::vector<proximity_auth::RemoteDevice>& remote_devices);
71
62 // EasyUnlockService implementation: 72 // EasyUnlockService implementation:
63 EasyUnlockService::Type GetType() const override; 73 EasyUnlockService::Type GetType() const override;
64 std::string GetUserEmail() const override; 74 std::string GetUserEmail() const override;
65 void LaunchSetup() override; 75 void LaunchSetup() override;
66 const base::DictionaryValue* GetPermitAccess() const override; 76 const base::DictionaryValue* GetPermitAccess() const override;
67 void SetPermitAccess(const base::DictionaryValue& permit) override; 77 void SetPermitAccess(const base::DictionaryValue& permit) override;
68 void ClearPermitAccess() override; 78 void ClearPermitAccess() override;
69 const base::ListValue* GetRemoteDevices() const override; 79 const base::ListValue* GetRemoteDevices() const override;
70 void SetRemoteDevices(const base::ListValue& devices) override; 80 void SetRemoteDevices(const base::ListValue& devices) override;
71 void RunTurnOffFlow() override; 81 void RunTurnOffFlow() override;
72 void ResetTurnOffFlow() override; 82 void ResetTurnOffFlow() override;
73 TurnOffFlowStatus GetTurnOffFlowStatus() const override; 83 TurnOffFlowStatus GetTurnOffFlowStatus() const override;
74 std::string GetChallenge() const override; 84 std::string GetChallenge() const override;
75 std::string GetWrappedSecret() const override; 85 std::string GetWrappedSecret() const override;
76 void RecordEasySignInOutcome(const std::string& user_id, 86 void RecordEasySignInOutcome(const std::string& user_id,
77 bool success) const override; 87 bool success) const override;
78 void RecordPasswordLoginEvent(const std::string& user_id) const override; 88 void RecordPasswordLoginEvent(const std::string& user_id) const override;
79 void StartAutoPairing(const AutoPairingResultCallback& callback) override; 89 void StartAutoPairing(const AutoPairingResultCallback& callback) override;
80 void SetAutoPairingResult(bool success, const std::string& error) override; 90 void SetAutoPairingResult(bool success, const std::string& error) override;
81 void InitializeInternal() override; 91 void InitializeInternal() override;
82 void ShutdownInternal() override; 92 void ShutdownInternal() override;
83 bool IsAllowedInternal() const override; 93 bool IsAllowedInternal() const override;
84 void OnWillFinalizeUnlock(bool success) override; 94 void OnWillFinalizeUnlock(bool success) override;
85 void OnSuspendDone() override; 95 void OnSuspendDoneInternal() override;
86 96
87 // OAuth2TokenService::Observer: 97 // OAuth2TokenService::Observer:
88 void OnRefreshTokenAvailable(const std::string& account_id) override; 98 void OnRefreshTokenAvailable(const std::string& account_id) override;
89 99
100 // CryptAuthDeviceManager::Observer:
101 void OnSyncStarted() override;
102 void OnSyncFinished(
103 proximity_auth::CryptAuthDeviceManager::SyncResult sync_result,
104 proximity_auth::CryptAuthDeviceManager::DeviceChangeResult
105 device_change_result) override;
106
90 // proximity_auth::ScreenlockBridge::Observer implementation: 107 // proximity_auth::ScreenlockBridge::Observer implementation:
91 void OnScreenDidLock(proximity_auth::ScreenlockBridge::LockHandler::ScreenType 108 void OnScreenDidLock(proximity_auth::ScreenlockBridge::LockHandler::ScreenType
92 screen_type) override; 109 screen_type) override;
93 void OnScreenDidUnlock( 110 void OnScreenDidUnlock(
94 proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type) 111 proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type)
95 override; 112 override;
96 void OnFocusedUserChanged(const std::string& user_id) override; 113 void OnFocusedUserChanged(const std::string& user_id) override;
97 114
98 115
99 // Callback when the controlling pref changes. 116 // Callback when the controlling pref changes.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 // sleep -- e.g. by opening the lid -- but can also be shown if the screen is 166 // sleep -- e.g. by opening the lid -- but can also be shown if the screen is
150 // locked but the computer does not go to sleep. 167 // locked but the computer does not go to sleep.
151 base::TimeTicks lock_screen_last_shown_timestamp_; 168 base::TimeTicks lock_screen_last_shown_timestamp_;
152 169
153 // Managers responsible for handling syncing and communications with 170 // Managers responsible for handling syncing and communications with
154 // CryptAuth. 171 // CryptAuth.
155 scoped_ptr<proximity_auth::CryptAuthGCMManager> gcm_manager_; 172 scoped_ptr<proximity_auth::CryptAuthGCMManager> gcm_manager_;
156 scoped_ptr<proximity_auth::CryptAuthEnrollmentManager> enrollment_manager_; 173 scoped_ptr<proximity_auth::CryptAuthEnrollmentManager> enrollment_manager_;
157 scoped_ptr<proximity_auth::CryptAuthDeviceManager> device_manager_; 174 scoped_ptr<proximity_auth::CryptAuthDeviceManager> device_manager_;
158 175
176 // Loads the RemoteDevice instances from CryptAuth and local data.
177 scoped_ptr<proximity_auth::RemoteDeviceLoader> remote_device_loader_;
178
179 // If a new RemoteDevice was synced while the screen is locked, for security
180 // reasons, we defer loading the RemoteDevice until the screen is unlocked.
181 bool deferring_device_load_;
sacomoto 2015/09/29 18:45:57 What exactly do you mean by security reasons?
Tim Song 2015/09/30 00:05:04 Basically, we don't want a network event to change
182
159 base::WeakPtrFactory<EasyUnlockServiceRegular> weak_ptr_factory_; 183 base::WeakPtrFactory<EasyUnlockServiceRegular> weak_ptr_factory_;
160 184
161 DISALLOW_COPY_AND_ASSIGN(EasyUnlockServiceRegular); 185 DISALLOW_COPY_AND_ASSIGN(EasyUnlockServiceRegular);
162 }; 186 };
163 187
164 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_REGULAR_H_ 188 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_REGULAR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698