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
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/login/wizard_controller.h"
14 #include "base/bind.h"
15 #include "base/callback_helpers.h"
16 #include "base/command_line.h"
17 #include "base/logging.h"
18 #include "base/metrics/histogram.h"
19 #include "base/prefs/pref_registry_simple.h"
20 #include "base/prefs/pref_service.h"
21 #include "base/strings/utf_string_conversions.h"
22 #include "chrome/browser/browser_process.h"
23 #include "chrome/browser/browser_process_platform_part.h"
24 #include "chrome/browser/chrome_notification_types.h"
25 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
26 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
27 #include "chrome/browser/chromeos/customization/customization_document.h"
28 #include "chrome/browser/chromeos/login/enrollment/auto_enrollment_check_screen.h"
29 #include "chrome/browser/chromeos/login/enrollment/enrollment_screen.h"
30 #include "chrome/browser/chromeos/login/existing_user_controller.h"
31 #include "chrome/browser/chromeos/login/helper.h"
32 #include "chrome/browser/chromeos/login/hwid_checker.h"
33 #include "chrome/browser/chromeos/login/screens/device_disabled_screen.h"
34 #include "chrome/browser/chromeos/login/screens/enable_debugging_screen.h"
35 #include "chrome/browser/chromeos/login/screens/error_screen.h"
36 #include "chrome/browser/chromeos/login/screens/eula_screen.h"
37 #include "chrome/browser/chromeos/login/screens/hid_detection_view.h"
38 #include "chrome/browser/chromeos/login/screens/kiosk_autolaunch_screen.h"
39 #include "chrome/browser/chromeos/login/screens/kiosk_enable_screen.h"
40 #include "chrome/browser/chromeos/login/screens/network_error.h"
41 #include "chrome/browser/chromeos/login/screens/network_view.h"
42 #include "chrome/browser/chromeos/login/screens/reset_screen.h"
43 #include "chrome/browser/chromeos/login/screens/terms_of_service_screen.h"
44 #include "chrome/browser/chromeos/login/screens/update_screen.h"
45 #include "chrome/browser/chromeos/login/screens/user_image_screen.h"
46 #include "chrome/browser/chromeos/login/screens/wrong_hwid_screen.h"
47 #include "chrome/browser/chromeos/login/session/user_session_manager.h"
48 #include "chrome/browser/chromeos/login/startup_utils.h"
49 #include "chrome/browser/chromeos/login/supervised/supervised_user_creation_screen.h"
50 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
51 #include "chrome/browser/chromeos/login/ui/oobe_display.h"
52 #include "chrome/browser/chromeos/net/delay_network_call.h"
53 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
54 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
55 #include "chrome/browser/chromeos/settings/cros_settings.h"
56 #include "chrome/browser/chromeos/system/device_disabling_manager.h"
57 #include "chrome/browser/lifetime/application_lifetime.h"
58 #include "chrome/browser/metrics/metrics_reporting_state.h"
59 #include "chrome/browser/profiles/profile.h"
60 #include "chrome/browser/profiles/profile_manager.h"
61 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
62 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
63 #include "chrome/common/chrome_constants.h"
64 #include "chrome/common/pref_names.h"
65 #include "chromeos/audio/cras_audio_handler.h"
66 #include "chromeos/chromeos_constants.h"
67 #include "chromeos/chromeos_switches.h"
68 #include "chromeos/dbus/dbus_thread_manager.h"
69 #include "chromeos/dbus/session_manager_client.h"
70 #include "chromeos/geolocation/simple_geolocation_provider.h"
71 #include "chromeos/network/network_state.h"
72 #include "chromeos/network/network_state_handler.h"
73 #include "chromeos/network/portal_detector/network_portal_detector.h"
74 #include "chromeos/settings/cros_settings_names.h"
75 #include "chromeos/settings/cros_settings_provider.h"
76 #include "chromeos/settings/timezone_settings.h"
77 #include "chromeos/timezone/timezone_provider.h"
78 #include "components/crash/app/breakpad_linux.h"
79 #include "components/pairing/bluetooth_controller_pairing_controller.h"
80 #include "components/pairing/bluetooth_host_pairing_controller.h"
81 #include "components/pairing/shark_connection_listener.h"
82 #include "components/user_manager/user_manager.h"
83 #include "content/public/browser/browser_thread.h"
84 #include "content/public/browser/notification_types.h"
85 #include "ui/base/accelerators/accelerator.h"
87 using content::BrowserThread
;
90 // Interval in ms which is used for smooth screen showing.
91 static int kShowDelayMs
= 400;
93 // Total timezone resolving process timeout.
94 const unsigned int kResolveTimeZoneTimeoutSeconds
= 60;
96 // Stores the list of all screens that should be shown when resuming OOBE.
97 const char *kResumableScreens
[] = {
98 chromeos::WizardController::kNetworkScreenName
,
99 chromeos::WizardController::kUpdateScreenName
,
100 chromeos::WizardController::kEulaScreenName
,
101 chromeos::WizardController::kEnrollmentScreenName
,
102 chromeos::WizardController::kTermsOfServiceScreenName
,
103 chromeos::WizardController::kAutoEnrollmentCheckScreenName
106 // Checks flag for HID-detection screen show.
107 bool CanShowHIDDetectionScreen() {
108 return !base::CommandLine::ForCurrentProcess()->HasSwitch(
109 chromeos::switches::kDisableHIDDetectionOnOOBE
);
112 bool IsResumableScreen(const std::string
& screen
) {
113 for (size_t i
= 0; i
< arraysize(kResumableScreens
); ++i
) {
114 if (screen
== kResumableScreens
[i
])
120 void RecordUMAHistogramForOOBEStepCompletionTime(std::string screen_name
,
121 base::TimeDelta step_time
) {
122 screen_name
[0] = std::toupper(screen_name
[0]);
123 std::string histogram_name
= "OOBE.StepCompletionTime." + screen_name
;
124 // Equivalent to using UMA_HISTOGRAM_MEDIUM_TIMES. UMA_HISTOGRAM_MEDIUM_TIMES
125 // can not be used here, because |histogram_name| is calculated dynamically
126 // and changes from call to call.
127 base::HistogramBase
* histogram
= base::Histogram::FactoryTimeGet(
129 base::TimeDelta::FromMilliseconds(10),
130 base::TimeDelta::FromMinutes(3),
132 base::HistogramBase::kUmaTargetedHistogramFlag
);
133 histogram
->AddTime(step_time
);
136 bool IsRemoraRequisition() {
137 return g_browser_process
->platform_part()
138 ->browser_policy_connector_chromeos()
139 ->GetDeviceCloudPolicyManager()
140 ->IsRemoraRequisition();
143 #if defined(GOOGLE_CHROME_BUILD)
144 void InitializeCrashReporter() {
145 // The crash reporter initialization needs IO to complete.
146 DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
147 breakpad::InitCrashReporter(std::string());
155 const char WizardController::kNetworkScreenName
[] = "network";
156 const char WizardController::kLoginScreenName
[] = "login";
157 const char WizardController::kUpdateScreenName
[] = "update";
158 const char WizardController::kUserImageScreenName
[] = "image";
159 const char WizardController::kEulaScreenName
[] = "eula";
160 const char WizardController::kEnableDebuggingScreenName
[] = "debugging";
161 const char WizardController::kEnrollmentScreenName
[] = "enroll";
162 const char WizardController::kResetScreenName
[] = "reset";
163 const char WizardController::kKioskEnableScreenName
[] = "kiosk-enable";
164 const char WizardController::kKioskAutolaunchScreenName
[] = "autolaunch";
165 const char WizardController::kErrorScreenName
[] = "error-message";
166 const char WizardController::kTermsOfServiceScreenName
[] = "tos";
167 const char WizardController::kAutoEnrollmentCheckScreenName
[] =
168 "auto-enrollment-check";
169 const char WizardController::kWrongHWIDScreenName
[] = "wrong-hwid";
170 const char WizardController::kSupervisedUserCreationScreenName
[] =
171 "supervised-user-creation-flow";
172 const char WizardController::kAppLaunchSplashScreenName
[] =
174 const char WizardController::kHIDDetectionScreenName
[] = "hid-detection";
175 const char WizardController::kControllerPairingScreenName
[] =
176 "controller-pairing";
177 const char WizardController::kHostPairingScreenName
[] = "host-pairing";
178 const char WizardController::kDeviceDisabledScreenName
[] = "device-disabled";
181 const int WizardController::kMinAudibleOutputVolumePercent
= 10;
183 // Passing this parameter as a "first screen" initiates full OOBE flow.
184 const char WizardController::kOutOfBoxScreenName
[] = "oobe";
186 // Special test value that commands not to create any window yet.
187 const char WizardController::kTestNoScreenName
[] = "test:nowindow";
189 // Initialize default controller.
191 WizardController
* WizardController::default_controller_
= NULL
;
194 bool WizardController::skip_post_login_screens_
= false;
197 bool WizardController::zero_delay_enabled_
= false;
199 ///////////////////////////////////////////////////////////////////////////////
200 // WizardController, public:
202 PrefService
* WizardController::local_state_for_testing_
= NULL
;
204 WizardController::WizardController(LoginDisplayHost
* host
,
205 OobeDisplay
* oobe_display
)
206 : current_screen_(NULL
),
207 previous_screen_(NULL
),
208 #if defined(GOOGLE_CHROME_BUILD)
209 is_official_build_(true),
211 is_official_build_(false),
213 is_out_of_box_(false),
215 oobe_display_(oobe_display
),
216 usage_statistics_reporting_(true),
217 skip_update_enroll_after_eula_(false),
218 retry_auto_enrollment_check_(false),
219 login_screen_started_(false),
220 user_image_screen_return_to_previous_hack_(false),
221 timezone_resolved_(false),
222 shark_controller_detected_(false),
223 hid_screen_(nullptr),
224 weak_factory_(this) {
225 DCHECK(default_controller_
== NULL
);
226 default_controller_
= this;
227 AccessibilityManager
* accessibility_manager
= AccessibilityManager::Get();
228 CHECK(accessibility_manager
);
229 accessibility_subscription_
= accessibility_manager
->RegisterCallback(
230 base::Bind(&WizardController::OnAccessibilityStatusChanged
,
231 base::Unretained(this)));
234 WizardController::~WizardController() {
235 if (default_controller_
== this) {
236 default_controller_
= NULL
;
238 NOTREACHED() << "More than one controller are alive.";
242 void WizardController::Init(const std::string
& first_screen_name
) {
243 VLOG(1) << "Starting OOBE wizard with screen: " << first_screen_name
;
244 first_screen_name_
= first_screen_name
;
246 bool oobe_complete
= StartupUtils::IsOobeCompleted();
247 if (!oobe_complete
|| first_screen_name
== kOutOfBoxScreenName
)
248 is_out_of_box_
= true;
250 // This is a hacky way to check for local state corruption, because
251 // it depends on the fact that the local state is loaded
252 // synchronously and at the first demand. IsEnterpriseManaged()
253 // check is required because currently powerwash is disabled for
254 // enterprise-enrolled devices.
256 // TODO (ygorshenin@): implement handling of the local state
257 // corruption in the case of asynchronious loading.
258 policy::BrowserPolicyConnectorChromeOS
* connector
=
259 g_browser_process
->platform_part()->browser_policy_connector_chromeos();
260 if (!connector
->IsEnterpriseManaged()) {
261 const PrefService::PrefInitializationStatus status
=
262 GetLocalState()->GetInitializationStatus();
263 if (status
== PrefService::INITIALIZATION_STATUS_ERROR
) {
264 OnLocalStateInitialized(false);
266 } else if (status
== PrefService::INITIALIZATION_STATUS_WAITING
) {
267 GetLocalState()->AddPrefInitObserver(
268 base::Bind(&WizardController::OnLocalStateInitialized
,
269 weak_factory_
.GetWeakPtr()));
273 // Use the saved screen preference from Local State.
274 const std::string screen_pref
=
275 GetLocalState()->GetString(prefs::kOobeScreenPending
);
276 if (is_out_of_box_
&& !screen_pref
.empty() && !IsHostPairingOobe() &&
277 (first_screen_name
.empty() ||
278 first_screen_name
== WizardController::kTestNoScreenName
)) {
279 first_screen_name_
= screen_pref
;
282 AdvanceToScreen(first_screen_name_
);
283 if (!IsMachineHWIDCorrect() && !StartupUtils::IsDeviceRegistered() &&
284 first_screen_name_
.empty())
285 ShowWrongHWIDScreen();
288 ErrorScreen
* WizardController::GetErrorScreen() {
289 return oobe_display_
->GetErrorScreen();
292 BaseScreen
* WizardController::GetScreen(const std::string
& screen_name
) {
293 if (screen_name
== kErrorScreenName
)
294 return GetErrorScreen();
295 return ScreenManager::GetScreen(screen_name
);
298 BaseScreen
* WizardController::CreateScreen(const std::string
& screen_name
) {
299 if (screen_name
== kNetworkScreenName
) {
300 scoped_ptr
<NetworkScreen
> screen(
301 new NetworkScreen(this, this, oobe_display_
->GetNetworkView()));
302 screen
->Initialize(nullptr /* context */);
303 return screen
.release();
304 } else if (screen_name
== kUpdateScreenName
) {
305 scoped_ptr
<UpdateScreen
> screen(new UpdateScreen(
306 this, oobe_display_
->GetUpdateView(), remora_controller_
.get()));
307 screen
->Initialize(nullptr /* context */);
308 return screen
.release();
309 } else if (screen_name
== kUserImageScreenName
) {
310 return new UserImageScreen(this, oobe_display_
->GetUserImageView());
311 } else if (screen_name
== kEulaScreenName
) {
312 return new EulaScreen(this, this, oobe_display_
->GetEulaView());
313 } else if (screen_name
== kEnrollmentScreenName
) {
314 return new EnrollmentScreen(this,
315 oobe_display_
->GetEnrollmentScreenActor());
316 } else if (screen_name
== kResetScreenName
) {
317 return new chromeos::ResetScreen(this,
318 oobe_display_
->GetResetView());
319 } else if (screen_name
== kEnableDebuggingScreenName
) {
320 return new EnableDebuggingScreen(
321 this, oobe_display_
->GetEnableDebuggingScreenActor());
322 } else if (screen_name
== kKioskEnableScreenName
) {
323 return new KioskEnableScreen(this,
324 oobe_display_
->GetKioskEnableScreenActor());
325 } else if (screen_name
== kKioskAutolaunchScreenName
) {
326 return new KioskAutolaunchScreen(
327 this, oobe_display_
->GetKioskAutolaunchScreenActor());
328 } else if (screen_name
== kTermsOfServiceScreenName
) {
329 return new TermsOfServiceScreen(
330 this, oobe_display_
->GetTermsOfServiceScreenActor());
331 } else if (screen_name
== kWrongHWIDScreenName
) {
332 return new WrongHWIDScreen(this, oobe_display_
->GetWrongHWIDScreenActor());
333 } else if (screen_name
== kSupervisedUserCreationScreenName
) {
334 return new SupervisedUserCreationScreen(
335 this, oobe_display_
->GetSupervisedUserCreationScreenActor());
336 } else if (screen_name
== kHIDDetectionScreenName
) {
337 scoped_ptr
<HIDDetectionScreen
> screen(new chromeos::HIDDetectionScreen(
338 this, oobe_display_
->GetHIDDetectionView()));
339 screen
->Initialize(nullptr /* context */);
340 return screen
.release();
341 } else if (screen_name
== kAutoEnrollmentCheckScreenName
) {
342 return new AutoEnrollmentCheckScreen(
343 this, oobe_display_
->GetAutoEnrollmentCheckScreenActor());
344 } else if (screen_name
== kControllerPairingScreenName
) {
345 if (!shark_controller_
) {
346 shark_controller_
.reset(
347 new pairing_chromeos::BluetoothControllerPairingController());
349 return new ControllerPairingScreen(
352 oobe_display_
->GetControllerPairingScreenActor(),
353 shark_controller_
.get());
354 } else if (screen_name
== kHostPairingScreenName
) {
355 if (!remora_controller_
) {
356 remora_controller_
.reset(
357 new pairing_chromeos::BluetoothHostPairingController());
358 remora_controller_
->StartPairing();
360 return new HostPairingScreen(this,
362 oobe_display_
->GetHostPairingScreenActor(),
363 remora_controller_
.get());
364 } else if (screen_name
== kDeviceDisabledScreenName
) {
365 return new DeviceDisabledScreen(
366 this, oobe_display_
->GetDeviceDisabledScreenActor());
372 void WizardController::ShowNetworkScreen() {
373 VLOG(1) << "Showing network screen.";
374 // Hide the status area initially; it only appears after OOBE first animates
375 // in. Keep it visible if the user goes back to the existing network screen.
376 SetStatusAreaVisible(HasScreen(kNetworkScreenName
));
377 SetCurrentScreen(GetScreen(kNetworkScreenName
));
379 MaybeStartListeningForSharkConnection();
382 void WizardController::ShowLoginScreen(const LoginScreenContext
& context
) {
383 if (!time_eula_accepted_
.is_null()) {
384 base::TimeDelta delta
= base::Time::Now() - time_eula_accepted_
;
385 UMA_HISTOGRAM_MEDIUM_TIMES("OOBE.EULAToSignInTime", delta
);
387 VLOG(1) << "Showing login screen.";
388 SetStatusAreaVisible(true);
389 host_
->StartSignInScreen(context
);
390 smooth_show_timer_
.Stop();
391 oobe_display_
= NULL
;
392 login_screen_started_
= true;
395 void WizardController::ShowUpdateScreen() {
396 VLOG(1) << "Showing update screen.";
397 SetStatusAreaVisible(true);
398 SetCurrentScreen(GetScreen(kUpdateScreenName
));
401 void WizardController::ShowUserImageScreen() {
402 const user_manager::UserManager
* user_manager
=
403 user_manager::UserManager::Get();
404 // Skip user image selection for public sessions and ephemeral non-regual user
406 if (user_manager
->IsLoggedInAsPublicAccount() ||
407 (user_manager
->IsCurrentUserNonCryptohomeDataEphemeral() &&
408 user_manager
->GetLoggedInUser()->GetType() !=
409 user_manager::USER_TYPE_REGULAR
)) {
410 OnUserImageSkipped();
413 VLOG(1) << "Showing user image screen.";
415 // Status area has been already shown at sign in screen so it
416 // doesn't make sense to hide it here and then show again at user session as
417 // this produces undesired UX transitions.
418 SetStatusAreaVisible(true);
420 SetCurrentScreen(GetScreen(kUserImageScreenName
));
423 void WizardController::ShowEulaScreen() {
424 VLOG(1) << "Showing EULA screen.";
425 SetStatusAreaVisible(true);
426 SetCurrentScreen(GetScreen(kEulaScreenName
));
429 void WizardController::ShowEnrollmentScreen() {
430 // Update the enrollment configuration and start the screen.
431 prescribed_enrollment_config_
= g_browser_process
->platform_part()
432 ->browser_policy_connector_chromeos()
433 ->GetPrescribedEnrollmentConfig();
434 StartEnrollmentScreen();
437 void WizardController::ShowResetScreen() {
438 VLOG(1) << "Showing reset screen.";
439 SetStatusAreaVisible(false);
440 SetCurrentScreen(GetScreen(kResetScreenName
));
443 void WizardController::ShowKioskEnableScreen() {
444 VLOG(1) << "Showing kiosk enable screen.";
445 SetStatusAreaVisible(false);
446 SetCurrentScreen(GetScreen(kKioskEnableScreenName
));
449 void WizardController::ShowKioskAutolaunchScreen() {
450 VLOG(1) << "Showing kiosk autolaunch screen.";
451 SetStatusAreaVisible(false);
452 SetCurrentScreen(GetScreen(kKioskAutolaunchScreenName
));
455 void WizardController::ShowEnableDebuggingScreen() {
456 VLOG(1) << "Showing enable developer features screen.";
457 SetStatusAreaVisible(false);
458 SetCurrentScreen(GetScreen(kEnableDebuggingScreenName
));
461 void WizardController::ShowTermsOfServiceScreen() {
462 // Only show the Terms of Service when logging into a public account and Terms
463 // of Service have been specified through policy. In all other cases, advance
464 // to the user image screen immediately.
465 if (!user_manager::UserManager::Get()->IsLoggedInAsPublicAccount() ||
466 !ProfileManager::GetActiveUserProfile()->GetPrefs()->IsManagedPreference(
467 prefs::kTermsOfServiceURL
)) {
468 ShowUserImageScreen();
472 VLOG(1) << "Showing Terms of Service screen.";
473 SetStatusAreaVisible(true);
474 SetCurrentScreen(GetScreen(kTermsOfServiceScreenName
));
477 void WizardController::ShowWrongHWIDScreen() {
478 VLOG(1) << "Showing wrong HWID screen.";
479 SetStatusAreaVisible(false);
480 SetCurrentScreen(GetScreen(kWrongHWIDScreenName
));
483 void WizardController::ShowAutoEnrollmentCheckScreen() {
484 VLOG(1) << "Showing Auto-enrollment check screen.";
485 SetStatusAreaVisible(true);
486 AutoEnrollmentCheckScreen
* screen
= AutoEnrollmentCheckScreen::Get(this);
487 if (retry_auto_enrollment_check_
)
488 screen
->ClearState();
489 screen
->set_auto_enrollment_controller(host_
->GetAutoEnrollmentController());
490 SetCurrentScreen(screen
);
493 void WizardController::ShowSupervisedUserCreationScreen() {
494 VLOG(1) << "Showing Locally managed user creation screen screen.";
495 SetStatusAreaVisible(true);
496 SetCurrentScreen(GetScreen(kSupervisedUserCreationScreenName
));
499 void WizardController::ShowHIDDetectionScreen() {
500 VLOG(1) << "Showing HID discovery screen.";
501 SetStatusAreaVisible(true);
502 SetCurrentScreen(GetScreen(kHIDDetectionScreenName
));
503 MaybeStartListeningForSharkConnection();
506 void WizardController::ShowControllerPairingScreen() {
507 VLOG(1) << "Showing controller pairing screen.";
508 SetStatusAreaVisible(false);
509 SetCurrentScreen(GetScreen(kControllerPairingScreenName
));
512 void WizardController::ShowHostPairingScreen() {
513 VLOG(1) << "Showing host pairing screen.";
514 SetStatusAreaVisible(false);
515 SetCurrentScreen(GetScreen(kHostPairingScreenName
));
518 void WizardController::ShowDeviceDisabledScreen() {
519 VLOG(1) << "Showing device disabled screen.";
520 SetStatusAreaVisible(true);
521 SetCurrentScreen(GetScreen(kDeviceDisabledScreenName
));
524 void WizardController::SkipToLoginForTesting(
525 const LoginScreenContext
& context
) {
526 VLOG(1) << "SkipToLoginForTesting.";
527 StartupUtils::MarkEulaAccepted();
528 PerformPostEulaActions();
529 OnDeviceDisabledChecked(false /* device_disabled */);
532 void WizardController::AddObserver(Observer
* observer
) {
533 observer_list_
.AddObserver(observer
);
536 void WizardController::RemoveObserver(Observer
* observer
) {
537 observer_list_
.RemoveObserver(observer
);
540 void WizardController::OnSessionStart() {
541 FOR_EACH_OBSERVER(Observer
, observer_list_
, OnSessionStart());
544 void WizardController::SkipUpdateEnrollAfterEula() {
545 skip_update_enroll_after_eula_
= true;
548 ///////////////////////////////////////////////////////////////////////////////
549 // WizardController, ExitHandlers:
550 void WizardController::OnHIDDetectionCompleted() {
551 // Check for tests configuration.
552 if (!StartupUtils::IsOobeCompleted())
556 void WizardController::OnNetworkConnected() {
557 if (is_official_build_
) {
558 if (!StartupUtils::IsEulaAccepted()) {
562 // 1. EULA was accepted, forced shutdown/reboot during update.
563 // 2. EULA was accepted, planned reboot after update.
564 // Make sure that device is up-to-date.
565 InitiateOOBEUpdate();
568 InitiateOOBEUpdate();
572 void WizardController::OnNetworkOffline() {
573 // TODO(dpolukhin): if(is_out_of_box_) we cannot work offline and
574 // should report some error message here and stay on the same screen.
575 ShowLoginScreen(LoginScreenContext());
578 void WizardController::OnConnectionFailed() {
579 // TODO(dpolukhin): show error message after login screen is displayed.
580 ShowLoginScreen(LoginScreenContext());
583 void WizardController::OnUpdateCompleted() {
584 const bool is_shark
= g_browser_process
->platform_part()
585 ->browser_policy_connector_chromeos()
586 ->GetDeviceCloudPolicyManager()
587 ->IsSharkRequisition();
589 ShowControllerPairingScreen();
591 ShowAutoEnrollmentCheckScreen();
595 void WizardController::OnEulaAccepted() {
596 time_eula_accepted_
= base::Time::Now();
597 StartupUtils::MarkEulaAccepted();
598 InitiateMetricsReportingChange(
599 usage_statistics_reporting_
,
600 base::Bind(&WizardController::InitiateMetricsReportingChangeCallback
,
601 weak_factory_
.GetWeakPtr()));
603 if (skip_update_enroll_after_eula_
) {
604 PerformPostEulaActions();
605 ShowAutoEnrollmentCheckScreen();
607 InitiateOOBEUpdate();
611 void WizardController::InitiateMetricsReportingChangeCallback(bool enabled
) {
612 CrosSettings::Get()->SetBoolean(kStatsReportingPref
, enabled
);
615 #if defined(GOOGLE_CHROME_BUILD)
616 if (!content::BrowserThread::PostBlockingPoolTask(
617 FROM_HERE
, base::Bind(&InitializeCrashReporter
))) {
618 LOG(ERROR
) << "Failed to start crash reporter initialization.";
623 void WizardController::OnUpdateErrorCheckingForUpdate() {
624 // TODO(nkostylev): Update should be required during OOBE.
625 // We do not want to block users from being able to proceed to the login
626 // screen if there is any error checking for an update.
627 // They could use "browse without sign-in" feature to set up the network to be
628 // able to perform the update later.
632 void WizardController::OnUpdateErrorUpdating() {
633 // If there was an error while getting or applying the update,
634 // return to network selection screen.
635 // TODO(nkostylev): Show message to the user explaining update error.
636 // TODO(nkostylev): Update should be required during OOBE.
637 // Temporary fix, need to migrate to new API. http://crosbug.com/4321
641 void WizardController::EnableUserImageScreenReturnToPreviousHack() {
642 user_image_screen_return_to_previous_hack_
= true;
645 void WizardController::OnUserImageSelected() {
646 if (user_image_screen_return_to_previous_hack_
) {
647 user_image_screen_return_to_previous_hack_
= false;
648 DCHECK(previous_screen_
);
649 if (previous_screen_
) {
650 SetCurrentScreen(previous_screen_
);
654 if (!time_oobe_started_
.is_null()) {
655 base::TimeDelta delta
= base::Time::Now() - time_oobe_started_
;
656 UMA_HISTOGRAM_CUSTOM_TIMES(
657 "OOBE.BootToSignInCompleted",
659 base::TimeDelta::FromMilliseconds(10),
660 base::TimeDelta::FromMinutes(30),
662 time_oobe_started_
= base::Time();
665 // Launch browser and delete login host controller.
666 BrowserThread::PostTask(
667 BrowserThread::UI
, FROM_HERE
,
668 base::Bind(&UserSessionManager::DoBrowserLaunch
,
669 base::Unretained(UserSessionManager::GetInstance()),
670 ProfileManager::GetActiveUserProfile(), host_
));
674 void WizardController::OnUserImageSkipped() {
675 OnUserImageSelected();
678 void WizardController::OnEnrollmentDone() {
679 // If the enrollment screen was shown as part of OOBE, OOBE is considered
680 // finished only after the enrollment screen is done. This is relevant for
681 // forced enrollment flows, e.g. for remora devices and forced re-enrollment.
682 if (prescribed_enrollment_config_
.should_enroll())
683 PerformOOBECompletedActions();
685 // TODO(mnissler): Unify the logic for auto-login for Public Sessions and
686 // Kiosk Apps and make this code cover both cases: http://crbug.com/234694.
687 if (KioskAppManager::Get()->IsAutoLaunchEnabled())
688 AutoLaunchKioskApp();
690 ShowLoginScreen(LoginScreenContext());
693 void WizardController::OnDeviceModificationCanceled() {
694 if (previous_screen_
) {
695 SetCurrentScreen(previous_screen_
);
697 ShowLoginScreen(LoginScreenContext());
701 void WizardController::OnKioskAutolaunchCanceled() {
702 ShowLoginScreen(LoginScreenContext());
705 void WizardController::OnKioskAutolaunchConfirmed() {
706 DCHECK(KioskAppManager::Get()->IsAutoLaunchEnabled());
707 AutoLaunchKioskApp();
710 void WizardController::OnKioskEnableCompleted() {
711 ShowLoginScreen(LoginScreenContext());
714 void WizardController::OnWrongHWIDWarningSkipped() {
715 if (previous_screen_
)
716 SetCurrentScreen(previous_screen_
);
718 ShowLoginScreen(LoginScreenContext());
721 void WizardController::OnTermsOfServiceDeclined() {
722 // If the user declines the Terms of Service, end the session and return to
724 DBusThreadManager::Get()->GetSessionManagerClient()->StopSession();
727 void WizardController::OnTermsOfServiceAccepted() {
728 // If the user accepts the Terms of Service, advance to the user image screen.
729 ShowUserImageScreen();
732 void WizardController::OnControllerPairingFinished() {
733 ShowAutoEnrollmentCheckScreen();
736 void WizardController::OnHostPairingFinished() {
737 InitiateOOBEUpdate();
740 void WizardController::OnAutoEnrollmentCheckCompleted() {
741 // Check whether the device is disabled. OnDeviceDisabledChecked() will be
742 // invoked when the result of this check is known. Until then, the current
743 // screen will remain visible and will continue showing a spinner.
744 g_browser_process
->platform_part()->device_disabling_manager()->
745 CheckWhetherDeviceDisabledDuringOOBE(base::Bind(
746 &WizardController::OnDeviceDisabledChecked
,
747 weak_factory_
.GetWeakPtr()));
750 void WizardController::OnDeviceDisabledChecked(bool device_disabled
) {
751 prescribed_enrollment_config_
= g_browser_process
->platform_part()
752 ->browser_policy_connector_chromeos()
753 ->GetPrescribedEnrollmentConfig();
754 if (device_disabled
) {
755 ShowDeviceDisabledScreen();
756 } else if (skip_update_enroll_after_eula_
||
757 prescribed_enrollment_config_
.should_enroll()) {
758 StartEnrollmentScreen();
760 PerformOOBECompletedActions();
761 ShowLoginScreen(LoginScreenContext());
765 void WizardController::InitiateOOBEUpdate() {
766 VLOG(1) << "InitiateOOBEUpdate";
767 PerformPostEulaActions();
768 SetCurrentScreenSmooth(GetScreen(kUpdateScreenName
), true);
769 UpdateScreen::Get(this)->StartNetworkCheck();
772 void WizardController::StartTimezoneResolve() {
773 geolocation_provider_
.reset(new SimpleGeolocationProvider(
774 g_browser_process
->system_request_context(),
775 SimpleGeolocationProvider::DefaultGeolocationProviderURL()));
776 geolocation_provider_
->RequestGeolocation(
777 base::TimeDelta::FromSeconds(kResolveTimeZoneTimeoutSeconds
),
778 base::Bind(&WizardController::OnLocationResolved
,
779 weak_factory_
.GetWeakPtr()));
782 void WizardController::PerformPostEulaActions() {
784 base::TimeDelta::FromMilliseconds(kDefaultNetworkRetryDelayMS
),
785 base::Bind(&WizardController::StartTimezoneResolve
,
786 weak_factory_
.GetWeakPtr()));
788 base::TimeDelta::FromMilliseconds(kDefaultNetworkRetryDelayMS
),
789 ServicesCustomizationDocument::GetInstance()
790 ->EnsureCustomizationAppliedClosure());
792 // Now that EULA has been accepted (for official builds), enable portal check.
793 // ChromiumOS builds would go though this code path too.
794 NetworkHandler::Get()->network_state_handler()->SetCheckPortalList(
795 NetworkStateHandler::kDefaultCheckPortalList
);
796 host_
->GetAutoEnrollmentController()->Start();
797 host_
->PrewarmAuthentication();
798 NetworkPortalDetector::Get()->Enable(true);
801 void WizardController::PerformOOBECompletedActions() {
802 UMA_HISTOGRAM_COUNTS_100(
803 "HIDDetection.TimesDialogShownPerOOBECompleted",
804 GetLocalState()->GetInteger(prefs::kTimesHIDDialogShown
));
805 GetLocalState()->ClearPref(prefs::kTimesHIDDialogShown
);
806 StartupUtils::MarkOobeCompleted();
808 // Restart to make the login page pick up the policy changes resulting from
809 // enrollment recovery.
810 // TODO(tnagel): Find a way to update login page without reboot.
811 if (prescribed_enrollment_config_
.mode
==
812 policy::EnrollmentConfig::MODE_RECOVERY
) {
813 chrome::AttemptRestart();
817 void WizardController::SetCurrentScreen(BaseScreen
* new_current
) {
818 SetCurrentScreenSmooth(new_current
, false);
821 void WizardController::ShowCurrentScreen() {
822 // ShowCurrentScreen may get called by smooth_show_timer_ even after
823 // flow has been switched to sign in screen (ExistingUserController).
827 // First remember how far have we reached so that we can resume if needed.
828 if (is_out_of_box_
&& IsResumableScreen(current_screen_
->GetName()))
829 StartupUtils::SaveOobePendingScreen(current_screen_
->GetName());
831 smooth_show_timer_
.Stop();
833 FOR_EACH_OBSERVER(Observer
, observer_list_
, OnScreenChanged(current_screen_
));
835 current_screen_
->Show();
838 void WizardController::SetCurrentScreenSmooth(BaseScreen
* new_current
,
839 bool use_smoothing
) {
840 if (current_screen_
== new_current
||
841 new_current
== NULL
||
842 oobe_display_
== NULL
) {
846 smooth_show_timer_
.Stop();
849 current_screen_
->Hide();
851 std::string screen_id
= new_current
->GetName();
852 if (IsOOBEStepToTrack(screen_id
))
853 screen_show_times_
[screen_id
] = base::Time::Now();
855 previous_screen_
= current_screen_
;
856 current_screen_
= new_current
;
859 smooth_show_timer_
.Start(
861 base::TimeDelta::FromMilliseconds(kShowDelayMs
),
863 &WizardController::ShowCurrentScreen
);
869 void WizardController::SetStatusAreaVisible(bool visible
) {
870 host_
->SetStatusAreaVisible(visible
);
873 void WizardController::OnHIDScreenNecessityCheck(bool screen_needed
) {
877 ShowHIDDetectionScreen();
882 void WizardController::AdvanceToScreen(const std::string
& screen_name
) {
883 if (screen_name
== kNetworkScreenName
) {
885 } else if (screen_name
== kLoginScreenName
) {
886 ShowLoginScreen(LoginScreenContext());
887 } else if (screen_name
== kUpdateScreenName
) {
888 InitiateOOBEUpdate();
889 } else if (screen_name
== kUserImageScreenName
) {
890 ShowUserImageScreen();
891 } else if (screen_name
== kEulaScreenName
) {
893 } else if (screen_name
== kResetScreenName
) {
895 } else if (screen_name
== kKioskEnableScreenName
) {
896 ShowKioskEnableScreen();
897 } else if (screen_name
== kKioskAutolaunchScreenName
) {
898 ShowKioskAutolaunchScreen();
899 } else if (screen_name
== kEnableDebuggingScreenName
) {
900 ShowEnableDebuggingScreen();
901 } else if (screen_name
== kEnrollmentScreenName
) {
902 ShowEnrollmentScreen();
903 } else if (screen_name
== kTermsOfServiceScreenName
) {
904 ShowTermsOfServiceScreen();
905 } else if (screen_name
== kWrongHWIDScreenName
) {
906 ShowWrongHWIDScreen();
907 } else if (screen_name
== kAutoEnrollmentCheckScreenName
) {
908 ShowAutoEnrollmentCheckScreen();
909 } else if (screen_name
== kSupervisedUserCreationScreenName
) {
910 ShowSupervisedUserCreationScreen();
911 } else if (screen_name
== kAppLaunchSplashScreenName
) {
912 AutoLaunchKioskApp();
913 } else if (screen_name
== kHIDDetectionScreenName
) {
914 ShowHIDDetectionScreen();
915 } else if (screen_name
== kControllerPairingScreenName
) {
916 ShowControllerPairingScreen();
917 } else if (screen_name
== kHostPairingScreenName
) {
918 ShowHostPairingScreen();
919 } else if (screen_name
== kDeviceDisabledScreenName
) {
920 ShowDeviceDisabledScreen();
921 } else if (screen_name
!= kTestNoScreenName
) {
922 if (is_out_of_box_
) {
923 time_oobe_started_
= base::Time::Now();
924 if (IsHostPairingOobe()) {
925 ShowHostPairingScreen();
926 } else if (CanShowHIDDetectionScreen()) {
927 hid_screen_
= GetScreen(kHIDDetectionScreenName
);
928 base::Callback
<void(bool)> on_check
= base::Bind(
929 &WizardController::OnHIDScreenNecessityCheck
,
930 weak_factory_
.GetWeakPtr());
931 oobe_display_
->GetHIDDetectionView()->CheckIsScreenRequired(on_check
);
936 ShowLoginScreen(LoginScreenContext());
941 ///////////////////////////////////////////////////////////////////////////////
942 // WizardController, BaseScreenDelegate overrides:
943 void WizardController::OnExit(BaseScreen
& /* screen */,
945 const ::login::ScreenContext
* /* context */) {
946 VLOG(1) << "Wizard screen exit code: " << exit_code
;
947 std::string previous_screen_id
= current_screen_
->GetName();
948 if (IsOOBEStepToTrack(previous_screen_id
)) {
949 RecordUMAHistogramForOOBEStepCompletionTime(
951 base::Time::Now() - screen_show_times_
[previous_screen_id
]);
954 case HID_DETECTION_COMPLETED
:
955 OnHIDDetectionCompleted();
957 case NETWORK_CONNECTED
:
958 OnNetworkConnected();
960 case CONNECTION_FAILED
:
961 OnConnectionFailed();
963 case UPDATE_INSTALLED
:
964 case UPDATE_NOUPDATE
:
967 case UPDATE_ERROR_CHECKING_FOR_UPDATE
:
968 OnUpdateErrorCheckingForUpdate();
970 case UPDATE_ERROR_UPDATING
:
971 OnUpdateErrorUpdating();
973 case USER_IMAGE_SELECTED
:
974 OnUserImageSelected();
982 case ENABLE_DEBUGGING_CANCELED
:
983 OnDeviceModificationCanceled();
985 case ENABLE_DEBUGGING_FINISHED
:
986 OnDeviceModificationCanceled();
988 case ENTERPRISE_AUTO_ENROLLMENT_CHECK_COMPLETED
:
989 OnAutoEnrollmentCheckCompleted();
991 case ENTERPRISE_ENROLLMENT_COMPLETED
:
994 case ENTERPRISE_ENROLLMENT_BACK
:
995 retry_auto_enrollment_check_
= true;
996 ShowAutoEnrollmentCheckScreen();
999 OnDeviceModificationCanceled();
1001 case KIOSK_AUTOLAUNCH_CANCELED
:
1002 OnKioskAutolaunchCanceled();
1004 case KIOSK_AUTOLAUNCH_CONFIRMED
:
1005 OnKioskAutolaunchConfirmed();
1007 case KIOSK_ENABLE_COMPLETED
:
1008 OnKioskEnableCompleted();
1010 case TERMS_OF_SERVICE_DECLINED
:
1011 OnTermsOfServiceDeclined();
1013 case TERMS_OF_SERVICE_ACCEPTED
:
1014 OnTermsOfServiceAccepted();
1016 case WRONG_HWID_WARNING_SKIPPED
:
1017 OnWrongHWIDWarningSkipped();
1019 case CONTROLLER_PAIRING_FINISHED
:
1020 OnControllerPairingFinished();
1022 case HOST_PAIRING_FINISHED
:
1023 OnHostPairingFinished();
1030 void WizardController::ShowErrorScreen() {
1031 VLOG(1) << "Showing error screen.";
1032 SetCurrentScreen(GetScreen(kErrorScreenName
));
1035 void WizardController::HideErrorScreen(BaseScreen
* parent_screen
) {
1036 DCHECK(parent_screen
);
1037 VLOG(1) << "Hiding error screen.";
1038 SetCurrentScreen(parent_screen
);
1041 void WizardController::SetUsageStatisticsReporting(bool val
) {
1042 usage_statistics_reporting_
= val
;
1045 bool WizardController::GetUsageStatisticsReporting() const {
1046 return usage_statistics_reporting_
;
1049 void WizardController::SetHostConfiguration() {
1050 if (shark_controller_
) {
1051 NetworkScreen
* network_screen
= NetworkScreen::Get(this);
1052 shark_controller_
->SetHostConfiguration(
1053 true, // Eula must be accepted before we get this far.
1054 network_screen
->GetApplicationLocale(), network_screen
->GetTimezone(),
1055 GetUsageStatisticsReporting(), network_screen
->GetInputMethod());
1059 void WizardController::ConfigureHostRequested(
1061 const std::string
& lang
,
1062 const std::string
& timezone
,
1064 const std::string
& keyboard_layout
) {
1065 VLOG(1) << "ConfigureHost locale=" << lang
<< ", timezone=" << timezone
1066 << ", keyboard_layout=" << keyboard_layout
;
1067 if (accepted_eula
) // Always true.
1068 StartupUtils::MarkEulaAccepted();
1069 SetUsageStatisticsReporting(send_reports
);
1071 NetworkScreen
* network_screen
= NetworkScreen::Get(this);
1072 network_screen
->SetApplicationLocale(lang
);
1073 network_screen
->SetTimezone(timezone
);
1074 network_screen
->SetInputMethod(keyboard_layout
);
1077 void WizardController::AddNetworkRequested(const std::string
& onc_spec
) {
1078 NetworkScreen
* network_screen
= NetworkScreen::Get(this);
1079 network_screen
->CreateNetworkFromOnc(onc_spec
);
1082 void WizardController::OnEnableDebuggingScreenRequested() {
1083 if (!login_screen_started())
1084 AdvanceToScreen(WizardController::kEnableDebuggingScreenName
);
1087 void WizardController::OnAccessibilityStatusChanged(
1088 const AccessibilityStatusEventDetails
& details
) {
1089 enum AccessibilityNotificationType type
= details
.notification_type
;
1090 if (type
== ACCESSIBILITY_MANAGER_SHUTDOWN
) {
1091 accessibility_subscription_
.reset();
1093 } else if (type
!= ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK
|| !details
.enabled
) {
1097 CrasAudioHandler
* cras
= CrasAudioHandler::Get();
1098 if (cras
->IsOutputMuted()) {
1099 cras
->SetOutputMute(false);
1100 cras
->SetOutputVolumePercent(kMinAudibleOutputVolumePercent
);
1101 } else if (cras
->GetOutputVolumePercent() < kMinAudibleOutputVolumePercent
) {
1102 cras
->SetOutputVolumePercent(kMinAudibleOutputVolumePercent
);
1106 void WizardController::AutoLaunchKioskApp() {
1107 KioskAppManager::App app_data
;
1108 std::string app_id
= KioskAppManager::Get()->GetAutoLaunchApp();
1109 CHECK(KioskAppManager::Get()->GetApp(app_id
, &app_data
));
1111 // Wait for the |CrosSettings| to become either trusted or permanently
1113 const CrosSettingsProvider::TrustedStatus status
=
1114 CrosSettings::Get()->PrepareTrustedValues(base::Bind(
1115 &WizardController::AutoLaunchKioskApp
,
1116 weak_factory_
.GetWeakPtr()));
1117 if (status
== CrosSettingsProvider::TEMPORARILY_UNTRUSTED
)
1120 if (status
== CrosSettingsProvider::PERMANENTLY_UNTRUSTED
) {
1121 // If the |cros_settings_| are permanently untrusted, show an error message
1122 // and refuse to auto-launch the kiosk app.
1123 GetErrorScreen()->SetUIState(NetworkError::UI_STATE_LOCAL_STATE_ERROR
);
1124 SetStatusAreaVisible(false);
1129 bool device_disabled
= false;
1130 CrosSettings::Get()->GetBoolean(kDeviceDisabled
, &device_disabled
);
1131 if (device_disabled
&& system::DeviceDisablingManager::
1132 HonorDeviceDisablingDuringNormalOperation()) {
1133 // If the device is disabled, bail out. A device disabled screen will be
1134 // shown by the DeviceDisablingManager.
1138 const bool diagnostic_mode
= false;
1139 const bool auto_launch
= true;
1140 host_
->StartAppLaunch(app_id
, diagnostic_mode
, auto_launch
);
1144 void WizardController::SetZeroDelays() {
1146 zero_delay_enabled_
= true;
1150 bool WizardController::IsZeroDelayEnabled() {
1151 return zero_delay_enabled_
;
1155 bool WizardController::IsOOBEStepToTrack(const std::string
& screen_id
) {
1156 return (screen_id
== kHIDDetectionScreenName
||
1157 screen_id
== kNetworkScreenName
||
1158 screen_id
== kUpdateScreenName
||
1159 screen_id
== kUserImageScreenName
||
1160 screen_id
== kEulaScreenName
||
1161 screen_id
== kLoginScreenName
||
1162 screen_id
== kWrongHWIDScreenName
);
1166 void WizardController::SkipPostLoginScreensForTesting() {
1167 skip_post_login_screens_
= true;
1170 void WizardController::OnLocalStateInitialized(bool /* succeeded */) {
1171 if (GetLocalState()->GetInitializationStatus() !=
1172 PrefService::INITIALIZATION_STATUS_ERROR
) {
1175 GetErrorScreen()->SetUIState(NetworkError::UI_STATE_LOCAL_STATE_ERROR
);
1176 SetStatusAreaVisible(false);
1180 PrefService
* WizardController::GetLocalState() {
1181 if (local_state_for_testing_
)
1182 return local_state_for_testing_
;
1183 return g_browser_process
->local_state();
1186 void WizardController::OnTimezoneResolved(
1187 scoped_ptr
<TimeZoneResponseData
> timezone
,
1188 bool server_error
) {
1189 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1190 DCHECK(timezone
.get());
1191 // To check that "this" is not destroyed try to access some member
1192 // (timezone_provider_) in this case. Expect crash here.
1193 DCHECK(timezone_provider_
.get());
1195 timezone_resolved_
= true;
1196 base::ScopedClosureRunner
inform_test(on_timezone_resolved_for_testing_
);
1197 on_timezone_resolved_for_testing_
.Reset();
1199 VLOG(1) << "Resolved local timezone={" << timezone
->ToStringForDebug()
1202 if (timezone
->status
!= TimeZoneResponseData::OK
) {
1203 LOG(WARNING
) << "Resolve TimeZone: failed to resolve timezone.";
1207 policy::BrowserPolicyConnectorChromeOS
* connector
=
1208 g_browser_process
->platform_part()->browser_policy_connector_chromeos();
1209 if (connector
->IsEnterpriseManaged()) {
1210 std::string policy_timezone
;
1211 if (CrosSettings::Get()->GetString(kSystemTimezonePolicy
,
1212 &policy_timezone
) &&
1213 !policy_timezone
.empty()) {
1214 VLOG(1) << "Resolve TimeZone: TimeZone settings are overridden"
1215 << " by DevicePolicy.";
1220 if (!timezone
->timeZoneId
.empty()) {
1221 VLOG(1) << "Resolve TimeZone: setting timezone to '" << timezone
->timeZoneId
1224 system::TimezoneSettings::GetInstance()->SetTimezoneFromID(
1225 base::UTF8ToUTF16(timezone
->timeZoneId
));
1229 TimeZoneProvider
* WizardController::GetTimezoneProvider() {
1230 if (!timezone_provider_
) {
1231 timezone_provider_
.reset(
1232 new TimeZoneProvider(g_browser_process
->system_request_context(),
1233 DefaultTimezoneProviderURL()));
1235 return timezone_provider_
.get();
1238 void WizardController::OnLocationResolved(const Geoposition
& position
,
1240 const base::TimeDelta elapsed
) {
1241 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
1243 const base::TimeDelta timeout
=
1244 base::TimeDelta::FromSeconds(kResolveTimeZoneTimeoutSeconds
);
1245 // Ignore invalid position.
1246 if (!position
.Valid())
1249 if (elapsed
>= timeout
) {
1250 LOG(WARNING
) << "Resolve TimeZone: got location after timeout ("
1251 << elapsed
.InSecondsF() << " seconds elapsed). Ignored.";
1255 // WizardController owns TimezoneProvider, so timezone request is silently
1256 // cancelled on destruction.
1257 GetTimezoneProvider()->RequestTimezone(
1260 base::Bind(&WizardController::OnTimezoneResolved
,
1261 base::Unretained(this)));
1264 bool WizardController::SetOnTimeZoneResolvedForTesting(
1265 const base::Closure
& callback
) {
1266 if (timezone_resolved_
)
1269 on_timezone_resolved_for_testing_
= callback
;
1273 bool WizardController::IsHostPairingOobe() const {
1274 return IsRemoraRequisition() &&
1275 (base::CommandLine::ForCurrentProcess()->HasSwitch(
1276 switches::kHostPairingOobe
) ||
1277 shark_controller_detected_
);
1280 void WizardController::MaybeStartListeningForSharkConnection() {
1281 if (!IsRemoraRequisition())
1284 // We shouldn't be here if we are running pairing OOBE already.
1285 DCHECK(!IsHostPairingOobe());
1287 if (!shark_connection_listener_
) {
1288 shark_connection_listener_
.reset(
1289 new pairing_chromeos::SharkConnectionListener(
1290 base::Bind(&WizardController::OnSharkConnected
,
1291 weak_factory_
.GetWeakPtr())));
1295 void WizardController::OnSharkConnected(
1296 scoped_ptr
<pairing_chromeos::HostPairingController
> remora_controller
) {
1297 VLOG(1) << "OnSharkConnected";
1298 remora_controller_
= remora_controller
.Pass();
1299 base::MessageLoop::current()->DeleteSoon(
1300 FROM_HERE
, shark_connection_listener_
.release());
1301 shark_controller_detected_
= true;
1302 ShowHostPairingScreen();
1305 void WizardController::StartEnrollmentScreen() {
1306 VLOG(1) << "Showing enrollment screen.";
1308 // Determine the effective enrollment configuration. If there is a valid
1309 // prescribed configuration, use that. If not, figure out which variant of
1310 // manual enrollment is taking place.
1311 policy::EnrollmentConfig effective_config
= prescribed_enrollment_config_
;
1312 if (!effective_config
.should_enroll()) {
1313 effective_config
.mode
=
1314 prescribed_enrollment_config_
.management_domain
.empty()
1315 ? policy::EnrollmentConfig::MODE_MANUAL
1316 : policy::EnrollmentConfig::MODE_MANUAL_REENROLLMENT
;
1319 EnrollmentScreen
* screen
= EnrollmentScreen::Get(this);
1320 screen
->SetParameters(effective_config
, shark_controller_
.get(),
1321 remora_controller_
.get());
1322 SetStatusAreaVisible(true);
1323 SetCurrentScreen(screen
);
1326 } // namespace chromeos