| 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 core()->Connect(client_to_connect.Pass()); | 245 core()->Connect(client_to_connect.Pass()); |
| 242 core()->StartRefreshScheduler(); | 246 core()->StartRefreshScheduler(); |
| 243 core()->TrackRefreshDelayPref(local_state_, | 247 core()->TrackRefreshDelayPref(local_state_, |
| 244 prefs::kDevicePolicyRefreshRate); | 248 prefs::kDevicePolicyRefreshRate); |
| 245 attestation_policy_observer_.reset( | 249 attestation_policy_observer_.reset( |
| 246 new chromeos::attestation::AttestationPolicyObserver(client())); | 250 new chromeos::attestation::AttestationPolicyObserver(client())); |
| 247 | 251 |
| 248 NotifyConnected(); | 252 NotifyConnected(); |
| 249 } | 253 } |
| 250 | 254 |
| 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 |
| 251 void DeviceCloudPolicyManagerChromeOS::OnStateKeysUpdated() { | 273 void DeviceCloudPolicyManagerChromeOS::OnStateKeysUpdated() { |
| 252 if (client() && ForcedReEnrollmentEnabled()) | 274 if (client() && ForcedReEnrollmentEnabled()) |
| 253 client()->SetStateKeysToUpload(state_keys_broker_->state_keys()); | 275 client()->SetStateKeysToUpload(state_keys_broker_->state_keys()); |
| 254 } | 276 } |
| 255 | 277 |
| 256 void DeviceCloudPolicyManagerChromeOS::InitializeRequisition() { | 278 void DeviceCloudPolicyManagerChromeOS::InitializeRequisition() { |
| 257 // OEM statistics are only loaded when OOBE is not completed. | 279 // OEM statistics are only loaded when OOBE is not completed. |
| 258 if (chromeos::StartupUtils::IsOobeCompleted()) | 280 if (chromeos::StartupUtils::IsOobeCompleted()) |
| 259 return; | 281 return; |
| 260 | 282 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 283 } | 305 } |
| 284 } | 306 } |
| 285 } | 307 } |
| 286 } | 308 } |
| 287 | 309 |
| 288 void DeviceCloudPolicyManagerChromeOS::NotifyConnected() { | 310 void DeviceCloudPolicyManagerChromeOS::NotifyConnected() { |
| 289 FOR_EACH_OBSERVER( | 311 FOR_EACH_OBSERVER( |
| 290 Observer, observers_, OnDeviceCloudPolicyManagerConnected()); | 312 Observer, observers_, OnDeviceCloudPolicyManagerConnected()); |
| 291 } | 313 } |
| 292 | 314 |
| 315 void DeviceCloudPolicyManagerChromeOS::NotifyDisconnected() { |
| 316 FOR_EACH_OBSERVER( |
| 317 Observer, observers_, OnDeviceCloudPolicyManagerDisconnected()); |
| 318 } |
| 319 |
| 293 } // namespace policy | 320 } // namespace policy |
| OLD | NEW |