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

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

Issue 2771803003: Don't start FRE from the login screen (Closed)
Patch Set: Fix browser tests Created 3 years, 8 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 bool fre_flag_found = provider->GetMachineStatistic( 72 bool fre_flag_found = provider->GetMachineStatistic(
73 system::kCheckEnrollmentKey, &check_enrollment_value); 73 system::kCheckEnrollmentKey, &check_enrollment_value);
74 74
75 if (fre_flag_found) { 75 if (fre_flag_found) {
76 if (check_enrollment_value == "0") 76 if (check_enrollment_value == "0")
77 return AutoEnrollmentController::EXPLICITLY_NOT_REQUIRED; 77 return AutoEnrollmentController::EXPLICITLY_NOT_REQUIRED;
78 if (check_enrollment_value == "1") 78 if (check_enrollment_value == "1")
79 return AutoEnrollmentController::EXPLICITLY_REQUIRED; 79 return AutoEnrollmentController::EXPLICITLY_REQUIRED;
80 } 80 }
81 if (!provider->GetMachineStatistic(system::kActivateDateKey, nullptr) && 81 if (!provider->GetMachineStatistic(system::kActivateDateKey, nullptr) &&
82 !provider->GetEnterpriseMachineID().empty()) 82 !provider->GetEnterpriseMachineID().empty()) {
83 return AutoEnrollmentController::NOT_REQUIRED; 83 return AutoEnrollmentController::NOT_REQUIRED;
84 }
84 return AutoEnrollmentController::REQUIRED; 85 return AutoEnrollmentController::REQUIRED;
85 } 86 }
86 87
87 std::string FRERequirementToString( 88 std::string FRERequirementToString(
88 AutoEnrollmentController::FRERequirement requirement) { 89 AutoEnrollmentController::FRERequirement requirement) {
89 switch (requirement) { 90 switch (requirement) {
90 case AutoEnrollmentController::REQUIRED: 91 case AutoEnrollmentController::REQUIRED:
91 return "Auto-enrollment required."; 92 return "Auto-enrollment required.";
92 case AutoEnrollmentController::NOT_REQUIRED: 93 case AutoEnrollmentController::NOT_REQUIRED:
93 return "Auto-enrollment disabled: first setup."; 94 return "Auto-enrollment disabled: first setup.";
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 134
134 LOG(FATAL) << "Unknown auto-enrollment mode " << command_line_mode; 135 LOG(FATAL) << "Unknown auto-enrollment mode " << command_line_mode;
135 return MODE_NONE; 136 return MODE_NONE;
136 } 137 }
137 138
138 AutoEnrollmentController::AutoEnrollmentController() {} 139 AutoEnrollmentController::AutoEnrollmentController() {}
139 140
140 AutoEnrollmentController::~AutoEnrollmentController() {} 141 AutoEnrollmentController::~AutoEnrollmentController() {}
141 142
142 void AutoEnrollmentController::Start() { 143 void AutoEnrollmentController::Start() {
143 // This method is called at the point in the OOBE/login flow at which the 144 // This method is called at the point in the OOBE/login flow at which the
Thiemo Nagel 2017/04/20 13:24:00 Deleting this comment since it's incomplete (doesn
144 // auto-enrollment check can start. This happens either after the EULA is 145 // auto-enrollment check can start. This happens either after the EULA is
145 // accepted, or right after a reboot if the EULA has already been accepted. 146 // accepted, or right after a reboot if the EULA has already been accepted.
146 147
147 // Skip if GAIA is disabled or modulus configuration is not present. 148 // Skip if GAIA is disabled or modulus configuration is not present.
148 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 149 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
149 if (command_line->HasSwitch(chromeos::switches::kDisableGaiaServices) || 150 if (command_line->HasSwitch(chromeos::switches::kDisableGaiaServices) ||
150 (!command_line->HasSwitch( 151 (!command_line->HasSwitch(
151 chromeos::switches::kEnterpriseEnrollmentInitialModulus) && 152 chromeos::switches::kEnterpriseEnrollmentInitialModulus) &&
152 !command_line->HasSwitch( 153 !command_line->HasSwitch(
153 chromeos::switches::kEnterpriseEnrollmentModulusLimit))) { 154 chromeos::switches::kEnterpriseEnrollmentModulusLimit))) {
154 VLOG(1) << "Auto-enrollment disabled: command line."; 155 VLOG(1) << "Auto-enrollment disabled: command line.";
155 UpdateState(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT); 156 UpdateState(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT);
156 return; 157 return;
157 } 158 }
158 159
159 // Skip if mode comes up as none. 160 // Skip if mode comes up as none.
160 if (GetMode() == MODE_NONE) { 161 if (GetMode() == MODE_NONE) {
achuithb 2017/04/19 19:04:43 Maybe add the state check here?
Thiemo Nagel 2017/04/20 13:24:00 I've put it right at the start of the method.
161 VLOG(1) << "Auto-enrollment disabled: no mode."; 162 VLOG(1) << "Auto-enrollment disabled: no mode.";
162 UpdateState(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT); 163 UpdateState(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT);
163 return; 164 return;
164 } 165 }
165 166
166 fre_requirement_ = GetFRERequirement(); 167 fre_requirement_ = GetFRERequirement();
167 VLOG(1) << FRERequirementToString(fre_requirement_); 168 VLOG(1) << FRERequirementToString(fre_requirement_);
168 if (fre_requirement_ == EXPLICITLY_NOT_REQUIRED || 169 if (fre_requirement_ == EXPLICITLY_NOT_REQUIRED ||
169 fre_requirement_ == NOT_REQUIRED) { 170 fre_requirement_ == NOT_REQUIRED) {
170 UpdateState(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT); 171 UpdateState(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT);
(...skipping 12 matching lines...) Expand all
183 base::Bind(&AutoEnrollmentController::Timeout, 184 base::Bind(&AutoEnrollmentController::Timeout,
184 weak_ptr_factory_.GetWeakPtr())); 185 weak_ptr_factory_.GetWeakPtr()));
185 186
186 // Start by checking if the device has already been owned. 187 // Start by checking if the device has already been owned.
187 UpdateState(policy::AUTO_ENROLLMENT_STATE_PENDING); 188 UpdateState(policy::AUTO_ENROLLMENT_STATE_PENDING);
188 DeviceSettingsService::Get()->GetOwnershipStatusAsync( 189 DeviceSettingsService::Get()->GetOwnershipStatusAsync(
189 base::Bind(&AutoEnrollmentController::OnOwnershipStatusCheckDone, 190 base::Bind(&AutoEnrollmentController::OnOwnershipStatusCheckDone,
190 client_start_weak_factory_.GetWeakPtr())); 191 client_start_weak_factory_.GetWeakPtr()));
191 } 192 }
192 193
193 void AutoEnrollmentController::Cancel() {
194 if (client_) {
195 // Cancelling the |client_| allows it to determine whether
196 // its protocol finished before login was complete.
197 client_.release()->CancelAndDeleteSoon();
198 }
199
200 // Make sure to nuke pending |client_| start sequences.
201 client_start_weak_factory_.InvalidateWeakPtrs();
202
203 safeguard_timer_.Stop();
204 }
205
206 void AutoEnrollmentController::Retry() { 194 void AutoEnrollmentController::Retry() {
207 if (client_) 195 if (client_)
208 client_->Retry(); 196 client_->Retry();
209 else 197 else
210 Start(); 198 Start();
211 } 199 }
212 200
213 std::unique_ptr<AutoEnrollmentController::ProgressCallbackList::Subscription> 201 std::unique_ptr<AutoEnrollmentController::ProgressCallbackList::Subscription>
214 AutoEnrollmentController::RegisterProgressCallback( 202 AutoEnrollmentController::RegisterProgressCallback(
215 const ProgressCallbackList::CallbackType& callback) { 203 const ProgressCallbackList::CallbackType& callback) {
216 return progress_callbacks_.Add(callback); 204 return progress_callbacks_.Add(callback);
217 } 205 }
218 206
219 void AutoEnrollmentController::OnOwnershipStatusCheckDone( 207 void AutoEnrollmentController::OnOwnershipStatusCheckDone(
220 DeviceSettingsService::OwnershipStatus status) { 208 DeviceSettingsService::OwnershipStatus status) {
221 policy::ServerBackedStateKeysBroker* state_keys_broker = 209 switch (status) {
210 case DeviceSettingsService::OWNERSHIP_NONE:
222 g_browser_process->platform_part() 211 g_browser_process->platform_part()
223 ->browser_policy_connector_chromeos() 212 ->browser_policy_connector_chromeos()
224 ->GetStateKeysBroker(); 213 ->GetStateKeysBroker()
225 switch (status) { 214 ->RequestStateKeys(
226 case DeviceSettingsService::OWNERSHIP_NONE: 215 base::Bind(&AutoEnrollmentController::StartClient,
227 // TODO(tnagel): Prevent missing state keys broker in the first place. 216 client_start_weak_factory_.GetWeakPtr()));
228 // https://crbug.com/703658
229 if (!state_keys_broker) {
230 LOG(ERROR) << "State keys broker missing.";
231 UpdateState(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT);
232 return;
233 }
234 state_keys_broker->RequestStateKeys(
235 base::Bind(&AutoEnrollmentController::StartClient,
236 client_start_weak_factory_.GetWeakPtr()));
237 return; 217 return;
238 case DeviceSettingsService::OWNERSHIP_TAKEN: 218 case DeviceSettingsService::OWNERSHIP_TAKEN:
239 VLOG(1) << "Device already owned, skipping auto-enrollment check."; 219 VLOG(1) << "Device already owned, skipping auto-enrollment check.";
240 UpdateState(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT); 220 UpdateState(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT);
241 return; 221 return;
242 case DeviceSettingsService::OWNERSHIP_UNKNOWN: 222 case DeviceSettingsService::OWNERSHIP_UNKNOWN:
243 LOG(ERROR) << "Ownership unknown, skipping auto-enrollment check."; 223 LOG(ERROR) << "Ownership unknown, skipping auto-enrollment check.";
244 UpdateState(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT); 224 UpdateState(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT);
245 return; 225 return;
246 } 226 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 UpdateState(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT); 322 UpdateState(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT);
343 } else { 323 } else {
344 // This can actually happen in some cases, for example when state key 324 // This can actually happen in some cases, for example when state key
345 // generation is waiting for time sync or the server just doesn't reply and 325 // generation is waiting for time sync or the server just doesn't reply and
346 // keeps the connection open. 326 // keeps the connection open.
347 LOG(ERROR) << "AutoEnrollmentClient didn't complete within time limit."; 327 LOG(ERROR) << "AutoEnrollmentClient didn't complete within time limit.";
348 UpdateState(policy::AUTO_ENROLLMENT_STATE_CONNECTION_ERROR); 328 UpdateState(policy::AUTO_ENROLLMENT_STATE_CONNECTION_ERROR);
349 } 329 }
350 330
351 // Reset state. 331 // Reset state.
352 Cancel(); 332 if (client_) {
333 // Cancelling the |client_| allows it to determine whether
334 // its protocol finished before login was complete.
335 client_.release()->CancelAndDeleteSoon();
336 }
337
338 // Make sure to nuke pending |client_| start sequences.
339 client_start_weak_factory_.InvalidateWeakPtrs();
353 } 340 }
354 341
355 } // namespace chromeos 342 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698