| OLD | NEW |
| 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" |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 | 180 |
| 181 SampleErrorStatus(status); | 181 SampleErrorStatus(status); |
| 182 | 182 |
| 183 switch (status) { | 183 switch (status) { |
| 184 case DM_STATUS_SUCCESS: { | 184 case DM_STATUS_SUCCESS: { |
| 185 const em::DeviceRegisterResponse& register_response = | 185 const em::DeviceRegisterResponse& register_response = |
| 186 response.register_response(); | 186 response.register_response(); |
| 187 if (register_response.has_device_management_token()) { | 187 if (register_response.has_device_management_token()) { |
| 188 UMA_HISTOGRAM_ENUMERATION(kMetricToken, kMetricTokenFetchOK, | 188 UMA_HISTOGRAM_ENUMERATION(kMetricToken, kMetricTokenFetchOK, |
| 189 kMetricTokenSize); | 189 kMetricTokenSize); |
| 190 if (register_response.has_enrollment_type()) |
| 191 data_store_->set_device_mode(register_response.enrollment_type()); |
| 192 else |
| 193 data_store_->set_device_mode(em::DeviceRegisterResponse::ENTERPRISE); |
| 194 |
| 190 data_store_->SetDeviceToken(register_response.device_management_token(), | 195 data_store_->SetDeviceToken(register_response.device_management_token(), |
| 191 false); | 196 false); |
| 192 SetState(STATE_TOKEN_AVAILABLE); | 197 SetState(STATE_TOKEN_AVAILABLE); |
| 193 } else { | 198 } else { |
| 194 NOTREACHED(); | 199 NOTREACHED(); |
| 195 UMA_HISTOGRAM_ENUMERATION(kMetricToken, kMetricTokenFetchBadResponse, | 200 UMA_HISTOGRAM_ENUMERATION(kMetricToken, kMetricTokenFetchBadResponse, |
| 196 kMetricTokenSize); | 201 kMetricTokenSize); |
| 197 SetState(STATE_ERROR); | 202 SetState(STATE_ERROR); |
| 198 } | 203 } |
| 199 return; | 204 return; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 case STATE_UNMANAGED: | 315 case STATE_UNMANAGED: |
| 311 case STATE_ERROR: | 316 case STATE_ERROR: |
| 312 case STATE_TEMPORARY_ERROR: | 317 case STATE_TEMPORARY_ERROR: |
| 313 case STATE_BAD_AUTH: | 318 case STATE_BAD_AUTH: |
| 314 FetchTokenInternal(); | 319 FetchTokenInternal(); |
| 315 break; | 320 break; |
| 316 } | 321 } |
| 317 } | 322 } |
| 318 | 323 |
| 319 } // namespace policy | 324 } // namespace policy |
| OLD | NEW |