Chromium Code Reviews| 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 248 /////////////////////////////////////////////////////////////////////////////// | 248 /////////////////////////////////////////////////////////////////////////////// |
| 249 // WizardController, public: | 249 // WizardController, public: |
| 250 | 250 |
| 251 PrefService* WizardController::local_state_for_testing_ = nullptr; | 251 PrefService* WizardController::local_state_for_testing_ = nullptr; |
| 252 | 252 |
| 253 WizardController::WizardController(LoginDisplayHost* host, OobeUI* oobe_ui) | 253 WizardController::WizardController(LoginDisplayHost* host, OobeUI* oobe_ui) |
| 254 : host_(host), oobe_ui_(oobe_ui), weak_factory_(this) { | 254 : host_(host), oobe_ui_(oobe_ui), weak_factory_(this) { |
| 255 DCHECK(default_controller_ == nullptr); | 255 DCHECK(default_controller_ == nullptr); |
| 256 default_controller_ = this; | 256 default_controller_ = this; |
| 257 screen_manager_ = base::MakeUnique<ScreenManager>(this); | 257 screen_manager_ = base::MakeUnique<ScreenManager>(this); |
| 258 device_marked_registered_ = StartupUtils::IsDeviceRegistered(); | |
|
xiyuan
2017/06/12 17:19:56
|device_marked_registered_| does not look like rel
yueli
2017/06/12 20:10:07
How about use IsSessionStarted instead and add com
| |
| 258 if (!ash_util::IsRunningInMash()) { | 259 if (!ash_util::IsRunningInMash()) { |
| 259 AccessibilityManager* accessibility_manager = AccessibilityManager::Get(); | 260 AccessibilityManager* accessibility_manager = AccessibilityManager::Get(); |
| 260 CHECK(accessibility_manager); | 261 CHECK(accessibility_manager); |
| 261 accessibility_subscription_ = accessibility_manager->RegisterCallback( | 262 accessibility_subscription_ = accessibility_manager->RegisterCallback( |
| 262 base::Bind(&WizardController::OnAccessibilityStatusChanged, | 263 base::Bind(&WizardController::OnAccessibilityStatusChanged, |
| 263 base::Unretained(this))); | 264 base::Unretained(this))); |
| 264 } else { | 265 } else { |
| 265 NOTIMPLEMENTED(); | 266 NOTIMPLEMENTED(); |
| 266 } | 267 } |
| 267 } | 268 } |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 821 DBusThreadManager::Get()->GetSessionManagerClient()->StopSession(); | 822 DBusThreadManager::Get()->GetSessionManagerClient()->StopSession(); |
| 822 } | 823 } |
| 823 | 824 |
| 824 void WizardController::OnTermsOfServiceAccepted() { | 825 void WizardController::OnTermsOfServiceAccepted() { |
| 825 // If the user accepts the Terms of Service, advance to the PlayStore terms | 826 // If the user accepts the Terms of Service, advance to the PlayStore terms |
| 826 // of serice. | 827 // of serice. |
| 827 ShowArcTermsOfServiceScreen(); | 828 ShowArcTermsOfServiceScreen(); |
| 828 } | 829 } |
| 829 | 830 |
| 830 void WizardController::OnArcTermsOfServiceFinished() { | 831 void WizardController::OnArcTermsOfServiceFinished() { |
| 832 const Profile* profile = ProfileManager::GetActiveUserProfile(); | |
| 833 if (device_marked_registered_) { | |
| 834 if (profile->GetPrefs()->GetBoolean(prefs::kArcTermsAccepted)) | |
| 835 StartVoiceInteractionSetupWizard(); | |
| 836 OnOobeFlowFinished(); | |
| 837 return; | |
| 838 } | |
| 831 // If the user finished with the PlayStore Terms of Service, advance to the | 839 // If the user finished with the PlayStore Terms of Service, advance to the |
| 832 // user image screen. | 840 // user image screen. |
| 833 ShowUserImageScreen(); | 841 ShowUserImageScreen(); |
| 834 } | 842 } |
| 835 | 843 |
| 836 void WizardController::OnVoiceInteractionValuePropSkipped() { | 844 void WizardController::OnVoiceInteractionValuePropSkipped() { |
| 837 OnOobeFlowFinished(); | 845 OnOobeFlowFinished(); |
| 838 } | 846 } |
| 839 | 847 |
| 840 void WizardController::OnVoiceInteractionValuePropAccepted() { | 848 void WizardController::OnVoiceInteractionValuePropAccepted() { |
| 841 // Start voice interaction setup wizard in container | 849 const Profile* profile = ProfileManager::GetActiveUserProfile(); |
| 842 arc::ArcVoiceInteractionFrameworkService* service = | 850 if (device_marked_registered_ && |
| 843 arc::ArcServiceManager::Get() | 851 !arc::IsArcPlayStoreEnabledForProfile(profile)) { |
| 844 ->GetService<arc::ArcVoiceInteractionFrameworkService>(); | 852 ShowArcTermsOfServiceScreen(); |
| 845 if (service) | 853 return; |
| 846 service->StartVoiceInteractionSetupWizard(); | 854 } |
| 855 StartVoiceInteractionSetupWizard(); | |
| 847 OnOobeFlowFinished(); | 856 OnOobeFlowFinished(); |
| 848 } | 857 } |
| 849 | 858 |
| 850 void WizardController::OnControllerPairingFinished() { | 859 void WizardController::OnControllerPairingFinished() { |
| 851 ShowAutoEnrollmentCheckScreen(); | 860 ShowAutoEnrollmentCheckScreen(); |
| 852 } | 861 } |
| 853 | 862 |
| 854 void WizardController::OnAutoEnrollmentCheckCompleted() { | 863 void WizardController::OnAutoEnrollmentCheckCompleted() { |
| 855 // Check whether the device is disabled. OnDeviceDisabledChecked() will be | 864 // Check whether the device is disabled. OnDeviceDisabledChecked() will be |
| 856 // invoked when the result of this check is known. Until then, the current | 865 // invoked when the result of this check is known. Until then, the current |
| 857 // screen will remain visible and will continue showing a spinner. | 866 // screen will remain visible and will continue showing a spinner. |
| 858 g_browser_process->platform_part()->device_disabling_manager()-> | 867 g_browser_process->platform_part()->device_disabling_manager()-> |
| 859 CheckWhetherDeviceDisabledDuringOOBE(base::Bind( | 868 CheckWhetherDeviceDisabledDuringOOBE(base::Bind( |
| 860 &WizardController::OnDeviceDisabledChecked, | 869 &WizardController::OnDeviceDisabledChecked, |
| 861 weak_factory_.GetWeakPtr())); | 870 weak_factory_.GetWeakPtr())); |
| 862 } | 871 } |
| 863 | 872 |
| 864 void WizardController::OnOobeFlowFinished() { | 873 void WizardController::OnOobeFlowFinished() { |
| 874 if (device_marked_registered_) { | |
| 875 host_->SetStatusAreaVisible(true); | |
| 876 base::OnceClosure empty_callback = base::BindOnce([] {}); | |
| 877 host_->Finalize(std::move(empty_callback)); | |
|
xiyuan
2017/06/12 17:19:56
Since you don't care about the callback, you can j
yueli
2017/06/12 20:10:07
Done.
| |
| 878 host_ = nullptr; | |
| 879 return; | |
| 880 } | |
| 881 | |
| 865 if (!time_oobe_started_.is_null()) { | 882 if (!time_oobe_started_.is_null()) { |
| 866 base::TimeDelta delta = base::Time::Now() - time_oobe_started_; | 883 base::TimeDelta delta = base::Time::Now() - time_oobe_started_; |
| 867 UMA_HISTOGRAM_CUSTOM_TIMES("OOBE.BootToSignInCompleted", delta, | 884 UMA_HISTOGRAM_CUSTOM_TIMES("OOBE.BootToSignInCompleted", delta, |
| 868 base::TimeDelta::FromMilliseconds(10), | 885 base::TimeDelta::FromMilliseconds(10), |
| 869 base::TimeDelta::FromMinutes(30), 100); | 886 base::TimeDelta::FromMinutes(30), 100); |
| 870 time_oobe_started_ = base::Time(); | 887 time_oobe_started_ = base::Time(); |
| 871 } | 888 } |
| 872 | 889 |
| 873 // Launch browser and delete login host controller. | 890 // Launch browser and delete login host controller. |
| 874 BrowserThread::PostTask( | 891 BrowserThread::PostTask( |
| (...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1537 } | 1554 } |
| 1538 if (profile->GetPrefs()->IsManagedPreference(prefs::kArcEnabled) && | 1555 if (profile->GetPrefs()->IsManagedPreference(prefs::kArcEnabled) && |
| 1539 !profile->GetPrefs()->GetBoolean(prefs::kArcEnabled)) { | 1556 !profile->GetPrefs()->GetBoolean(prefs::kArcEnabled)) { |
| 1540 VLOG(1) << "Skip ARC Terms of Service screen because ARC is disabled."; | 1557 VLOG(1) << "Skip ARC Terms of Service screen because ARC is disabled."; |
| 1541 return false; | 1558 return false; |
| 1542 } | 1559 } |
| 1543 return true; | 1560 return true; |
| 1544 } | 1561 } |
| 1545 | 1562 |
| 1546 bool WizardController::ShouldShowVoiceInteractionValueProp() const { | 1563 bool WizardController::ShouldShowVoiceInteractionValueProp() const { |
| 1547 if (!arc::IsArcPlayStoreEnabledForProfile( | 1564 if (!device_marked_registered_ && |
|
xc
2017/06/09 18:00:14
Add comment on why we need to do these check this
yueli
2017/06/12 20:10:07
Done.
| |
| 1565 !arc::IsArcPlayStoreEnabledForProfile( | |
| 1548 ProfileManager::GetActiveUserProfile())) { | 1566 ProfileManager::GetActiveUserProfile())) { |
| 1549 VLOG(1) << "Skip Voice Interaction Value Prop screen because Arc Terms is " | 1567 VLOG(1) << "Skip Voice Interaction Value Prop screen because Arc Terms is " |
| 1550 << "skipped."; | 1568 << "skipped."; |
| 1551 return false; | 1569 return false; |
| 1552 } | 1570 } |
| 1553 if (!chromeos::switches::IsVoiceInteractionEnabled()) { | 1571 if (!chromeos::switches::IsVoiceInteractionEnabled()) { |
| 1554 VLOG(1) << "Skip Voice Interaction Value Prop screen because voice " | 1572 VLOG(1) << "Skip Voice Interaction Value Prop screen because voice " |
| 1555 << "interaction service is disabled."; | 1573 << "interaction service is disabled."; |
| 1556 return false; | 1574 return false; |
| 1557 } | 1575 } |
| 1558 return true; | 1576 return true; |
| 1559 } | 1577 } |
| 1560 | 1578 |
| 1579 void WizardController::StartVoiceInteractionSetupWizard() { | |
| 1580 arc::ArcVoiceInteractionFrameworkService* service = | |
| 1581 arc::ArcServiceManager::Get() | |
| 1582 ->GetService<arc::ArcVoiceInteractionFrameworkService>(); | |
| 1583 if (service) | |
| 1584 service->StartVoiceInteractionSetupWizard(); | |
| 1585 } | |
| 1586 | |
| 1561 void WizardController::MaybeStartListeningForSharkConnection() { | 1587 void WizardController::MaybeStartListeningForSharkConnection() { |
| 1562 // We shouldn't be here if we are running pairing OOBE already. | 1588 // We shouldn't be here if we are running pairing OOBE already. |
| 1563 if (IsControllerDetected()) | 1589 if (IsControllerDetected()) |
| 1564 return; | 1590 return; |
| 1565 | 1591 |
| 1566 if (!shark_connection_listener_) { | 1592 if (!shark_connection_listener_) { |
| 1567 shark_connection_listener_.reset( | 1593 shark_connection_listener_.reset( |
| 1568 new pairing_chromeos::SharkConnectionListener( | 1594 new pairing_chromeos::SharkConnectionListener( |
| 1569 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE), | 1595 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE), |
| 1570 base::Bind(&WizardController::OnSharkConnected, | 1596 base::Bind(&WizardController::OnSharkConnected, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1616 SetCurrentScreen(screen); | 1642 SetCurrentScreen(screen); |
| 1617 } | 1643 } |
| 1618 | 1644 |
| 1619 AutoEnrollmentController* WizardController::GetAutoEnrollmentController() { | 1645 AutoEnrollmentController* WizardController::GetAutoEnrollmentController() { |
| 1620 if (!auto_enrollment_controller_) | 1646 if (!auto_enrollment_controller_) |
| 1621 auto_enrollment_controller_ = base::MakeUnique<AutoEnrollmentController>(); | 1647 auto_enrollment_controller_ = base::MakeUnique<AutoEnrollmentController>(); |
| 1622 return auto_enrollment_controller_.get(); | 1648 return auto_enrollment_controller_.get(); |
| 1623 } | 1649 } |
| 1624 | 1650 |
| 1625 } // namespace chromeos | 1651 } // namespace chromeos |
| OLD | NEW |