OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
| 8 #include <utility> |
| 9 |
8 #include "base/bind.h" | 10 #include "base/bind.h" |
9 #include "base/command_line.h" | 11 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
11 #include "base/location.h" | 13 #include "base/location.h" |
12 #include "base/logging.h" | 14 #include "base/logging.h" |
13 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
14 #include "base/path_service.h" | 16 #include "base/path_service.h" |
15 #include "base/prefs/pref_registry_simple.h" | 17 #include "base/prefs/pref_registry_simple.h" |
16 #include "base/sequenced_task_runner.h" | 18 #include "base/sequenced_task_runner.h" |
17 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 cryptohome_client, | 134 cryptohome_client, |
133 chromeos::DeviceSettingsService::Get())); | 135 chromeos::DeviceSettingsService::Get())); |
134 } | 136 } |
135 | 137 |
136 scoped_ptr<DeviceCloudPolicyStoreChromeOS> device_cloud_policy_store( | 138 scoped_ptr<DeviceCloudPolicyStoreChromeOS> device_cloud_policy_store( |
137 new DeviceCloudPolicyStoreChromeOS( | 139 new DeviceCloudPolicyStoreChromeOS( |
138 chromeos::DeviceSettingsService::Get(), | 140 chromeos::DeviceSettingsService::Get(), |
139 install_attributes_.get(), | 141 install_attributes_.get(), |
140 GetBackgroundTaskRunner())); | 142 GetBackgroundTaskRunner())); |
141 device_cloud_policy_manager_ = new DeviceCloudPolicyManagerChromeOS( | 143 device_cloud_policy_manager_ = new DeviceCloudPolicyManagerChromeOS( |
142 device_cloud_policy_store.Pass(), base::ThreadTaskRunnerHandle::Get(), | 144 std::move(device_cloud_policy_store), |
143 state_keys_broker_.get()); | 145 base::ThreadTaskRunnerHandle::Get(), state_keys_broker_.get()); |
144 AddPolicyProvider( | 146 AddPolicyProvider( |
145 scoped_ptr<ConfigurationPolicyProvider>(device_cloud_policy_manager_)); | 147 scoped_ptr<ConfigurationPolicyProvider>(device_cloud_policy_manager_)); |
146 } | 148 } |
147 | 149 |
148 global_user_cloud_policy_provider_ = new ProxyPolicyProvider(); | 150 global_user_cloud_policy_provider_ = new ProxyPolicyProvider(); |
149 AddPolicyProvider(scoped_ptr<ConfigurationPolicyProvider>( | 151 AddPolicyProvider(scoped_ptr<ConfigurationPolicyProvider>( |
150 global_user_cloud_policy_provider_)); | 152 global_user_cloud_policy_provider_)); |
151 } | 153 } |
152 | 154 |
153 BrowserPolicyConnectorChromeOS::~BrowserPolicyConnectorChromeOS() {} | 155 BrowserPolicyConnectorChromeOS::~BrowserPolicyConnectorChromeOS() {} |
154 | 156 |
155 void BrowserPolicyConnectorChromeOS::Init( | 157 void BrowserPolicyConnectorChromeOS::Init( |
156 PrefService* local_state, | 158 PrefService* local_state, |
157 scoped_refptr<net::URLRequestContextGetter> request_context) { | 159 scoped_refptr<net::URLRequestContextGetter> request_context) { |
158 local_state_ = local_state; | 160 local_state_ = local_state; |
159 ChromeBrowserPolicyConnector::Init(local_state, request_context); | 161 ChromeBrowserPolicyConnector::Init(local_state, request_context); |
160 | 162 |
161 affiliated_invalidation_service_provider_.reset( | 163 affiliated_invalidation_service_provider_.reset( |
162 new AffiliatedInvalidationServiceProviderImpl); | 164 new AffiliatedInvalidationServiceProviderImpl); |
163 | 165 |
164 const base::CommandLine* command_line = | 166 const base::CommandLine* command_line = |
165 base::CommandLine::ForCurrentProcess(); | 167 base::CommandLine::ForCurrentProcess(); |
166 if (command_line->HasSwitch(chromeos::switches::kEnableConsumerManagement)) { | 168 if (command_line->HasSwitch(chromeos::switches::kEnableConsumerManagement)) { |
167 scoped_ptr<DeviceManagementService::Configuration> configuration( | 169 scoped_ptr<DeviceManagementService::Configuration> configuration( |
168 new DeviceManagementServiceConfiguration( | 170 new DeviceManagementServiceConfiguration( |
169 GetDeviceManagementServerUrlForConsumer())); | 171 GetDeviceManagementServerUrlForConsumer())); |
170 consumer_device_management_service_.reset( | 172 consumer_device_management_service_.reset( |
171 new DeviceManagementService(configuration.Pass())); | 173 new DeviceManagementService(std::move(configuration))); |
172 consumer_device_management_service_->ScheduleInitialization( | 174 consumer_device_management_service_->ScheduleInitialization( |
173 kServiceInitializationStartupDelay); | 175 kServiceInitializationStartupDelay); |
174 } | 176 } |
175 | 177 |
176 if (device_cloud_policy_manager_) { | 178 if (device_cloud_policy_manager_) { |
177 // Note: for now the |device_cloud_policy_manager_| is using the global | 179 // Note: for now the |device_cloud_policy_manager_| is using the global |
178 // schema registry. Eventually it will have its own registry, once device | 180 // schema registry. Eventually it will have its own registry, once device |
179 // cloud policy for extensions is introduced. That means it'd have to be | 181 // cloud policy for extensions is introduced. That means it'd have to be |
180 // initialized from here instead of BrowserPolicyConnector::Init(). | 182 // initialized from here instead of BrowserPolicyConnector::Init(). |
181 | 183 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 return EnrollmentConfig(); | 286 return EnrollmentConfig(); |
285 } | 287 } |
286 | 288 |
287 void BrowserPolicyConnectorChromeOS::SetUserPolicyDelegate( | 289 void BrowserPolicyConnectorChromeOS::SetUserPolicyDelegate( |
288 ConfigurationPolicyProvider* user_policy_provider) { | 290 ConfigurationPolicyProvider* user_policy_provider) { |
289 global_user_cloud_policy_provider_->SetDelegate(user_policy_provider); | 291 global_user_cloud_policy_provider_->SetDelegate(user_policy_provider); |
290 } | 292 } |
291 | 293 |
292 void BrowserPolicyConnectorChromeOS::SetConsumerManagementServiceForTesting( | 294 void BrowserPolicyConnectorChromeOS::SetConsumerManagementServiceForTesting( |
293 scoped_ptr<ConsumerManagementService> service) { | 295 scoped_ptr<ConsumerManagementService> service) { |
294 consumer_management_service_ = service.Pass(); | 296 consumer_management_service_ = std::move(service); |
295 } | 297 } |
296 | 298 |
297 void BrowserPolicyConnectorChromeOS::SetDeviceCloudPolicyInitializerForTesting( | 299 void BrowserPolicyConnectorChromeOS::SetDeviceCloudPolicyInitializerForTesting( |
298 scoped_ptr<DeviceCloudPolicyInitializer> initializer) { | 300 scoped_ptr<DeviceCloudPolicyInitializer> initializer) { |
299 device_cloud_policy_initializer_ = initializer.Pass(); | 301 device_cloud_policy_initializer_ = std::move(initializer); |
300 } | 302 } |
301 | 303 |
302 // static | 304 // static |
303 void BrowserPolicyConnectorChromeOS::SetInstallAttributesForTesting( | 305 void BrowserPolicyConnectorChromeOS::SetInstallAttributesForTesting( |
304 EnterpriseInstallAttributes* attributes) { | 306 EnterpriseInstallAttributes* attributes) { |
305 DCHECK(!g_testing_install_attributes); | 307 DCHECK(!g_testing_install_attributes); |
306 g_testing_install_attributes = attributes; | 308 g_testing_install_attributes = attributes; |
307 } | 309 } |
308 | 310 |
309 // static | 311 // static |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 device_cloud_policy_manager_->device_store()->policy(); | 381 device_cloud_policy_manager_->device_store()->policy(); |
380 if (policy_data) { | 382 if (policy_data) { |
381 affiliation_ids.insert(policy_data->device_affiliation_ids().begin(), | 383 affiliation_ids.insert(policy_data->device_affiliation_ids().begin(), |
382 policy_data->device_affiliation_ids().end()); | 384 policy_data->device_affiliation_ids().end()); |
383 } | 385 } |
384 } | 386 } |
385 return affiliation_ids; | 387 return affiliation_ids; |
386 } | 388 } |
387 | 389 |
388 } // namespace policy | 390 } // namespace policy |
OLD | NEW |