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_ = screen_pref; |
| 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 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 void WizardController::SetCurrentScreen(WizardScreen* new_current) { | 739 void WizardController::SetCurrentScreen(WizardScreen* new_current) { |
716 SetCurrentScreenSmooth(new_current, false); | 740 SetCurrentScreenSmooth(new_current, false); |
717 } | 741 } |
718 | 742 |
719 void WizardController::ShowCurrentScreen() { | 743 void WizardController::ShowCurrentScreen() { |
720 // ShowCurrentScreen may get called by smooth_show_timer_ even after | 744 // ShowCurrentScreen may get called by smooth_show_timer_ even after |
721 // flow has been switched to sign in screen (ExistingUserController). | 745 // flow has been switched to sign in screen (ExistingUserController). |
722 if (!oobe_display_) | 746 if (!oobe_display_) |
723 return; | 747 return; |
724 | 748 |
| 749 // First remember how far have we reached so that we can resume if needed. |
| 750 if (is_out_of_box_ && IsResumableScreen(current_screen_->GetName())) |
| 751 StartupUtils::SaveOobePendingScreen(current_screen_->GetName()); |
| 752 |
725 smooth_show_timer_.Stop(); | 753 smooth_show_timer_.Stop(); |
726 | 754 |
727 FOR_EACH_OBSERVER(Observer, observer_list_, OnScreenChanged(current_screen_)); | 755 FOR_EACH_OBSERVER(Observer, observer_list_, OnScreenChanged(current_screen_)); |
728 | 756 |
729 oobe_display_->ShowScreen(current_screen_); | 757 oobe_display_->ShowScreen(current_screen_); |
730 } | 758 } |
731 | 759 |
732 void WizardController::SetCurrentScreenSmooth(WizardScreen* new_current, | 760 void WizardController::SetCurrentScreenSmooth(WizardScreen* new_current, |
733 bool use_smoothing) { | 761 bool use_smoothing) { |
734 if (current_screen_ == new_current || | 762 if (current_screen_ == new_current || |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1060 // cancelled on destruction. | 1088 // cancelled on destruction. |
1061 GetTimezoneProvider()->RequestTimezone( | 1089 GetTimezoneProvider()->RequestTimezone( |
1062 position, | 1090 position, |
1063 false, // sensor | 1091 false, // sensor |
1064 timeout - elapsed, | 1092 timeout - elapsed, |
1065 base::Bind(&WizardController::OnTimezoneResolved, | 1093 base::Bind(&WizardController::OnTimezoneResolved, |
1066 base::Unretained(this))); | 1094 base::Unretained(this))); |
1067 } | 1095 } |
1068 | 1096 |
1069 } // namespace chromeos | 1097 } // namespace chromeos |
OLD | NEW |