OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_SERVICE_H_ |
6 #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_SERVICE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_SERVICE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
18 #include "chrome/browser/chromeos/extensions/device_local_account_external_polic
y_loader.h" | 18 #include "chrome/browser/chromeos/extensions/device_local_account_external_polic
y_loader.h" |
| 19 #include "chrome/browser/chromeos/policy/device_local_account_external_data_mana
ger.h" |
19 #include "chrome/browser/chromeos/settings/cros_settings.h" | 20 #include "chrome/browser/chromeos/settings/cros_settings.h" |
20 #include "chrome/browser/policy/cloud/cloud_policy_core.h" | 21 #include "chrome/browser/policy/cloud/cloud_policy_core.h" |
21 #include "chrome/browser/policy/cloud/cloud_policy_store.h" | 22 #include "chrome/browser/policy/cloud/cloud_policy_store.h" |
22 | 23 |
23 namespace base { | 24 namespace base { |
24 class SequencedTaskRunner; | 25 class SequencedTaskRunner; |
25 } | 26 } |
26 | 27 |
27 namespace chromeos { | 28 namespace chromeos { |
28 class DeviceSettingsService; | 29 class DeviceSettingsService; |
29 class SessionManagerClient; | 30 class SessionManagerClient; |
30 } | 31 } |
31 | 32 |
| 33 namespace net { |
| 34 class URLRequestContextGetter; |
| 35 } |
| 36 |
32 namespace policy { | 37 namespace policy { |
33 | 38 |
34 struct DeviceLocalAccount; | 39 struct DeviceLocalAccount; |
| 40 class DeviceLocalAccountExternalDataService; |
35 class DeviceLocalAccountPolicyStore; | 41 class DeviceLocalAccountPolicyStore; |
36 class DeviceManagementService; | 42 class DeviceManagementService; |
37 | 43 |
38 // The main switching central that downloads, caches, refreshes, etc. policy for | 44 // The main switching central that downloads, caches, refreshes, etc. policy for |
39 // a single device-local account. | 45 // a single device-local account. |
40 class DeviceLocalAccountPolicyBroker { | 46 class DeviceLocalAccountPolicyBroker { |
41 public: | 47 public: |
42 // |task_runner| is the runner for policy refresh tasks. | 48 // |task_runner| is the runner for policy refresh tasks. |
43 DeviceLocalAccountPolicyBroker( | 49 DeviceLocalAccountPolicyBroker( |
44 const DeviceLocalAccount& account, | 50 const DeviceLocalAccount& account, |
45 scoped_ptr<DeviceLocalAccountPolicyStore> store, | 51 scoped_ptr<DeviceLocalAccountPolicyStore> store, |
| 52 scoped_refptr<DeviceLocalAccountExternalDataManager> |
| 53 external_data_manager, |
46 const scoped_refptr<base::SequencedTaskRunner>& task_runner); | 54 const scoped_refptr<base::SequencedTaskRunner>& task_runner); |
47 ~DeviceLocalAccountPolicyBroker(); | 55 ~DeviceLocalAccountPolicyBroker(); |
48 | 56 |
49 // Initialize the broker, loading its |store_|. | 57 // Initialize the broker, loading its |store_|. |
50 void Initialize(); | 58 void Initialize(); |
51 | 59 |
52 // For the difference between |account_id| and |user_id|, see the | 60 // For the difference between |account_id| and |user_id|, see the |
53 // documentation of DeviceLocalAccount. | 61 // documentation of DeviceLocalAccount. |
54 const std::string& account_id() const { return account_id_; } | 62 const std::string& account_id() const { return account_id_; } |
55 const std::string& user_id() const { return user_id_; } | 63 const std::string& user_id() const { return user_id_; } |
56 | 64 |
57 scoped_refptr<chromeos::DeviceLocalAccountExternalPolicyLoader> | 65 scoped_refptr<chromeos::DeviceLocalAccountExternalPolicyLoader> |
58 extension_loader() const { return extension_loader_; } | 66 extension_loader() const { return extension_loader_; } |
59 | 67 |
60 CloudPolicyCore* core() { return &core_; } | 68 CloudPolicyCore* core() { return &core_; } |
61 const CloudPolicyCore* core() const { return &core_; } | 69 const CloudPolicyCore* core() const { return &core_; } |
62 | 70 |
| 71 scoped_refptr<DeviceLocalAccountExternalDataManager> external_data_manager() { |
| 72 return external_data_manager_; |
| 73 } |
| 74 |
63 // Fire up the cloud connection for fetching policy for the account from the | 75 // Fire up the cloud connection for fetching policy for the account from the |
64 // cloud if this is an enterprise-managed device. | 76 // cloud if this is an enterprise-managed device. |
65 void ConnectIfPossible( | 77 void ConnectIfPossible( |
66 chromeos::DeviceSettingsService* device_settings_service, | 78 chromeos::DeviceSettingsService* device_settings_service, |
67 DeviceManagementService* device_management_service); | 79 DeviceManagementService* device_management_service, |
68 | 80 scoped_refptr<net::URLRequestContextGetter> request_context); |
69 // Destroy the cloud connection, stopping policy refreshes. | |
70 void Disconnect(); | |
71 | 81 |
72 // Reads the refresh delay from policy and configures the refresh scheduler. | 82 // Reads the refresh delay from policy and configures the refresh scheduler. |
73 void UpdateRefreshDelay(); | 83 void UpdateRefreshDelay(); |
74 | 84 |
75 // Retrieves the display name for the account as stored in policy. Returns an | 85 // Retrieves the display name for the account as stored in policy. Returns an |
76 // empty string if the policy is not present. | 86 // empty string if the policy is not present. |
77 std::string GetDisplayName() const; | 87 std::string GetDisplayName() const; |
78 | 88 |
79 private: | 89 private: |
80 const std::string account_id_; | 90 const std::string account_id_; |
81 const std::string user_id_; | 91 const std::string user_id_; |
82 const scoped_ptr<DeviceLocalAccountPolicyStore> store_; | 92 const scoped_ptr<DeviceLocalAccountPolicyStore> store_; |
| 93 scoped_refptr<DeviceLocalAccountExternalDataManager> external_data_manager_; |
83 scoped_refptr<chromeos::DeviceLocalAccountExternalPolicyLoader> | 94 scoped_refptr<chromeos::DeviceLocalAccountExternalPolicyLoader> |
84 extension_loader_; | 95 extension_loader_; |
85 CloudPolicyCore core_; | 96 CloudPolicyCore core_; |
86 | 97 |
87 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyBroker); | 98 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyBroker); |
88 }; | 99 }; |
89 | 100 |
90 // Manages user policy blobs for device-local accounts present on the device. | 101 // Manages user policy blobs for device-local accounts present on the device. |
91 // The actual policy blobs are brokered by session_manager (to prevent file | 102 // The actual policy blobs are brokered by session_manager (to prevent file |
92 // manipulation), and we're making signature checks on the policy blobs to | 103 // manipulation), and we're making signature checks on the policy blobs to |
(...skipping 10 matching lines...) Expand all Loading... |
103 | 114 |
104 // The list of accounts has been updated. | 115 // The list of accounts has been updated. |
105 virtual void OnDeviceLocalAccountsChanged() = 0; | 116 virtual void OnDeviceLocalAccountsChanged() = 0; |
106 }; | 117 }; |
107 | 118 |
108 DeviceLocalAccountPolicyService( | 119 DeviceLocalAccountPolicyService( |
109 chromeos::SessionManagerClient* session_manager_client, | 120 chromeos::SessionManagerClient* session_manager_client, |
110 chromeos::DeviceSettingsService* device_settings_service, | 121 chromeos::DeviceSettingsService* device_settings_service, |
111 chromeos::CrosSettings* cros_settings, | 122 chromeos::CrosSettings* cros_settings, |
112 scoped_refptr<base::SequencedTaskRunner> store_background_task_runner, | 123 scoped_refptr<base::SequencedTaskRunner> store_background_task_runner, |
113 scoped_refptr<base::SequencedTaskRunner> extension_cache_task_runner); | 124 scoped_refptr<base::SequencedTaskRunner> extension_cache_task_runner, |
| 125 scoped_refptr<base::SequencedTaskRunner> |
| 126 external_data_service_backend_task_runner, |
| 127 scoped_refptr<base::SequencedTaskRunner> io_task_runner, |
| 128 scoped_refptr<net::URLRequestContextGetter> request_context); |
114 virtual ~DeviceLocalAccountPolicyService(); | 129 virtual ~DeviceLocalAccountPolicyService(); |
115 | 130 |
| 131 // Shuts down the service and prevents further policy fetches from the cloud. |
| 132 void Shutdown(); |
| 133 |
116 // Initializes the cloud policy service connection. | 134 // Initializes the cloud policy service connection. |
117 void Connect(DeviceManagementService* device_management_service); | 135 void Connect(DeviceManagementService* device_management_service); |
118 | 136 |
119 // Prevents further policy fetches from the cloud. | |
120 void Disconnect(); | |
121 | |
122 // Get the policy broker for a given |user_id|. Returns NULL if that |user_id| | 137 // Get the policy broker for a given |user_id|. Returns NULL if that |user_id| |
123 // does not belong to an existing device-local account. | 138 // does not belong to an existing device-local account. |
124 DeviceLocalAccountPolicyBroker* GetBrokerForUser(const std::string& user_id); | 139 DeviceLocalAccountPolicyBroker* GetBrokerForUser(const std::string& user_id); |
125 | 140 |
126 // Indicates whether policy has been successfully fetched for the given | 141 // Indicates whether policy has been successfully fetched for the given |
127 // |user_id|. | 142 // |user_id|. |
128 bool IsPolicyAvailableForUser(const std::string& user_id); | 143 bool IsPolicyAvailableForUser(const std::string& user_id); |
129 | 144 |
130 void AddObserver(Observer* observer); | 145 void AddObserver(Observer* observer); |
131 void RemoveObserver(Observer* observer); | 146 void RemoveObserver(Observer* observer); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 | 183 |
169 // Calls |UpdateAccountList| if there are no previous calls pending. | 184 // Calls |UpdateAccountList| if there are no previous calls pending. |
170 void UpdateAccountListIfNonePending(); | 185 void UpdateAccountListIfNonePending(); |
171 | 186 |
172 // Deletes brokers in |map| and clears it. | 187 // Deletes brokers in |map| and clears it. |
173 void DeleteBrokers(PolicyBrokerMap* map); | 188 void DeleteBrokers(PolicyBrokerMap* map); |
174 | 189 |
175 // Find the broker for a given |store|. Returns NULL if |store| is unknown. | 190 // Find the broker for a given |store|. Returns NULL if |store| is unknown. |
176 DeviceLocalAccountPolicyBroker* GetBrokerForStore(CloudPolicyStore* store); | 191 DeviceLocalAccountPolicyBroker* GetBrokerForStore(CloudPolicyStore* store); |
177 | 192 |
| 193 ObserverList<Observer, true> observers_; |
| 194 |
178 chromeos::SessionManagerClient* session_manager_client_; | 195 chromeos::SessionManagerClient* session_manager_client_; |
179 chromeos::DeviceSettingsService* device_settings_service_; | 196 chromeos::DeviceSettingsService* device_settings_service_; |
180 chromeos::CrosSettings* cros_settings_; | 197 chromeos::CrosSettings* cros_settings_; |
181 | 198 |
182 DeviceManagementService* device_management_service_; | 199 DeviceManagementService* device_management_service_; |
183 | 200 |
184 // The device-local account policy brokers, keyed by user ID. | 201 // The device-local account policy brokers, keyed by user ID. |
185 PolicyBrokerMap policy_brokers_; | 202 PolicyBrokerMap policy_brokers_; |
186 | 203 |
187 // Whether a call to UpdateAccountList() is pending because |cros_settings_| | 204 // Whether a call to UpdateAccountList() is pending because |cros_settings_| |
(...skipping 10 matching lines...) Expand all Loading... |
198 OrphanCacheDeletionState orphan_cache_deletion_state_; | 215 OrphanCacheDeletionState orphan_cache_deletion_state_; |
199 | 216 |
200 // Account IDs whose extension cache directories are busy, either because a | 217 // Account IDs whose extension cache directories are busy, either because a |
201 // broker for the account has not shut down completely yet or because the | 218 // broker for the account has not shut down completely yet or because the |
202 // directory is being deleted. | 219 // directory is being deleted. |
203 std::set<std::string> busy_extension_cache_directories_; | 220 std::set<std::string> busy_extension_cache_directories_; |
204 | 221 |
205 const scoped_refptr<base::SequencedTaskRunner> store_background_task_runner_; | 222 const scoped_refptr<base::SequencedTaskRunner> store_background_task_runner_; |
206 const scoped_refptr<base::SequencedTaskRunner> extension_cache_task_runner_; | 223 const scoped_refptr<base::SequencedTaskRunner> extension_cache_task_runner_; |
207 | 224 |
208 ObserverList<Observer, true> observers_; | 225 scoped_ptr<DeviceLocalAccountExternalDataService> external_data_service_; |
| 226 |
| 227 scoped_refptr<net::URLRequestContextGetter> request_context_; |
209 | 228 |
210 const scoped_ptr<chromeos::CrosSettings::ObserverSubscription> | 229 const scoped_ptr<chromeos::CrosSettings::ObserverSubscription> |
211 local_accounts_subscription_; | 230 local_accounts_subscription_; |
212 | 231 |
213 base::WeakPtrFactory<DeviceLocalAccountPolicyService> weak_factory_; | 232 base::WeakPtrFactory<DeviceLocalAccountPolicyService> weak_factory_; |
214 | 233 |
215 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyService); | 234 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyService); |
216 }; | 235 }; |
217 | 236 |
218 } // namespace policy | 237 } // namespace policy |
219 | 238 |
220 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_SERVICE_H_ | 239 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_SERVICE_H_ |
OLD | NEW |