| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/prefs/pref_registry_simple.h" | 12 #include "base/prefs/pref_registry_simple.h" |
| 13 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
| 14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/chromeos/attestation/attestation_policy_observer.h" | 17 #include "chrome/browser/chromeos/attestation/attestation_policy_observer.h" |
| 18 #include "chrome/browser/chromeos/login/enrollment/auto_enrollment_controller.h" | 18 #include "chrome/browser/chromeos/login/enrollment/auto_enrollment_controller.h" |
| 19 #include "chrome/browser/chromeos/login/startup_utils.h" | 19 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 20 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" | 20 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" |
| 21 #include "chrome/browser/chromeos/policy/device_status_collector.h" | 21 #include "chrome/browser/chromeos/policy/device_status_collector.h" |
| 22 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" | 22 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" |
| 23 #include "chrome/browser/chromeos/policy/heartbeat_scheduler.h" | 23 #include "chrome/browser/chromeos/policy/heartbeat_scheduler.h" |
| 24 #include "chrome/browser/chromeos/policy/remote_commands/device_commands_factory
_chromeos.h" | 24 #include "chrome/browser/chromeos/policy/remote_commands/device_commands_factory
_chromeos.h" |
| 25 #include "chrome/browser/chromeos/policy/server_backed_state_keys_broker.h" | 25 #include "chrome/browser/chromeos/policy/server_backed_state_keys_broker.h" |
| 26 #include "chrome/browser/chromeos/policy/status_uploader.h" | 26 #include "chrome/browser/chromeos/policy/status_uploader.h" |
| 27 #include "chrome/browser/chromeos/policy/system_log_uploader.h" |
| 27 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
| 28 #include "chromeos/chromeos_constants.h" | 29 #include "chromeos/chromeos_constants.h" |
| 29 #include "chromeos/chromeos_switches.h" | 30 #include "chromeos/chromeos_switches.h" |
| 30 #include "chromeos/system/statistics_provider.h" | 31 #include "chromeos/system/statistics_provider.h" |
| 31 #include "components/policy/core/common/cloud/cloud_policy_core.h" | 32 #include "components/policy/core/common/cloud/cloud_policy_core.h" |
| 32 #include "components/policy/core/common/cloud/cloud_policy_service.h" | 33 #include "components/policy/core/common/cloud/cloud_policy_service.h" |
| 33 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 34 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
| 34 #include "components/policy/core/common/remote_commands/remote_commands_factory.
h" | 35 #include "components/policy/core/common/remote_commands/remote_commands_factory.
h" |
| 35 #include "content/public/browser/browser_thread.h" | 36 #include "content/public/browser/browser_thread.h" |
| 36 #include "crypto/sha2.h" | 37 #include "crypto/sha2.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 bool DeviceCloudPolicyManagerChromeOS::IsRemoraRequisition() const { | 183 bool DeviceCloudPolicyManagerChromeOS::IsRemoraRequisition() const { |
| 183 return GetDeviceRequisition() == kRemoraRequisition; | 184 return GetDeviceRequisition() == kRemoraRequisition; |
| 184 } | 185 } |
| 185 | 186 |
| 186 bool DeviceCloudPolicyManagerChromeOS::IsSharkRequisition() const { | 187 bool DeviceCloudPolicyManagerChromeOS::IsSharkRequisition() const { |
| 187 return GetDeviceRequisition() == kSharkRequisition; | 188 return GetDeviceRequisition() == kSharkRequisition; |
| 188 } | 189 } |
| 189 | 190 |
| 190 void DeviceCloudPolicyManagerChromeOS::Shutdown() { | 191 void DeviceCloudPolicyManagerChromeOS::Shutdown() { |
| 191 status_uploader_.reset(); | 192 status_uploader_.reset(); |
| 193 syslog_uploader_.reset(); |
| 192 heartbeat_scheduler_.reset(); | 194 heartbeat_scheduler_.reset(); |
| 193 state_keys_update_subscription_.reset(); | 195 state_keys_update_subscription_.reset(); |
| 194 CloudPolicyManager::Shutdown(); | 196 CloudPolicyManager::Shutdown(); |
| 195 } | 197 } |
| 196 | 198 |
| 197 // static | 199 // static |
| 198 void DeviceCloudPolicyManagerChromeOS::RegisterPrefs( | 200 void DeviceCloudPolicyManagerChromeOS::RegisterPrefs( |
| 199 PrefRegistrySimple* registry) { | 201 PrefRegistrySimple* registry) { |
| 200 registry->RegisterStringPref(prefs::kDeviceEnrollmentRequisition, | 202 registry->RegisterStringPref(prefs::kDeviceEnrollmentRequisition, |
| 201 std::string()); | 203 std::string()); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 attestation_policy_observer_.reset( | 248 attestation_policy_observer_.reset( |
| 247 new chromeos::attestation::AttestationPolicyObserver(client())); | 249 new chromeos::attestation::AttestationPolicyObserver(client())); |
| 248 | 250 |
| 249 // Enable device reporting and status monitoring for enterprise enrolled | 251 // Enable device reporting and status monitoring for enterprise enrolled |
| 250 // devices. We want to create these objects for enrolled devices, even if | 252 // devices. We want to create these objects for enrolled devices, even if |
| 251 // monitoring is currently inactive, in case monitoring is turned back on in | 253 // monitoring is currently inactive, in case monitoring is turned back on in |
| 252 // a future policy fetch - the classes themselves track the current state of | 254 // a future policy fetch - the classes themselves track the current state of |
| 253 // the monitoring settings and only perform monitoring if it is active. | 255 // the monitoring settings and only perform monitoring if it is active. |
| 254 if (install_attributes->IsEnterpriseDevice()) { | 256 if (install_attributes->IsEnterpriseDevice()) { |
| 255 CreateStatusUploader(); | 257 CreateStatusUploader(); |
| 258 syslog_uploader_.reset(new SystemLogUploader(nullptr, task_runner_)); |
| 256 heartbeat_scheduler_.reset( | 259 heartbeat_scheduler_.reset( |
| 257 new HeartbeatScheduler(g_browser_process->gcm_driver(), | 260 new HeartbeatScheduler(g_browser_process->gcm_driver(), |
| 258 install_attributes->GetDomain(), | 261 install_attributes->GetDomain(), |
| 259 install_attributes->GetDeviceId(), | 262 install_attributes->GetDeviceId(), |
| 260 task_runner_)); | 263 task_runner_)); |
| 261 } | 264 } |
| 262 | 265 |
| 263 NotifyConnected(); | 266 NotifyConnected(); |
| 264 } | 267 } |
| 265 | 268 |
| 266 void DeviceCloudPolicyManagerChromeOS::Unregister( | 269 void DeviceCloudPolicyManagerChromeOS::Unregister( |
| 267 const UnregisterCallback& callback) { | 270 const UnregisterCallback& callback) { |
| 268 if (!service()) { | 271 if (!service()) { |
| 269 LOG(ERROR) << "Tried to unregister but DeviceCloudPolicyManagerChromeOS is " | 272 LOG(ERROR) << "Tried to unregister but DeviceCloudPolicyManagerChromeOS is " |
| 270 << "not connected."; | 273 << "not connected."; |
| 271 callback.Run(false); | 274 callback.Run(false); |
| 272 return; | 275 return; |
| 273 } | 276 } |
| 274 | 277 |
| 275 service()->Unregister(callback); | 278 service()->Unregister(callback); |
| 276 } | 279 } |
| 277 | 280 |
| 278 void DeviceCloudPolicyManagerChromeOS::Disconnect() { | 281 void DeviceCloudPolicyManagerChromeOS::Disconnect() { |
| 279 status_uploader_.reset(); | 282 status_uploader_.reset(); |
| 283 syslog_uploader_.reset(); |
| 280 heartbeat_scheduler_.reset(); | 284 heartbeat_scheduler_.reset(); |
| 281 core()->Disconnect(); | 285 core()->Disconnect(); |
| 282 | 286 |
| 283 NotifyDisconnected(); | 287 NotifyDisconnected(); |
| 284 } | 288 } |
| 285 | 289 |
| 286 void DeviceCloudPolicyManagerChromeOS::OnStateKeysUpdated() { | 290 void DeviceCloudPolicyManagerChromeOS::OnStateKeysUpdated() { |
| 287 if (client() && ForcedReEnrollmentEnabled()) | 291 if (client() && ForcedReEnrollmentEnabled()) |
| 288 client()->SetStateKeysToUpload(state_keys_broker_->state_keys()); | 292 client()->SetStateKeysToUpload(state_keys_broker_->state_keys()); |
| 289 } | 293 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 make_scoped_ptr(new DeviceStatusCollector( | 340 make_scoped_ptr(new DeviceStatusCollector( |
| 337 local_state_, chromeos::system::StatisticsProvider::GetInstance(), | 341 local_state_, chromeos::system::StatisticsProvider::GetInstance(), |
| 338 DeviceStatusCollector::LocationUpdateRequester(), | 342 DeviceStatusCollector::LocationUpdateRequester(), |
| 339 DeviceStatusCollector::VolumeInfoFetcher(), | 343 DeviceStatusCollector::VolumeInfoFetcher(), |
| 340 DeviceStatusCollector::CPUStatisticsFetcher(), | 344 DeviceStatusCollector::CPUStatisticsFetcher(), |
| 341 DeviceStatusCollector::CPUTempFetcher())), | 345 DeviceStatusCollector::CPUTempFetcher())), |
| 342 task_runner_)); | 346 task_runner_)); |
| 343 } | 347 } |
| 344 | 348 |
| 345 } // namespace policy | 349 } // namespace policy |
| OLD | NEW |