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