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_SIGNIN_CHROMEOS_H_ | 5 #ifndef CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_SIGNIN_CHROMEOS_H_ |
6 #define CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_SIGNIN_CHROMEOS_H_ | 6 #define CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_SIGNIN_CHROMEOS_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
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/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_types.h" | 15 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_types.h" |
16 #include "chrome/browser/signin/easy_unlock_service.h" | 16 #include "chrome/browser/signin/easy_unlock_service.h" |
| 17 #include "chrome/browser/signin/screenlock_bridge.h" |
| 18 #include "chromeos/login/login_state.h" |
17 | 19 |
18 // EasyUnlockService instance that should be used for signin profile. | 20 // EasyUnlockService instance that should be used for signin profile. |
19 class EasyUnlockServiceSignin : public EasyUnlockService { | 21 class EasyUnlockServiceSignin : public EasyUnlockService, |
| 22 public ScreenlockBridge::Observer, |
| 23 public chromeos::LoginState::Observer { |
20 public: | 24 public: |
21 explicit EasyUnlockServiceSignin(Profile* profile); | 25 explicit EasyUnlockServiceSignin(Profile* profile); |
22 virtual ~EasyUnlockServiceSignin(); | 26 virtual ~EasyUnlockServiceSignin(); |
23 | 27 |
24 private: | 28 private: |
25 // The load state of a user's cryptohome key data. | 29 // The load state of a user's cryptohome key data. |
26 enum UserDataState { | 30 enum UserDataState { |
27 // Initial state, the key data is empty and not being loaded. | 31 // Initial state, the key data is empty and not being loaded. |
28 USER_DATA_STATE_INITIAL, | 32 USER_DATA_STATE_INITIAL, |
29 // The key data is empty, but being loaded. | 33 // The key data is empty, but being loaded. |
(...skipping 28 matching lines...) Expand all Loading... |
58 virtual const base::DictionaryValue* GetPermitAccess() const OVERRIDE; | 62 virtual const base::DictionaryValue* GetPermitAccess() const OVERRIDE; |
59 virtual void SetPermitAccess(const base::DictionaryValue& permit) OVERRIDE; | 63 virtual void SetPermitAccess(const base::DictionaryValue& permit) OVERRIDE; |
60 virtual void ClearPermitAccess() OVERRIDE; | 64 virtual void ClearPermitAccess() OVERRIDE; |
61 virtual const base::ListValue* GetRemoteDevices() const OVERRIDE; | 65 virtual const base::ListValue* GetRemoteDevices() const OVERRIDE; |
62 virtual void SetRemoteDevices(const base::ListValue& devices) OVERRIDE; | 66 virtual void SetRemoteDevices(const base::ListValue& devices) OVERRIDE; |
63 virtual void ClearRemoteDevices() OVERRIDE; | 67 virtual void ClearRemoteDevices() OVERRIDE; |
64 virtual void RunTurnOffFlow() OVERRIDE; | 68 virtual void RunTurnOffFlow() OVERRIDE; |
65 virtual void ResetTurnOffFlow() OVERRIDE; | 69 virtual void ResetTurnOffFlow() OVERRIDE; |
66 virtual TurnOffFlowStatus GetTurnOffFlowStatus() const OVERRIDE; | 70 virtual TurnOffFlowStatus GetTurnOffFlowStatus() const OVERRIDE; |
67 virtual std::string GetChallenge() const OVERRIDE; | 71 virtual std::string GetChallenge() const OVERRIDE; |
| 72 virtual void InitializeInternal() OVERRIDE; |
| 73 virtual void ShutdownInternal() OVERRIDE; |
68 virtual bool IsAllowedInternal() OVERRIDE; | 74 virtual bool IsAllowedInternal() OVERRIDE; |
69 virtual void InitializeInternal() OVERRIDE; | 75 |
| 76 // ScreenlockBridge::Observer implementation: |
| 77 virtual void OnScreenDidLock() OVERRIDE; |
| 78 virtual void OnScreenDidUnlock() OVERRIDE; |
| 79 virtual void OnFocusedUserChanged(const std::string& user_id) OVERRIDE; |
| 80 |
| 81 // chromeos::LoginState::Observer implementation: |
| 82 virtual void LoggedInStateChanged() OVERRIDE; |
70 | 83 |
71 // Loads the device data associated with the user's Easy unlock keys from | 84 // Loads the device data associated with the user's Easy unlock keys from |
72 // crypthome. | 85 // crypthome. |
73 void LoadCurrentUserDataIfNeeded(); | 86 void LoadCurrentUserDataIfNeeded(); |
74 | 87 |
75 // Callback invoked when the user's device data is loaded from cryptohome. | 88 // Callback invoked when the user's device data is loaded from cryptohome. |
76 void OnUserDataLoaded( | 89 void OnUserDataLoaded( |
77 const std::string& user_id, | 90 const std::string& user_id, |
78 bool success, | 91 bool success, |
79 const chromeos::EasyUnlockDeviceKeyDataList& data); | 92 const chromeos::EasyUnlockDeviceKeyDataList& data); |
80 | 93 |
81 // If the device data has been loaded for the current user, returns is. | 94 // If the device data has been loaded for the current user, returns it. |
82 // Otherwise, returns NULL. | 95 // Otherwise, returns NULL. |
83 const UserData* FindLoadedDataForCurrentUser() const; | 96 const UserData* FindLoadedDataForCurrentUser() const; |
84 | 97 |
85 // User id of the user currently associated with the service. | 98 // User id of the user currently associated with the service. |
86 std::string user_id_; | 99 std::string user_id_; |
87 | 100 |
88 // Maps user ids to their fetched cryptohome key data. | 101 // Maps user ids to their fetched cryptohome key data. |
89 std::map<std::string, UserData*> user_data_; | 102 std::map<std::string, UserData*> user_data_; |
90 | 103 |
91 // Whether failed attempts to load user data should be retried. | 104 // Whether failed attempts to load user data should be retried. |
92 // This is to handle case where cryptohome daemon is not started in time the | 105 // This is to handle case where cryptohome daemon is not started in time the |
93 // service attempts to load some data. Retries will be allowed only until the | 106 // service attempts to load some data. Retries will be allowed only until the |
94 // first data load finishes (even if it fails). | 107 // first data load finishes (even if it fails). |
95 bool allow_cryptohome_backoff_; | 108 bool allow_cryptohome_backoff_; |
96 | 109 |
| 110 // Whether the service has been successfully initialized, and has not been |
| 111 // shut down. |
| 112 bool service_active_; |
| 113 |
97 base::WeakPtrFactory<EasyUnlockServiceSignin> weak_ptr_factory_; | 114 base::WeakPtrFactory<EasyUnlockServiceSignin> weak_ptr_factory_; |
98 | 115 |
99 DISALLOW_COPY_AND_ASSIGN(EasyUnlockServiceSignin); | 116 DISALLOW_COPY_AND_ASSIGN(EasyUnlockServiceSignin); |
100 }; | 117 }; |
101 | 118 |
102 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_SIGNIN_CHROMEOS_H_ | 119 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_SERVICE_SIGNIN_CHROMEOS_H_ |
OLD | NEW |