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