| 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/device_local_account_extension_tracker.
h" | 21 #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" | 22 #include "chrome/browser/chromeos/policy/device_local_account_external_data_mana
ger.h" |
| 23 #include "chrome/browser/chromeos/settings/cros_settings.h" | 23 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 24 #include "components/policy/core/common/cloud/cloud_policy_core.h" | 24 #include "components/policy/core/common/cloud/cloud_policy_core.h" |
| 25 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 25 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
| 26 #include "components/policy/core/common/cloud/component_cloud_policy_service.h" | 26 #include "components/policy/core/common/cloud/component_cloud_policy_service.h" |
| 27 #include "components/policy/core/common/schema_registry.h" | 27 #include "components/policy/core/common/schema_registry.h" |
| 28 #include "components/user_manager/user_id.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 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 68 const scoped_refptr<base::SequencedTaskRunner>& task_runner, | 69 const scoped_refptr<base::SequencedTaskRunner>& task_runner, |
| 69 AffiliatedInvalidationServiceProvider* invalidation_service_provider); | 70 AffiliatedInvalidationServiceProvider* invalidation_service_provider); |
| 70 ~DeviceLocalAccountPolicyBroker() override; | 71 ~DeviceLocalAccountPolicyBroker() override; |
| 71 | 72 |
| 72 // Initialize the broker, loading its |store_|. | 73 // Initialize the broker, loading its |store_|. |
| 73 void Initialize(); | 74 void Initialize(); |
| 74 | 75 |
| 75 // For the difference between |account_id| and |user_id|, see the | 76 // For the difference between |account_id| and |user_id|, see the |
| 76 // documentation of DeviceLocalAccount. | 77 // documentation of DeviceLocalAccount. |
| 77 const std::string& account_id() const { return account_id_; } | 78 const std::string& account_id() const { return account_id_; } |
| 78 const std::string& user_id() const { return user_id_; } | 79 const user_manager::UserID& user_id() const { return user_id_; } |
| 79 | 80 |
| 80 scoped_refptr<chromeos::DeviceLocalAccountExternalPolicyLoader> | 81 scoped_refptr<chromeos::DeviceLocalAccountExternalPolicyLoader> |
| 81 extension_loader() const { return extension_loader_; } | 82 extension_loader() const { return extension_loader_; } |
| 82 | 83 |
| 83 CloudPolicyCore* core() { return &core_; } | 84 CloudPolicyCore* core() { return &core_; } |
| 84 const CloudPolicyCore* core() const { return &core_; } | 85 const CloudPolicyCore* core() const { return &core_; } |
| 85 | 86 |
| 86 scoped_refptr<DeviceLocalAccountExternalDataManager> external_data_manager() { | 87 scoped_refptr<DeviceLocalAccountExternalDataManager> external_data_manager() { |
| 87 return external_data_manager_; | 88 return external_data_manager_; |
| 88 } | 89 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 116 // ComponentCloudPolicyService::Delegate: | 117 // ComponentCloudPolicyService::Delegate: |
| 117 void OnComponentCloudPolicyUpdated() override; | 118 void OnComponentCloudPolicyUpdated() override; |
| 118 | 119 |
| 119 private: | 120 private: |
| 120 void CreateComponentCloudPolicyService( | 121 void CreateComponentCloudPolicyService( |
| 121 const scoped_refptr<net::URLRequestContextGetter>& request_context, | 122 const scoped_refptr<net::URLRequestContextGetter>& request_context, |
| 122 CloudPolicyClient* client); | 123 CloudPolicyClient* client); |
| 123 | 124 |
| 124 AffiliatedInvalidationServiceProvider* const invalidation_service_provider_; | 125 AffiliatedInvalidationServiceProvider* const invalidation_service_provider_; |
| 125 const std::string account_id_; | 126 const std::string account_id_; |
| 126 const std::string user_id_; | 127 const user_manager::UserID user_id_; |
| 127 const base::FilePath component_policy_cache_path_; | 128 const base::FilePath component_policy_cache_path_; |
| 128 SchemaRegistry schema_registry_; | 129 SchemaRegistry schema_registry_; |
| 129 const scoped_ptr<DeviceLocalAccountPolicyStore> store_; | 130 const scoped_ptr<DeviceLocalAccountPolicyStore> store_; |
| 130 DeviceLocalAccountExtensionTracker extension_tracker_; | 131 DeviceLocalAccountExtensionTracker extension_tracker_; |
| 131 scoped_refptr<DeviceLocalAccountExternalDataManager> external_data_manager_; | 132 scoped_refptr<DeviceLocalAccountExternalDataManager> external_data_manager_; |
| 132 scoped_refptr<chromeos::DeviceLocalAccountExternalPolicyLoader> | 133 scoped_refptr<chromeos::DeviceLocalAccountExternalPolicyLoader> |
| 133 extension_loader_; | 134 extension_loader_; |
| 134 CloudPolicyCore core_; | 135 CloudPolicyCore core_; |
| 135 scoped_ptr<ComponentCloudPolicyService> component_policy_service_; | 136 scoped_ptr<ComponentCloudPolicyService> component_policy_service_; |
| 136 base::Closure policy_update_callback_; | 137 base::Closure policy_update_callback_; |
| 137 scoped_ptr<AffiliatedCloudPolicyInvalidator> invalidator_; | 138 scoped_ptr<AffiliatedCloudPolicyInvalidator> invalidator_; |
| 138 | 139 |
| 139 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyBroker); | 140 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyBroker); |
| 140 }; | 141 }; |
| 141 | 142 |
| 142 // Manages user policy blobs for device-local accounts present on the device. | 143 // Manages user policy blobs for device-local accounts present on the device. |
| 143 // The actual policy blobs are brokered by session_manager (to prevent file | 144 // The actual policy blobs are brokered by session_manager (to prevent file |
| 144 // manipulation), and we're making signature checks on the policy blobs to | 145 // manipulation), and we're making signature checks on the policy blobs to |
| 145 // ensure they're issued by the device owner. | 146 // ensure they're issued by the device owner. |
| 146 class DeviceLocalAccountPolicyService { | 147 class DeviceLocalAccountPolicyService { |
| 147 public: | 148 public: |
| 148 // Interface for interested parties to observe policy changes. | 149 // Interface for interested parties to observe policy changes. |
| 149 class Observer { | 150 class Observer { |
| 150 public: | 151 public: |
| 151 virtual ~Observer() {} | 152 virtual ~Observer() {} |
| 152 | 153 |
| 153 // Policy for the given |user_id| has changed. | 154 // Policy for the given |user_id| has changed. |
| 154 virtual void OnPolicyUpdated(const std::string& user_id) = 0; | 155 virtual void OnPolicyUpdated(const user_manager::UserID& user_id) = 0; |
| 155 | 156 |
| 156 // The list of accounts has been updated. | 157 // The list of accounts has been updated. |
| 157 virtual void OnDeviceLocalAccountsChanged() = 0; | 158 virtual void OnDeviceLocalAccountsChanged() = 0; |
| 158 }; | 159 }; |
| 159 | 160 |
| 160 DeviceLocalAccountPolicyService( | 161 DeviceLocalAccountPolicyService( |
| 161 chromeos::SessionManagerClient* session_manager_client, | 162 chromeos::SessionManagerClient* session_manager_client, |
| 162 chromeos::DeviceSettingsService* device_settings_service, | 163 chromeos::DeviceSettingsService* device_settings_service, |
| 163 chromeos::CrosSettings* cros_settings, | 164 chromeos::CrosSettings* cros_settings, |
| 164 AffiliatedInvalidationServiceProvider* invalidation_service_provider, | 165 AffiliatedInvalidationServiceProvider* invalidation_service_provider, |
| 165 scoped_refptr<base::SequencedTaskRunner> store_background_task_runner, | 166 scoped_refptr<base::SequencedTaskRunner> store_background_task_runner, |
| 166 scoped_refptr<base::SequencedTaskRunner> extension_cache_task_runner, | 167 scoped_refptr<base::SequencedTaskRunner> extension_cache_task_runner, |
| 167 scoped_refptr<base::SequencedTaskRunner> | 168 scoped_refptr<base::SequencedTaskRunner> |
| 168 external_data_service_backend_task_runner, | 169 external_data_service_backend_task_runner, |
| 169 scoped_refptr<base::SequencedTaskRunner> io_task_runner, | 170 scoped_refptr<base::SequencedTaskRunner> io_task_runner, |
| 170 scoped_refptr<net::URLRequestContextGetter> request_context); | 171 scoped_refptr<net::URLRequestContextGetter> request_context); |
| 171 virtual ~DeviceLocalAccountPolicyService(); | 172 virtual ~DeviceLocalAccountPolicyService(); |
| 172 | 173 |
| 173 // Shuts down the service and prevents further policy fetches from the cloud. | 174 // Shuts down the service and prevents further policy fetches from the cloud. |
| 174 void Shutdown(); | 175 void Shutdown(); |
| 175 | 176 |
| 176 // Initializes the cloud policy service connection. | 177 // Initializes the cloud policy service connection. |
| 177 void Connect(DeviceManagementService* device_management_service); | 178 void Connect(DeviceManagementService* device_management_service); |
| 178 | 179 |
| 179 // Get the policy broker for a given |user_id|. Returns NULL if that |user_id| | 180 // Get the policy broker for a given |user_id|. Returns NULL if that |user_id| |
| 180 // does not belong to an existing device-local account. | 181 // does not belong to an existing device-local account. |
| 181 DeviceLocalAccountPolicyBroker* GetBrokerForUser(const std::string& user_id); | 182 DeviceLocalAccountPolicyBroker* GetBrokerForUser(const user_manager::UserID& u
ser_id); |
| 182 | 183 |
| 183 // Indicates whether policy has been successfully fetched for the given | 184 // Indicates whether policy has been successfully fetched for the given |
| 184 // |user_id|. | 185 // |user_id|. |
| 185 bool IsPolicyAvailableForUser(const std::string& user_id); | 186 bool IsPolicyAvailableForUser(const user_manager::UserID& user_id); |
| 186 | 187 |
| 187 void AddObserver(Observer* observer); | 188 void AddObserver(Observer* observer); |
| 188 void RemoveObserver(Observer* observer); | 189 void RemoveObserver(Observer* observer); |
| 189 | 190 |
| 190 private: | 191 private: |
| 191 typedef std::map<std::string, DeviceLocalAccountPolicyBroker*> | 192 typedef std::map<user_manager::UserID, DeviceLocalAccountPolicyBroker*> |
| 192 PolicyBrokerMap; | 193 PolicyBrokerMap; |
| 193 | 194 |
| 194 // Returns |true| if the directory in which force-installed extensions are | 195 // Returns |true| if the directory in which force-installed extensions are |
| 195 // cached for |account_id| is busy, either because a broker that was using | 196 // cached for |account_id| is busy, either because a broker that was using |
| 196 // this directory has not shut down completely yet or because the directory is | 197 // this directory has not shut down completely yet or because the directory is |
| 197 // being deleted. | 198 // being deleted. |
| 198 bool IsExtensionCacheDirectoryBusy(const std::string& account_id); | 199 bool IsExtensionCacheDirectoryBusy(const std::string& account_id); |
| 199 | 200 |
| 200 // Starts any extension caches that are not running yet but can be started now | 201 // Starts any extension caches that are not running yet but can be started now |
| 201 // because their cache directories are no longer busy. | 202 // because their cache directories are no longer busy. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 222 // Calls |UpdateAccountList| if there are no previous calls pending. | 223 // Calls |UpdateAccountList| if there are no previous calls pending. |
| 223 void UpdateAccountListIfNonePending(); | 224 void UpdateAccountListIfNonePending(); |
| 224 | 225 |
| 225 // Deletes brokers in |map| and clears it. | 226 // Deletes brokers in |map| and clears it. |
| 226 void DeleteBrokers(PolicyBrokerMap* map); | 227 void DeleteBrokers(PolicyBrokerMap* map); |
| 227 | 228 |
| 228 // Find the broker for a given |store|. Returns NULL if |store| is unknown. | 229 // Find the broker for a given |store|. Returns NULL if |store| is unknown. |
| 229 DeviceLocalAccountPolicyBroker* GetBrokerForStore(CloudPolicyStore* store); | 230 DeviceLocalAccountPolicyBroker* GetBrokerForStore(CloudPolicyStore* store); |
| 230 | 231 |
| 231 // Notifies the |observers_| that the policy for |user_id| has changed. | 232 // Notifies the |observers_| that the policy for |user_id| has changed. |
| 232 void NotifyPolicyUpdated(const std::string& user_id); | 233 void NotifyPolicyUpdated(const user_manager::UserID& user_id); |
| 233 | 234 |
| 234 ObserverList<Observer, true> observers_; | 235 ObserverList<Observer, true> observers_; |
| 235 | 236 |
| 236 chromeos::SessionManagerClient* session_manager_client_; | 237 chromeos::SessionManagerClient* session_manager_client_; |
| 237 chromeos::DeviceSettingsService* device_settings_service_; | 238 chromeos::DeviceSettingsService* device_settings_service_; |
| 238 chromeos::CrosSettings* cros_settings_; | 239 chromeos::CrosSettings* cros_settings_; |
| 239 AffiliatedInvalidationServiceProvider* invalidation_service_provider_; | 240 AffiliatedInvalidationServiceProvider* invalidation_service_provider_; |
| 240 | 241 |
| 241 DeviceManagementService* device_management_service_; | 242 DeviceManagementService* device_management_service_; |
| 242 | 243 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 base::FilePath component_policy_cache_root_; | 277 base::FilePath component_policy_cache_root_; |
| 277 | 278 |
| 278 base::WeakPtrFactory<DeviceLocalAccountPolicyService> weak_factory_; | 279 base::WeakPtrFactory<DeviceLocalAccountPolicyService> weak_factory_; |
| 279 | 280 |
| 280 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyService); | 281 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyService); |
| 281 }; | 282 }; |
| 282 | 283 |
| 283 } // namespace policy | 284 } // namespace policy |
| 284 | 285 |
| 285 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_SERVICE_H_ | 286 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_SERVICE_H_ |
| OLD | NEW |