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 30 matching lines...) Expand all Loading... |
41 // Builds an uninitialized BrowserPolicyConnector, suitable for testing. | 41 // Builds an uninitialized BrowserPolicyConnector, suitable for testing. |
42 // Init() should be called to create and start the policy machinery. | 42 // Init() should be called to create and start the policy machinery. |
43 BrowserPolicyConnector(); | 43 BrowserPolicyConnector(); |
44 virtual ~BrowserPolicyConnector(); | 44 virtual ~BrowserPolicyConnector(); |
45 | 45 |
46 // Creates the policy providers and finalizes the initialization of the | 46 // Creates the policy providers and finalizes the initialization of the |
47 // connector. This call can be skipped on tests that don't require the full | 47 // connector. This call can be skipped on tests that don't require the full |
48 // policy system running. | 48 // policy system running. |
49 void Init(); | 49 void Init(); |
50 | 50 |
51 // Creates a UserCloudPolicyManager for the given profile, or returns NULL if | |
52 // it is not supported on this platform. Ownership is transferred to the | |
53 // caller. | |
54 scoped_ptr<UserCloudPolicyManager> CreateCloudPolicyManager(Profile* profile); | |
55 | |
56 // Creates a new policy service for the given profile, or a global one if | 51 // Creates a new policy service for the given profile, or a global one if |
57 // it is NULL. Ownership is transferred to the caller. | 52 // it is NULL. Ownership is transferred to the caller. |
58 scoped_ptr<PolicyService> CreatePolicyService(Profile* profile); | 53 PolicyService* CreatePolicyService(Profile* profile); |
59 | 54 |
60 // Returns a weak pointer to the CloudPolicySubsystem corresponding to the | 55 // Returns a weak pointer to the CloudPolicySubsystem corresponding to the |
61 // device policy managed by this policy connector, or NULL if no such | 56 // device policy managed by this policy connector, or NULL if no such |
62 // subsystem exists (i.e. when running outside ChromeOS). | 57 // subsystem exists (i.e. when running outside ChromeOS). |
63 CloudPolicySubsystem* device_cloud_policy_subsystem() { | 58 CloudPolicySubsystem* device_cloud_policy_subsystem() { |
64 #if defined(OS_CHROMEOS) | 59 #if defined(OS_CHROMEOS) |
65 return device_cloud_policy_subsystem_.get(); | 60 return device_cloud_policy_subsystem_.get(); |
66 #else | 61 #else |
67 return NULL; | 62 return NULL; |
68 #endif | 63 #endif |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 CloudPolicyDataStore* GetUserCloudPolicyDataStore(); | 133 CloudPolicyDataStore* GetUserCloudPolicyDataStore(); |
139 | 134 |
140 const ConfigurationPolicyHandlerList* GetHandlerList() const; | 135 const ConfigurationPolicyHandlerList* GetHandlerList() const; |
141 | 136 |
142 // Works out the user affiliation by checking the given |user_name| against | 137 // Works out the user affiliation by checking the given |user_name| against |
143 // the installation attributes. | 138 // the installation attributes. |
144 UserAffiliation GetUserAffiliation(const std::string& user_name); | 139 UserAffiliation GetUserAffiliation(const std::string& user_name); |
145 | 140 |
146 AppPackUpdater* GetAppPackUpdater(); | 141 AppPackUpdater* GetAppPackUpdater(); |
147 | 142 |
148 DeviceManagementService* device_management_service() { | |
149 return device_management_service_.get(); | |
150 } | |
151 | |
152 // Sets a |provider| that will be included in PolicyServices returned by | 143 // Sets a |provider| that will be included in PolicyServices returned by |
153 // CreatePolicyService. This is a static method because local state is | 144 // CreatePolicyService. This is a static method because local state is |
154 // created immediately after the connector, and tests don't have a chance to | 145 // created immediately after the connector, and tests don't have a chance to |
155 // inject the provider otherwise. |provider| must outlive the connector, and | 146 // inject the provider otherwise. |provider| must outlive the connector, and |
156 // its ownership is not taken. | 147 // its ownership is not taken. |
157 static void SetPolicyProviderForTesting( | 148 static void SetPolicyProviderForTesting( |
158 ConfigurationPolicyProvider* provider); | 149 ConfigurationPolicyProvider* provider); |
159 | 150 |
160 // Gets the URL of the DM server (either the default or a URL provided via the | |
161 // command line). | |
162 static std::string GetDeviceManagementUrl(); | |
163 | |
164 private: | 151 private: |
165 // content::NotificationObserver method overrides: | 152 // content::NotificationObserver method overrides: |
166 virtual void Observe(int type, | 153 virtual void Observe(int type, |
167 const content::NotificationSource& source, | 154 const content::NotificationSource& source, |
168 const content::NotificationDetails& details) OVERRIDE; | 155 const content::NotificationDetails& details) OVERRIDE; |
169 | 156 |
170 // Initializes the device cloud policy infrasturcture. | 157 // Initializes the device cloud policy infrasturcture. |
171 void InitializeDevicePolicy(); | 158 void InitializeDevicePolicy(); |
172 | 159 |
173 // Complete initialization once the message loops are running and the | 160 // Complete initialization once the message loops are running and the |
(...skipping 22 matching lines...) Expand all Loading... |
196 scoped_ptr<UserPolicyTokenCache> user_policy_token_cache_; | 183 scoped_ptr<UserPolicyTokenCache> user_policy_token_cache_; |
197 scoped_ptr<CloudPolicyDataStore> user_data_store_; | 184 scoped_ptr<CloudPolicyDataStore> user_data_store_; |
198 scoped_ptr<CloudPolicySubsystem> user_cloud_policy_subsystem_; | 185 scoped_ptr<CloudPolicySubsystem> user_cloud_policy_subsystem_; |
199 | 186 |
200 // Components of the new-style cloud policy implementation. | 187 // Components of the new-style cloud policy implementation. |
201 // TODO(mnissler): Remove the old-style components above once we have | 188 // TODO(mnissler): Remove the old-style components above once we have |
202 // completed the switch to the new cloud policy implementation. | 189 // completed the switch to the new cloud policy implementation. |
203 scoped_ptr<DeviceManagementService> device_management_service_; | 190 scoped_ptr<DeviceManagementService> device_management_service_; |
204 | 191 |
205 ProxyPolicyProvider user_cloud_policy_provider_; | 192 ProxyPolicyProvider user_cloud_policy_provider_; |
| 193 scoped_ptr<UserCloudPolicyManager> user_cloud_policy_manager_; |
206 | 194 |
207 // Used to initialize the device policy subsystem once the message loops | 195 // Used to initialize the device policy subsystem once the message loops |
208 // are spinning. | 196 // are spinning. |
209 base::WeakPtrFactory<BrowserPolicyConnector> weak_ptr_factory_; | 197 base::WeakPtrFactory<BrowserPolicyConnector> weak_ptr_factory_; |
210 | 198 |
211 // Registers the provider for notification of successful Gaia logins. | 199 // Registers the provider for notification of successful Gaia logins. |
212 content::NotificationRegistrar registrar_; | 200 content::NotificationRegistrar registrar_; |
213 | 201 |
214 // Weak reference to the TokenService we are listening to for user cloud | 202 // Weak reference to the TokenService we are listening to for user cloud |
215 // policy authentication tokens. | 203 // policy authentication tokens. |
216 TokenService* token_service_; | 204 TokenService* token_service_; |
217 | 205 |
218 #if defined(OS_CHROMEOS) | 206 #if defined(OS_CHROMEOS) |
219 scoped_ptr<AppPackUpdater> app_pack_updater_; | 207 scoped_ptr<AppPackUpdater> app_pack_updater_; |
220 #endif | 208 #endif |
221 | 209 |
222 DISALLOW_COPY_AND_ASSIGN(BrowserPolicyConnector); | 210 DISALLOW_COPY_AND_ASSIGN(BrowserPolicyConnector); |
223 }; | 211 }; |
224 | 212 |
225 } // namespace policy | 213 } // namespace policy |
226 | 214 |
227 #endif // CHROME_BROWSER_POLICY_BROWSER_POLICY_CONNECTOR_H_ | 215 #endif // CHROME_BROWSER_POLICY_BROWSER_POLICY_CONNECTOR_H_ |
OLD | NEW |