| 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 <stdlib.h> | 8 #include <stdlib.h> |
| 9 #include <sys/types.h> | 9 #include <sys/types.h> |
| 10 | 10 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 histogram->AddTime(step_time); | 133 histogram->AddTime(step_time); |
| 134 } | 134 } |
| 135 | 135 |
| 136 bool IsRemoraRequisition() { | 136 bool IsRemoraRequisition() { |
| 137 return g_browser_process->platform_part() | 137 return g_browser_process->platform_part() |
| 138 ->browser_policy_connector_chromeos() | 138 ->browser_policy_connector_chromeos() |
| 139 ->GetDeviceCloudPolicyManager() | 139 ->GetDeviceCloudPolicyManager() |
| 140 ->IsRemoraRequisition(); | 140 ->IsRemoraRequisition(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 // Checks if the device is a "Slave" device in the bootstrapping process. |
| 144 bool IsBootstrappingSlave() { |
| 145 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 146 chromeos::switches::kOobeBootstrappingSlave); |
| 147 } |
| 148 |
| 149 // Checks if the device is a "Master" device in the bootstrapping process. |
| 150 bool IsBootstrappingMaster() { |
| 151 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 152 chromeos::switches::kOobeBootstrappingMaster); |
| 153 } |
| 154 |
| 143 #if defined(GOOGLE_CHROME_BUILD) | 155 #if defined(GOOGLE_CHROME_BUILD) |
| 144 void InitializeCrashReporter() { | 156 void InitializeCrashReporter() { |
| 145 // The crash reporter initialization needs IO to complete. | 157 // The crash reporter initialization needs IO to complete. |
| 146 DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); | 158 DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); |
| 147 breakpad::InitCrashReporter(std::string()); | 159 breakpad::InitCrashReporter(std::string()); |
| 148 } | 160 } |
| 149 #endif | 161 #endif |
| 150 | 162 |
| 151 } // namespace | 163 } // namespace |
| 152 | 164 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 if (status == PrefService::INITIALIZATION_STATUS_ERROR) { | 275 if (status == PrefService::INITIALIZATION_STATUS_ERROR) { |
| 264 OnLocalStateInitialized(false); | 276 OnLocalStateInitialized(false); |
| 265 return; | 277 return; |
| 266 } else if (status == PrefService::INITIALIZATION_STATUS_WAITING) { | 278 } else if (status == PrefService::INITIALIZATION_STATUS_WAITING) { |
| 267 GetLocalState()->AddPrefInitObserver( | 279 GetLocalState()->AddPrefInitObserver( |
| 268 base::Bind(&WizardController::OnLocalStateInitialized, | 280 base::Bind(&WizardController::OnLocalStateInitialized, |
| 269 weak_factory_.GetWeakPtr())); | 281 weak_factory_.GetWeakPtr())); |
| 270 } | 282 } |
| 271 } | 283 } |
| 272 | 284 |
| 285 // If the device is a Master device in bootstrapping process (mostly for demo |
| 286 // and test purpose), start the enrollment OOBE flow. |
| 287 if (IsBootstrappingMaster()) |
| 288 connector->GetDeviceCloudPolicyManager()->SetDeviceEnrollmentAutoStart(); |
| 289 |
| 273 // Use the saved screen preference from Local State. | 290 // Use the saved screen preference from Local State. |
| 274 const std::string screen_pref = | 291 const std::string screen_pref = |
| 275 GetLocalState()->GetString(prefs::kOobeScreenPending); | 292 GetLocalState()->GetString(prefs::kOobeScreenPending); |
| 276 if (is_out_of_box_ && !screen_pref.empty() && !IsHostPairingOobe() && | 293 if (is_out_of_box_ && !screen_pref.empty() && !IsHostPairingOobe() && |
| 277 (first_screen_name.empty() || | 294 (first_screen_name.empty() || |
| 278 first_screen_name == WizardController::kTestNoScreenName)) { | 295 first_screen_name == WizardController::kTestNoScreenName)) { |
| 279 first_screen_name_ = screen_pref; | 296 first_screen_name_ = screen_pref; |
| 280 } | 297 } |
| 281 | 298 |
| 282 AdvanceToScreen(first_screen_name_); | 299 AdvanceToScreen(first_screen_name_); |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 void WizardController::OnConnectionFailed() { | 595 void WizardController::OnConnectionFailed() { |
| 579 // TODO(dpolukhin): show error message after login screen is displayed. | 596 // TODO(dpolukhin): show error message after login screen is displayed. |
| 580 ShowLoginScreen(LoginScreenContext()); | 597 ShowLoginScreen(LoginScreenContext()); |
| 581 } | 598 } |
| 582 | 599 |
| 583 void WizardController::OnUpdateCompleted() { | 600 void WizardController::OnUpdateCompleted() { |
| 584 const bool is_shark = g_browser_process->platform_part() | 601 const bool is_shark = g_browser_process->platform_part() |
| 585 ->browser_policy_connector_chromeos() | 602 ->browser_policy_connector_chromeos() |
| 586 ->GetDeviceCloudPolicyManager() | 603 ->GetDeviceCloudPolicyManager() |
| 587 ->IsSharkRequisition(); | 604 ->IsSharkRequisition(); |
| 588 if (is_shark) { | 605 if (is_shark || IsBootstrappingMaster()) { |
| 589 ShowControllerPairingScreen(); | 606 ShowControllerPairingScreen(); |
| 590 } else { | 607 } else { |
| 591 ShowAutoEnrollmentCheckScreen(); | 608 ShowAutoEnrollmentCheckScreen(); |
| 592 } | 609 } |
| 593 } | 610 } |
| 594 | 611 |
| 595 void WizardController::OnEulaAccepted() { | 612 void WizardController::OnEulaAccepted() { |
| 596 time_eula_accepted_ = base::Time::Now(); | 613 time_eula_accepted_ = base::Time::Now(); |
| 597 StartupUtils::MarkEulaAccepted(); | 614 StartupUtils::MarkEulaAccepted(); |
| 598 InitiateMetricsReportingChange( | 615 InitiateMetricsReportingChange( |
| (...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1280 } | 1297 } |
| 1281 | 1298 |
| 1282 bool WizardController::IsHostPairingOobe() const { | 1299 bool WizardController::IsHostPairingOobe() const { |
| 1283 return IsRemoraRequisition() && | 1300 return IsRemoraRequisition() && |
| 1284 (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1301 (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1285 switches::kHostPairingOobe) || | 1302 switches::kHostPairingOobe) || |
| 1286 shark_controller_detected_); | 1303 shark_controller_detected_); |
| 1287 } | 1304 } |
| 1288 | 1305 |
| 1289 void WizardController::MaybeStartListeningForSharkConnection() { | 1306 void WizardController::MaybeStartListeningForSharkConnection() { |
| 1290 if (!IsRemoraRequisition()) | 1307 if (!IsRemoraRequisition() && !IsBootstrappingSlave()) |
| 1291 return; | 1308 return; |
| 1292 | 1309 |
| 1293 // We shouldn't be here if we are running pairing OOBE already. | 1310 // We shouldn't be here if we are running pairing OOBE already. |
| 1294 DCHECK(!IsHostPairingOobe()); | 1311 DCHECK(!IsHostPairingOobe()); |
| 1295 | 1312 |
| 1296 if (!shark_connection_listener_) { | 1313 if (!shark_connection_listener_) { |
| 1297 shark_connection_listener_.reset( | 1314 shark_connection_listener_.reset( |
| 1298 new pairing_chromeos::SharkConnectionListener( | 1315 new pairing_chromeos::SharkConnectionListener( |
| 1299 base::Bind(&WizardController::OnSharkConnected, | 1316 base::Bind(&WizardController::OnSharkConnected, |
| 1300 weak_factory_.GetWeakPtr()))); | 1317 weak_factory_.GetWeakPtr()))); |
| 1301 } | 1318 } |
| 1302 } | 1319 } |
| 1303 | 1320 |
| 1304 void WizardController::OnSharkConnected( | 1321 void WizardController::OnSharkConnected( |
| 1305 scoped_ptr<pairing_chromeos::HostPairingController> remora_controller) { | 1322 scoped_ptr<pairing_chromeos::HostPairingController> remora_controller) { |
| 1306 VLOG(1) << "OnSharkConnected"; | 1323 VLOG(1) << "OnSharkConnected"; |
| 1307 remora_controller_ = remora_controller.Pass(); | 1324 remora_controller_ = remora_controller.Pass(); |
| 1308 base::MessageLoop::current()->DeleteSoon( | 1325 base::MessageLoop::current()->DeleteSoon( |
| 1309 FROM_HERE, shark_connection_listener_.release()); | 1326 FROM_HERE, shark_connection_listener_.release()); |
| 1310 shark_controller_detected_ = true; | 1327 shark_controller_detected_ = true; |
| 1328 |
| 1329 if (IsBootstrappingSlave()) { |
| 1330 g_browser_process->platform_part() |
| 1331 ->browser_policy_connector_chromeos() |
| 1332 ->GetDeviceCloudPolicyManager() |
| 1333 ->SetDeviceEnrollmentAutoStart(); |
| 1334 } |
| 1335 |
| 1311 ShowHostPairingScreen(); | 1336 ShowHostPairingScreen(); |
| 1312 } | 1337 } |
| 1313 | 1338 |
| 1314 void WizardController::StartEnrollmentScreen() { | 1339 void WizardController::StartEnrollmentScreen() { |
| 1315 VLOG(1) << "Showing enrollment screen."; | 1340 VLOG(1) << "Showing enrollment screen."; |
| 1316 | 1341 |
| 1317 // Determine the effective enrollment configuration. If there is a valid | 1342 // Determine the effective enrollment configuration. If there is a valid |
| 1318 // prescribed configuration, use that. If not, figure out which variant of | 1343 // prescribed configuration, use that. If not, figure out which variant of |
| 1319 // manual enrollment is taking place. | 1344 // manual enrollment is taking place. |
| 1320 policy::EnrollmentConfig effective_config = prescribed_enrollment_config_; | 1345 policy::EnrollmentConfig effective_config = prescribed_enrollment_config_; |
| 1321 if (!effective_config.should_enroll()) { | 1346 if (!effective_config.should_enroll()) { |
| 1322 effective_config.mode = | 1347 effective_config.mode = |
| 1323 prescribed_enrollment_config_.management_domain.empty() | 1348 prescribed_enrollment_config_.management_domain.empty() |
| 1324 ? policy::EnrollmentConfig::MODE_MANUAL | 1349 ? policy::EnrollmentConfig::MODE_MANUAL |
| 1325 : policy::EnrollmentConfig::MODE_MANUAL_REENROLLMENT; | 1350 : policy::EnrollmentConfig::MODE_MANUAL_REENROLLMENT; |
| 1326 } | 1351 } |
| 1327 | 1352 |
| 1328 EnrollmentScreen* screen = EnrollmentScreen::Get(this); | 1353 EnrollmentScreen* screen = EnrollmentScreen::Get(this); |
| 1329 screen->SetParameters(effective_config, shark_controller_.get(), | 1354 screen->SetParameters(effective_config, shark_controller_.get(), |
| 1330 remora_controller_.get()); | 1355 remora_controller_.get()); |
| 1331 SetStatusAreaVisible(true); | 1356 SetStatusAreaVisible(true); |
| 1332 SetCurrentScreen(screen); | 1357 SetCurrentScreen(screen); |
| 1333 } | 1358 } |
| 1334 | 1359 |
| 1335 } // namespace chromeos | 1360 } // namespace chromeos |
| OLD | NEW |