OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_initializer.h" | 5 #include "chrome/browser/chromeos/policy/device_cloud_policy_initializer.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/logging.h" | 9 #include "base/logging.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 if (local_state_->HasPrefPath(prefs::kDeviceEnrollmentAutoStart)) | 126 if (local_state_->HasPrefPath(prefs::kDeviceEnrollmentAutoStart)) |
127 return local_state_->GetBoolean(prefs::kDeviceEnrollmentAutoStart); | 127 return local_state_->GetBoolean(prefs::kDeviceEnrollmentAutoStart); |
128 | 128 |
129 return GetMachineFlag(chromeos::system::kOemIsEnterpriseManagedKey, false); | 129 return GetMachineFlag(chromeos::system::kOemIsEnterpriseManagedKey, false); |
130 } | 130 } |
131 | 131 |
132 bool DeviceCloudPolicyInitializer::ShouldRecoverEnrollment() const { | 132 bool DeviceCloudPolicyInitializer::ShouldRecoverEnrollment() const { |
133 if (install_attributes_->IsEnterpriseDevice() && | 133 if (install_attributes_->IsEnterpriseDevice() && |
134 chromeos::StartupUtils::IsEnrollmentRecoveryRequired()) { | 134 chromeos::StartupUtils::IsEnrollmentRecoveryRequired()) { |
135 LOG(WARNING) << "Enrollment recovery required according to pref."; | 135 LOG(WARNING) << "Enrollment recovery required according to pref."; |
136 std::string machine_id; | 136 if (!DeviceCloudPolicyManagerChromeOS::GetMachineID().empty()) |
137 bool machine_id_success = | |
138 chromeos::system::StatisticsProvider::GetInstance() | |
139 ->GetMachineStatistic(chromeos::system::kHardwareClassKey, | |
140 &machine_id); | |
141 if (machine_id_success && machine_id != "") | |
142 return true; | 137 return true; |
143 LOG(WARNING) << "Postponing recovery because machine id is missing."; | 138 LOG(WARNING) << "Postponing recovery because machine id is missing."; |
144 } | 139 } |
145 return false; | 140 return false; |
146 } | 141 } |
147 | 142 |
148 bool DeviceCloudPolicyInitializer::CanExitEnrollment() const { | 143 bool DeviceCloudPolicyInitializer::CanExitEnrollment() const { |
149 if (GetRestoreMode() == kDeviceStateRestoreModeReEnrollmentEnforced) | 144 if (GetRestoreMode() == kDeviceStateRestoreModeReEnrollmentEnforced) |
150 return false; | 145 return false; |
151 | 146 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 | 233 |
239 std::string DeviceCloudPolicyInitializer::GetRestoreMode() const { | 234 std::string DeviceCloudPolicyInitializer::GetRestoreMode() const { |
240 const base::DictionaryValue* device_state_dict = | 235 const base::DictionaryValue* device_state_dict = |
241 local_state_->GetDictionary(prefs::kServerBackedDeviceState); | 236 local_state_->GetDictionary(prefs::kServerBackedDeviceState); |
242 std::string restore_mode; | 237 std::string restore_mode; |
243 device_state_dict->GetString(kDeviceStateRestoreMode, &restore_mode); | 238 device_state_dict->GetString(kDeviceStateRestoreMode, &restore_mode); |
244 return restore_mode; | 239 return restore_mode; |
245 } | 240 } |
246 | 241 |
247 } // namespace policy | 242 } // namespace policy |
OLD | NEW |