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_POLICY_BROWSER_POLICY_CONNECTOR_H_ | 5 #ifndef CHROME_BROWSER_POLICY_BROWSER_POLICY_CONNECTOR_H_ |
6 #define CHROME_BROWSER_POLICY_BROWSER_POLICY_CONNECTOR_H_ | 6 #define CHROME_BROWSER_POLICY_BROWSER_POLICY_CONNECTOR_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 14 matching lines...) Expand all Loading... | |
25 class AppPackUpdater; | 25 class AppPackUpdater; |
26 class CloudPolicyDataStore; | 26 class CloudPolicyDataStore; |
27 class CloudPolicyProvider; | 27 class CloudPolicyProvider; |
28 class CloudPolicySubsystem; | 28 class CloudPolicySubsystem; |
29 class ConfigurationPolicyProvider; | 29 class ConfigurationPolicyProvider; |
30 class DeviceCloudPolicyManagerChromeOS; | 30 class DeviceCloudPolicyManagerChromeOS; |
31 class DeviceManagementService; | 31 class DeviceManagementService; |
32 class NetworkConfigurationUpdater; | 32 class NetworkConfigurationUpdater; |
33 class PolicyService; | 33 class PolicyService; |
34 class PolicyStatisticsCollector; | 34 class PolicyStatisticsCollector; |
35 class UserCloudPolicyManager; | 35 class UserCloudPolicyManager; |
Joao da Silva
2012/11/21 17:06:34
nit: not needed
Mattias Nissler (ping if slow)
2012/11/22 20:51:59
Done.
| |
36 class UserCloudPolicyManagerChromeOS; | |
36 class UserPolicyTokenCache; | 37 class UserPolicyTokenCache; |
37 | 38 |
38 // Manages the lifecycle of browser-global policy infrastructure, such as the | 39 // Manages the lifecycle of browser-global policy infrastructure, such as the |
39 // platform policy providers, device- and the user-cloud policy infrastructure. | 40 // platform policy providers, device- and the user-cloud policy infrastructure. |
40 // TODO(gfeher,mnissler): Factor out device and user specific methods into their | 41 // TODO(gfeher,mnissler): Factor out device and user specific methods into their |
41 // respective classes. | 42 // respective classes. |
42 class BrowserPolicyConnector : public content::NotificationObserver { | 43 class BrowserPolicyConnector : public content::NotificationObserver { |
43 public: | 44 public: |
44 // Builds an uninitialized BrowserPolicyConnector, suitable for testing. | 45 // Builds an uninitialized BrowserPolicyConnector, suitable for testing. |
45 // Init() should be called to create and start the policy machinery. | 46 // Init() should be called to create and start the policy machinery. |
46 BrowserPolicyConnector(); | 47 BrowserPolicyConnector(); |
47 | 48 |
48 // Invoke Shutdown() before deleting, see below. | 49 // Invoke Shutdown() before deleting, see below. |
49 virtual ~BrowserPolicyConnector(); | 50 virtual ~BrowserPolicyConnector(); |
50 | 51 |
51 // Creates the policy providers and finalizes the initialization of the | 52 // Creates the policy providers and finalizes the initialization of the |
52 // connector. This call can be skipped on tests that don't require the full | 53 // connector. This call can be skipped on tests that don't require the full |
53 // policy system running. | 54 // policy system running. |
54 void Init(); | 55 void Init(); |
55 | 56 |
56 // Stops the policy providers and cleans up the connector before it can be | 57 // Stops the policy providers and cleans up the connector before it can be |
57 // safely deleted. This must be invoked before the destructor and while the | 58 // safely deleted. This must be invoked before the destructor and while the |
58 // threads are still running. The policy providers are still valid but won't | 59 // threads are still running. The policy providers are still valid but won't |
59 // update anymore after this call. | 60 // update anymore after this call. |
60 void Shutdown(); | 61 void Shutdown(); |
61 | 62 |
62 // Returns true if Init() has been called but Shutdown() hasn't been yet. | 63 // Returns true if Init() has been called but Shutdown() hasn't been yet. |
63 bool is_initialized() const { return is_initialized_; } | 64 bool is_initialized() const { return is_initialized_; } |
64 | 65 |
65 // Creates a UserCloudPolicyManager for the given profile, or returns NULL if | |
66 // it is not supported on this platform. If |force_immediate_policy_load| is | |
67 // true, then any underlying policy files will be loaded before this routine | |
68 // returns - this is used when the caller (such as | |
69 // CreateProfile(CREATE_MODE_SYNCHRONOUS)) needs to access the policy values | |
70 // immediately without waiting for tasks to complete. | |
71 scoped_ptr<UserCloudPolicyManager> CreateCloudPolicyManager( | |
72 Profile* profile, | |
73 bool force_immediate_policy_load); | |
74 | |
75 // Creates a new policy service for the given profile. | 66 // Creates a new policy service for the given profile. |
76 scoped_ptr<PolicyService> CreatePolicyService(Profile* profile); | 67 scoped_ptr<PolicyService> CreatePolicyService(Profile* profile); |
77 | 68 |
78 // Returns the browser-global PolicyService, that contains policies for the | 69 // Returns the browser-global PolicyService, that contains policies for the |
79 // whole browser. | 70 // whole browser. |
80 PolicyService* GetPolicyService(); | 71 PolicyService* GetPolicyService(); |
81 | 72 |
82 // Returns a weak pointer to the CloudPolicySubsystem corresponding to the | 73 // Returns a weak pointer to the CloudPolicySubsystem corresponding to the |
83 // device policy managed by this policy connector, or NULL if no such | 74 // device policy managed by this policy connector, or NULL if no such |
84 // subsystem exists (i.e. when running outside ChromeOS). | 75 // subsystem exists (i.e. when running outside ChromeOS). |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 NetworkConfigurationUpdater* GetNetworkConfigurationUpdater(); | 158 NetworkConfigurationUpdater* GetNetworkConfigurationUpdater(); |
168 | 159 |
169 DeviceManagementService* device_management_service() { | 160 DeviceManagementService* device_management_service() { |
170 return device_management_service_.get(); | 161 return device_management_service_.get(); |
171 } | 162 } |
172 | 163 |
173 #if defined(OS_CHROMEOS) | 164 #if defined(OS_CHROMEOS) |
174 DeviceCloudPolicyManagerChromeOS* GetDeviceCloudPolicyManager() { | 165 DeviceCloudPolicyManagerChromeOS* GetDeviceCloudPolicyManager() { |
175 return device_cloud_policy_manager_.get(); | 166 return device_cloud_policy_manager_.get(); |
176 } | 167 } |
168 UserCloudPolicyManagerChromeOS* GetUserCloudPolicyManager() { | |
169 return user_cloud_policy_manager_.get(); | |
170 } | |
177 #endif | 171 #endif |
178 | 172 |
179 // Sets a |provider| that will be included in PolicyServices returned by | 173 // Sets a |provider| that will be included in PolicyServices returned by |
180 // CreatePolicyService. This is a static method because local state is | 174 // CreatePolicyService. This is a static method because local state is |
181 // created immediately after the connector, and tests don't have a chance to | 175 // created immediately after the connector, and tests don't have a chance to |
182 // inject the provider otherwise. |provider| must outlive the connector, and | 176 // inject the provider otherwise. |provider| must outlive the connector, and |
183 // its ownership is not taken though the connector will initialize and shut it | 177 // its ownership is not taken though the connector will initialize and shut it |
184 // down. | 178 // down. |
185 static void SetPolicyProviderForTesting( | 179 static void SetPolicyProviderForTesting( |
186 ConfigurationPolicyProvider* provider); | 180 ConfigurationPolicyProvider* provider); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
225 | 219 |
226 scoped_ptr<ConfigurationPolicyProvider> platform_provider_; | 220 scoped_ptr<ConfigurationPolicyProvider> platform_provider_; |
227 scoped_ptr<CloudPolicyProvider> cloud_provider_; | 221 scoped_ptr<CloudPolicyProvider> cloud_provider_; |
228 | 222 |
229 // Components of the new-style cloud policy implementation. | 223 // Components of the new-style cloud policy implementation. |
230 // TODO(mnissler): Remove the old-style components below once we have | 224 // TODO(mnissler): Remove the old-style components below once we have |
231 // completed the switch to the new cloud policy implementation. | 225 // completed the switch to the new cloud policy implementation. |
232 #if defined(OS_CHROMEOS) | 226 #if defined(OS_CHROMEOS) |
233 scoped_ptr<EnterpriseInstallAttributes> install_attributes_; | 227 scoped_ptr<EnterpriseInstallAttributes> install_attributes_; |
234 scoped_ptr<DeviceCloudPolicyManagerChromeOS> device_cloud_policy_manager_; | 228 scoped_ptr<DeviceCloudPolicyManagerChromeOS> device_cloud_policy_manager_; |
229 scoped_ptr<UserCloudPolicyManagerChromeOS> user_cloud_policy_manager_; | |
230 | |
231 // This policy provider is used on Chrome OS to feed user policy into the | |
232 // global PolicyService instance. This works by installing | |
233 // |user_cloud_policy_manager_| as the delegate once the former is | |
234 // initialized. | |
235 ProxyPolicyProvider global_user_cloud_policy_provider_; | |
Joao da Silva
2012/11/21 17:06:34
This works but I'd prefer to always create the use
Mattias Nissler (ping if slow)
2012/11/22 20:51:59
I disagree strongly on the becoming ready part. If
| |
235 #endif | 236 #endif |
236 ProxyPolicyProvider user_cloud_policy_provider_; | |
237 | 237 |
238 // Must be deleted before all the policy providers. | 238 // Must be deleted before all the policy providers. |
239 scoped_ptr<PolicyService> policy_service_; | 239 scoped_ptr<PolicyService> policy_service_; |
240 | 240 |
241 #if defined(OS_CHROMEOS) | 241 #if defined(OS_CHROMEOS) |
242 scoped_ptr<CloudPolicyDataStore> device_data_store_; | 242 scoped_ptr<CloudPolicyDataStore> device_data_store_; |
243 scoped_ptr<CloudPolicySubsystem> device_cloud_policy_subsystem_; | 243 scoped_ptr<CloudPolicySubsystem> device_cloud_policy_subsystem_; |
244 #endif | 244 #endif |
245 | 245 |
246 scoped_ptr<UserPolicyTokenCache> user_policy_token_cache_; | 246 scoped_ptr<UserPolicyTokenCache> user_policy_token_cache_; |
(...skipping 19 matching lines...) Expand all Loading... | |
266 scoped_ptr<AppPackUpdater> app_pack_updater_; | 266 scoped_ptr<AppPackUpdater> app_pack_updater_; |
267 scoped_ptr<NetworkConfigurationUpdater> network_configuration_updater_; | 267 scoped_ptr<NetworkConfigurationUpdater> network_configuration_updater_; |
268 #endif | 268 #endif |
269 | 269 |
270 DISALLOW_COPY_AND_ASSIGN(BrowserPolicyConnector); | 270 DISALLOW_COPY_AND_ASSIGN(BrowserPolicyConnector); |
271 }; | 271 }; |
272 | 272 |
273 } // namespace policy | 273 } // namespace policy |
274 | 274 |
275 #endif // CHROME_BROWSER_POLICY_BROWSER_POLICY_CONNECTOR_H_ | 275 #endif // CHROME_BROWSER_POLICY_BROWSER_POLICY_CONNECTOR_H_ |
OLD | NEW |