Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3406)

Unified Diff: chrome/browser/policy/device_cloud_policy_manager_chromeos.cc

Issue 10928036: Implement Chrome OS device enrollment on the new cloud policy stack. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/device_cloud_policy_manager_chromeos.cc
diff --git a/chrome/browser/policy/device_cloud_policy_manager_chromeos.cc b/chrome/browser/policy/device_cloud_policy_manager_chromeos.cc
index 18af570b9bb62f53f52b58e2fa5b2f028f0ac9d7..20a547cd6c88b4d52c214291ee52184a7456588b 100644
--- a/chrome/browser/policy/device_cloud_policy_manager_chromeos.cc
+++ b/chrome/browser/policy/device_cloud_policy_manager_chromeos.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/policy/cloud_policy_client.h"
#include "chrome/browser/policy/device_cloud_policy_store_chromeos.h"
#include "chrome/browser/policy/device_management_service.h"
+#include "chrome/browser/policy/enrollment_handler_chromeos.h"
#include "chrome/browser/policy/enterprise_install_attributes.h"
#include "chrome/common/pref_names.h"
@@ -70,9 +71,31 @@ void DeviceCloudPolicyManagerChromeOS::Initialize(
}
void DeviceCloudPolicyManagerChromeOS::Shutdown() {
+ enrollment_handler_.reset();
ShutdownService();
}
+void DeviceCloudPolicyManagerChromeOS::StartEnrollment(
+ const std::string& auth_token,
+ const EnrollmentCallback& callback) {
+ CHECK(device_management_service_);
+ ShutdownService();
+
+ enrollment_handler_.reset(
+ new EnrollmentHandlerChromeOS(
+ device_store_, install_attributes_, CreateClient(), auth_token,
+ base::Bind(&DeviceCloudPolicyManagerChromeOS::EnrollmentCompleted,
+ base::Unretained(this), callback)));
+ enrollment_handler_->StartEnrollment();
+}
+
+void DeviceCloudPolicyManagerChromeOS::CancelEnrollment() {
+ if (enrollment_handler_.get()) {
+ enrollment_handler_.reset();
+ StartIfInitialized();
Joao da Silva 2012/09/07 14:01:42 Why? Is this for the re-enrollment case?
Mattias Nissler (ping if slow) 2012/10/23 15:30:41 Yes. Also, for robustness. While enrollment is on,
+ }
+}
+
// static
std::string DeviceCloudPolicyManagerChromeOS::GetMachineID() {
std::string machine_id;
@@ -106,7 +129,7 @@ std::string DeviceCloudPolicyManagerChromeOS::GetMachineModel() {
void DeviceCloudPolicyManagerChromeOS::OnStoreLoaded(CloudPolicyStore* store) {
CloudPolicyManager::OnStoreLoaded(store);
- if (device_management_service_ && local_state_)
+ if (!enrollment_handler_.get() && device_management_service_ && local_state_)
StartIfInitialized();
}
@@ -117,6 +140,24 @@ scoped_ptr<CloudPolicyClient> DeviceCloudPolicyManagerChromeOS::CreateClient() {
device_management_service_));
}
+void DeviceCloudPolicyManagerChromeOS::EnrollmentCompleted(
+ const EnrollmentCallback& callback,
+ EnrollmentStatus status,
+ DeviceManagementStatus dm_status,
+ CloudPolicyValidatorBase::Status validator_status,
+ CloudPolicyStore::Status store_status) {
+ if (status == ENROLLMENT_STATUS_SUCCESS) {
+ InitializeService(enrollment_handler_->ReleaseClient());
+ StartRefreshScheduler(local_state_, prefs::kDevicePolicyRefreshRate);
+ } else {
+ StartIfInitialized();
+ }
+
+ enrollment_handler_.reset();
+ if (!callback.is_null())
+ callback.Run(status, dm_status, validator_status, store_status);
+}
+
void DeviceCloudPolicyManagerChromeOS::StartIfInitialized() {
if (cloud_policy_store()->is_initialized() &&
cloud_policy_store()->has_policy()) {

Powered by Google App Engine
This is Rietveld 408576698