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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 namespace { | 79 namespace { |
80 // If reboot didn't happen, ask user to reboot device manually. | 80 // If reboot didn't happen, ask user to reboot device manually. |
81 const int kWaitForRebootTimeSec = 3; | 81 const int kWaitForRebootTimeSec = 3; |
82 | 82 |
83 // Interval in ms which is used for smooth screen showing. | 83 // Interval in ms which is used for smooth screen showing. |
84 static int kShowDelayMs = 400; | 84 static int kShowDelayMs = 400; |
85 | 85 |
86 // Total timezone resolving process timeout. | 86 // Total timezone resolving process timeout. |
87 const unsigned int kResolveTimeZoneTimeoutSeconds = 60; | 87 const unsigned int kResolveTimeZoneTimeoutSeconds = 60; |
88 | 88 |
89 // Stores the list of all screens that should be shown when resuming OOBE. | |
90 const char *kResumableScreens[] = { | |
91 chromeos::WizardController::kNetworkScreenName, | |
92 chromeos::WizardController::kUpdateScreenName, | |
93 chromeos::WizardController::kEulaScreenName, | |
94 chromeos::WizardController::kEnrollmentScreenName, | |
95 chromeos::WizardController::kTermsOfServiceScreenName | |
96 }; | |
97 | |
89 // Checks flag for HID-detection screen show. | 98 // Checks flag for HID-detection screen show. |
90 bool CanShowHIDDetectionScreen() { | 99 bool CanShowHIDDetectionScreen() { |
91 return CommandLine::ForCurrentProcess()->HasSwitch( | 100 return CommandLine::ForCurrentProcess()->HasSwitch( |
92 chromeos::switches::kEnableHIDDetectionOnOOBE); | 101 chromeos::switches::kEnableHIDDetectionOnOOBE); |
93 } | 102 } |
94 | 103 |
104 bool IsResumableScreen(const std::string& screen) { | |
105 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kResumableScreens); ++i) { | |
106 if (screen == kResumableScreens[i]) | |
107 return true; | |
108 } | |
109 return false; | |
110 } | |
111 | |
95 } // namespace | 112 } // namespace |
96 | 113 |
97 namespace chromeos { | 114 namespace chromeos { |
98 | 115 |
99 const char WizardController::kNetworkScreenName[] = "network"; | 116 const char WizardController::kNetworkScreenName[] = "network"; |
100 const char WizardController::kLoginScreenName[] = "login"; | 117 const char WizardController::kLoginScreenName[] = "login"; |
101 const char WizardController::kUpdateScreenName[] = "update"; | 118 const char WizardController::kUpdateScreenName[] = "update"; |
102 const char WizardController::kUserImageScreenName[] = "image"; | 119 const char WizardController::kUserImageScreenName[] = "image"; |
103 const char WizardController::kEulaScreenName[] = "eula"; | 120 const char WizardController::kEulaScreenName[] = "eula"; |
104 const char WizardController::kEnrollmentScreenName[] = "enroll"; | 121 const char WizardController::kEnrollmentScreenName[] = "enroll"; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 if (status == PrefService::INITIALIZATION_STATUS_ERROR) { | 219 if (status == PrefService::INITIALIZATION_STATUS_ERROR) { |
203 OnLocalStateInitialized(false); | 220 OnLocalStateInitialized(false); |
204 return; | 221 return; |
205 } else if (status == PrefService::INITIALIZATION_STATUS_WAITING) { | 222 } else if (status == PrefService::INITIALIZATION_STATUS_WAITING) { |
206 GetLocalState()->AddPrefInitObserver( | 223 GetLocalState()->AddPrefInitObserver( |
207 base::Bind(&WizardController::OnLocalStateInitialized, | 224 base::Bind(&WizardController::OnLocalStateInitialized, |
208 weak_factory_.GetWeakPtr())); | 225 weak_factory_.GetWeakPtr())); |
209 } | 226 } |
210 } | 227 } |
211 | 228 |
212 AdvanceToScreen(first_screen_name); | 229 const std::string screen_pref = |
230 GetLocalState()->GetString(prefs::kOobeScreenPending); | |
231 if (is_out_of_box_ && !screen_pref.empty() && (first_screen_name.empty() || | |
232 first_screen_name == WizardController::kTestNoScreenName)) { | |
233 first_screen_name_ = GetLocalState()->GetString(prefs::kOobeScreenPending); | |
Mattias Nissler (ping if slow)
2014/05/20 09:33:12
nit: no need to ask local_state again, just assign
pastarmovj
2014/05/20 13:57:01
Of course :) this was a branch messing artifact :)
| |
234 } | |
235 | |
236 AdvanceToScreen(first_screen_name_); | |
213 if (!IsMachineHWIDCorrect() && !StartupUtils::IsDeviceRegistered() && | 237 if (!IsMachineHWIDCorrect() && !StartupUtils::IsDeviceRegistered() && |
214 first_screen_name.empty()) | 238 first_screen_name_.empty()) |
215 ShowWrongHWIDScreen(); | 239 ShowWrongHWIDScreen(); |
216 } | 240 } |
217 | 241 |
218 chromeos::NetworkScreen* WizardController::GetNetworkScreen() { | 242 chromeos::NetworkScreen* WizardController::GetNetworkScreen() { |
219 if (!network_screen_.get()) | 243 if (!network_screen_.get()) |
220 network_screen_.reset(new chromeos::NetworkScreen( | 244 network_screen_.reset(new chromeos::NetworkScreen( |
221 this, oobe_display_->GetNetworkScreenActor())); | 245 this, oobe_display_->GetNetworkScreenActor())); |
222 return network_screen_.get(); | 246 return network_screen_.get(); |
223 } | 247 } |
224 | 248 |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
706 host_->GetAutoEnrollmentController()->Start(); | 730 host_->GetAutoEnrollmentController()->Start(); |
707 host_->PrewarmAuthentication(); | 731 host_->PrewarmAuthentication(); |
708 NetworkPortalDetector::Get()->Enable(true); | 732 NetworkPortalDetector::Get()->Enable(true); |
709 } | 733 } |
710 | 734 |
711 void WizardController::PerformOOBECompletedActions() { | 735 void WizardController::PerformOOBECompletedActions() { |
712 StartupUtils::MarkOobeCompleted(); | 736 StartupUtils::MarkOobeCompleted(); |
713 } | 737 } |
714 | 738 |
715 void WizardController::SetCurrentScreen(WizardScreen* new_current) { | 739 void WizardController::SetCurrentScreen(WizardScreen* new_current) { |
740 // First remember how far have we reached so that we can resume if needed. | |
741 if (is_out_of_box_ && IsResumableScreen(new_current->GetName())) | |
742 StartupUtils::SaveOobePendingScreen(new_current->GetName()); | |
Mattias Nissler (ping if slow)
2014/05/20 09:33:12
Shouldn't this code be in SetCurrentScreenSmooth (
pastarmovj
2014/05/20 13:57:01
Done.
| |
743 | |
716 SetCurrentScreenSmooth(new_current, false); | 744 SetCurrentScreenSmooth(new_current, false); |
717 } | 745 } |
718 | 746 |
719 void WizardController::ShowCurrentScreen() { | 747 void WizardController::ShowCurrentScreen() { |
720 // ShowCurrentScreen may get called by smooth_show_timer_ even after | 748 // ShowCurrentScreen may get called by smooth_show_timer_ even after |
721 // flow has been switched to sign in screen (ExistingUserController). | 749 // flow has been switched to sign in screen (ExistingUserController). |
722 if (!oobe_display_) | 750 if (!oobe_display_) |
723 return; | 751 return; |
724 | 752 |
725 smooth_show_timer_.Stop(); | 753 smooth_show_timer_.Stop(); |
(...skipping 28 matching lines...) Expand all Loading... | |
754 } else { | 782 } else { |
755 ShowCurrentScreen(); | 783 ShowCurrentScreen(); |
756 } | 784 } |
757 } | 785 } |
758 | 786 |
759 void WizardController::SetStatusAreaVisible(bool visible) { | 787 void WizardController::SetStatusAreaVisible(bool visible) { |
760 host_->SetStatusAreaVisible(visible); | 788 host_->SetStatusAreaVisible(visible); |
761 } | 789 } |
762 | 790 |
763 void WizardController::AdvanceToScreen(const std::string& screen_name) { | 791 void WizardController::AdvanceToScreen(const std::string& screen_name) { |
792 // First remember how far have we reached so that we can resume if needed. | |
793 if (is_out_of_box_ && IsResumableScreen(screen_name)) | |
794 StartupUtils::SaveOobePendingScreen(screen_name); | |
Mattias Nissler (ping if slow)
2014/05/20 09:33:12
Isn't the code below going through SetCurrentScree
pastarmovj
2014/05/20 13:57:01
Done.
| |
795 | |
764 if (screen_name == kNetworkScreenName) { | 796 if (screen_name == kNetworkScreenName) { |
765 ShowNetworkScreen(); | 797 ShowNetworkScreen(); |
766 } else if (screen_name == kLoginScreenName) { | 798 } else if (screen_name == kLoginScreenName) { |
767 ShowLoginScreen(LoginScreenContext()); | 799 ShowLoginScreen(LoginScreenContext()); |
768 } else if (screen_name == kUpdateScreenName) { | 800 } else if (screen_name == kUpdateScreenName) { |
769 InitiateOOBEUpdate(); | 801 InitiateOOBEUpdate(); |
770 } else if (screen_name == kUserImageScreenName) { | 802 } else if (screen_name == kUserImageScreenName) { |
771 ShowUserImageScreen(); | 803 ShowUserImageScreen(); |
772 } else if (screen_name == kEulaScreenName) { | 804 } else if (screen_name == kEulaScreenName) { |
773 ShowEulaScreen(); | 805 ShowEulaScreen(); |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1060 // cancelled on destruction. | 1092 // cancelled on destruction. |
1061 GetTimezoneProvider()->RequestTimezone( | 1093 GetTimezoneProvider()->RequestTimezone( |
1062 position, | 1094 position, |
1063 false, // sensor | 1095 false, // sensor |
1064 timeout - elapsed, | 1096 timeout - elapsed, |
1065 base::Bind(&WizardController::OnTimezoneResolved, | 1097 base::Bind(&WizardController::OnTimezoneResolved, |
1066 base::Unretained(this))); | 1098 base::Unretained(this))); |
1067 } | 1099 } |
1068 | 1100 |
1069 } // namespace chromeos | 1101 } // namespace chromeos |
OLD | NEW |