Chromium Code Reviews| 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..26855e36f6f4ba3aaaf1860ae09392a236a21d45 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; |
|
Joao da Silva
2012/09/07 14:01:42
nit: one space after return
Mattias Nissler (ping if slow)
2012/10/23 15:30:41
Done.
|
| +} |
| + |
| +} // 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), |
| @@ -168,10 +187,14 @@ void CloudPolicyClient::SetPolicyType(em::PolicyFetchRequest* request) const { |
| void CloudPolicyClient::OnRegisterCompleted( |
| DeviceManagementStatus status, |
| const em::DeviceManagementResponse& response) { |
| + device_mode_ = TranslateProtobufDeviceMode( |
| + response.register_response().enrollment_type()); |
| if (status == DM_STATUS_SUCCESS && |
| (!response.has_register_response() || |
| - !response.register_response().has_device_management_token())) { |
| - LOG(WARNING) << "Empty registration response."; |
| + !response.register_response().has_device_management_token() || |
| + (device_mode_ != DEVICE_MODE_ENTERPRISE && |
| + device_mode_ != DEVICE_MODE_KIOSK))) { |
|
pastarmovj
2012/09/07 12:16:27
I know that this check is happening only once but
Joao da Silva
2012/09/07 14:01:42
Please add a comment explaining what the device_mo
Mattias Nissler (ping if slow)
2012/10/23 15:30:41
Done.
Mattias Nissler (ping if slow)
2012/10/23 15:30:41
I thought about this some more and ended up re-str
|
| + LOG(WARNING) << "Invalid registration response."; |
| status = DM_STATUS_RESPONSE_DECODING_ERROR; |
| } |