Chromium Code Reviews| 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/server_backed_state_keys_broker.h" | 21 #include "chrome/browser/chromeos/policy/server_backed_state_keys_broker.h" |
| 20 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 21 #include "chromeos/chromeos_constants.h" | 23 #include "chromeos/chromeos_constants.h" |
| 22 #include "chromeos/chromeos_switches.h" | 24 #include "chromeos/chromeos_switches.h" |
| 23 #include "chromeos/system/statistics_provider.h" | 25 #include "chromeos/system/statistics_provider.h" |
| 26 #include "components/policy/core/common/cloud/cloud_policy_service.h" | |
| 24 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 27 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
| 25 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
| 26 #include "crypto/sha2.h" | 29 #include "crypto/sha2.h" |
| 27 #include "policy/proto/device_management_backend.pb.h" | 30 #include "policy/proto/device_management_backend.pb.h" |
| 28 #include "url/gurl.h" | 31 #include "url/gurl.h" |
| 29 | 32 |
| 30 using content::BrowserThread; | 33 using content::BrowserThread; |
| 31 | 34 |
| 32 namespace em = enterprise_management; | 35 namespace em = enterprise_management; |
| 33 | 36 |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 core()->Connect(client_to_connect.Pass()); | 230 core()->Connect(client_to_connect.Pass()); |
| 228 core()->StartRefreshScheduler(); | 231 core()->StartRefreshScheduler(); |
| 229 core()->TrackRefreshDelayPref(local_state_, | 232 core()->TrackRefreshDelayPref(local_state_, |
| 230 prefs::kDevicePolicyRefreshRate); | 233 prefs::kDevicePolicyRefreshRate); |
| 231 attestation_policy_observer_.reset( | 234 attestation_policy_observer_.reset( |
| 232 new chromeos::attestation::AttestationPolicyObserver(client())); | 235 new chromeos::attestation::AttestationPolicyObserver(client())); |
| 233 | 236 |
| 234 NotifyConnected(); | 237 NotifyConnected(); |
| 235 } | 238 } |
| 236 | 239 |
| 240 void DeviceCloudPolicyManagerChromeOS::Unregister( | |
| 241 const base::Callback<void(bool)>& callback) { | |
| 242 if (!service()) { | |
| 243 LOG(ERROR) << "Tried to unregister but DeviceCloudPolicyManagerChromeOS is " | |
| 244 << "not connected."; | |
| 245 callback.Run(false); | |
| 246 return; | |
| 247 } | |
| 248 | |
| 249 service()->Unregister(callback); | |
| 250 } | |
| 251 | |
| 252 void DeviceCloudPolicyManagerChromeOS::Disconnect() { | |
| 253 core()->Disconnect(); | |
|
bartfab (slow)
2014/11/28 13:25:18
Nit: #include "components/policy/core/common/cloud
davidyu
2014/12/01 17:05:22
Done.
| |
| 254 | |
| 255 NotifyDisconnected(); | |
| 256 } | |
| 257 | |
| 237 void DeviceCloudPolicyManagerChromeOS::OnStateKeysUpdated() { | 258 void DeviceCloudPolicyManagerChromeOS::OnStateKeysUpdated() { |
| 238 if (client() && ForcedReEnrollmentEnabled()) | 259 if (client() && ForcedReEnrollmentEnabled()) |
| 239 client()->SetStateKeysToUpload(state_keys_broker_->state_keys()); | 260 client()->SetStateKeysToUpload(state_keys_broker_->state_keys()); |
| 240 } | 261 } |
| 241 | 262 |
| 242 void DeviceCloudPolicyManagerChromeOS::InitializeRequisition() { | 263 void DeviceCloudPolicyManagerChromeOS::InitializeRequisition() { |
| 243 // OEM statistics are only loaded when OOBE is not completed. | 264 // OEM statistics are only loaded when OOBE is not completed. |
| 244 if (chromeos::StartupUtils::IsOobeCompleted()) | 265 if (chromeos::StartupUtils::IsOobeCompleted()) |
| 245 return; | 266 return; |
| 246 | 267 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 269 } | 290 } |
| 270 } | 291 } |
| 271 } | 292 } |
| 272 } | 293 } |
| 273 | 294 |
| 274 void DeviceCloudPolicyManagerChromeOS::NotifyConnected() { | 295 void DeviceCloudPolicyManagerChromeOS::NotifyConnected() { |
| 275 FOR_EACH_OBSERVER( | 296 FOR_EACH_OBSERVER( |
| 276 Observer, observers_, OnDeviceCloudPolicyManagerConnected()); | 297 Observer, observers_, OnDeviceCloudPolicyManagerConnected()); |
| 277 } | 298 } |
| 278 | 299 |
| 300 void DeviceCloudPolicyManagerChromeOS::NotifyDisconnected() { | |
| 301 FOR_EACH_OBSERVER( | |
| 302 Observer, observers_, OnDeviceCloudPolicyManagerDisconnected()); | |
| 303 } | |
| 304 | |
| 279 } // namespace policy | 305 } // namespace policy |
| OLD | NEW |