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

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: Created 3 years, 9 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 bool fre_flag_found = provider->GetMachineStatistic( 69 bool fre_flag_found = provider->GetMachineStatistic(
70 system::kCheckEnrollmentKey, &check_enrollment_value); 70 system::kCheckEnrollmentKey, &check_enrollment_value);
71 71
72 if (fre_flag_found) { 72 if (fre_flag_found) {
73 if (check_enrollment_value == "0") 73 if (check_enrollment_value == "0")
74 return AutoEnrollmentController::EXPLICITLY_NOT_REQUIRED; 74 return AutoEnrollmentController::EXPLICITLY_NOT_REQUIRED;
75 if (check_enrollment_value == "1") 75 if (check_enrollment_value == "1")
76 return AutoEnrollmentController::EXPLICITLY_REQUIRED; 76 return AutoEnrollmentController::EXPLICITLY_REQUIRED;
77 } 77 }
78 if (!provider->GetMachineStatistic(system::kActivateDateKey, nullptr) && 78 if (!provider->GetMachineStatistic(system::kActivateDateKey, nullptr) &&
79 !provider->GetEnterpriseMachineID().empty()) 79 !provider->GetEnterpriseMachineID().empty()) {
80 return AutoEnrollmentController::NOT_REQUIRED; 80 return AutoEnrollmentController::NOT_REQUIRED;
81 }
81 return AutoEnrollmentController::REQUIRED; 82 return AutoEnrollmentController::REQUIRED;
82 } 83 }
83 84
84 std::string FRERequirementToString( 85 std::string FRERequirementToString(
85 AutoEnrollmentController::FRERequirement requirement) { 86 AutoEnrollmentController::FRERequirement requirement) {
86 switch (requirement) { 87 switch (requirement) {
87 case AutoEnrollmentController::REQUIRED: 88 case AutoEnrollmentController::REQUIRED:
88 return "Auto-enrollment required."; 89 return "Auto-enrollment required.";
89 case AutoEnrollmentController::NOT_REQUIRED: 90 case AutoEnrollmentController::NOT_REQUIRED:
90 return "Auto-enrollment disabled: first setup."; 91 return "Auto-enrollment disabled: first setup.";
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 FROM_HERE, base::TimeDelta::FromSeconds(kSafeguardTimeoutSeconds), 183 FROM_HERE, base::TimeDelta::FromSeconds(kSafeguardTimeoutSeconds),
183 base::Bind(&AutoEnrollmentController::Timeout, base::Unretained(this))); 184 base::Bind(&AutoEnrollmentController::Timeout, base::Unretained(this)));
184 185
185 // Start by checking if the device has already been owned. 186 // Start by checking if the device has already been owned.
186 UpdateState(policy::AUTO_ENROLLMENT_STATE_PENDING); 187 UpdateState(policy::AUTO_ENROLLMENT_STATE_PENDING);
187 DeviceSettingsService::Get()->GetOwnershipStatusAsync( 188 DeviceSettingsService::Get()->GetOwnershipStatusAsync(
188 base::Bind(&AutoEnrollmentController::OnOwnershipStatusCheckDone, 189 base::Bind(&AutoEnrollmentController::OnOwnershipStatusCheckDone,
189 client_start_weak_factory_.GetWeakPtr())); 190 client_start_weak_factory_.GetWeakPtr()));
190 } 191 }
191 192
192 void AutoEnrollmentController::Cancel() {
193 if (client_) {
194 // Cancelling the |client_| allows it to determine whether
195 // its protocol finished before login was complete.
196 client_.release()->CancelAndDeleteSoon();
197 }
198
199 // Make sure to nuke pending |client_| start sequences.
200 client_start_weak_factory_.InvalidateWeakPtrs();
201
202 safeguard_timer_.Stop();
203 }
204
205 void AutoEnrollmentController::Retry() { 193 void AutoEnrollmentController::Retry() {
206 if (client_) 194 if (client_)
207 client_->Retry(); 195 client_->Retry();
208 else 196 else
209 Start(); 197 Start();
210 } 198 }
211 199
212 std::unique_ptr<AutoEnrollmentController::ProgressCallbackList::Subscription> 200 std::unique_ptr<AutoEnrollmentController::ProgressCallbackList::Subscription>
213 AutoEnrollmentController::RegisterProgressCallback( 201 AutoEnrollmentController::RegisterProgressCallback(
214 const ProgressCallbackList::CallbackType& callback) { 202 const ProgressCallbackList::CallbackType& callback) {
215 return progress_callbacks_.Add(callback); 203 return progress_callbacks_.Add(callback);
216 } 204 }
217 205
218 void AutoEnrollmentController::OnOwnershipStatusCheckDone( 206 void AutoEnrollmentController::OnOwnershipStatusCheckDone(
219 DeviceSettingsService::OwnershipStatus status) { 207 DeviceSettingsService::OwnershipStatus status) {
220 policy::ServerBackedStateKeysBroker* state_keys_broker = 208 switch (status) {
209 case DeviceSettingsService::OWNERSHIP_NONE:
221 g_browser_process->platform_part() 210 g_browser_process->platform_part()
222 ->browser_policy_connector_chromeos() 211 ->browser_policy_connector_chromeos()
223 ->GetStateKeysBroker(); 212 ->GetStateKeysBroker()
224 switch (status) { 213 ->RequestStateKeys(
225 case DeviceSettingsService::OWNERSHIP_NONE: 214 base::Bind(&AutoEnrollmentController::StartClient,
226 // TODO(tnagel): Prevent missing state keys broker in the first place. 215 client_start_weak_factory_.GetWeakPtr()));
227 // https://crbug.com/703658
228 if (!state_keys_broker) {
229 LOG(ERROR) << "State keys broker missing.";
230 UpdateState(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT);
231 return;
232 }
233 state_keys_broker->RequestStateKeys(
234 base::Bind(&AutoEnrollmentController::StartClient,
235 client_start_weak_factory_.GetWeakPtr()));
236 return; 216 return;
237 case DeviceSettingsService::OWNERSHIP_TAKEN: 217 case DeviceSettingsService::OWNERSHIP_TAKEN:
238 VLOG(1) << "Device already owned, skipping auto-enrollment check."; 218 VLOG(1) << "Device already owned, skipping auto-enrollment check.";
239 UpdateState(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT); 219 UpdateState(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT);
240 return; 220 return;
241 case DeviceSettingsService::OWNERSHIP_UNKNOWN: 221 case DeviceSettingsService::OWNERSHIP_UNKNOWN:
242 LOG(ERROR) << "Ownership unknown, skipping auto-enrollment check."; 222 LOG(ERROR) << "Ownership unknown, skipping auto-enrollment check.";
243 UpdateState(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT); 223 UpdateState(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT);
244 return; 224 return;
245 } 225 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 UpdateState(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT); 295 UpdateState(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT);
316 } else { 296 } else {
317 // This can actually happen in some cases, for example when state key 297 // This can actually happen in some cases, for example when state key
318 // generation is waiting for time sync or the server just doesn't reply and 298 // generation is waiting for time sync or the server just doesn't reply and
319 // keeps the connection open. 299 // keeps the connection open.
320 LOG(ERROR) << "AutoEnrollmentClient didn't complete within time limit."; 300 LOG(ERROR) << "AutoEnrollmentClient didn't complete within time limit.";
321 UpdateState(policy::AUTO_ENROLLMENT_STATE_CONNECTION_ERROR); 301 UpdateState(policy::AUTO_ENROLLMENT_STATE_CONNECTION_ERROR);
322 } 302 }
323 303
324 // Reset state. 304 // Reset state.
325 Cancel(); 305 if (client_) {
306 // Cancelling the |client_| allows it to determine whether
307 // its protocol finished before login was complete.
308 client_.release()->CancelAndDeleteSoon();
309 }
310
311 // Make sure to nuke pending |client_| start sequences.
312 client_start_weak_factory_.InvalidateWeakPtrs();
326 } 313 }
327 314
328 } // namespace chromeos 315 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698