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

Side by Side Diff: chrome/browser/chromeos/login/wizard_controller.cc

Issue 1887953002: Revert of [Merge to M50] Enable bootstrapping feature by default. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2661
Patch Set: Created 4 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/wizard_controller.h" 5 #include "chrome/browser/chromeos/login/wizard_controller.h"
6 6
7 #include <signal.h> 7 #include <signal.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <sys/types.h> 10 #include <sys/types.h>
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 histogram->AddTime(step_time); 136 histogram->AddTime(step_time);
137 } 137 }
138 138
139 bool IsRemoraRequisition() { 139 bool IsRemoraRequisition() {
140 return g_browser_process->platform_part() 140 return g_browser_process->platform_part()
141 ->browser_policy_connector_chromeos() 141 ->browser_policy_connector_chromeos()
142 ->GetDeviceCloudPolicyManager() 142 ->GetDeviceCloudPolicyManager()
143 ->IsRemoraRequisition(); 143 ->IsRemoraRequisition();
144 } 144 }
145 145
146 // Checks if a controller device ("Master") is detected during the bootstrapping 146 // Checks if the device is a "Slave" device in the bootstrapping process.
147 // or shark/remora setup process. 147 bool IsBootstrappingSlave() {
148 bool IsControllerDetected() { 148 return base::CommandLine::ForCurrentProcess()->HasSwitch(
149 return g_browser_process->local_state()->GetBoolean( 149 chromeos::switches::kOobeBootstrappingSlave);
150 prefs::kOobeControllerDetected);
151 }
152
153 void SetControllerDetectedPref(bool value) {
154 PrefService* prefs = g_browser_process->local_state();
155 prefs->SetBoolean(prefs::kOobeControllerDetected, value);
156 prefs->CommitPendingWrite();
157 } 150 }
158 151
159 // Checks if the device is a "Master" device in the bootstrapping process. 152 // Checks if the device is a "Master" device in the bootstrapping process.
160 bool IsBootstrappingMaster() { 153 bool IsBootstrappingMaster() {
161 return base::CommandLine::ForCurrentProcess()->HasSwitch( 154 return base::CommandLine::ForCurrentProcess()->HasSwitch(
162 chromeos::switches::kOobeBootstrappingMaster); 155 chromeos::switches::kOobeBootstrappingMaster);
163 } 156 }
164 157
165 bool NetworkAllowUpdate(const chromeos::NetworkState* network) { 158 bool NetworkAllowUpdate(const chromeos::NetworkState* network) {
166 if (!network || !network->IsConnectedState()) 159 if (!network || !network->IsConnectedState())
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 DCHECK(default_controller_ == nullptr); 235 DCHECK(default_controller_ == nullptr);
243 default_controller_ = this; 236 default_controller_ = this;
244 AccessibilityManager* accessibility_manager = AccessibilityManager::Get(); 237 AccessibilityManager* accessibility_manager = AccessibilityManager::Get();
245 CHECK(accessibility_manager); 238 CHECK(accessibility_manager);
246 accessibility_subscription_ = accessibility_manager->RegisterCallback( 239 accessibility_subscription_ = accessibility_manager->RegisterCallback(
247 base::Bind(&WizardController::OnAccessibilityStatusChanged, 240 base::Bind(&WizardController::OnAccessibilityStatusChanged,
248 base::Unretained(this))); 241 base::Unretained(this)));
249 } 242 }
250 243
251 WizardController::~WizardController() { 244 WizardController::~WizardController() {
252 if (shark_connection_listener_.get()) {
253 base::MessageLoop::current()->DeleteSoon(
254 FROM_HERE, shark_connection_listener_.release());
255 }
256 if (default_controller_ == this) { 245 if (default_controller_ == this) {
257 default_controller_ = nullptr; 246 default_controller_ = nullptr;
258 } else { 247 } else {
259 NOTREACHED() << "More than one controller are alive."; 248 NOTREACHED() << "More than one controller are alive.";
260 } 249 }
261 } 250 }
262 251
263 void WizardController::Init(const std::string& first_screen_name) { 252 void WizardController::Init(const std::string& first_screen_name) {
264 VLOG(1) << "Starting OOBE wizard with screen: " << first_screen_name; 253 VLOG(1) << "Starting OOBE wizard with screen: " << first_screen_name;
265 first_screen_name_ = first_screen_name; 254 first_screen_name_ = first_screen_name;
(...skipping 27 matching lines...) Expand all
293 282
294 // If the device is a Master device in bootstrapping process (mostly for demo 283 // If the device is a Master device in bootstrapping process (mostly for demo
295 // and test purpose), start the enrollment OOBE flow. 284 // and test purpose), start the enrollment OOBE flow.
296 if (IsBootstrappingMaster()) 285 if (IsBootstrappingMaster())
297 connector->GetDeviceCloudPolicyManager()->SetDeviceEnrollmentAutoStart(); 286 connector->GetDeviceCloudPolicyManager()->SetDeviceEnrollmentAutoStart();
298 287
299 // Use the saved screen preference from Local State. 288 // Use the saved screen preference from Local State.
300 const std::string screen_pref = 289 const std::string screen_pref =
301 GetLocalState()->GetString(prefs::kOobeScreenPending); 290 GetLocalState()->GetString(prefs::kOobeScreenPending);
302 if (is_out_of_box_ && !screen_pref.empty() && !IsRemoraPairingOobe() && 291 if (is_out_of_box_ && !screen_pref.empty() && !IsRemoraPairingOobe() &&
303 !IsControllerDetected() && 292 !IsBootstrappingSlave() &&
304 (first_screen_name.empty() || 293 (first_screen_name.empty() ||
305 first_screen_name == WizardController::kTestNoScreenName)) { 294 first_screen_name == WizardController::kTestNoScreenName)) {
306 first_screen_name_ = screen_pref; 295 first_screen_name_ = screen_pref;
307 } 296 }
308 // We need to reset the kOobeControllerDetected pref to allow the user to have
309 // the choice to setup the device manually. The pref will be set properly if
310 // an eligible controller is detected later.
311 SetControllerDetectedPref(false);
312 297
313 AdvanceToScreen(first_screen_name_); 298 AdvanceToScreen(first_screen_name_);
314 if (!IsMachineHWIDCorrect() && !StartupUtils::IsDeviceRegistered() && 299 if (!IsMachineHWIDCorrect() && !StartupUtils::IsDeviceRegistered() &&
315 first_screen_name_.empty()) 300 first_screen_name_.empty())
316 ShowWrongHWIDScreen(); 301 ShowWrongHWIDScreen();
317 } 302 }
318 303
319 ErrorScreen* WizardController::GetErrorScreen() { 304 ErrorScreen* WizardController::GetErrorScreen() {
320 return oobe_display_->GetErrorScreen(); 305 return oobe_display_->GetErrorScreen();
321 } 306 }
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 ShowLoginScreen(LoginScreenContext()); 596 ShowLoginScreen(LoginScreenContext());
612 } 597 }
613 598
614 void WizardController::OnUpdateCompleted() { 599 void WizardController::OnUpdateCompleted() {
615 const bool is_shark = g_browser_process->platform_part() 600 const bool is_shark = g_browser_process->platform_part()
616 ->browser_policy_connector_chromeos() 601 ->browser_policy_connector_chromeos()
617 ->GetDeviceCloudPolicyManager() 602 ->GetDeviceCloudPolicyManager()
618 ->IsSharkRequisition(); 603 ->IsSharkRequisition();
619 if (is_shark || IsBootstrappingMaster()) { 604 if (is_shark || IsBootstrappingMaster()) {
620 ShowControllerPairingScreen(); 605 ShowControllerPairingScreen();
621 } else if (IsControllerDetected()) { 606 } else if (IsBootstrappingSlave() && shark_controller_detected_) {
622 ShowHostPairingScreen(); 607 ShowHostPairingScreen();
623 } else { 608 } else {
624 ShowAutoEnrollmentCheckScreen(); 609 ShowAutoEnrollmentCheckScreen();
625 } 610 }
626 } 611 }
627 612
628 void WizardController::OnEulaAccepted() { 613 void WizardController::OnEulaAccepted() {
629 time_eula_accepted_ = base::Time::Now(); 614 time_eula_accepted_ = base::Time::Now();
630 StartupUtils::MarkEulaAccepted(); 615 StartupUtils::MarkEulaAccepted();
631 InitiateMetricsReportingChange( 616 InitiateMetricsReportingChange(
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 ShowHIDDetectionScreen(); 930 ShowHIDDetectionScreen();
946 } else if (screen_name == kControllerPairingScreenName) { 931 } else if (screen_name == kControllerPairingScreenName) {
947 ShowControllerPairingScreen(); 932 ShowControllerPairingScreen();
948 } else if (screen_name == kHostPairingScreenName) { 933 } else if (screen_name == kHostPairingScreenName) {
949 ShowHostPairingScreen(); 934 ShowHostPairingScreen();
950 } else if (screen_name == kDeviceDisabledScreenName) { 935 } else if (screen_name == kDeviceDisabledScreenName) {
951 ShowDeviceDisabledScreen(); 936 ShowDeviceDisabledScreen();
952 } else if (screen_name != kTestNoScreenName) { 937 } else if (screen_name != kTestNoScreenName) {
953 if (is_out_of_box_) { 938 if (is_out_of_box_) {
954 time_oobe_started_ = base::Time::Now(); 939 time_oobe_started_ = base::Time::Now();
955 if (IsRemoraPairingOobe() || IsControllerDetected()) { 940 if (IsRemoraPairingOobe() || IsSlavePairingOobe()) {
956 ShowHostPairingScreen(); 941 ShowHostPairingScreen();
957 } else if (CanShowHIDDetectionScreen()) { 942 } else if (CanShowHIDDetectionScreen()) {
958 hid_screen_ = GetScreen(kHIDDetectionScreenName); 943 hid_screen_ = GetScreen(kHIDDetectionScreenName);
959 base::Callback<void(bool)> on_check = base::Bind( 944 base::Callback<void(bool)> on_check = base::Bind(
960 &WizardController::OnHIDScreenNecessityCheck, 945 &WizardController::OnHIDScreenNecessityCheck,
961 weak_factory_.GetWeakPtr()); 946 weak_factory_.GetWeakPtr());
962 oobe_display_->GetHIDDetectionView()->CheckIsScreenRequired(on_check); 947 oobe_display_->GetHIDDetectionView()->CheckIsScreenRequired(on_check);
963 } else { 948 } else {
964 ShowNetworkScreen(); 949 ShowNetworkScreen();
965 } 950 }
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1322 bool WizardController::SetOnTimeZoneResolvedForTesting( 1307 bool WizardController::SetOnTimeZoneResolvedForTesting(
1323 const base::Closure& callback) { 1308 const base::Closure& callback) {
1324 if (timezone_resolved_) 1309 if (timezone_resolved_)
1325 return false; 1310 return false;
1326 1311
1327 on_timezone_resolved_for_testing_ = callback; 1312 on_timezone_resolved_for_testing_ = callback;
1328 return true; 1313 return true;
1329 } 1314 }
1330 1315
1331 bool WizardController::IsRemoraPairingOobe() const { 1316 bool WizardController::IsRemoraPairingOobe() const {
1332 return base::CommandLine::ForCurrentProcess()->HasSwitch( 1317 return IsRemoraRequisition() &&
1333 switches::kHostPairingOobe); 1318 (base::CommandLine::ForCurrentProcess()->HasSwitch(
1319 switches::kHostPairingOobe) ||
1320 shark_controller_detected_);
1321 }
1322
1323 bool WizardController::IsSlavePairingOobe() const {
1324 return IsBootstrappingSlave() && shark_controller_detected_;
1334 } 1325 }
1335 1326
1336 void WizardController::MaybeStartListeningForSharkConnection() { 1327 void WizardController::MaybeStartListeningForSharkConnection() {
1328 if (!IsRemoraRequisition() && !IsBootstrappingSlave())
1329 return;
1330
1337 // We shouldn't be here if we are running pairing OOBE already. 1331 // We shouldn't be here if we are running pairing OOBE already.
1338 if (IsControllerDetected()) 1332 DCHECK(!IsRemoraPairingOobe() && !IsSlavePairingOobe());
1339 return;
1340 1333
1341 if (!shark_connection_listener_) { 1334 if (!shark_connection_listener_) {
1342 shark_connection_listener_.reset( 1335 shark_connection_listener_.reset(
1343 new pairing_chromeos::SharkConnectionListener( 1336 new pairing_chromeos::SharkConnectionListener(
1344 base::Bind(&WizardController::OnSharkConnected, 1337 base::Bind(&WizardController::OnSharkConnected,
1345 weak_factory_.GetWeakPtr()))); 1338 weak_factory_.GetWeakPtr())));
1346 } 1339 }
1347 } 1340 }
1348 1341
1349 void WizardController::OnSharkConnected( 1342 void WizardController::OnSharkConnected(
1350 scoped_ptr<pairing_chromeos::HostPairingController> remora_controller) { 1343 scoped_ptr<pairing_chromeos::HostPairingController> remora_controller) {
1351 VLOG(1) << "OnSharkConnected"; 1344 VLOG(1) << "OnSharkConnected";
1352 remora_controller_ = std::move(remora_controller); 1345 remora_controller_ = std::move(remora_controller);
1353 base::MessageLoop::current()->DeleteSoon( 1346 base::MessageLoop::current()->DeleteSoon(
1354 FROM_HERE, shark_connection_listener_.release()); 1347 FROM_HERE, shark_connection_listener_.release());
1355 SetControllerDetectedPref(true); 1348 shark_controller_detected_ = true;
1356 ShowHostPairingScreen(); 1349 ShowHostPairingScreen();
1357 } 1350 }
1358 1351
1359 void WizardController::OnSetHostNetworkFailed() { 1352 void WizardController::OnSetHostNetworkFailed() {
1360 remora_controller_->OnNetworkConnectivityChanged( 1353 remora_controller_->OnNetworkConnectivityChanged(
1361 pairing_chromeos::HostPairingController::CONNECTIVITY_NONE); 1354 pairing_chromeos::HostPairingController::CONNECTIVITY_NONE);
1362 } 1355 }
1363 1356
1364 void WizardController::StartEnrollmentScreen() { 1357 void WizardController::StartEnrollmentScreen() {
1365 VLOG(1) << "Showing enrollment screen."; 1358 VLOG(1) << "Showing enrollment screen.";
1366 1359
1367 // Determine the effective enrollment configuration. If there is a valid 1360 // Determine the effective enrollment configuration. If there is a valid
1368 // prescribed configuration, use that. If not, figure out which variant of 1361 // prescribed configuration, use that. If not, figure out which variant of
1369 // manual enrollment is taking place. 1362 // manual enrollment is taking place.
1370 policy::EnrollmentConfig effective_config = prescribed_enrollment_config_; 1363 policy::EnrollmentConfig effective_config = prescribed_enrollment_config_;
1371 if (!effective_config.should_enroll()) { 1364 if (!effective_config.should_enroll()) {
1372 effective_config.mode = 1365 effective_config.mode =
1373 prescribed_enrollment_config_.management_domain.empty() 1366 prescribed_enrollment_config_.management_domain.empty()
1374 ? policy::EnrollmentConfig::MODE_MANUAL 1367 ? policy::EnrollmentConfig::MODE_MANUAL
1375 : policy::EnrollmentConfig::MODE_MANUAL_REENROLLMENT; 1368 : policy::EnrollmentConfig::MODE_MANUAL_REENROLLMENT;
1376 } 1369 }
1377 1370
1378 EnrollmentScreen* screen = EnrollmentScreen::Get(this); 1371 EnrollmentScreen* screen = EnrollmentScreen::Get(this);
1379 screen->SetParameters(effective_config, shark_controller_.get()); 1372 screen->SetParameters(effective_config, shark_controller_.get());
1380 SetStatusAreaVisible(true); 1373 SetStatusAreaVisible(true);
1381 SetCurrentScreen(screen); 1374 SetCurrentScreen(screen);
1382 } 1375 }
1383 1376
1384 } // namespace chromeos 1377 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698