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

Side by Side 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: Addressed comments and added more tests. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/policy/device_token_fetcher.h" 5 #include "chrome/browser/policy/device_token_fetcher.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/time.h" 11 #include "base/time.h"
12 #include "chrome/browser/policy/cloud_policy_cache_base.h" 12 #include "chrome/browser/policy/cloud_policy_cache_base.h"
13 #include "chrome/browser/policy/cloud_policy_constants.h" 13 #include "chrome/browser/policy/cloud_policy_constants.h"
14 #include "chrome/browser/policy/cloud_policy_data_store.h" 14 #include "chrome/browser/policy/cloud_policy_data_store.h"
15 #include "chrome/browser/policy/delayed_work_scheduler.h" 15 #include "chrome/browser/policy/delayed_work_scheduler.h"
16 #include "chrome/browser/policy/device_management_service.h" 16 #include "chrome/browser/policy/device_management_service.h"
17 #include "chrome/browser/policy/enterprise_install_attributes.h"
17 #include "chrome/browser/policy/enterprise_metrics.h" 18 #include "chrome/browser/policy/enterprise_metrics.h"
18 #include "chrome/browser/policy/policy_notifier.h" 19 #include "chrome/browser/policy/policy_notifier.h"
19 #include "chrome/browser/policy/proto/device_management_local.pb.h" 20 #include "chrome/browser/policy/proto/device_management_local.pb.h"
20 21
21 namespace policy { 22 namespace policy {
22 23
23 namespace { 24 namespace {
24 25
25 // Retry after 5 minutes (with exponential backoff) after token fetch errors. 26 // Retry after 5 minutes (with exponential backoff) after token fetch errors.
26 const int64 kTokenFetchErrorDelayMilliseconds = 5 * 60 * 1000; 27 const int64 kTokenFetchErrorDelayMilliseconds = 5 * 60 * 1000;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 181
181 SampleErrorStatus(status); 182 SampleErrorStatus(status);
182 183
183 switch (status) { 184 switch (status) {
184 case DM_STATUS_SUCCESS: { 185 case DM_STATUS_SUCCESS: {
185 const em::DeviceRegisterResponse& register_response = 186 const em::DeviceRegisterResponse& register_response =
186 response.register_response(); 187 response.register_response();
187 if (register_response.has_device_management_token()) { 188 if (register_response.has_device_management_token()) {
188 UMA_HISTOGRAM_ENUMERATION(kMetricToken, kMetricTokenFetchOK, 189 UMA_HISTOGRAM_ENUMERATION(kMetricToken, kMetricTokenFetchOK,
189 kMetricTokenSize); 190 kMetricTokenSize);
191 if (register_response.has_enrollment_type()) {
192 switch (register_response.enrollment_type()) {
193 case em::DeviceRegisterResponse::ENTERPRISE:
194 data_store_->set_device_mode(
195 EnterpriseInstallAttributes::ENTERPRISE_DEVICE);
196 break;
197 case em::DeviceRegisterResponse::KIOSK:
198 data_store_->set_device_mode(
199 EnterpriseInstallAttributes::KIOSK_DEVICE);
200 break;
201 }
Mattias Nissler (ping if slow) 2012/02/16 10:36:27 we should do the right thing when there is a value
pastarmovj 2012/02/17 13:59:47 Done.
202 } else {
203 // If this field is not present we should assume we are running
204 // against old DMServer and go in enterprise enrollment mode.
205 data_store_->set_device_mode(
206 EnterpriseInstallAttributes::ENTERPRISE_DEVICE);
207 }
208
190 data_store_->SetDeviceToken(register_response.device_management_token(), 209 data_store_->SetDeviceToken(register_response.device_management_token(),
191 false); 210 false);
192 SetState(STATE_TOKEN_AVAILABLE); 211 SetState(STATE_TOKEN_AVAILABLE);
193 } else { 212 } else {
194 NOTREACHED(); 213 NOTREACHED();
195 UMA_HISTOGRAM_ENUMERATION(kMetricToken, kMetricTokenFetchBadResponse, 214 UMA_HISTOGRAM_ENUMERATION(kMetricToken, kMetricTokenFetchBadResponse,
196 kMetricTokenSize); 215 kMetricTokenSize);
197 SetState(STATE_ERROR); 216 SetState(STATE_ERROR);
198 } 217 }
199 return; 218 return;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 case STATE_UNMANAGED: 329 case STATE_UNMANAGED:
311 case STATE_ERROR: 330 case STATE_ERROR:
312 case STATE_TEMPORARY_ERROR: 331 case STATE_TEMPORARY_ERROR:
313 case STATE_BAD_AUTH: 332 case STATE_BAD_AUTH:
314 FetchTokenInternal(); 333 FetchTokenInternal();
315 break; 334 break;
316 } 335 }
317 } 336 }
318 337
319 } // namespace policy 338 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698