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

Unified Diff: chrome/browser/policy/cloud_policy_client.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: fix some build glitches. 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/cloud_policy_client.cc
diff --git a/chrome/browser/policy/cloud_policy_client.cc b/chrome/browser/policy/cloud_policy_client.cc
index 6a27d06f0d4bbb3f545641f403607d88867afd48..2920072f4c532d45ae83f72da0f42b8f920139d1 100644
--- a/chrome/browser/policy/cloud_policy_client.cc
+++ b/chrome/browser/policy/cloud_policy_client.cc
@@ -14,6 +14,24 @@ namespace em = enterprise_management;
namespace policy {
+namespace {
+
+// Translates the DeviceRegisterResponse::DeviceMode |mode| to the enum used
+// internally to represent different device modes.
+DeviceMode TranslateProtobufDeviceMode(
+ em::DeviceRegisterResponse::DeviceMode mode) {
+ switch (mode) {
+ case em::DeviceRegisterResponse::ENTERPRISE:
+ return DEVICE_MODE_ENTERPRISE;
+ case em::DeviceRegisterResponse::RETAIL:
+ return DEVICE_MODE_KIOSK;
+ }
+ LOG(ERROR) << "Unknown enrollment mode in registration response: " << mode;
+ return DEVICE_MODE_NOT_SET;
+}
+
+} // namespace
+
CloudPolicyClient::Observer::~Observer() {}
CloudPolicyClient::StatusProvider::~StatusProvider() {}
@@ -28,6 +46,7 @@ CloudPolicyClient::CloudPolicyClient(const std::string& machine_id,
machine_model_(machine_model),
user_affiliation_(user_affiliation),
scope_(scope),
+ device_mode_(DEVICE_MODE_NOT_SET),
submit_machine_id_(false),
public_key_version_(-1),
public_key_version_valid_(false),
@@ -169,15 +188,24 @@ void CloudPolicyClient::OnRegisterCompleted(
DeviceManagementStatus status,
const em::DeviceManagementResponse& response) {
if (status == DM_STATUS_SUCCESS &&
- (!response.has_register_response() ||
- !response.register_response().has_device_management_token())) {
- LOG(WARNING) << "Empty registration response.";
+ !(response.has_register_response() ||
+ response.register_response().has_device_management_token())) {
Joao da Silva 2012/10/23 18:58:50 The previous logic was correct. This will ref regi
Mattias Nissler (ping if slow) 2012/10/24 10:33:18 Reverted, I find the old version actually easier t
+ LOG(WARNING) << "Invalid registration response.";
status = DM_STATUS_RESPONSE_DECODING_ERROR;
}
status_ = status;
if (status == DM_STATUS_SUCCESS) {
dm_token_ = response.register_response().device_management_token();
+
+ // Device mode is only relevant for device policy really, it's the
+ // responsibility of the consumer of the field to check validity.
+ device_mode_ = DEVICE_MODE_NOT_SET;
+ if (response.register_response().has_enrollment_type()) {
+ device_mode_ = TranslateProtobufDeviceMode(
+ response.register_response().enrollment_type());
+ }
+
NotifyRegistrationStateChanged();
} else {
NotifyClientError();

Powered by Google App Engine
This is Rietveld 408576698