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/files/file_path.h" | |
14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
17 #include "base/observer_list.h" | 18 #include "base/observer_list.h" |
18 #include "chrome/browser/chromeos/extensions/device_local_account_external_polic y_loader.h" | 19 #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" | 20 #include "chrome/browser/chromeos/policy/device_local_account_external_data_mana ger.h" |
20 #include "chrome/browser/chromeos/settings/cros_settings.h" | 21 #include "chrome/browser/chromeos/settings/cros_settings.h" |
21 #include "components/policy/core/common/cloud/cloud_policy_core.h" | 22 #include "components/policy/core/common/cloud/cloud_policy_core.h" |
22 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 23 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
23 | 24 |
(...skipping 17 matching lines...) Expand all Loading... | |
41 class DeviceLocalAccountPolicyStore; | 42 class DeviceLocalAccountPolicyStore; |
42 class DeviceManagementService; | 43 class DeviceManagementService; |
43 | 44 |
44 // The main switching central that downloads, caches, refreshes, etc. policy for | 45 // The main switching central that downloads, caches, refreshes, etc. policy for |
45 // a single device-local account. | 46 // a single device-local account. |
46 class DeviceLocalAccountPolicyBroker { | 47 class DeviceLocalAccountPolicyBroker { |
47 public: | 48 public: |
48 // |task_runner| is the runner for policy refresh tasks. | 49 // |task_runner| is the runner for policy refresh tasks. |
49 DeviceLocalAccountPolicyBroker( | 50 DeviceLocalAccountPolicyBroker( |
50 const DeviceLocalAccount& account, | 51 const DeviceLocalAccount& account, |
52 const base::FilePath& component_policy_cache_path, | |
51 scoped_ptr<DeviceLocalAccountPolicyStore> store, | 53 scoped_ptr<DeviceLocalAccountPolicyStore> store, |
52 scoped_refptr<DeviceLocalAccountExternalDataManager> | 54 scoped_refptr<DeviceLocalAccountExternalDataManager> |
53 external_data_manager, | 55 external_data_manager, |
54 const scoped_refptr<base::SequencedTaskRunner>& task_runner); | 56 const scoped_refptr<base::SequencedTaskRunner>& task_runner); |
55 ~DeviceLocalAccountPolicyBroker(); | 57 ~DeviceLocalAccountPolicyBroker(); |
56 | 58 |
57 // Initialize the broker, loading its |store_|. | 59 // Initialize the broker, loading its |store_|. |
58 void Initialize(); | 60 void Initialize(); |
59 | 61 |
60 // For the difference between |account_id| and |user_id|, see the | 62 // For the difference between |account_id| and |user_id|, see the |
(...skipping 18 matching lines...) Expand all Loading... | |
79 DeviceManagementService* device_management_service, | 81 DeviceManagementService* device_management_service, |
80 scoped_refptr<net::URLRequestContextGetter> request_context); | 82 scoped_refptr<net::URLRequestContextGetter> request_context); |
81 | 83 |
82 // Reads the refresh delay from policy and configures the refresh scheduler. | 84 // Reads the refresh delay from policy and configures the refresh scheduler. |
83 void UpdateRefreshDelay(); | 85 void UpdateRefreshDelay(); |
84 | 86 |
85 // Retrieves the display name for the account as stored in policy. Returns an | 87 // Retrieves the display name for the account as stored in policy. Returns an |
86 // empty string if the policy is not present. | 88 // empty string if the policy is not present. |
87 std::string GetDisplayName() const; | 89 std::string GetDisplayName() const; |
88 | 90 |
91 // Returns a directory where component policy for this account can be cached. | |
92 // The DeviceManagementService takes care of cleaning up caches of accounts | |
93 // that have been removed. | |
94 base::FilePath GetComponentPolicyCachePath() const; | |
95 | |
89 private: | 96 private: |
90 const std::string account_id_; | 97 const std::string account_id_; |
91 const std::string user_id_; | 98 const std::string user_id_; |
99 const base::FilePath component_policy_cache_path_; | |
92 const scoped_ptr<DeviceLocalAccountPolicyStore> store_; | 100 const scoped_ptr<DeviceLocalAccountPolicyStore> store_; |
93 scoped_refptr<DeviceLocalAccountExternalDataManager> external_data_manager_; | 101 scoped_refptr<DeviceLocalAccountExternalDataManager> external_data_manager_; |
94 scoped_refptr<chromeos::DeviceLocalAccountExternalPolicyLoader> | 102 scoped_refptr<chromeos::DeviceLocalAccountExternalPolicyLoader> |
95 extension_loader_; | 103 extension_loader_; |
96 CloudPolicyCore core_; | 104 CloudPolicyCore core_; |
97 | 105 |
98 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyBroker); | 106 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyBroker); |
99 }; | 107 }; |
100 | 108 |
101 // Manages user policy blobs for device-local accounts present on the device. | 109 // Manages user policy blobs for device-local accounts present on the device. |
102 // The actual policy blobs are brokered by session_manager (to prevent file | 110 // The actual policy blobs are brokered by session_manager (to prevent file |
103 // manipulation), and we're making signature checks on the policy blobs to | 111 // manipulation), and we're making signature checks on the policy blobs to |
104 // ensure they're issued by the device owner. | 112 // ensure they're issued by the device owner. |
105 class DeviceLocalAccountPolicyService : public CloudPolicyStore::Observer { | 113 class DeviceLocalAccountPolicyService : public CloudPolicyStore::Observer { |
106 public: | 114 public: |
107 // Interface for interested parties to observe policy changes. | 115 // Interface for interested parties to observe policy changes. |
108 class Observer { | 116 class Observer { |
109 public: | 117 public: |
110 virtual ~Observer() {} | 118 virtual ~Observer() {} |
111 | 119 |
112 // Policy for the given |user_id| has changed. | 120 // Policy for the given |user_id| has changed. |
113 virtual void OnPolicyUpdated(const std::string& user_id) = 0; | 121 virtual void OnPolicyUpdated(const std::string& user_id) = 0; |
114 | 122 |
115 // The list of accounts has been updated. | 123 // The list of accounts has been updated. |
116 virtual void OnDeviceLocalAccountsChanged() = 0; | 124 virtual void OnDeviceLocalAccountsChanged() = 0; |
125 | |
126 // The given |broken| is about to be destroyed. | |
Bernhard Bauer
2014/06/19 16:59:27
Nit: "broker"
Joao da Silva
2014/06/19 17:04:56
Done.
| |
127 virtual void OnBrokerShutdown(DeviceLocalAccountPolicyBroker* broker) {} | |
117 }; | 128 }; |
118 | 129 |
119 DeviceLocalAccountPolicyService( | 130 DeviceLocalAccountPolicyService( |
120 chromeos::SessionManagerClient* session_manager_client, | 131 chromeos::SessionManagerClient* session_manager_client, |
121 chromeos::DeviceSettingsService* device_settings_service, | 132 chromeos::DeviceSettingsService* device_settings_service, |
122 chromeos::CrosSettings* cros_settings, | 133 chromeos::CrosSettings* cros_settings, |
123 scoped_refptr<base::SequencedTaskRunner> store_background_task_runner, | 134 scoped_refptr<base::SequencedTaskRunner> store_background_task_runner, |
124 scoped_refptr<base::SequencedTaskRunner> extension_cache_task_runner, | 135 scoped_refptr<base::SequencedTaskRunner> extension_cache_task_runner, |
125 scoped_refptr<base::SequencedTaskRunner> | 136 scoped_refptr<base::SequencedTaskRunner> |
126 external_data_service_backend_task_runner, | 137 external_data_service_backend_task_runner, |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
222 const scoped_refptr<base::SequencedTaskRunner> store_background_task_runner_; | 233 const scoped_refptr<base::SequencedTaskRunner> store_background_task_runner_; |
223 const scoped_refptr<base::SequencedTaskRunner> extension_cache_task_runner_; | 234 const scoped_refptr<base::SequencedTaskRunner> extension_cache_task_runner_; |
224 | 235 |
225 scoped_ptr<DeviceLocalAccountExternalDataService> external_data_service_; | 236 scoped_ptr<DeviceLocalAccountExternalDataService> external_data_service_; |
226 | 237 |
227 scoped_refptr<net::URLRequestContextGetter> request_context_; | 238 scoped_refptr<net::URLRequestContextGetter> request_context_; |
228 | 239 |
229 const scoped_ptr<chromeos::CrosSettings::ObserverSubscription> | 240 const scoped_ptr<chromeos::CrosSettings::ObserverSubscription> |
230 local_accounts_subscription_; | 241 local_accounts_subscription_; |
231 | 242 |
243 // Path to the directory that contains the cached policies for components | |
244 // for device local accounts. | |
245 base::FilePath component_policy_cache_root_; | |
246 | |
232 base::WeakPtrFactory<DeviceLocalAccountPolicyService> weak_factory_; | 247 base::WeakPtrFactory<DeviceLocalAccountPolicyService> weak_factory_; |
233 | 248 |
234 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyService); | 249 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyService); |
235 }; | 250 }; |
236 | 251 |
237 } // namespace policy | 252 } // namespace policy |
238 | 253 |
239 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_SERVICE_H_ | 254 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_SERVICE_H_ |
OLD | NEW |