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

Side by Side Diff: chrome/browser/chromeos/login/enrollment/auto_enrollment_controller.cc

Issue 2898003002: Allow the powerwash shortcut only for devices without FRE (Closed)
Patch Set: Let the powerwash shortcut only for devices without FRE Created 3 years, 7 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
OLDNEW
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"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } 48 }
49 if (int_value > policy::AutoEnrollmentClient::kMaximumPower) { 49 if (int_value > policy::AutoEnrollmentClient::kMaximumPower) {
50 LOG(ERROR) << "Switch \"" << switch_name << "\" can't be greater than " 50 LOG(ERROR) << "Switch \"" << switch_name << "\" can't be greater than "
51 << policy::AutoEnrollmentClient::kMaximumPower << ". Using " 51 << policy::AutoEnrollmentClient::kMaximumPower << ". Using "
52 << policy::AutoEnrollmentClient::kMaximumPower; 52 << policy::AutoEnrollmentClient::kMaximumPower;
53 return policy::AutoEnrollmentClient::kMaximumPower; 53 return policy::AutoEnrollmentClient::kMaximumPower;
54 } 54 }
55 return int_value; 55 return int_value;
56 } 56 }
57 57
58 // Returns whether the auto-enrollment check is required. When
59 // kCheckEnrollmentKey VPD entry is present, it is explicitly stating whether
60 // the forced re-enrollment is required or not. Otherwise, for backward
61 // compatibility with devices upgrading from an older version of Chrome OS, the
62 // kActivateDateKey VPD entry is queried. If it's missing, FRE is not required.
63 // This enables factories to start full guest sessions for testing, see
64 // http://crbug.com/397354 for more context. The requirement for the machine
65 // serial number to be present is a sanity-check to ensure that the VPD has
66 // actually been read successfully. If VPD read failed, the FRE check is
67 // required.
68 AutoEnrollmentController::FRERequirement GetFRERequirement() {
69 std::string check_enrollment_value;
70 system::StatisticsProvider* provider =
71 system::StatisticsProvider::GetInstance();
72 bool fre_flag_found = provider->GetMachineStatistic(
73 system::kCheckEnrollmentKey, &check_enrollment_value);
74
75 if (fre_flag_found) {
76 if (check_enrollment_value == "0")
77 return AutoEnrollmentController::EXPLICITLY_NOT_REQUIRED;
78 if (check_enrollment_value == "1")
79 return AutoEnrollmentController::EXPLICITLY_REQUIRED;
80 }
81 if (!provider->GetMachineStatistic(system::kActivateDateKey, nullptr) &&
82 !provider->GetEnterpriseMachineID().empty()) {
83 return AutoEnrollmentController::NOT_REQUIRED;
84 }
85 return AutoEnrollmentController::REQUIRED;
86 }
87
88 std::string FRERequirementToString( 58 std::string FRERequirementToString(
89 AutoEnrollmentController::FRERequirement requirement) { 59 AutoEnrollmentController::FRERequirement requirement) {
90 switch (requirement) { 60 switch (requirement) {
91 case AutoEnrollmentController::REQUIRED: 61 case AutoEnrollmentController::REQUIRED:
92 return "Auto-enrollment required."; 62 return "Auto-enrollment required.";
93 case AutoEnrollmentController::NOT_REQUIRED: 63 case AutoEnrollmentController::NOT_REQUIRED:
94 return "Auto-enrollment disabled: first setup."; 64 return "Auto-enrollment disabled: first setup.";
95 case AutoEnrollmentController::EXPLICITLY_REQUIRED: 65 case AutoEnrollmentController::EXPLICITLY_REQUIRED:
96 return "Auto-enrollment required: flag in VPD."; 66 return "Auto-enrollment required: flag in VPD.";
97 case AutoEnrollmentController::EXPLICITLY_NOT_REQUIRED: 67 case AutoEnrollmentController::EXPLICITLY_NOT_REQUIRED:
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 return MODE_NONE; 99 return MODE_NONE;
130 #endif 100 #endif
131 } else if (command_line_mode == kForcedReEnrollmentNever) { 101 } else if (command_line_mode == kForcedReEnrollmentNever) {
132 return MODE_NONE; 102 return MODE_NONE;
133 } 103 }
134 104
135 LOG(FATAL) << "Unknown auto-enrollment mode " << command_line_mode; 105 LOG(FATAL) << "Unknown auto-enrollment mode " << command_line_mode;
136 return MODE_NONE; 106 return MODE_NONE;
137 } 107 }
138 108
109 AutoEnrollmentController::FRERequirement
110 AutoEnrollmentController::GetFRERequirement() {
Andrew T Wilson (Slow) 2017/05/23 05:32:06 I'm not a huge fan of moving code around unnecessa
igorcov 2017/05/23 09:28:49 I need this function to be visible from outside, s
111 std::string check_enrollment_value;
112 system::StatisticsProvider* provider =
113 system::StatisticsProvider::GetInstance();
114 bool fre_flag_found = provider->GetMachineStatistic(
115 system::kCheckEnrollmentKey, &check_enrollment_value);
116
117 if (fre_flag_found) {
118 if (check_enrollment_value == "0")
119 return AutoEnrollmentController::EXPLICITLY_NOT_REQUIRED;
120 if (check_enrollment_value == "1")
121 return AutoEnrollmentController::EXPLICITLY_REQUIRED;
122 }
123 if (!provider->GetMachineStatistic(system::kActivateDateKey, nullptr) &&
124 !provider->GetEnterpriseMachineID().empty()) {
125 return AutoEnrollmentController::NOT_REQUIRED;
126 }
127 return AutoEnrollmentController::REQUIRED;
128 }
129
139 AutoEnrollmentController::AutoEnrollmentController() {} 130 AutoEnrollmentController::AutoEnrollmentController() {}
140 131
141 AutoEnrollmentController::~AutoEnrollmentController() {} 132 AutoEnrollmentController::~AutoEnrollmentController() {}
142 133
143 void AutoEnrollmentController::Start() { 134 void AutoEnrollmentController::Start() {
144 switch (state_) { 135 switch (state_) {
145 case policy::AUTO_ENROLLMENT_STATE_PENDING: 136 case policy::AUTO_ENROLLMENT_STATE_PENDING:
146 // Abort re-start if the check is still running. 137 // Abort re-start if the check is still running.
147 return; 138 return;
148 case policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT: 139 case policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT:
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 // Cancelling the |client_| allows it to determine whether 336 // Cancelling the |client_| allows it to determine whether
346 // its protocol finished before login was complete. 337 // its protocol finished before login was complete.
347 client_.release()->CancelAndDeleteSoon(); 338 client_.release()->CancelAndDeleteSoon();
348 } 339 }
349 340
350 // Make sure to nuke pending |client_| start sequences. 341 // Make sure to nuke pending |client_| start sequences.
351 client_start_weak_factory_.InvalidateWeakPtrs(); 342 client_start_weak_factory_.InvalidateWeakPtrs();
352 } 343 }
353 344
354 } // namespace chromeos 345 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698