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