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

Side by Side Diff: chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.cc

Issue 188243003: Merge 254685 "Fixed handling of 'oem_device_requisition' VPD value." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1847/src/
Patch Set: Created 6 years, 9 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/chromeos/policy/device_cloud_policy_manager_chromeos.h" 5 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/prefs/pref_registry_simple.h" 9 #include "base/prefs/pref_registry_simple.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 16 matching lines...) Expand all
27 #include "url/gurl.h" 27 #include "url/gurl.h"
28 28
29 using content::BrowserThread; 29 using content::BrowserThread;
30 30
31 namespace em = enterprise_management; 31 namespace em = enterprise_management;
32 32
33 namespace policy { 33 namespace policy {
34 34
35 namespace { 35 namespace {
36 36
37 // Overridden no requisition value.
38 const char kNoRequisition[] = "none";
39
40 // Overridden no requisition value.
41 const char kRemoraRequisition[] = "remora";
42
37 // MachineInfo key names. 43 // MachineInfo key names.
38 const char kMachineInfoSystemHwqual[] = "hardware_class"; 44 const char kMachineInfoSystemHwqual[] = "hardware_class";
39 45
40 // These are the machine serial number keys that we check in order until we 46 // These are the machine serial number keys that we check in order until we
41 // find a non-empty serial number. The VPD spec says the serial number should be 47 // find a non-empty serial number. The VPD spec says the serial number should be
42 // in the "serial_number" key for v2+ VPDs. However, legacy devices used a 48 // in the "serial_number" key for v2+ VPDs. However, legacy devices used a
43 // different keys to report their serial number, which we fall back to if 49 // different keys to report their serial number, which we fall back to if
44 // "serial_number" is not present. 50 // "serial_number" is not present.
45 // 51 //
46 // Product_S/N is still special-cased due to inconsistencies with serial 52 // Product_S/N is still special-cased due to inconsistencies with serial
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 DeviceManagementService* device_management_service, 117 DeviceManagementService* device_management_service,
112 scoped_ptr<CloudPolicyClient::StatusProvider> device_status_provider) { 118 scoped_ptr<CloudPolicyClient::StatusProvider> device_status_provider) {
113 CHECK(!device_management_service_); 119 CHECK(!device_management_service_);
114 CHECK(device_management_service); 120 CHECK(device_management_service);
115 CHECK(local_state); 121 CHECK(local_state);
116 122
117 local_state_ = local_state; 123 local_state_ = local_state;
118 device_management_service_ = device_management_service; 124 device_management_service_ = device_management_service;
119 device_status_provider_ = device_status_provider.Pass(); 125 device_status_provider_ = device_status_provider.Pass();
120 126
127 InitalizeRequisition();
121 StartIfManaged(); 128 StartIfManaged();
122 } 129 }
123 130
124 void DeviceCloudPolicyManagerChromeOS::StartEnrollment( 131 void DeviceCloudPolicyManagerChromeOS::StartEnrollment(
125 const std::string& auth_token, 132 const std::string& auth_token,
126 bool is_auto_enrollment, 133 bool is_auto_enrollment,
127 const AllowedDeviceModes& allowed_device_modes, 134 const AllowedDeviceModes& allowed_device_modes,
128 const EnrollmentCallback& callback) { 135 const EnrollmentCallback& callback) {
129 CHECK(device_management_service_); 136 CHECK(device_management_service_);
130 core()->Disconnect(); 137 core()->Disconnect();
(...skipping 13 matching lines...) Expand all
144 if (enrollment_handler_.get()) { 151 if (enrollment_handler_.get()) {
145 enrollment_handler_.reset(); 152 enrollment_handler_.reset();
146 StartIfManaged(); 153 StartIfManaged();
147 } 154 }
148 } 155 }
149 156
150 std::string DeviceCloudPolicyManagerChromeOS::GetDeviceRequisition() const { 157 std::string DeviceCloudPolicyManagerChromeOS::GetDeviceRequisition() const {
151 std::string requisition; 158 std::string requisition;
152 const PrefService::Preference* pref = local_state_->FindPreference( 159 const PrefService::Preference* pref = local_state_->FindPreference(
153 prefs::kDeviceEnrollmentRequisition); 160 prefs::kDeviceEnrollmentRequisition);
154 if (pref->IsDefaultValue() && !chromeos::StartupUtils::IsOobeCompleted()) { 161 if (!pref->IsDefaultValue())
155 // OEM statistics are only loaded when OOBE is not completed.
156 requisition =
157 GetMachineStatistic(chromeos::system::kOemDeviceRequisitionKey);
158 } else {
159 pref->GetValue()->GetAsString(&requisition); 162 pref->GetValue()->GetAsString(&requisition);
160 } 163
164 if (requisition == kNoRequisition)
165 requisition.clear();
161 166
162 return requisition; 167 return requisition;
163 } 168 }
164 169
165 void DeviceCloudPolicyManagerChromeOS::SetDeviceRequisition( 170 void DeviceCloudPolicyManagerChromeOS::SetDeviceRequisition(
166 const std::string& requisition) { 171 const std::string& requisition) {
167 if (local_state_) { 172 if (local_state_) {
168 if (requisition.empty()) { 173 if (requisition.empty()) {
169 local_state_->ClearPref(prefs::kDeviceEnrollmentRequisition); 174 local_state_->ClearPref(prefs::kDeviceEnrollmentRequisition);
170 local_state_->ClearPref(prefs::kDeviceEnrollmentAutoStart); 175 local_state_->ClearPref(prefs::kDeviceEnrollmentAutoStart);
171 local_state_->ClearPref(prefs::kDeviceEnrollmentCanExit); 176 local_state_->ClearPref(prefs::kDeviceEnrollmentCanExit);
172 } else { 177 } else {
173 local_state_->SetString(prefs::kDeviceEnrollmentRequisition, requisition); 178 local_state_->SetString(prefs::kDeviceEnrollmentRequisition, requisition);
174 local_state_->SetBoolean(prefs::kDeviceEnrollmentAutoStart, true); 179 if (requisition == kNoRequisition) {
175 local_state_->SetBoolean(prefs::kDeviceEnrollmentCanExit, false); 180 local_state_->ClearPref(prefs::kDeviceEnrollmentAutoStart);
181 local_state_->ClearPref(prefs::kDeviceEnrollmentCanExit);
182 } else {
183 local_state_->SetBoolean(prefs::kDeviceEnrollmentAutoStart, true);
184 local_state_->SetBoolean(prefs::kDeviceEnrollmentCanExit, false);
185 }
176 } 186 }
177 } 187 }
178 } 188 }
179 189
180 bool DeviceCloudPolicyManagerChromeOS::ShouldAutoStartEnrollment() const { 190 bool DeviceCloudPolicyManagerChromeOS::ShouldAutoStartEnrollment() const {
181 if (local_state_->HasPrefPath(prefs::kDeviceEnrollmentAutoStart)) 191 if (local_state_->HasPrefPath(prefs::kDeviceEnrollmentAutoStart))
182 return local_state_->GetBoolean(prefs::kDeviceEnrollmentAutoStart); 192 return local_state_->GetBoolean(prefs::kDeviceEnrollmentAutoStart);
183 193
184 return GetMachineFlag(chromeos::system::kOemIsEnterpriseManagedKey, false); 194 return GetMachineFlag(chromeos::system::kOemIsEnterpriseManagedKey, false);
185 } 195 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 !service()) { 295 !service()) {
286 core()->Connect(CreateClient()); 296 core()->Connect(CreateClient());
287 core()->StartRefreshScheduler(); 297 core()->StartRefreshScheduler();
288 core()->TrackRefreshDelayPref(local_state_, 298 core()->TrackRefreshDelayPref(local_state_,
289 prefs::kDevicePolicyRefreshRate); 299 prefs::kDevicePolicyRefreshRate);
290 attestation_policy_observer_.reset( 300 attestation_policy_observer_.reset(
291 new chromeos::attestation::AttestationPolicyObserver(client())); 301 new chromeos::attestation::AttestationPolicyObserver(client()));
292 } 302 }
293 } 303 }
294 304
305 void DeviceCloudPolicyManagerChromeOS::InitalizeRequisition() {
306 // OEM statistics are only loaded when OOBE is not completed.
307 if (chromeos::StartupUtils::IsOobeCompleted())
308 return;
309
310 const PrefService::Preference* pref = local_state_->FindPreference(
311 prefs::kDeviceEnrollmentRequisition);
312 if (pref->IsDefaultValue()) {
313 std::string requisition =
314 GetMachineStatistic(chromeos::system::kOemDeviceRequisitionKey);
315
316 if (!requisition.empty()) {
317 local_state_->SetString(prefs::kDeviceEnrollmentRequisition,
318 requisition);
319 if (requisition == kRemoraRequisition) {
320 local_state_->SetBoolean(prefs::kDeviceEnrollmentAutoStart, true);
321 local_state_->SetBoolean(prefs::kDeviceEnrollmentCanExit, false);
322 } else {
323 local_state_->SetBoolean(
324 prefs::kDeviceEnrollmentAutoStart,
325 GetMachineFlag(chromeos::system::kOemIsEnterpriseManagedKey,
326 false));
327 local_state_->SetBoolean(
328 prefs::kDeviceEnrollmentCanExit,
329 GetMachineFlag(chromeos::system::kOemCanExitEnterpriseEnrollmentKey,
330 false));
331 }
332 }
333 }
334 }
335
295 } // namespace policy 336 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698