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

Side by Side Diff: chrome/browser/policy/device_token_fetcher.cc

Issue 10628008: If there is a device id use that instead of a new one for re-enrolling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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
« no previous file with comments | « chrome/browser/policy/cloud_policy_data_store.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 request_job_->SetClientID(data_store_->device_id()); 171 request_job_->SetClientID(data_store_->device_id());
172 em::DeviceRegisterRequest* request = 172 em::DeviceRegisterRequest* request =
173 request_job_->GetRequest()->mutable_register_request(); 173 request_job_->GetRequest()->mutable_register_request();
174 request->set_type(data_store_->policy_register_type()); 174 request->set_type(data_store_->policy_register_type());
175 if (!data_store_->machine_id().empty()) 175 if (!data_store_->machine_id().empty())
176 request->set_machine_id(data_store_->machine_id()); 176 request->set_machine_id(data_store_->machine_id());
177 if (!data_store_->machine_model().empty()) 177 if (!data_store_->machine_model().empty())
178 request->set_machine_model(data_store_->machine_model()); 178 request->set_machine_model(data_store_->machine_model());
179 if (data_store_->known_machine_id()) 179 if (data_store_->known_machine_id())
180 request->set_auto_enrolled(true); 180 request->set_auto_enrolled(true);
181 if (data_store_->reregister())
182 request->set_reregister(true);
181 request_job_->Start(base::Bind(&DeviceTokenFetcher::OnTokenFetchCompleted, 183 request_job_->Start(base::Bind(&DeviceTokenFetcher::OnTokenFetchCompleted,
182 base::Unretained(this))); 184 base::Unretained(this)));
183 UMA_HISTOGRAM_ENUMERATION(kMetricToken, kMetricTokenFetchRequested, 185 UMA_HISTOGRAM_ENUMERATION(kMetricToken, kMetricTokenFetchRequested,
184 kMetricTokenSize); 186 kMetricTokenSize);
185 } 187 }
186 188
187 void DeviceTokenFetcher::OnTokenFetchCompleted( 189 void DeviceTokenFetcher::OnTokenFetchCompleted(
188 DeviceManagementStatus status, 190 DeviceManagementStatus status,
189 const em::DeviceManagementResponse& response) { 191 const em::DeviceManagementResponse& response) {
190 if (status == DM_STATUS_SUCCESS && !response.has_register_response()) { 192 if (status == DM_STATUS_SUCCESS && !response.has_register_response()) {
191 // Handled below. 193 // Handled below.
192 status = DM_STATUS_RESPONSE_DECODING_ERROR; 194 status = DM_STATUS_RESPONSE_DECODING_ERROR;
193 } 195 }
194 196
197 LOG_IF(ERROR, status != DM_STATUS_SUCCESS) << "DMServer returned error code: "
198 << status;
195 SampleErrorStatus(status); 199 SampleErrorStatus(status);
196 200
197 switch (status) { 201 switch (status) {
198 case DM_STATUS_SUCCESS: { 202 case DM_STATUS_SUCCESS: {
199 const em::DeviceRegisterResponse& register_response = 203 const em::DeviceRegisterResponse& register_response =
200 response.register_response(); 204 response.register_response();
201 if (register_response.has_device_management_token()) { 205 if (register_response.has_device_management_token()) {
202 UMA_HISTOGRAM_ENUMERATION(kMetricToken, kMetricTokenFetchOK, 206 UMA_HISTOGRAM_ENUMERATION(kMetricToken, kMetricTokenFetchOK,
203 kMetricTokenSize); 207 kMetricTokenSize);
204 208
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 case STATE_UNMANAGED: 351 case STATE_UNMANAGED:
348 case STATE_ERROR: 352 case STATE_ERROR:
349 case STATE_TEMPORARY_ERROR: 353 case STATE_TEMPORARY_ERROR:
350 case STATE_BAD_AUTH: 354 case STATE_BAD_AUTH:
351 FetchTokenInternal(); 355 FetchTokenInternal();
352 break; 356 break;
353 } 357 }
354 } 358 }
355 359
356 } // namespace policy 360 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/cloud_policy_data_store.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698