Chromium Code Reviews| 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/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 19 #include "base/observer_list.h" | 19 #include "base/observer_list.h" |
| 20 #include "chrome/browser/chromeos/extensions/device_local_account_external_polic y_loader.h" | 20 #include "chrome/browser/chromeos/extensions/device_local_account_external_polic y_loader.h" |
| 21 #include "chrome/browser/chromeos/policy/affiliated_invalidation_service_provide r.h" | |
| 21 #include "chrome/browser/chromeos/policy/device_local_account_extension_tracker. h" | 22 #include "chrome/browser/chromeos/policy/device_local_account_extension_tracker. h" |
| 22 #include "chrome/browser/chromeos/policy/device_local_account_external_data_mana ger.h" | 23 #include "chrome/browser/chromeos/policy/device_local_account_external_data_mana ger.h" |
| 23 #include "chrome/browser/chromeos/settings/cros_settings.h" | 24 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 24 #include "components/policy/core/common/cloud/cloud_policy_core.h" | 25 #include "components/policy/core/common/cloud/cloud_policy_core.h" |
| 25 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 26 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
| 26 #include "components/policy/core/common/cloud/component_cloud_policy_service.h" | 27 #include "components/policy/core/common/cloud/component_cloud_policy_service.h" |
| 27 #include "components/policy/core/common/schema_registry.h" | 28 #include "components/policy/core/common/schema_registry.h" |
| 28 | 29 |
| 29 namespace base { | 30 namespace base { |
| 30 class SequencedTaskRunner; | 31 class SequencedTaskRunner; |
| 31 } | 32 } |
| 32 | 33 |
| 33 namespace chromeos { | 34 namespace chromeos { |
| 34 class DeviceSettingsService; | 35 class DeviceSettingsService; |
| 35 class SessionManagerClient; | 36 class SessionManagerClient; |
| 36 } | 37 } |
| 37 | 38 |
| 39 namespace invalidation { | |
| 40 class InvalidationService; | |
| 41 } | |
| 42 | |
| 38 namespace net { | 43 namespace net { |
| 39 class URLRequestContextGetter; | 44 class URLRequestContextGetter; |
| 40 } | 45 } |
| 41 | 46 |
| 42 namespace policy { | 47 namespace policy { |
| 43 | 48 |
| 49 class CloudPolicyInvalidator; | |
| 44 struct DeviceLocalAccount; | 50 struct DeviceLocalAccount; |
| 45 class DeviceLocalAccountExternalDataService; | 51 class DeviceLocalAccountExternalDataService; |
| 46 class DeviceLocalAccountPolicyStore; | 52 class DeviceLocalAccountPolicyStore; |
| 47 class DeviceManagementService; | 53 class DeviceManagementService; |
| 48 | 54 |
| 49 // The main switching central that downloads, caches, refreshes, etc. policy for | 55 // The main switching central that downloads, caches, refreshes, etc. policy for |
| 50 // a single device-local account. | 56 // a single device-local account. |
| 51 class DeviceLocalAccountPolicyBroker | 57 class DeviceLocalAccountPolicyBroker |
| 52 : public CloudPolicyStore::Observer, | 58 : public CloudPolicyStore::Observer, |
| 53 public ComponentCloudPolicyService::Delegate { | 59 public ComponentCloudPolicyService::Delegate, |
| 60 public AffiliatedInvalidationServiceProvider::Consumer { | |
| 54 public: | 61 public: |
| 62 // |invalidation_service_provider| must outlive |this|. | |
| 55 // |policy_update_callback| will be invoked to notify observers that the | 63 // |policy_update_callback| will be invoked to notify observers that the |
| 56 // policy for |account| has been updated. | 64 // policy for |account| has been updated. |
| 57 // |task_runner| is the runner for policy refresh tasks. | 65 // |task_runner| is the runner for policy refresh tasks. |
| 58 DeviceLocalAccountPolicyBroker( | 66 DeviceLocalAccountPolicyBroker( |
| 67 AffiliatedInvalidationServiceProvider* invalidation_service_provider, | |
|
pneubeck (no reviews)
2015/01/30 14:23:58
nitty:
non const& arguments tend to be add the e
bartfab (slow)
2015/02/03 18:31:06
Done.
| |
| 59 const DeviceLocalAccount& account, | 68 const DeviceLocalAccount& account, |
| 60 const base::FilePath& component_policy_cache_path, | 69 const base::FilePath& component_policy_cache_path, |
| 61 scoped_ptr<DeviceLocalAccountPolicyStore> store, | 70 scoped_ptr<DeviceLocalAccountPolicyStore> store, |
| 62 scoped_refptr<DeviceLocalAccountExternalDataManager> | 71 scoped_refptr<DeviceLocalAccountExternalDataManager> |
| 63 external_data_manager, | 72 external_data_manager, |
| 64 const base::Closure& policy_updated_callback, | 73 const base::Closure& policy_updated_callback, |
| 65 const scoped_refptr<base::SequencedTaskRunner>& task_runner); | 74 const scoped_refptr<base::SequencedTaskRunner>& task_runner); |
| 66 ~DeviceLocalAccountPolicyBroker() override; | 75 ~DeviceLocalAccountPolicyBroker() override; |
| 67 | 76 |
| 68 // Initialize the broker, loading its |store_|. | 77 // Initialize the broker, loading its |store_|. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 // empty string if the policy is not present. | 112 // empty string if the policy is not present. |
| 104 std::string GetDisplayName() const; | 113 std::string GetDisplayName() const; |
| 105 | 114 |
| 106 // CloudPolicyStore::Observer: | 115 // CloudPolicyStore::Observer: |
| 107 void OnStoreLoaded(CloudPolicyStore* store) override; | 116 void OnStoreLoaded(CloudPolicyStore* store) override; |
| 108 void OnStoreError(CloudPolicyStore* store) override; | 117 void OnStoreError(CloudPolicyStore* store) override; |
| 109 | 118 |
| 110 // ComponentCloudPolicyService::Delegate: | 119 // ComponentCloudPolicyService::Delegate: |
| 111 void OnComponentCloudPolicyUpdated() override; | 120 void OnComponentCloudPolicyUpdated() override; |
| 112 | 121 |
| 122 // AffiliatedInvalidationServiceProvider::Consumer: | |
| 123 void OnInvalidationServiceSet( | |
| 124 invalidation::InvalidationService* invalidation_service) override; | |
| 125 | |
| 126 CloudPolicyInvalidator* GetInvalidatorForTest() const; | |
| 127 | |
| 113 private: | 128 private: |
| 129 bool IsConnected(); | |
|
pneubeck (no reviews)
2015/01/30 14:23:58
could have a comment
bartfab (slow)
2015/02/03 18:31:06
Added comment. Also, renamed this to HasClient().
| |
| 130 | |
| 114 void CreateComponentCloudPolicyService( | 131 void CreateComponentCloudPolicyService( |
| 115 const scoped_refptr<net::URLRequestContextGetter>& request_context, | 132 const scoped_refptr<net::URLRequestContextGetter>& request_context, |
| 116 CloudPolicyClient* client); | 133 CloudPolicyClient* client); |
| 117 | 134 |
| 135 // Creates an |invalidator_| if an |invalidation_service_| is available and | |
| 136 // the |core_| is connected. | |
| 137 void CreateInvalidatorIfPossible(); | |
| 138 | |
| 139 void DestroyInvalidator(); | |
| 140 | |
| 141 AffiliatedInvalidationServiceProvider* invalidation_service_provider_; | |
| 118 const std::string account_id_; | 142 const std::string account_id_; |
| 119 const std::string user_id_; | 143 const std::string user_id_; |
| 120 const base::FilePath component_policy_cache_path_; | 144 const base::FilePath component_policy_cache_path_; |
| 121 SchemaRegistry schema_registry_; | 145 SchemaRegistry schema_registry_; |
| 122 const scoped_ptr<DeviceLocalAccountPolicyStore> store_; | 146 const scoped_ptr<DeviceLocalAccountPolicyStore> store_; |
| 123 DeviceLocalAccountExtensionTracker extension_tracker_; | 147 DeviceLocalAccountExtensionTracker extension_tracker_; |
| 124 scoped_refptr<DeviceLocalAccountExternalDataManager> external_data_manager_; | 148 scoped_refptr<DeviceLocalAccountExternalDataManager> external_data_manager_; |
| 125 scoped_refptr<chromeos::DeviceLocalAccountExternalPolicyLoader> | 149 scoped_refptr<chromeos::DeviceLocalAccountExternalPolicyLoader> |
| 126 extension_loader_; | 150 extension_loader_; |
| 127 CloudPolicyCore core_; | 151 CloudPolicyCore core_; |
| 128 scoped_ptr<ComponentCloudPolicyService> component_policy_service_; | 152 scoped_ptr<ComponentCloudPolicyService> component_policy_service_; |
| 129 base::Closure policy_update_callback_; | 153 base::Closure policy_update_callback_; |
| 130 | 154 |
| 155 int64 highest_handled_invalidation_version_; | |
| 156 invalidation::InvalidationService* invalidation_service_; | |
| 157 scoped_ptr<CloudPolicyInvalidator> invalidator_; | |
| 158 | |
| 131 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyBroker); | 159 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyBroker); |
| 132 }; | 160 }; |
| 133 | 161 |
| 134 // Manages user policy blobs for device-local accounts present on the device. | 162 // Manages user policy blobs for device-local accounts present on the device. |
| 135 // The actual policy blobs are brokered by session_manager (to prevent file | 163 // The actual policy blobs are brokered by session_manager (to prevent file |
| 136 // manipulation), and we're making signature checks on the policy blobs to | 164 // manipulation), and we're making signature checks on the policy blobs to |
| 137 // ensure they're issued by the device owner. | 165 // ensure they're issued by the device owner. |
| 138 class DeviceLocalAccountPolicyService { | 166 class DeviceLocalAccountPolicyService { |
| 139 public: | 167 public: |
| 140 // Interface for interested parties to observe policy changes. | 168 // Interface for interested parties to observe policy changes. |
| 141 class Observer { | 169 class Observer { |
| 142 public: | 170 public: |
| 143 virtual ~Observer() {} | 171 virtual ~Observer() {} |
| 144 | 172 |
| 145 // Policy for the given |user_id| has changed. | 173 // Policy for the given |user_id| has changed. |
| 146 virtual void OnPolicyUpdated(const std::string& user_id) = 0; | 174 virtual void OnPolicyUpdated(const std::string& user_id) = 0; |
| 147 | 175 |
| 148 // The list of accounts has been updated. | 176 // The list of accounts has been updated. |
| 149 virtual void OnDeviceLocalAccountsChanged() = 0; | 177 virtual void OnDeviceLocalAccountsChanged() = 0; |
| 150 }; | 178 }; |
| 151 | 179 |
| 152 DeviceLocalAccountPolicyService( | 180 DeviceLocalAccountPolicyService( |
| 153 chromeos::SessionManagerClient* session_manager_client, | 181 chromeos::SessionManagerClient* session_manager_client, |
| 154 chromeos::DeviceSettingsService* device_settings_service, | 182 chromeos::DeviceSettingsService* device_settings_service, |
| 155 chromeos::CrosSettings* cros_settings, | 183 chromeos::CrosSettings* cros_settings, |
| 184 AffiliatedInvalidationServiceProvider* invalidation_service_provider, | |
| 156 scoped_refptr<base::SequencedTaskRunner> store_background_task_runner, | 185 scoped_refptr<base::SequencedTaskRunner> store_background_task_runner, |
| 157 scoped_refptr<base::SequencedTaskRunner> extension_cache_task_runner, | 186 scoped_refptr<base::SequencedTaskRunner> extension_cache_task_runner, |
| 158 scoped_refptr<base::SequencedTaskRunner> | 187 scoped_refptr<base::SequencedTaskRunner> |
| 159 external_data_service_backend_task_runner, | 188 external_data_service_backend_task_runner, |
| 160 scoped_refptr<base::SequencedTaskRunner> io_task_runner, | 189 scoped_refptr<base::SequencedTaskRunner> io_task_runner, |
| 161 scoped_refptr<net::URLRequestContextGetter> request_context); | 190 scoped_refptr<net::URLRequestContextGetter> request_context); |
| 162 virtual ~DeviceLocalAccountPolicyService(); | 191 virtual ~DeviceLocalAccountPolicyService(); |
| 163 | 192 |
| 164 // Shuts down the service and prevents further policy fetches from the cloud. | 193 // Shuts down the service and prevents further policy fetches from the cloud. |
| 165 void Shutdown(); | 194 void Shutdown(); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 DeviceLocalAccountPolicyBroker* GetBrokerForStore(CloudPolicyStore* store); | 249 DeviceLocalAccountPolicyBroker* GetBrokerForStore(CloudPolicyStore* store); |
| 221 | 250 |
| 222 // Notifies the |observers_| that the policy for |user_id| has changed. | 251 // Notifies the |observers_| that the policy for |user_id| has changed. |
| 223 void NotifyPolicyUpdated(const std::string& user_id); | 252 void NotifyPolicyUpdated(const std::string& user_id); |
| 224 | 253 |
| 225 ObserverList<Observer, true> observers_; | 254 ObserverList<Observer, true> observers_; |
| 226 | 255 |
| 227 chromeos::SessionManagerClient* session_manager_client_; | 256 chromeos::SessionManagerClient* session_manager_client_; |
| 228 chromeos::DeviceSettingsService* device_settings_service_; | 257 chromeos::DeviceSettingsService* device_settings_service_; |
| 229 chromeos::CrosSettings* cros_settings_; | 258 chromeos::CrosSettings* cros_settings_; |
| 259 AffiliatedInvalidationServiceProvider* invalidation_service_provider_; | |
| 230 | 260 |
| 231 DeviceManagementService* device_management_service_; | 261 DeviceManagementService* device_management_service_; |
| 232 | 262 |
| 233 // The device-local account policy brokers, keyed by user ID. | 263 // The device-local account policy brokers, keyed by user ID. |
| 234 PolicyBrokerMap policy_brokers_; | 264 PolicyBrokerMap policy_brokers_; |
| 235 | 265 |
| 236 // Whether a call to UpdateAccountList() is pending because |cros_settings_| | 266 // Whether a call to UpdateAccountList() is pending because |cros_settings_| |
| 237 // are not trusted yet. | 267 // are not trusted yet. |
| 238 bool waiting_for_cros_settings_; | 268 bool waiting_for_cros_settings_; |
| 239 | 269 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 266 base::FilePath component_policy_cache_root_; | 296 base::FilePath component_policy_cache_root_; |
| 267 | 297 |
| 268 base::WeakPtrFactory<DeviceLocalAccountPolicyService> weak_factory_; | 298 base::WeakPtrFactory<DeviceLocalAccountPolicyService> weak_factory_; |
| 269 | 299 |
| 270 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyService); | 300 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyService); |
| 271 }; | 301 }; |
| 272 | 302 |
| 273 } // namespace policy | 303 } // namespace policy |
| 274 | 304 |
| 275 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_SERVICE_H_ | 305 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_SERVICE_H_ |
| OLD | NEW |