Chromium Code Reviews| 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/login/enrollment/auto_enrollment_controller.h" | 5 #include "chrome/browser/chromeos/login/enrollment/auto_enrollment_controller.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/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 13 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 14 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" | |
| 15 #include "chrome/browser/chromeos/policy/server_backed_state_keys_broker.h" | 14 #include "chrome/browser/chromeos/policy/server_backed_state_keys_broker.h" |
| 16 #include "chromeos/chromeos_switches.h" | 15 #include "chromeos/chromeos_switches.h" |
| 17 #include "chromeos/system/statistics_provider.h" | 16 #include "chromeos/system/statistics_provider.h" |
| 18 #include "components/policy/core/common/cloud/device_management_service.h" | 17 #include "components/policy/core/common/cloud/device_management_service.h" |
| 19 #include "net/url_request/url_request_context_getter.h" | 18 #include "net/url_request/url_request_context_getter.h" |
| 20 | 19 |
| 21 namespace chromeos { | 20 namespace chromeos { |
| 22 | 21 |
| 23 namespace { | 22 namespace { |
| 24 | 23 |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 53 return int_value; | 52 return int_value; |
| 54 } | 53 } |
| 55 | 54 |
| 56 // Determine whether the auto-enrollment check can be skipped. This is true when | 55 // Determine whether the auto-enrollment check can be skipped. This is true when |
| 57 // kCheckEnrollmentKey VPD entry doesn't indicate the device as being enrolled | 56 // kCheckEnrollmentKey VPD entry doesn't indicate the device as being enrolled |
| 58 // in the past. For backward compatibility with devices upgrading from an older | 57 // in the past. For backward compatibility with devices upgrading from an older |
| 59 // version of Chrome OS, the kActivateDateKey VPD entry should be missing too. | 58 // version of Chrome OS, the kActivateDateKey VPD entry should be missing too. |
| 60 // The requirement for the machine serial number to be present as well is a | 59 // The requirement for the machine serial number to be present as well is a |
| 61 // sanity-check to ensure that the VPD has actually been read successfully. | 60 // sanity-check to ensure that the VPD has actually been read successfully. |
| 62 bool CanSkipFRE() { | 61 bool CanSkipFRE() { |
| 62 chromeos::system::StatisticsProvider* provider = | |
|
emaxx
2016/09/30 16:17:59
nit: "chromeos::" is unnecessary.
Thiemo Nagel
2016/09/30 16:57:58
Done.
| |
| 63 chromeos::system::StatisticsProvider::GetInstance(); | |
| 63 std::string check_enrollment_value; | 64 std::string check_enrollment_value; |
| 64 bool is_enrolled = | 65 bool is_enrolled = |
| 65 system::StatisticsProvider::GetInstance()->GetMachineStatistic( | 66 provider->GetMachineStatistic( |
| 66 system::kCheckEnrollmentKey, &check_enrollment_value) && | 67 system::kCheckEnrollmentKey, &check_enrollment_value) && |
| 67 check_enrollment_value == "1"; | 68 check_enrollment_value == "1"; |
| 68 return !system::StatisticsProvider::GetInstance()->HasMachineStatistic( | 69 return !provider->GetMachineStatistic(system::kActivateDateKey, nullptr) && |
| 69 system::kActivateDateKey) && | |
| 70 !is_enrolled && | 70 !is_enrolled && |
| 71 !policy::DeviceCloudPolicyManagerChromeOS::GetMachineID().empty(); | 71 !provider->GetMachineID().empty(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 } // namespace | 74 } // namespace |
| 75 | 75 |
| 76 const char AutoEnrollmentController::kForcedReEnrollmentAlways[] = "always"; | 76 const char AutoEnrollmentController::kForcedReEnrollmentAlways[] = "always"; |
| 77 const char AutoEnrollmentController::kForcedReEnrollmentNever[] = "never"; | 77 const char AutoEnrollmentController::kForcedReEnrollmentNever[] = "never"; |
| 78 const char AutoEnrollmentController::kForcedReEnrollmentOfficialBuild[] = | 78 const char AutoEnrollmentController::kForcedReEnrollmentOfficialBuild[] = |
| 79 "official"; | 79 "official"; |
| 80 | 80 |
| 81 AutoEnrollmentController::Mode AutoEnrollmentController::GetMode() { | 81 AutoEnrollmentController::Mode AutoEnrollmentController::GetMode() { |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 290 // open. | 290 // open. |
| 291 LOG(ERROR) << "AutoEnrollmentClient didn't complete within time limit."; | 291 LOG(ERROR) << "AutoEnrollmentClient didn't complete within time limit."; |
| 292 UpdateState(policy::AUTO_ENROLLMENT_STATE_CONNECTION_ERROR); | 292 UpdateState(policy::AUTO_ENROLLMENT_STATE_CONNECTION_ERROR); |
| 293 } | 293 } |
| 294 | 294 |
| 295 // Reset state. | 295 // Reset state. |
| 296 Cancel(); | 296 Cancel(); |
| 297 } | 297 } |
| 298 | 298 |
| 299 } // namespace chromeos | 299 } // namespace chromeos |
| OLD | NEW |