| 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/chromeos/policy/device_cloud_policy_manager_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 #include "url/gurl.h" | 45 #include "url/gurl.h" |
| 46 | 46 |
| 47 using content::BrowserThread; | 47 using content::BrowserThread; |
| 48 | 48 |
| 49 namespace em = enterprise_management; | 49 namespace em = enterprise_management; |
| 50 | 50 |
| 51 namespace policy { | 51 namespace policy { |
| 52 | 52 |
| 53 namespace { | 53 namespace { |
| 54 | 54 |
| 55 // Well-known requisition types. |
| 55 const char kNoRequisition[] = "none"; | 56 const char kNoRequisition[] = "none"; |
| 56 const char kRemoraRequisition[] = "remora"; | 57 const char kRemoraRequisition[] = "remora"; |
| 57 const char kSharkRequisition[] = "shark"; | 58 const char kSharkRequisition[] = "shark"; |
| 58 | 59 |
| 60 // Zero-touch enrollment flag values. |
| 61 const char kZeroTouchEnrollmentForced[] = "forced"; |
| 62 |
| 59 // These are the machine serial number keys that we check in order until we | 63 // These are the machine serial number keys that we check in order until we |
| 60 // find a non-empty serial number. The VPD spec says the serial number should be | 64 // find a non-empty serial number. The VPD spec says the serial number should be |
| 61 // in the "serial_number" key for v2+ VPDs. However, legacy devices used a | 65 // in the "serial_number" key for v2+ VPDs. However, legacy devices used a |
| 62 // different key to report their serial number, which we fall back to if | 66 // different key to report their serial number, which we fall back to if |
| 63 // "serial_number" is not present. | 67 // "serial_number" is not present. |
| 64 // | 68 // |
| 65 // Product_S/N is still special-cased due to inconsistencies with serial | 69 // Product_S/N is still special-cased due to inconsistencies with serial |
| 66 // numbers on Lumpy devices: On these devices, serial_number is identical to | 70 // numbers on Lumpy devices: On these devices, serial_number is identical to |
| 67 // Product_S/N with an appended checksum. Unfortunately, the sticker on the | 71 // Product_S/N with an appended checksum. Unfortunately, the sticker on the |
| 68 // packaging doesn't include that checksum either (the sticker on the device | 72 // packaging doesn't include that checksum either (the sticker on the device |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 void DeviceCloudPolicyManagerChromeOS::Initialize(PrefService* local_state) { | 133 void DeviceCloudPolicyManagerChromeOS::Initialize(PrefService* local_state) { |
| 130 CHECK(local_state); | 134 CHECK(local_state); |
| 131 | 135 |
| 132 local_state_ = local_state; | 136 local_state_ = local_state; |
| 133 | 137 |
| 134 state_keys_update_subscription_ = state_keys_broker_->RegisterUpdateCallback( | 138 state_keys_update_subscription_ = state_keys_broker_->RegisterUpdateCallback( |
| 135 base::Bind(&DeviceCloudPolicyManagerChromeOS::OnStateKeysUpdated, | 139 base::Bind(&DeviceCloudPolicyManagerChromeOS::OnStateKeysUpdated, |
| 136 base::Unretained(this))); | 140 base::Unretained(this))); |
| 137 | 141 |
| 138 InitializeRequisition(); | 142 InitializeRequisition(); |
| 143 InitializeEnrollment(); |
| 139 } | 144 } |
| 140 | 145 |
| 141 void DeviceCloudPolicyManagerChromeOS::AddDeviceCloudPolicyManagerObserver( | 146 void DeviceCloudPolicyManagerChromeOS::AddDeviceCloudPolicyManagerObserver( |
| 142 Observer* observer) { | 147 Observer* observer) { |
| 143 observers_.AddObserver(observer); | 148 observers_.AddObserver(observer); |
| 144 } | 149 } |
| 145 | 150 |
| 146 void DeviceCloudPolicyManagerChromeOS::RemoveDeviceCloudPolicyManagerObserver( | 151 void DeviceCloudPolicyManagerChromeOS::RemoveDeviceCloudPolicyManagerObserver( |
| 147 Observer* observer) { | 152 Observer* observer) { |
| 148 observers_.RemoveObserver(observer); | 153 observers_.RemoveObserver(observer); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 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 if (requisition == kNoRequisition) { | 179 if (requisition == kNoRequisition) { |
| 175 local_state_->ClearPref(prefs::kDeviceEnrollmentAutoStart); | 180 local_state_->ClearPref(prefs::kDeviceEnrollmentAutoStart); |
| 176 local_state_->ClearPref(prefs::kDeviceEnrollmentCanExit); | 181 local_state_->ClearPref(prefs::kDeviceEnrollmentCanExit); |
| 177 } else { | 182 } else { |
| 178 local_state_->SetBoolean(prefs::kDeviceEnrollmentAutoStart, true); | 183 SetDeviceEnrollmentAutoStart(); |
| 179 local_state_->SetBoolean(prefs::kDeviceEnrollmentCanExit, false); | |
| 180 } | 184 } |
| 181 } | 185 } |
| 182 } | 186 } |
| 183 } | 187 } |
| 184 | 188 |
| 185 bool DeviceCloudPolicyManagerChromeOS::IsRemoraRequisition() const { | 189 bool DeviceCloudPolicyManagerChromeOS::IsRemoraRequisition() const { |
| 186 return GetDeviceRequisition() == kRemoraRequisition; | 190 return GetDeviceRequisition() == kRemoraRequisition; |
| 187 } | 191 } |
| 188 | 192 |
| 189 bool DeviceCloudPolicyManagerChromeOS::IsSharkRequisition() const { | 193 bool DeviceCloudPolicyManagerChromeOS::IsSharkRequisition() const { |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 prefs::kDeviceEnrollmentRequisition); | 317 prefs::kDeviceEnrollmentRequisition); |
| 314 if (pref->IsDefaultValue()) { | 318 if (pref->IsDefaultValue()) { |
| 315 std::string requisition = | 319 std::string requisition = |
| 316 GetMachineStatistic(chromeos::system::kOemDeviceRequisitionKey); | 320 GetMachineStatistic(chromeos::system::kOemDeviceRequisitionKey); |
| 317 | 321 |
| 318 if (!requisition.empty()) { | 322 if (!requisition.empty()) { |
| 319 local_state_->SetString(prefs::kDeviceEnrollmentRequisition, | 323 local_state_->SetString(prefs::kDeviceEnrollmentRequisition, |
| 320 requisition); | 324 requisition); |
| 321 if (requisition == kRemoraRequisition || | 325 if (requisition == kRemoraRequisition || |
| 322 requisition == kSharkRequisition) { | 326 requisition == kSharkRequisition) { |
| 323 local_state_->SetBoolean(prefs::kDeviceEnrollmentAutoStart, true); | 327 SetDeviceEnrollmentAutoStart(); |
| 324 local_state_->SetBoolean(prefs::kDeviceEnrollmentCanExit, false); | |
| 325 } else { | 328 } else { |
| 326 local_state_->SetBoolean( | 329 local_state_->SetBoolean( |
| 327 prefs::kDeviceEnrollmentAutoStart, | 330 prefs::kDeviceEnrollmentAutoStart, |
| 328 GetMachineFlag(chromeos::system::kOemIsEnterpriseManagedKey, | 331 GetMachineFlag(chromeos::system::kOemIsEnterpriseManagedKey, |
| 329 false)); | 332 false)); |
| 330 local_state_->SetBoolean( | 333 local_state_->SetBoolean( |
| 331 prefs::kDeviceEnrollmentCanExit, | 334 prefs::kDeviceEnrollmentCanExit, |
| 332 GetMachineFlag(chromeos::system::kOemCanExitEnterpriseEnrollmentKey, | 335 GetMachineFlag(chromeos::system::kOemCanExitEnterpriseEnrollmentKey, |
| 333 false)); | 336 false)); |
| 334 } | 337 } |
| 335 } | 338 } |
| 336 } | 339 } |
| 337 } | 340 } |
| 338 | 341 |
| 342 void DeviceCloudPolicyManagerChromeOS::InitializeEnrollment() { |
| 343 // Enrollment happens during OOBE only. |
| 344 if (chromeos::StartupUtils::IsOobeCompleted()) |
| 345 return; |
| 346 |
| 347 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 348 if (command_line->HasSwitch( |
| 349 chromeos::switches::kEnterpriseEnableZeroTouchEnrollment) && |
| 350 command_line->GetSwitchValueASCII( |
| 351 chromeos::switches::kEnterpriseEnableZeroTouchEnrollment) == |
| 352 kZeroTouchEnrollmentForced) { |
| 353 SetDeviceEnrollmentAutoStart(); |
| 354 } |
| 355 } |
| 356 |
| 339 void DeviceCloudPolicyManagerChromeOS::NotifyConnected() { | 357 void DeviceCloudPolicyManagerChromeOS::NotifyConnected() { |
| 340 FOR_EACH_OBSERVER( | 358 FOR_EACH_OBSERVER( |
| 341 Observer, observers_, OnDeviceCloudPolicyManagerConnected()); | 359 Observer, observers_, OnDeviceCloudPolicyManagerConnected()); |
| 342 } | 360 } |
| 343 | 361 |
| 344 void DeviceCloudPolicyManagerChromeOS::NotifyDisconnected() { | 362 void DeviceCloudPolicyManagerChromeOS::NotifyDisconnected() { |
| 345 FOR_EACH_OBSERVER( | 363 FOR_EACH_OBSERVER( |
| 346 Observer, observers_, OnDeviceCloudPolicyManagerDisconnected()); | 364 Observer, observers_, OnDeviceCloudPolicyManagerDisconnected()); |
| 347 } | 365 } |
| 348 | 366 |
| 349 void DeviceCloudPolicyManagerChromeOS::CreateStatusUploader() { | 367 void DeviceCloudPolicyManagerChromeOS::CreateStatusUploader() { |
| 350 status_uploader_.reset(new StatusUploader( | 368 status_uploader_.reset(new StatusUploader( |
| 351 client(), | 369 client(), |
| 352 base::WrapUnique(new DeviceStatusCollector( | 370 base::WrapUnique(new DeviceStatusCollector( |
| 353 local_state_, chromeos::system::StatisticsProvider::GetInstance(), | 371 local_state_, chromeos::system::StatisticsProvider::GetInstance(), |
| 354 DeviceStatusCollector::LocationUpdateRequester(), | 372 DeviceStatusCollector::LocationUpdateRequester(), |
| 355 DeviceStatusCollector::VolumeInfoFetcher(), | 373 DeviceStatusCollector::VolumeInfoFetcher(), |
| 356 DeviceStatusCollector::CPUStatisticsFetcher(), | 374 DeviceStatusCollector::CPUStatisticsFetcher(), |
| 357 DeviceStatusCollector::CPUTempFetcher())), | 375 DeviceStatusCollector::CPUTempFetcher())), |
| 358 task_runner_)); | 376 task_runner_)); |
| 359 } | 377 } |
| 360 | 378 |
| 361 } // namespace policy | 379 } // namespace policy |
| OLD | NEW |