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

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

Issue 9403010: Add support for kiosk mode on the client. Make sure the settings are written in the lockbox. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Made registration fail on missing enrollment type. Created 8 years, 10 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_token_fetcher.cc
diff --git a/chrome/browser/policy/device_token_fetcher.cc b/chrome/browser/policy/device_token_fetcher.cc
index 3faf3e1a5b61b3045349f3dcfe45a413c735ac62..377f674e49c37f4f7ed57a204b14eca68dd8c83c 100644
--- a/chrome/browser/policy/device_token_fetcher.cc
+++ b/chrome/browser/policy/device_token_fetcher.cc
@@ -14,10 +14,13 @@
#include "chrome/browser/policy/cloud_policy_data_store.h"
#include "chrome/browser/policy/delayed_work_scheduler.h"
#include "chrome/browser/policy/device_management_service.h"
+#include "chrome/browser/policy/enterprise_install_attributes.h"
#include "chrome/browser/policy/enterprise_metrics.h"
#include "chrome/browser/policy/policy_notifier.h"
#include "chrome/browser/policy/proto/device_management_local.pb.h"
+namespace em = enterprise_management;
+
namespace policy {
namespace {
@@ -71,9 +74,21 @@ void SampleErrorStatus(DeviceManagementStatus status) {
NOTREACHED();
}
-} // namespace
+// Translates the DeviceRegisterResponse::DeviceMode |mode| to the enum used
+// internally throughout ChromeOS to represent different device modes.
+EnterpriseInstallAttributes::DeviceMode
+ TranslateProtobufDeviceMode(em::DeviceRegisterResponse::DeviceMode mode) {
+ switch (mode) {
+ case em::DeviceRegisterResponse::ENTERPRISE:
+ return EnterpriseInstallAttributes::DEVICE_MODE_ENTERPRISE;
+ case em::DeviceRegisterResponse::KIOSK:
+ return EnterpriseInstallAttributes::DEVICE_MODE_KIOSK;
+ }
+ LOG(ERROR) << "Unknown enrollment mode in registration response: " << mode;
+ return EnterpriseInstallAttributes::DEVICE_MODE_UNKNOWN;
+}
-namespace em = enterprise_management;
+} // namespace
DeviceTokenFetcher::DeviceTokenFetcher(
DeviceManagementService* service,
@@ -187,6 +202,19 @@ void DeviceTokenFetcher::OnTokenFetchCompleted(
if (register_response.has_device_management_token()) {
UMA_HISTOGRAM_ENUMERATION(kMetricToken, kMetricTokenFetchOK,
kMetricTokenSize);
+
+ EnterpriseInstallAttributes::DeviceMode mode =
+ EnterpriseInstallAttributes::DEVICE_MODE_UNKNOWN;
+ if (register_response.has_enrollment_type()) {
+ mode =
+ TranslateProtobufDeviceMode(register_response.enrollment_type());
+ }
+ if (mode == EnterpriseInstallAttributes::DEVICE_MODE_UNKNOWN) {
+ LOG(ERROR) << "Enrollment mode missing or unknown!";
+ SetState(STATE_BAD_ENROLLMENT_MODE);
+ return;
+ }
+ data_store_->set_device_mode(mode);
data_store_->SetDeviceToken(register_response.device_management_token(),
false);
SetState(STATE_TOKEN_AVAILABLE);
@@ -251,6 +279,11 @@ void DeviceTokenFetcher::SetState(FetcherState state) {
CloudPolicySubsystem::BAD_SERIAL_NUMBER,
PolicyNotifier::TOKEN_FETCHER);
break;
+ case STATE_BAD_ENROLLMENT_MODE:
+ notifier_->Inform(CloudPolicySubsystem::UNENROLLED,
+ CloudPolicySubsystem::BAD_ENROLLMENT_MODE,
+ PolicyNotifier::TOKEN_FETCHER);
+ break;
case STATE_UNMANAGED:
delayed_work_at = cache_->last_policy_refresh_time() +
base::TimeDelta::FromMilliseconds(
@@ -306,6 +339,7 @@ void DeviceTokenFetcher::DoWork() {
case STATE_INACTIVE:
case STATE_TOKEN_AVAILABLE:
case STATE_BAD_SERIAL:
+ case STATE_BAD_ENROLLMENT_MODE:
break;
case STATE_UNMANAGED:
case STATE_ERROR:

Powered by Google App Engine
This is Rietveld 408576698