| 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 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 |
| 8 #include <utility> | 9 #include <utility> |
| 9 | 10 |
| 10 #include "base/bind.h" | 11 #include "base/bind.h" |
| 11 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 12 #include "base/callback.h" | 13 #include "base/callback.h" |
| 13 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 14 #include "base/logging.h" | 15 #include "base/logging.h" |
| 15 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/ptr_util.h" |
| 16 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 17 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 18 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
| 19 #include "chrome/browser/chromeos/attestation/attestation_policy_observer.h" | 21 #include "chrome/browser/chromeos/attestation/attestation_policy_observer.h" |
| 20 #include "chrome/browser/chromeos/login/enrollment/auto_enrollment_controller.h" | 22 #include "chrome/browser/chromeos/login/enrollment/auto_enrollment_controller.h" |
| 21 #include "chrome/browser/chromeos/login/startup_utils.h" | 23 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 22 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" | 24 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" |
| 23 #include "chrome/browser/chromeos/policy/device_status_collector.h" | 25 #include "chrome/browser/chromeos/policy/device_status_collector.h" |
| 24 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" | 26 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" |
| 25 #include "chrome/browser/chromeos/policy/heartbeat_scheduler.h" | 27 #include "chrome/browser/chromeos/policy/heartbeat_scheduler.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 | 102 |
| 101 // Checks whether forced re-enrollment is enabled. | 103 // Checks whether forced re-enrollment is enabled. |
| 102 bool ForcedReEnrollmentEnabled() { | 104 bool ForcedReEnrollmentEnabled() { |
| 103 return chromeos::AutoEnrollmentController::GetMode() == | 105 return chromeos::AutoEnrollmentController::GetMode() == |
| 104 chromeos::AutoEnrollmentController::MODE_FORCED_RE_ENROLLMENT; | 106 chromeos::AutoEnrollmentController::MODE_FORCED_RE_ENROLLMENT; |
| 105 } | 107 } |
| 106 | 108 |
| 107 } // namespace | 109 } // namespace |
| 108 | 110 |
| 109 DeviceCloudPolicyManagerChromeOS::DeviceCloudPolicyManagerChromeOS( | 111 DeviceCloudPolicyManagerChromeOS::DeviceCloudPolicyManagerChromeOS( |
| 110 scoped_ptr<DeviceCloudPolicyStoreChromeOS> store, | 112 std::unique_ptr<DeviceCloudPolicyStoreChromeOS> store, |
| 111 const scoped_refptr<base::SequencedTaskRunner>& task_runner, | 113 const scoped_refptr<base::SequencedTaskRunner>& task_runner, |
| 112 ServerBackedStateKeysBroker* state_keys_broker) | 114 ServerBackedStateKeysBroker* state_keys_broker) |
| 113 : CloudPolicyManager( | 115 : CloudPolicyManager( |
| 114 dm_protocol::kChromeDevicePolicyType, | 116 dm_protocol::kChromeDevicePolicyType, |
| 115 std::string(), | 117 std::string(), |
| 116 store.get(), | 118 store.get(), |
| 117 task_runner, | 119 task_runner, |
| 118 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), | 120 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), |
| 119 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)), | 121 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)), |
| 120 device_store_(std::move(store)), | 122 device_store_(std::move(store)), |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 | 237 |
| 236 return machine_id; | 238 return machine_id; |
| 237 } | 239 } |
| 238 | 240 |
| 239 // static | 241 // static |
| 240 std::string DeviceCloudPolicyManagerChromeOS::GetMachineModel() { | 242 std::string DeviceCloudPolicyManagerChromeOS::GetMachineModel() { |
| 241 return GetMachineStatistic(chromeos::system::kHardwareClassKey); | 243 return GetMachineStatistic(chromeos::system::kHardwareClassKey); |
| 242 } | 244 } |
| 243 | 245 |
| 244 void DeviceCloudPolicyManagerChromeOS::StartConnection( | 246 void DeviceCloudPolicyManagerChromeOS::StartConnection( |
| 245 scoped_ptr<CloudPolicyClient> client_to_connect, | 247 std::unique_ptr<CloudPolicyClient> client_to_connect, |
| 246 EnterpriseInstallAttributes* install_attributes) { | 248 EnterpriseInstallAttributes* install_attributes) { |
| 247 CHECK(!service()); | 249 CHECK(!service()); |
| 248 | 250 |
| 249 // Set state keys here so the first policy fetch submits them to the server. | 251 // Set state keys here so the first policy fetch submits them to the server. |
| 250 if (ForcedReEnrollmentEnabled()) | 252 if (ForcedReEnrollmentEnabled()) |
| 251 client_to_connect->SetStateKeysToUpload(state_keys_broker_->state_keys()); | 253 client_to_connect->SetStateKeysToUpload(state_keys_broker_->state_keys()); |
| 252 | 254 |
| 253 core()->Connect(std::move(client_to_connect)); | 255 core()->Connect(std::move(client_to_connect)); |
| 254 core()->StartRefreshScheduler(); | 256 core()->StartRefreshScheduler(); |
| 255 core()->StartRemoteCommandsService( | 257 core()->StartRemoteCommandsService(std::unique_ptr<RemoteCommandsFactory>( |
| 256 scoped_ptr<RemoteCommandsFactory>(new DeviceCommandsFactoryChromeOS())); | 258 new DeviceCommandsFactoryChromeOS())); |
| 257 core()->TrackRefreshDelayPref(local_state_, | 259 core()->TrackRefreshDelayPref(local_state_, |
| 258 prefs::kDevicePolicyRefreshRate); | 260 prefs::kDevicePolicyRefreshRate); |
| 259 attestation_policy_observer_.reset( | 261 attestation_policy_observer_.reset( |
| 260 new chromeos::attestation::AttestationPolicyObserver(client())); | 262 new chromeos::attestation::AttestationPolicyObserver(client())); |
| 261 | 263 |
| 262 // Enable device reporting and status monitoring for enterprise enrolled | 264 // Enable device reporting and status monitoring for enterprise enrolled |
| 263 // devices. We want to create these objects for enrolled devices, even if | 265 // devices. We want to create these objects for enrolled devices, even if |
| 264 // monitoring is currently inactive, in case monitoring is turned back on in | 266 // monitoring is currently inactive, in case monitoring is turned back on in |
| 265 // a future policy fetch - the classes themselves track the current state of | 267 // a future policy fetch - the classes themselves track the current state of |
| 266 // the monitoring settings and only perform monitoring if it is active. | 268 // the monitoring settings and only perform monitoring if it is active. |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 } | 342 } |
| 341 | 343 |
| 342 void DeviceCloudPolicyManagerChromeOS::NotifyDisconnected() { | 344 void DeviceCloudPolicyManagerChromeOS::NotifyDisconnected() { |
| 343 FOR_EACH_OBSERVER( | 345 FOR_EACH_OBSERVER( |
| 344 Observer, observers_, OnDeviceCloudPolicyManagerDisconnected()); | 346 Observer, observers_, OnDeviceCloudPolicyManagerDisconnected()); |
| 345 } | 347 } |
| 346 | 348 |
| 347 void DeviceCloudPolicyManagerChromeOS::CreateStatusUploader() { | 349 void DeviceCloudPolicyManagerChromeOS::CreateStatusUploader() { |
| 348 status_uploader_.reset(new StatusUploader( | 350 status_uploader_.reset(new StatusUploader( |
| 349 client(), | 351 client(), |
| 350 make_scoped_ptr(new DeviceStatusCollector( | 352 base::WrapUnique(new DeviceStatusCollector( |
| 351 local_state_, chromeos::system::StatisticsProvider::GetInstance(), | 353 local_state_, chromeos::system::StatisticsProvider::GetInstance(), |
| 352 DeviceStatusCollector::LocationUpdateRequester(), | 354 DeviceStatusCollector::LocationUpdateRequester(), |
| 353 DeviceStatusCollector::VolumeInfoFetcher(), | 355 DeviceStatusCollector::VolumeInfoFetcher(), |
| 354 DeviceStatusCollector::CPUStatisticsFetcher(), | 356 DeviceStatusCollector::CPUStatisticsFetcher(), |
| 355 DeviceStatusCollector::CPUTempFetcher())), | 357 DeviceStatusCollector::CPUTempFetcher())), |
| 356 task_runner_)); | 358 task_runner_)); |
| 357 } | 359 } |
| 358 | 360 |
| 359 } // namespace policy | 361 } // namespace policy |
| OLD | NEW |