| 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/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/logging.h" |
| 10 #include "base/port.h" | 12 #include "base/port.h" |
| 11 #include "base/prefs/pref_registry_simple.h" | 13 #include "base/prefs/pref_registry_simple.h" |
| 12 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
| 13 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 15 #include "chrome/browser/chromeos/attestation/attestation_policy_observer.h" | 17 #include "chrome/browser/chromeos/attestation/attestation_policy_observer.h" |
| 16 #include "chrome/browser/chromeos/login/enrollment/auto_enrollment_controller.h" | 18 #include "chrome/browser/chromeos/login/enrollment/auto_enrollment_controller.h" |
| 17 #include "chrome/browser/chromeos/login/startup_utils.h" | 19 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 18 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" | 20 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" |
| 19 #include "chrome/browser/chromeos/policy/device_status_collector.h" | 21 #include "chrome/browser/chromeos/policy/device_status_collector.h" |
| 20 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" | 22 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" |
| 21 #include "chrome/browser/chromeos/policy/server_backed_state_keys_broker.h" | 23 #include "chrome/browser/chromeos/policy/server_backed_state_keys_broker.h" |
| 22 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
| 23 #include "chromeos/chromeos_constants.h" | 25 #include "chromeos/chromeos_constants.h" |
| 24 #include "chromeos/chromeos_switches.h" | 26 #include "chromeos/chromeos_switches.h" |
| 25 #include "chromeos/system/statistics_provider.h" | 27 #include "chromeos/system/statistics_provider.h" |
| 28 #include "components/policy/core/common/cloud/cloud_policy_core.h" |
| 29 #include "components/policy/core/common/cloud/cloud_policy_service.h" |
| 26 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 30 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
| 27 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
| 28 #include "crypto/sha2.h" | 32 #include "crypto/sha2.h" |
| 29 #include "policy/proto/device_management_backend.pb.h" | 33 #include "policy/proto/device_management_backend.pb.h" |
| 30 #include "url/gurl.h" | 34 #include "url/gurl.h" |
| 31 | 35 |
| 32 using content::BrowserThread; | 36 using content::BrowserThread; |
| 33 | 37 |
| 34 namespace em = enterprise_management; | 38 namespace em = enterprise_management; |
| 35 | 39 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 core()->Connect(client_to_connect.Pass()); | 244 core()->Connect(client_to_connect.Pass()); |
| 241 core()->StartRefreshScheduler(); | 245 core()->StartRefreshScheduler(); |
| 242 core()->TrackRefreshDelayPref(local_state_, | 246 core()->TrackRefreshDelayPref(local_state_, |
| 243 prefs::kDevicePolicyRefreshRate); | 247 prefs::kDevicePolicyRefreshRate); |
| 244 attestation_policy_observer_.reset( | 248 attestation_policy_observer_.reset( |
| 245 new chromeos::attestation::AttestationPolicyObserver(client())); | 249 new chromeos::attestation::AttestationPolicyObserver(client())); |
| 246 | 250 |
| 247 NotifyConnected(); | 251 NotifyConnected(); |
| 248 } | 252 } |
| 249 | 253 |
| 254 void DeviceCloudPolicyManagerChromeOS::Unregister( |
| 255 const UnregisterCallback& callback) { |
| 256 if (!service()) { |
| 257 LOG(ERROR) << "Tried to unregister but DeviceCloudPolicyManagerChromeOS is " |
| 258 << "not connected."; |
| 259 callback.Run(false); |
| 260 return; |
| 261 } |
| 262 |
| 263 service()->Unregister(callback); |
| 264 } |
| 265 |
| 266 void DeviceCloudPolicyManagerChromeOS::Disconnect() { |
| 267 core()->Disconnect(); |
| 268 |
| 269 NotifyDisconnected(); |
| 270 } |
| 271 |
| 250 void DeviceCloudPolicyManagerChromeOS::OnStateKeysUpdated() { | 272 void DeviceCloudPolicyManagerChromeOS::OnStateKeysUpdated() { |
| 251 if (client() && ForcedReEnrollmentEnabled()) | 273 if (client() && ForcedReEnrollmentEnabled()) |
| 252 client()->SetStateKeysToUpload(state_keys_broker_->state_keys()); | 274 client()->SetStateKeysToUpload(state_keys_broker_->state_keys()); |
| 253 } | 275 } |
| 254 | 276 |
| 255 void DeviceCloudPolicyManagerChromeOS::InitializeRequisition() { | 277 void DeviceCloudPolicyManagerChromeOS::InitializeRequisition() { |
| 256 // OEM statistics are only loaded when OOBE is not completed. | 278 // OEM statistics are only loaded when OOBE is not completed. |
| 257 if (chromeos::StartupUtils::IsOobeCompleted()) | 279 if (chromeos::StartupUtils::IsOobeCompleted()) |
| 258 return; | 280 return; |
| 259 | 281 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 282 } | 304 } |
| 283 } | 305 } |
| 284 } | 306 } |
| 285 } | 307 } |
| 286 | 308 |
| 287 void DeviceCloudPolicyManagerChromeOS::NotifyConnected() { | 309 void DeviceCloudPolicyManagerChromeOS::NotifyConnected() { |
| 288 FOR_EACH_OBSERVER( | 310 FOR_EACH_OBSERVER( |
| 289 Observer, observers_, OnDeviceCloudPolicyManagerConnected()); | 311 Observer, observers_, OnDeviceCloudPolicyManagerConnected()); |
| 290 } | 312 } |
| 291 | 313 |
| 314 void DeviceCloudPolicyManagerChromeOS::NotifyDisconnected() { |
| 315 FOR_EACH_OBSERVER( |
| 316 Observer, observers_, OnDeviceCloudPolicyManagerDisconnected()); |
| 317 } |
| 318 |
| 292 } // namespace policy | 319 } // namespace policy |
| OLD | NEW |