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

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

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

Powered by Google App Engine
This is Rietveld 408576698