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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 void DeviceCloudPolicyManagerChromeOS::Initialize(PrefService* local_state) { | 129 void DeviceCloudPolicyManagerChromeOS::Initialize(PrefService* local_state) { |
130 CHECK(local_state); | 130 CHECK(local_state); |
131 | 131 |
132 local_state_ = local_state; | 132 local_state_ = local_state; |
133 | 133 |
134 state_keys_update_subscription_ = state_keys_broker_->RegisterUpdateCallback( | 134 state_keys_update_subscription_ = state_keys_broker_->RegisterUpdateCallback( |
135 base::Bind(&DeviceCloudPolicyManagerChromeOS::OnStateKeysUpdated, | 135 base::Bind(&DeviceCloudPolicyManagerChromeOS::OnStateKeysUpdated, |
136 base::Unretained(this))); | 136 base::Unretained(this))); |
137 | 137 |
138 InitializeRequisition(); | 138 InitializeRequisition(); |
139 InitializeEnrollment(); | |
139 } | 140 } |
140 | 141 |
141 void DeviceCloudPolicyManagerChromeOS::AddDeviceCloudPolicyManagerObserver( | 142 void DeviceCloudPolicyManagerChromeOS::AddDeviceCloudPolicyManagerObserver( |
142 Observer* observer) { | 143 Observer* observer) { |
143 observers_.AddObserver(observer); | 144 observers_.AddObserver(observer); |
144 } | 145 } |
145 | 146 |
146 void DeviceCloudPolicyManagerChromeOS::RemoveDeviceCloudPolicyManagerObserver( | 147 void DeviceCloudPolicyManagerChromeOS::RemoveDeviceCloudPolicyManagerObserver( |
147 Observer* observer) { | 148 Observer* observer) { |
148 observers_.RemoveObserver(observer); | 149 observers_.RemoveObserver(observer); |
(...skipping 19 matching lines...) Expand all Loading... | |
168 if (requisition.empty()) { | 169 if (requisition.empty()) { |
169 local_state_->ClearPref(prefs::kDeviceEnrollmentRequisition); | 170 local_state_->ClearPref(prefs::kDeviceEnrollmentRequisition); |
170 local_state_->ClearPref(prefs::kDeviceEnrollmentAutoStart); | 171 local_state_->ClearPref(prefs::kDeviceEnrollmentAutoStart); |
171 local_state_->ClearPref(prefs::kDeviceEnrollmentCanExit); | 172 local_state_->ClearPref(prefs::kDeviceEnrollmentCanExit); |
172 } else { | 173 } else { |
173 local_state_->SetString(prefs::kDeviceEnrollmentRequisition, requisition); | 174 local_state_->SetString(prefs::kDeviceEnrollmentRequisition, requisition); |
174 if (requisition == kNoRequisition) { | 175 if (requisition == kNoRequisition) { |
175 local_state_->ClearPref(prefs::kDeviceEnrollmentAutoStart); | 176 local_state_->ClearPref(prefs::kDeviceEnrollmentAutoStart); |
176 local_state_->ClearPref(prefs::kDeviceEnrollmentCanExit); | 177 local_state_->ClearPref(prefs::kDeviceEnrollmentCanExit); |
177 } else { | 178 } else { |
178 local_state_->SetBoolean(prefs::kDeviceEnrollmentAutoStart, true); | 179 SetDeviceEnrollmentAutoStart(); |
179 local_state_->SetBoolean(prefs::kDeviceEnrollmentCanExit, false); | |
180 } | 180 } |
181 } | 181 } |
182 } | 182 } |
183 } | 183 } |
184 | 184 |
185 bool DeviceCloudPolicyManagerChromeOS::IsRemoraRequisition() const { | 185 bool DeviceCloudPolicyManagerChromeOS::IsRemoraRequisition() const { |
186 return GetDeviceRequisition() == kRemoraRequisition; | 186 return GetDeviceRequisition() == kRemoraRequisition; |
187 } | 187 } |
188 | 188 |
189 bool DeviceCloudPolicyManagerChromeOS::IsSharkRequisition() const { | 189 bool DeviceCloudPolicyManagerChromeOS::IsSharkRequisition() const { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
313 prefs::kDeviceEnrollmentRequisition); | 313 prefs::kDeviceEnrollmentRequisition); |
314 if (pref->IsDefaultValue()) { | 314 if (pref->IsDefaultValue()) { |
315 std::string requisition = | 315 std::string requisition = |
316 GetMachineStatistic(chromeos::system::kOemDeviceRequisitionKey); | 316 GetMachineStatistic(chromeos::system::kOemDeviceRequisitionKey); |
317 | 317 |
318 if (!requisition.empty()) { | 318 if (!requisition.empty()) { |
319 local_state_->SetString(prefs::kDeviceEnrollmentRequisition, | 319 local_state_->SetString(prefs::kDeviceEnrollmentRequisition, |
320 requisition); | 320 requisition); |
321 if (requisition == kRemoraRequisition || | 321 if (requisition == kRemoraRequisition || |
322 requisition == kSharkRequisition) { | 322 requisition == kSharkRequisition) { |
323 local_state_->SetBoolean(prefs::kDeviceEnrollmentAutoStart, true); | 323 SetDeviceEnrollmentAutoStart(); |
324 local_state_->SetBoolean(prefs::kDeviceEnrollmentCanExit, false); | |
325 } else { | 324 } else { |
326 local_state_->SetBoolean( | 325 local_state_->SetBoolean( |
327 prefs::kDeviceEnrollmentAutoStart, | 326 prefs::kDeviceEnrollmentAutoStart, |
328 GetMachineFlag(chromeos::system::kOemIsEnterpriseManagedKey, | 327 GetMachineFlag(chromeos::system::kOemIsEnterpriseManagedKey, |
329 false)); | 328 false)); |
330 local_state_->SetBoolean( | 329 local_state_->SetBoolean( |
331 prefs::kDeviceEnrollmentCanExit, | 330 prefs::kDeviceEnrollmentCanExit, |
332 GetMachineFlag(chromeos::system::kOemCanExitEnterpriseEnrollmentKey, | 331 GetMachineFlag(chromeos::system::kOemCanExitEnterpriseEnrollmentKey, |
333 false)); | 332 false)); |
334 } | 333 } |
335 } | 334 } |
336 } | 335 } |
337 } | 336 } |
338 | 337 |
338 const char kZeroTouchEnrollmentForced[] = "forced"; | |
pastarmovj
2016/06/29 08:46:01
nit: Can you move this to the top of the file plea
The one and only Dr. Crash
2016/06/29 21:04:38
Done.
| |
339 | |
340 void DeviceCloudPolicyManagerChromeOS::InitializeEnrollment() { | |
341 // Enrollment happens during OOBE only. | |
342 if (chromeos::StartupUtils::IsOobeCompleted()) | |
343 return; | |
344 | |
345 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |
346 if (command_line->HasSwitch( | |
347 chromeos::switches::kEnterpriseEnableZeroTouchEnrollment) && | |
348 command_line->GetSwitchValueASCII( | |
349 chromeos::switches::kEnterpriseEnableZeroTouchEnrollment) == | |
350 kZeroTouchEnrollmentForced) { | |
351 SetDeviceEnrollmentAutoStart(); | |
352 } | |
353 } | |
354 | |
339 void DeviceCloudPolicyManagerChromeOS::NotifyConnected() { | 355 void DeviceCloudPolicyManagerChromeOS::NotifyConnected() { |
340 FOR_EACH_OBSERVER( | 356 FOR_EACH_OBSERVER( |
341 Observer, observers_, OnDeviceCloudPolicyManagerConnected()); | 357 Observer, observers_, OnDeviceCloudPolicyManagerConnected()); |
342 } | 358 } |
343 | 359 |
344 void DeviceCloudPolicyManagerChromeOS::NotifyDisconnected() { | 360 void DeviceCloudPolicyManagerChromeOS::NotifyDisconnected() { |
345 FOR_EACH_OBSERVER( | 361 FOR_EACH_OBSERVER( |
346 Observer, observers_, OnDeviceCloudPolicyManagerDisconnected()); | 362 Observer, observers_, OnDeviceCloudPolicyManagerDisconnected()); |
347 } | 363 } |
348 | 364 |
349 void DeviceCloudPolicyManagerChromeOS::CreateStatusUploader() { | 365 void DeviceCloudPolicyManagerChromeOS::CreateStatusUploader() { |
350 status_uploader_.reset(new StatusUploader( | 366 status_uploader_.reset(new StatusUploader( |
351 client(), | 367 client(), |
352 base::WrapUnique(new DeviceStatusCollector( | 368 base::WrapUnique(new DeviceStatusCollector( |
353 local_state_, chromeos::system::StatisticsProvider::GetInstance(), | 369 local_state_, chromeos::system::StatisticsProvider::GetInstance(), |
354 DeviceStatusCollector::LocationUpdateRequester(), | 370 DeviceStatusCollector::LocationUpdateRequester(), |
355 DeviceStatusCollector::VolumeInfoFetcher(), | 371 DeviceStatusCollector::VolumeInfoFetcher(), |
356 DeviceStatusCollector::CPUStatisticsFetcher(), | 372 DeviceStatusCollector::CPUStatisticsFetcher(), |
357 DeviceStatusCollector::CPUTempFetcher())), | 373 DeviceStatusCollector::CPUTempFetcher())), |
358 task_runner_)); | 374 task_runner_)); |
359 } | 375 } |
360 | 376 |
361 } // namespace policy | 377 } // namespace policy |
OLD | NEW |