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

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: Addressed comments, rebased. Created 8 years, 2 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 80da7b60bb02d58fe8e96c05d15cdad0eb2c8083..7ac9b9c854635bd98775e30883ca3f99c2a31eda 100644
--- a/chrome/browser/policy/device_cloud_policy_manager_chromeos.cc
+++ b/chrome/browser/policy/device_cloud_policy_manager_chromeos.cc
@@ -4,10 +4,13 @@
#include "chrome/browser/policy/device_cloud_policy_manager_chromeos.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "chrome/browser/chromeos/system/statistics_provider.h"
#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"
@@ -67,10 +70,34 @@ void DeviceCloudPolicyManagerChromeOS::Connect(
StartIfManaged();
}
+void DeviceCloudPolicyManagerChromeOS::StartEnrollment(
+ const std::string& auth_token,
+ const AllowedDeviceModes& allowed_device_modes,
+ const EnrollmentCallback& callback) {
+ CHECK(device_management_service_);
+ ShutdownService();
+
+ enrollment_handler_.reset(
+ new EnrollmentHandlerChromeOS(
+ device_store_, install_attributes_, CreateClient(), auth_token,
+ allowed_device_modes,
+ base::Bind(&DeviceCloudPolicyManagerChromeOS::EnrollmentCompleted,
+ base::Unretained(this), callback)));
+ enrollment_handler_->StartEnrollment();
+}
+
+void DeviceCloudPolicyManagerChromeOS::CancelEnrollment() {
+ if (enrollment_handler_.get()) {
+ enrollment_handler_.reset();
+ StartIfManaged();
+ }
+}
+
void DeviceCloudPolicyManagerChromeOS::OnStoreLoaded(CloudPolicyStore* store) {
CloudPolicyManager::OnStoreLoaded(store);
- StartIfManaged();
+ if (!enrollment_handler_.get())
+ StartIfManaged();
}
// static
@@ -110,6 +137,21 @@ scoped_ptr<CloudPolicyClient> DeviceCloudPolicyManagerChromeOS::CreateClient() {
device_management_service_));
}
+void DeviceCloudPolicyManagerChromeOS::EnrollmentCompleted(
+ const EnrollmentCallback& callback,
+ EnrollmentStatus status) {
+ if (status.status() == EnrollmentStatus::STATUS_SUCCESS) {
pastarmovj 2012/10/23 15:58:08 Isn't it possible to call StartIfManaged() uncondi
Mattias Nissler (ping if slow) 2012/10/23 16:33:03 No, in this case we want to reuse the client. I gu
+ InitializeService(enrollment_handler_->ReleaseClient());
+ StartRefreshScheduler(local_state_, prefs::kDevicePolicyRefreshRate);
+ } else {
+ StartIfManaged();
+ }
+
+ enrollment_handler_.reset();
+ if (!callback.is_null())
+ callback.Run(status);
+}
+
void DeviceCloudPolicyManagerChromeOS::StartIfManaged() {
if (device_management_service_ &&
local_state_ &&

Powered by Google App Engine
This is Rietveld 408576698