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/signin_screen_handler.h"
62 #include "chrome/common/chrome_constants.h"
63 #include "chrome/common/pref_names.h"
64 #include "chromeos/audio/cras_audio_handler.h"
65 #include "chromeos/chromeos_constants.h"
66 #include "chromeos/chromeos_switches.h"
67 #include "chromeos/dbus/dbus_thread_manager.h"
68 #include "chromeos/dbus/session_manager_client.h"
69 #include "chromeos/geolocation/simple_geolocation_provider.h"
70 #include "chromeos/network/network_state.h"
71 #include "chromeos/network/network_state_handler.h"
72 #include "chromeos/network/portal_detector/network_portal_detector.h"
73 #include "chromeos/settings/cros_settings_names.h"
74 #include "chromeos/settings/cros_settings_provider.h"
75 #include "chromeos/settings/timezone_settings.h"
76 #include "chromeos/timezone/timezone_provider.h"
77 #include "components/crash/app/breakpad_linux.h"
78 #include "components/pairing/bluetooth_controller_pairing_controller.h"
79 #include "components/pairing/bluetooth_host_pairing_controller.h"
80 #include "components/pairing/shark_connection_listener.h"
81 #include "components/user_manager/user_manager.h"
82 #include "content/public/browser/browser_thread.h"
83 #include "content/public/browser/notification_types.h"
84 #include "ui/base/accelerators/accelerator.h"
86 using content::BrowserThread
;
89 // Interval in ms which is used for smooth screen showing.
90 static int kShowDelayMs
= 400;
92 // Total timezone resolving process timeout.
93 const unsigned int kResolveTimeZoneTimeoutSeconds
= 60;
95 // Stores the list of all screens that should be shown when resuming OOBE.
96 const char *kResumableScreens
[] = {
97 chromeos::WizardController::kNetworkScreenName
,
98 chromeos::WizardController::kUpdateScreenName
,
99 chromeos::WizardController::kEulaScreenName
,
100 chromeos::WizardController::kEnrollmentScreenName
,
101 chromeos::WizardController::kTermsOfServiceScreenName
,
102 chromeos::WizardController::kAutoEnrollmentCheckScreenName
105 // Checks flag for HID-detection screen show.
106 bool CanShowHIDDetectionScreen() {
107 return !base::CommandLine::ForCurrentProcess()->HasSwitch(
108 chromeos::switches::kDisableHIDDetectionOnOOBE
);
111 bool IsResumableScreen(const std::string
& screen
) {
112 for (size_t i
= 0; i
< arraysize(kResumableScreens
); ++i
) {
113 if (screen
== kResumableScreens
[i
])
119 void RecordUMAHistogramForOOBEStepCompletionTime(std::string screen_name
,
120 base::TimeDelta step_time
) {
121 screen_name
[0] = std::toupper(screen_name
[0]);
122 std::string histogram_name
= "OOBE.StepCompletionTime." + screen_name
;
123 // Equivalent to using UMA_HISTOGRAM_MEDIUM_TIMES. UMA_HISTOGRAM_MEDIUM_TIMES
124 // can not be used here, because |histogram_name| is calculated dynamically
125 // and changes from call to call.
126 base::HistogramBase
* histogram
= base::Histogram::FactoryTimeGet(
128 base::TimeDelta::FromMilliseconds(10),
129 base::TimeDelta::FromMinutes(3),
131 base::HistogramBase::kUmaTargetedHistogramFlag
);
132 histogram
->AddTime(step_time
);
135 bool IsRemoraRequisition() {
136 return g_browser_process
->platform_part()
137 ->browser_policy_connector_chromeos()
138 ->GetDeviceCloudPolicyManager()
139 ->IsRemoraRequisition();
142 #if defined(GOOGLE_CHROME_BUILD)
143 void InitializeCrashReporter() {
144 // The crash reporter initialization needs IO to complete.
145 DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
146 breakpad::InitCrashReporter(std::string());
154 const char WizardController::kNetworkScreenName
[] = "network";
155 const char WizardController::kLoginScreenName
[] = "login";
156 const char WizardController::kUpdateScreenName
[] = "update";
157 const char WizardController::kUserImageScreenName
[] = "image";
158 const char WizardController::kEulaScreenName
[] = "eula";
159 const char WizardController::kEnableDebuggingScreenName
[] = "debugging";
160 const char WizardController::kEnrollmentScreenName
[] = "enroll";
161 const char WizardController::kResetScreenName
[] = "reset";
162 const char WizardController::kKioskEnableScreenName
[] = "kiosk-enable";
163 const char WizardController::kKioskAutolaunchScreenName
[] = "autolaunch";
164 const char WizardController::kErrorScreenName
[] = "error-message";
165 const char WizardController::kTermsOfServiceScreenName
[] = "tos";
166 const char WizardController::kAutoEnrollmentCheckScreenName
[] =
167 "auto-enrollment-check";
168 const char WizardController::kWrongHWIDScreenName
[] = "wrong-hwid";
169 const char WizardController::kSupervisedUserCreationScreenName
[] =
170 "supervised-user-creation-flow";
171 const char WizardController::kAppLaunchSplashScreenName
[] =
173 const char WizardController::kHIDDetectionScreenName
[] = "hid-detection";
174 const char WizardController::kControllerPairingScreenName
[] =
175 "controller-pairing";
176 const char WizardController::kHostPairingScreenName
[] = "host-pairing";
177 const char WizardController::kDeviceDisabledScreenName
[] = "device-disabled";
180 const int WizardController::kMinAudibleOutputVolumePercent
= 10;
182 // Passing this parameter as a "first screen" initiates full OOBE flow.
183 const char WizardController::kOutOfBoxScreenName
[] = "oobe";
185 // Special test value that commands not to create any window yet.
186 const char WizardController::kTestNoScreenName
[] = "test:nowindow";
188 // Initialize default controller.
190 WizardController
* WizardController::default_controller_
= NULL
;
193 bool WizardController::skip_post_login_screens_
= false;
196 bool WizardController::zero_delay_enabled_
= false;
198 ///////////////////////////////////////////////////////////////////////////////
199 // WizardController, public:
201 PrefService
* WizardController::local_state_for_testing_
= NULL
;
203 WizardController::WizardController(LoginDisplayHost
* host
,
204 OobeDisplay
* oobe_display
)
205 : current_screen_(NULL
),
206 previous_screen_(NULL
),
207 #if defined(GOOGLE_CHROME_BUILD)
208 is_official_build_(true),
210 is_official_build_(false),
212 is_out_of_box_(false),
214 oobe_display_(oobe_display
),
215 usage_statistics_reporting_(true),
216 skip_update_enroll_after_eula_(false),
217 retry_auto_enrollment_check_(false),
218 login_screen_started_(false),
219 user_image_screen_return_to_previous_hack_(false),
220 timezone_resolved_(false),
221 shark_controller_detected_(false),
222 hid_screen_(nullptr),
223 weak_factory_(this) {
224 DCHECK(default_controller_
== NULL
);
225 default_controller_
= this;
226 AccessibilityManager
* accessibility_manager
= AccessibilityManager::Get();
227 CHECK(accessibility_manager
);
228 accessibility_subscription_
= accessibility_manager
->RegisterCallback(
229 base::Bind(&WizardController::OnAccessibilityStatusChanged
,
230 base::Unretained(this)));
233 WizardController::~WizardController() {
234 if (default_controller_
== this) {
235 default_controller_
= NULL
;
237 NOTREACHED() << "More than one controller are alive.";
241 void WizardController::Init(const std::string
& first_screen_name
) {
242 VLOG(1) << "Starting OOBE wizard with screen: " << first_screen_name
;
243 first_screen_name_
= first_screen_name
;
245 bool oobe_complete
= StartupUtils::IsOobeCompleted();
246 if (!oobe_complete
|| first_screen_name
== kOutOfBoxScreenName
)
247 is_out_of_box_
= true;
249 // This is a hacky way to check for local state corruption, because
250 // it depends on the fact that the local state is loaded
251 // synchronously and at the first demand. IsEnterpriseManaged()
252 // check is required because currently powerwash is disabled for
253 // enterprise-enrolled devices.
255 // TODO (ygorshenin@): implement handling of the local state
256 // corruption in the case of asynchronious loading.
257 policy::BrowserPolicyConnectorChromeOS
* connector
=
258 g_browser_process
->platform_part()->browser_policy_connector_chromeos();
259 if (!connector
->IsEnterpriseManaged()) {
260 const PrefService::PrefInitializationStatus status
=
261 GetLocalState()->GetInitializationStatus();
262 if (status
== PrefService::INITIALIZATION_STATUS_ERROR
) {
263 OnLocalStateInitialized(false);
265 } else if (status
== PrefService::INITIALIZATION_STATUS_WAITING
) {
266 GetLocalState()->AddPrefInitObserver(
267 base::Bind(&WizardController::OnLocalStateInitialized
,
268 weak_factory_
.GetWeakPtr()));
272 // Use the saved screen preference from Local State.
273 const std::string screen_pref
=
274 GetLocalState()->GetString(prefs::kOobeScreenPending
);
275 if (is_out_of_box_
&& !screen_pref
.empty() && !IsHostPairingOobe() &&
276 (first_screen_name
.empty() ||
277 first_screen_name
== WizardController::kTestNoScreenName
)) {
278 first_screen_name_
= screen_pref
;
281 AdvanceToScreen(first_screen_name_
);
282 if (!IsMachineHWIDCorrect() && !StartupUtils::IsDeviceRegistered() &&
283 first_screen_name_
.empty())
284 ShowWrongHWIDScreen();
287 ErrorScreen
* WizardController::GetErrorScreen() {
288 return static_cast<ErrorScreen
*>(GetScreen(kErrorScreenName
));
291 BaseScreen
* WizardController::CreateScreen(const std::string
& screen_name
) {
292 if (screen_name
== kNetworkScreenName
) {
293 scoped_ptr
<NetworkScreen
> screen(
294 new NetworkScreen(this, this, oobe_display_
->GetNetworkView()));
295 screen
->Initialize(nullptr /* context */);
296 return screen
.release();
297 } else if (screen_name
== kErrorScreenName
) {
298 scoped_ptr
<ErrorScreen
> screen(
299 new ErrorScreen(this, oobe_display_
->GetNetworkErrorView()));
300 screen
->Initialize(nullptr /* context */);
301 return screen
.release();
302 } else if (screen_name
== kUpdateScreenName
) {
303 scoped_ptr
<UpdateScreen
> screen(new UpdateScreen(
304 this, oobe_display_
->GetUpdateView(), remora_controller_
.get()));
305 screen
->Initialize(nullptr /* context */);
306 return screen
.release();
307 } else if (screen_name
== kUserImageScreenName
) {
308 return new UserImageScreen(this, oobe_display_
->GetUserImageView());
309 } else if (screen_name
== kEulaScreenName
) {
310 return new EulaScreen(this, this, oobe_display_
->GetEulaView());
311 } else if (screen_name
== kEnrollmentScreenName
) {
312 return new EnrollmentScreen(this,
313 oobe_display_
->GetEnrollmentScreenActor());
314 } else if (screen_name
== kResetScreenName
) {
315 return new chromeos::ResetScreen(this,
316 oobe_display_
->GetResetView());
317 } else if (screen_name
== kEnableDebuggingScreenName
) {
318 return new EnableDebuggingScreen(
319 this, oobe_display_
->GetEnableDebuggingScreenActor());
320 } else if (screen_name
== kKioskEnableScreenName
) {
321 return new KioskEnableScreen(this,
322 oobe_display_
->GetKioskEnableScreenActor());
323 } else if (screen_name
== kKioskAutolaunchScreenName
) {
324 return new KioskAutolaunchScreen(
325 this, oobe_display_
->GetKioskAutolaunchScreenActor());
326 } else if (screen_name
== kTermsOfServiceScreenName
) {
327 return new TermsOfServiceScreen(
328 this, oobe_display_
->GetTermsOfServiceScreenActor());
329 } else if (screen_name
== kWrongHWIDScreenName
) {
330 return new WrongHWIDScreen(this, oobe_display_
->GetWrongHWIDScreenActor());
331 } else if (screen_name
== kSupervisedUserCreationScreenName
) {
332 return new SupervisedUserCreationScreen(
333 this, oobe_display_
->GetSupervisedUserCreationScreenActor());
334 } else if (screen_name
== kHIDDetectionScreenName
) {
335 scoped_ptr
<HIDDetectionScreen
> screen(new chromeos::HIDDetectionScreen(
336 this, oobe_display_
->GetHIDDetectionView()));
337 screen
->Initialize(nullptr /* context */);
338 return screen
.release();
339 } else if (screen_name
== kAutoEnrollmentCheckScreenName
) {
340 return new AutoEnrollmentCheckScreen(
341 this, oobe_display_
->GetAutoEnrollmentCheckScreenActor());
342 } else if (screen_name
== kControllerPairingScreenName
) {
343 if (!shark_controller_
) {
344 shark_controller_
.reset(
345 new pairing_chromeos::BluetoothControllerPairingController());
347 return new ControllerPairingScreen(
350 oobe_display_
->GetControllerPairingScreenActor(),
351 shark_controller_
.get());
352 } else if (screen_name
== kHostPairingScreenName
) {
353 if (!remora_controller_
) {
354 remora_controller_
.reset(
355 new pairing_chromeos::BluetoothHostPairingController());
356 remora_controller_
->StartPairing();
358 return new HostPairingScreen(this,
360 oobe_display_
->GetHostPairingScreenActor(),
361 remora_controller_
.get());
362 } else if (screen_name
== kDeviceDisabledScreenName
) {
363 return new DeviceDisabledScreen(
364 this, oobe_display_
->GetDeviceDisabledScreenActor());
370 void WizardController::ShowNetworkScreen() {
371 VLOG(1) << "Showing network screen.";
372 // Hide the status area initially; it only appears after OOBE first animates
373 // in. Keep it visible if the user goes back to the existing network screen.
374 SetStatusAreaVisible(HasScreen(kNetworkScreenName
));
375 SetCurrentScreen(GetScreen(kNetworkScreenName
));
377 MaybeStartListeningForSharkConnection();
380 void WizardController::ShowLoginScreen(const LoginScreenContext
& context
) {
381 if (!time_eula_accepted_
.is_null()) {
382 base::TimeDelta delta
= base::Time::Now() - time_eula_accepted_
;
383 UMA_HISTOGRAM_MEDIUM_TIMES("OOBE.EULAToSignInTime", delta
);
385 VLOG(1) << "Showing login screen.";
386 SetStatusAreaVisible(true);
387 host_
->StartSignInScreen(context
);
388 smooth_show_timer_
.Stop();
389 oobe_display_
= NULL
;
390 login_screen_started_
= true;
393 void WizardController::ShowUpdateScreen() {
394 VLOG(1) << "Showing update screen.";
395 SetStatusAreaVisible(true);
396 SetCurrentScreen(GetScreen(kUpdateScreenName
));
399 void WizardController::ShowUserImageScreen() {
400 const user_manager::UserManager
* user_manager
=
401 user_manager::UserManager::Get();
402 // Skip user image selection for public sessions and ephemeral logins.
403 if (user_manager
->IsLoggedInAsPublicAccount() ||
404 user_manager
->IsCurrentUserNonCryptohomeDataEphemeral()) {
405 OnUserImageSkipped();
408 VLOG(1) << "Showing user image screen.";
410 // Status area has been already shown at sign in screen so it
411 // doesn't make sense to hide it here and then show again at user session as
412 // this produces undesired UX transitions.
413 SetStatusAreaVisible(true);
415 SetCurrentScreen(GetScreen(kUserImageScreenName
));
418 void WizardController::ShowEulaScreen() {
419 VLOG(1) << "Showing EULA screen.";
420 SetStatusAreaVisible(true);
421 SetCurrentScreen(GetScreen(kEulaScreenName
));
424 void WizardController::ShowEnrollmentScreen() {
425 // Update the enrollment configuration and start the screen.
426 prescribed_enrollment_config_
= g_browser_process
->platform_part()
427 ->browser_policy_connector_chromeos()
428 ->GetPrescribedEnrollmentConfig();
429 StartEnrollmentScreen();
432 void WizardController::ShowResetScreen() {
433 VLOG(1) << "Showing reset screen.";
434 SetStatusAreaVisible(false);
435 SetCurrentScreen(GetScreen(kResetScreenName
));
438 void WizardController::ShowKioskEnableScreen() {
439 VLOG(1) << "Showing kiosk enable screen.";
440 SetStatusAreaVisible(false);
441 SetCurrentScreen(GetScreen(kKioskEnableScreenName
));
444 void WizardController::ShowKioskAutolaunchScreen() {
445 VLOG(1) << "Showing kiosk autolaunch screen.";
446 SetStatusAreaVisible(false);
447 SetCurrentScreen(GetScreen(kKioskAutolaunchScreenName
));
450 void WizardController::ShowEnableDebuggingScreen() {
451 VLOG(1) << "Showing enable developer features screen.";
452 SetStatusAreaVisible(false);
453 SetCurrentScreen(GetScreen(kEnableDebuggingScreenName
));
456 void WizardController::ShowTermsOfServiceScreen() {
457 // Only show the Terms of Service when logging into a public account and Terms
458 // of Service have been specified through policy. In all other cases, advance
459 // to the user image screen immediately.
460 if (!user_manager::UserManager::Get()->IsLoggedInAsPublicAccount() ||
461 !ProfileManager::GetActiveUserProfile()->GetPrefs()->IsManagedPreference(
462 prefs::kTermsOfServiceURL
)) {
463 ShowUserImageScreen();
467 VLOG(1) << "Showing Terms of Service screen.";
468 SetStatusAreaVisible(true);
469 SetCurrentScreen(GetScreen(kTermsOfServiceScreenName
));
472 void WizardController::ShowWrongHWIDScreen() {
473 VLOG(1) << "Showing wrong HWID screen.";
474 SetStatusAreaVisible(false);
475 SetCurrentScreen(GetScreen(kWrongHWIDScreenName
));
478 void WizardController::ShowAutoEnrollmentCheckScreen() {
479 VLOG(1) << "Showing Auto-enrollment check screen.";
480 SetStatusAreaVisible(true);
481 AutoEnrollmentCheckScreen
* screen
= AutoEnrollmentCheckScreen::Get(this);
482 if (retry_auto_enrollment_check_
)
483 screen
->ClearState();
484 screen
->set_auto_enrollment_controller(host_
->GetAutoEnrollmentController());
485 SetCurrentScreen(screen
);
488 void WizardController::ShowSupervisedUserCreationScreen() {
489 VLOG(1) << "Showing Locally managed user creation screen screen.";
490 SetStatusAreaVisible(true);
491 SetCurrentScreen(GetScreen(kSupervisedUserCreationScreenName
));
494 void WizardController::ShowHIDDetectionScreen() {
495 VLOG(1) << "Showing HID discovery screen.";
496 SetStatusAreaVisible(true);
497 SetCurrentScreen(GetScreen(kHIDDetectionScreenName
));
498 MaybeStartListeningForSharkConnection();
501 void WizardController::ShowControllerPairingScreen() {
502 VLOG(1) << "Showing controller pairing screen.";
503 SetStatusAreaVisible(false);
504 SetCurrentScreen(GetScreen(kControllerPairingScreenName
));
507 void WizardController::ShowHostPairingScreen() {
508 VLOG(1) << "Showing host pairing screen.";
509 SetStatusAreaVisible(false);
510 SetCurrentScreen(GetScreen(kHostPairingScreenName
));
513 void WizardController::ShowDeviceDisabledScreen() {
514 VLOG(1) << "Showing device disabled screen.";
515 SetStatusAreaVisible(true);
516 SetCurrentScreen(GetScreen(kDeviceDisabledScreenName
));
519 void WizardController::SkipToLoginForTesting(
520 const LoginScreenContext
& context
) {
521 VLOG(1) << "SkipToLoginForTesting.";
522 StartupUtils::MarkEulaAccepted();
523 PerformPostEulaActions();
524 OnDeviceDisabledChecked(false /* device_disabled */);
527 void WizardController::AddObserver(Observer
* observer
) {
528 observer_list_
.AddObserver(observer
);
531 void WizardController::RemoveObserver(Observer
* observer
) {
532 observer_list_
.RemoveObserver(observer
);
535 void WizardController::OnSessionStart() {
536 FOR_EACH_OBSERVER(Observer
, observer_list_
, OnSessionStart());
539 void WizardController::SkipUpdateEnrollAfterEula() {
540 skip_update_enroll_after_eula_
= true;
543 ///////////////////////////////////////////////////////////////////////////////
544 // WizardController, ExitHandlers:
545 void WizardController::OnHIDDetectionCompleted() {
546 // Check for tests configuration.
547 if (!StartupUtils::IsOobeCompleted())
551 void WizardController::OnNetworkConnected() {
552 if (is_official_build_
) {
553 if (!StartupUtils::IsEulaAccepted()) {
557 // 1. EULA was accepted, forced shutdown/reboot during update.
558 // 2. EULA was accepted, planned reboot after update.
559 // Make sure that device is up-to-date.
560 InitiateOOBEUpdate();
563 InitiateOOBEUpdate();
567 void WizardController::OnNetworkOffline() {
568 // TODO(dpolukhin): if(is_out_of_box_) we cannot work offline and
569 // should report some error message here and stay on the same screen.
570 ShowLoginScreen(LoginScreenContext());
573 void WizardController::OnConnectionFailed() {
574 // TODO(dpolukhin): show error message after login screen is displayed.
575 ShowLoginScreen(LoginScreenContext());
578 void WizardController::OnUpdateCompleted() {
579 const bool is_shark
= g_browser_process
->platform_part()
580 ->browser_policy_connector_chromeos()
581 ->GetDeviceCloudPolicyManager()
582 ->IsSharkRequisition();
584 ShowControllerPairingScreen();
586 ShowAutoEnrollmentCheckScreen();
590 void WizardController::OnEulaAccepted() {
591 time_eula_accepted_
= base::Time::Now();
592 StartupUtils::MarkEulaAccepted();
593 InitiateMetricsReportingChange(
594 usage_statistics_reporting_
,
595 base::Bind(&WizardController::InitiateMetricsReportingChangeCallback
,
596 weak_factory_
.GetWeakPtr()));
598 if (skip_update_enroll_after_eula_
) {
599 PerformPostEulaActions();
600 ShowAutoEnrollmentCheckScreen();
602 InitiateOOBEUpdate();
606 void WizardController::InitiateMetricsReportingChangeCallback(bool enabled
) {
607 CrosSettings::Get()->SetBoolean(kStatsReportingPref
, enabled
);
610 #if defined(GOOGLE_CHROME_BUILD)
611 if (!content::BrowserThread::PostBlockingPoolTask(
612 FROM_HERE
, base::Bind(&InitializeCrashReporter
))) {
613 LOG(ERROR
) << "Failed to start crash reporter initialization.";
618 void WizardController::OnUpdateErrorCheckingForUpdate() {
619 // TODO(nkostylev): Update should be required during OOBE.
620 // We do not want to block users from being able to proceed to the login
621 // screen if there is any error checking for an update.
622 // They could use "browse without sign-in" feature to set up the network to be
623 // able to perform the update later.
627 void WizardController::OnUpdateErrorUpdating() {
628 // If there was an error while getting or applying the update,
629 // return to network selection screen.
630 // TODO(nkostylev): Show message to the user explaining update error.
631 // TODO(nkostylev): Update should be required during OOBE.
632 // Temporary fix, need to migrate to new API. http://crosbug.com/4321
636 void WizardController::EnableUserImageScreenReturnToPreviousHack() {
637 user_image_screen_return_to_previous_hack_
= true;
640 void WizardController::OnUserImageSelected() {
641 if (user_image_screen_return_to_previous_hack_
) {
642 user_image_screen_return_to_previous_hack_
= false;
643 DCHECK(previous_screen_
);
644 if (previous_screen_
) {
645 SetCurrentScreen(previous_screen_
);
649 if (!time_oobe_started_
.is_null()) {
650 base::TimeDelta delta
= base::Time::Now() - time_oobe_started_
;
651 UMA_HISTOGRAM_CUSTOM_TIMES(
652 "OOBE.BootToSignInCompleted",
654 base::TimeDelta::FromMilliseconds(10),
655 base::TimeDelta::FromMinutes(30),
657 time_oobe_started_
= base::Time();
660 // Launch browser and delete login host controller.
661 BrowserThread::PostTask(
662 BrowserThread::UI
, FROM_HERE
,
663 base::Bind(&UserSessionManager::DoBrowserLaunch
,
664 base::Unretained(UserSessionManager::GetInstance()),
665 ProfileManager::GetActiveUserProfile(), host_
));
669 void WizardController::OnUserImageSkipped() {
670 OnUserImageSelected();
673 void WizardController::OnEnrollmentDone() {
674 // If the enrollment screen was shown as part of OOBE, OOBE is considered
675 // finished only after the enrollment screen is done. This is relevant for
676 // forced enrollment flows, e.g. for remora devices and forced re-enrollment.
677 if (prescribed_enrollment_config_
.should_enroll())
678 PerformOOBECompletedActions();
680 // TODO(mnissler): Unify the logic for auto-login for Public Sessions and
681 // Kiosk Apps and make this code cover both cases: http://crbug.com/234694.
682 if (KioskAppManager::Get()->IsAutoLaunchEnabled())
683 AutoLaunchKioskApp();
685 ShowLoginScreen(LoginScreenContext());
688 void WizardController::OnDeviceModificationCanceled() {
689 if (previous_screen_
) {
690 SetCurrentScreen(previous_screen_
);
692 ShowLoginScreen(LoginScreenContext());
696 void WizardController::OnKioskAutolaunchCanceled() {
697 ShowLoginScreen(LoginScreenContext());
700 void WizardController::OnKioskAutolaunchConfirmed() {
701 DCHECK(KioskAppManager::Get()->IsAutoLaunchEnabled());
702 AutoLaunchKioskApp();
705 void WizardController::OnKioskEnableCompleted() {
706 ShowLoginScreen(LoginScreenContext());
709 void WizardController::OnWrongHWIDWarningSkipped() {
710 if (previous_screen_
)
711 SetCurrentScreen(previous_screen_
);
713 ShowLoginScreen(LoginScreenContext());
716 void WizardController::OnTermsOfServiceDeclined() {
717 // If the user declines the Terms of Service, end the session and return to
719 DBusThreadManager::Get()->GetSessionManagerClient()->StopSession();
722 void WizardController::OnTermsOfServiceAccepted() {
723 // If the user accepts the Terms of Service, advance to the user image screen.
724 ShowUserImageScreen();
727 void WizardController::OnControllerPairingFinished() {
728 ShowAutoEnrollmentCheckScreen();
731 void WizardController::OnHostPairingFinished() {
732 InitiateOOBEUpdate();
735 void WizardController::OnAutoEnrollmentCheckCompleted() {
736 // Check whether the device is disabled. OnDeviceDisabledChecked() will be
737 // invoked when the result of this check is known. Until then, the current
738 // screen will remain visible and will continue showing a spinner.
739 g_browser_process
->platform_part()->device_disabling_manager()->
740 CheckWhetherDeviceDisabledDuringOOBE(base::Bind(
741 &WizardController::OnDeviceDisabledChecked
,
742 weak_factory_
.GetWeakPtr()));
745 void WizardController::OnDeviceDisabledChecked(bool device_disabled
) {
746 prescribed_enrollment_config_
= g_browser_process
->platform_part()
747 ->browser_policy_connector_chromeos()
748 ->GetPrescribedEnrollmentConfig();
749 if (device_disabled
) {
750 ShowDeviceDisabledScreen();
751 } else if (skip_update_enroll_after_eula_
||
752 prescribed_enrollment_config_
.should_enroll()) {
753 StartEnrollmentScreen();
755 PerformOOBECompletedActions();
756 ShowLoginScreen(LoginScreenContext());
760 void WizardController::InitiateOOBEUpdate() {
761 VLOG(1) << "InitiateOOBEUpdate";
762 PerformPostEulaActions();
763 SetCurrentScreenSmooth(GetScreen(kUpdateScreenName
), true);
764 UpdateScreen::Get(this)->StartNetworkCheck();
767 void WizardController::StartTimezoneResolve() {
768 geolocation_provider_
.reset(new SimpleGeolocationProvider(
769 g_browser_process
->system_request_context(),
770 SimpleGeolocationProvider::DefaultGeolocationProviderURL()));
771 geolocation_provider_
->RequestGeolocation(
772 base::TimeDelta::FromSeconds(kResolveTimeZoneTimeoutSeconds
),
773 base::Bind(&WizardController::OnLocationResolved
,
774 weak_factory_
.GetWeakPtr()));
777 void WizardController::PerformPostEulaActions() {
779 base::TimeDelta::FromMilliseconds(kDefaultNetworkRetryDelayMS
),
780 base::Bind(&WizardController::StartTimezoneResolve
,
781 weak_factory_
.GetWeakPtr()));
783 base::TimeDelta::FromMilliseconds(kDefaultNetworkRetryDelayMS
),
784 ServicesCustomizationDocument::GetInstance()
785 ->EnsureCustomizationAppliedClosure());
787 // Now that EULA has been accepted (for official builds), enable portal check.
788 // ChromiumOS builds would go though this code path too.
789 NetworkHandler::Get()->network_state_handler()->SetCheckPortalList(
790 NetworkStateHandler::kDefaultCheckPortalList
);
791 host_
->GetAutoEnrollmentController()->Start();
792 host_
->PrewarmAuthentication();
793 NetworkPortalDetector::Get()->Enable(true);
796 void WizardController::PerformOOBECompletedActions() {
797 UMA_HISTOGRAM_COUNTS_100(
798 "HIDDetection.TimesDialogShownPerOOBECompleted",
799 GetLocalState()->GetInteger(prefs::kTimesHIDDialogShown
));
800 GetLocalState()->ClearPref(prefs::kTimesHIDDialogShown
);
801 StartupUtils::MarkOobeCompleted();
803 // Restart to make the login page pick up the policy changes resulting from
804 // enrollment recovery.
805 // TODO(tnagel): Find a way to update login page without reboot.
806 if (prescribed_enrollment_config_
.mode
==
807 policy::EnrollmentConfig::MODE_RECOVERY
) {
808 chrome::AttemptRestart();
812 void WizardController::SetCurrentScreen(BaseScreen
* new_current
) {
813 SetCurrentScreenSmooth(new_current
, false);
816 void WizardController::ShowCurrentScreen() {
817 // ShowCurrentScreen may get called by smooth_show_timer_ even after
818 // flow has been switched to sign in screen (ExistingUserController).
822 // First remember how far have we reached so that we can resume if needed.
823 if (is_out_of_box_
&& IsResumableScreen(current_screen_
->GetName()))
824 StartupUtils::SaveOobePendingScreen(current_screen_
->GetName());
826 smooth_show_timer_
.Stop();
828 FOR_EACH_OBSERVER(Observer
, observer_list_
, OnScreenChanged(current_screen_
));
830 current_screen_
->Show();
833 void WizardController::SetCurrentScreenSmooth(BaseScreen
* new_current
,
834 bool use_smoothing
) {
835 if (current_screen_
== new_current
||
836 new_current
== NULL
||
837 oobe_display_
== NULL
) {
841 smooth_show_timer_
.Stop();
844 current_screen_
->Hide();
846 std::string screen_id
= new_current
->GetName();
847 if (IsOOBEStepToTrack(screen_id
))
848 screen_show_times_
[screen_id
] = base::Time::Now();
850 previous_screen_
= current_screen_
;
851 current_screen_
= new_current
;
854 smooth_show_timer_
.Start(
856 base::TimeDelta::FromMilliseconds(kShowDelayMs
),
858 &WizardController::ShowCurrentScreen
);
864 void WizardController::SetStatusAreaVisible(bool visible
) {
865 host_
->SetStatusAreaVisible(visible
);
868 void WizardController::OnHIDScreenNecessityCheck(bool screen_needed
) {
872 ShowHIDDetectionScreen();
877 void WizardController::AdvanceToScreen(const std::string
& screen_name
) {
878 if (screen_name
== kNetworkScreenName
) {
880 } else if (screen_name
== kLoginScreenName
) {
881 ShowLoginScreen(LoginScreenContext());
882 } else if (screen_name
== kUpdateScreenName
) {
883 InitiateOOBEUpdate();
884 } else if (screen_name
== kUserImageScreenName
) {
885 ShowUserImageScreen();
886 } else if (screen_name
== kEulaScreenName
) {
888 } else if (screen_name
== kResetScreenName
) {
890 } else if (screen_name
== kKioskEnableScreenName
) {
891 ShowKioskEnableScreen();
892 } else if (screen_name
== kKioskAutolaunchScreenName
) {
893 ShowKioskAutolaunchScreen();
894 } else if (screen_name
== kEnableDebuggingScreenName
) {
895 ShowEnableDebuggingScreen();
896 } else if (screen_name
== kEnrollmentScreenName
) {
897 ShowEnrollmentScreen();
898 } else if (screen_name
== kTermsOfServiceScreenName
) {
899 ShowTermsOfServiceScreen();
900 } else if (screen_name
== kWrongHWIDScreenName
) {
901 ShowWrongHWIDScreen();
902 } else if (screen_name
== kAutoEnrollmentCheckScreenName
) {
903 ShowAutoEnrollmentCheckScreen();
904 } else if (screen_name
== kSupervisedUserCreationScreenName
) {
905 ShowSupervisedUserCreationScreen();
906 } else if (screen_name
== kAppLaunchSplashScreenName
) {
907 AutoLaunchKioskApp();
908 } else if (screen_name
== kHIDDetectionScreenName
) {
909 ShowHIDDetectionScreen();
910 } else if (screen_name
== kControllerPairingScreenName
) {
911 ShowControllerPairingScreen();
912 } else if (screen_name
== kHostPairingScreenName
) {
913 ShowHostPairingScreen();
914 } else if (screen_name
== kDeviceDisabledScreenName
) {
915 ShowDeviceDisabledScreen();
916 } else if (screen_name
!= kTestNoScreenName
) {
917 if (is_out_of_box_
) {
918 time_oobe_started_
= base::Time::Now();
919 if (IsHostPairingOobe()) {
920 ShowHostPairingScreen();
921 } else if (CanShowHIDDetectionScreen()) {
922 hid_screen_
= GetScreen(kHIDDetectionScreenName
);
923 base::Callback
<void(bool)> on_check
= base::Bind(
924 &WizardController::OnHIDScreenNecessityCheck
,
925 weak_factory_
.GetWeakPtr());
926 oobe_display_
->GetHIDDetectionView()->CheckIsScreenRequired(on_check
);
931 ShowLoginScreen(LoginScreenContext());
936 ///////////////////////////////////////////////////////////////////////////////
937 // WizardController, BaseScreenDelegate overrides:
938 void WizardController::OnExit(BaseScreen
& /* screen */,
940 const ::login::ScreenContext
* /* context */) {
941 VLOG(1) << "Wizard screen exit code: " << exit_code
;
942 std::string previous_screen_id
= current_screen_
->GetName();
943 if (IsOOBEStepToTrack(previous_screen_id
)) {
944 RecordUMAHistogramForOOBEStepCompletionTime(
946 base::Time::Now() - screen_show_times_
[previous_screen_id
]);
949 case HID_DETECTION_COMPLETED
:
950 OnHIDDetectionCompleted();
952 case NETWORK_CONNECTED
:
953 OnNetworkConnected();
955 case CONNECTION_FAILED
:
956 OnConnectionFailed();
958 case UPDATE_INSTALLED
:
959 case UPDATE_NOUPDATE
:
962 case UPDATE_ERROR_CHECKING_FOR_UPDATE
:
963 OnUpdateErrorCheckingForUpdate();
965 case UPDATE_ERROR_UPDATING
:
966 OnUpdateErrorUpdating();
968 case USER_IMAGE_SELECTED
:
969 OnUserImageSelected();
977 case ENABLE_DEBUGGING_CANCELED
:
978 OnDeviceModificationCanceled();
980 case ENABLE_DEBUGGING_FINISHED
:
981 OnDeviceModificationCanceled();
983 case ENTERPRISE_AUTO_ENROLLMENT_CHECK_COMPLETED
:
984 OnAutoEnrollmentCheckCompleted();
986 case ENTERPRISE_ENROLLMENT_COMPLETED
:
989 case ENTERPRISE_ENROLLMENT_BACK
:
990 retry_auto_enrollment_check_
= true;
991 ShowAutoEnrollmentCheckScreen();
994 OnDeviceModificationCanceled();
996 case KIOSK_AUTOLAUNCH_CANCELED
:
997 OnKioskAutolaunchCanceled();
999 case KIOSK_AUTOLAUNCH_CONFIRMED
:
1000 OnKioskAutolaunchConfirmed();
1002 case KIOSK_ENABLE_COMPLETED
:
1003 OnKioskEnableCompleted();
1005 case TERMS_OF_SERVICE_DECLINED
:
1006 OnTermsOfServiceDeclined();
1008 case TERMS_OF_SERVICE_ACCEPTED
:
1009 OnTermsOfServiceAccepted();
1011 case WRONG_HWID_WARNING_SKIPPED
:
1012 OnWrongHWIDWarningSkipped();
1014 case CONTROLLER_PAIRING_FINISHED
:
1015 OnControllerPairingFinished();
1017 case HOST_PAIRING_FINISHED
:
1018 OnHostPairingFinished();
1025 void WizardController::ShowErrorScreen() {
1026 VLOG(1) << "Showing error screen.";
1027 SetCurrentScreen(GetScreen(kErrorScreenName
));
1030 void WizardController::HideErrorScreen(BaseScreen
* parent_screen
) {
1031 DCHECK(parent_screen
);
1032 VLOG(1) << "Hiding error screen.";
1033 SetCurrentScreen(parent_screen
);
1036 void WizardController::SetUsageStatisticsReporting(bool val
) {
1037 usage_statistics_reporting_
= val
;
1040 bool WizardController::GetUsageStatisticsReporting() const {
1041 return usage_statistics_reporting_
;
1044 void WizardController::SetHostConfiguration() {
1045 if (shark_controller_
) {
1046 NetworkScreen
* network_screen
= NetworkScreen::Get(this);
1047 shark_controller_
->SetHostConfiguration(
1048 true, // Eula must be accepted before we get this far.
1049 network_screen
->GetApplicationLocale(), network_screen
->GetTimezone(),
1050 GetUsageStatisticsReporting(), network_screen
->GetInputMethod());
1054 void WizardController::ConfigureHost(bool accepted_eula
,
1055 const std::string
& lang
,
1056 const std::string
& timezone
,
1058 const std::string
& keyboard_layout
) {
1059 VLOG(1) << "ConfigureHost locale=" << lang
<< ", timezone=" << timezone
1060 << ", keyboard_layout=" << keyboard_layout
;
1061 if (accepted_eula
) // Always true.
1062 StartupUtils::MarkEulaAccepted();
1063 SetUsageStatisticsReporting(send_reports
);
1065 NetworkScreen
* network_screen
= NetworkScreen::Get(this);
1066 network_screen
->SetApplicationLocale(lang
);
1067 network_screen
->SetTimezone(timezone
);
1068 network_screen
->SetInputMethod(keyboard_layout
);
1071 void WizardController::OnEnableDebuggingScreenRequested() {
1072 if (!login_screen_started())
1073 AdvanceToScreen(WizardController::kEnableDebuggingScreenName
);
1076 void WizardController::OnAccessibilityStatusChanged(
1077 const AccessibilityStatusEventDetails
& details
) {
1078 enum AccessibilityNotificationType type
= details
.notification_type
;
1079 if (type
== ACCESSIBILITY_MANAGER_SHUTDOWN
) {
1080 accessibility_subscription_
.reset();
1082 } else if (type
!= ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK
|| !details
.enabled
) {
1086 CrasAudioHandler
* cras
= CrasAudioHandler::Get();
1087 if (cras
->IsOutputMuted()) {
1088 cras
->SetOutputMute(false);
1089 cras
->SetOutputVolumePercent(kMinAudibleOutputVolumePercent
);
1090 } else if (cras
->GetOutputVolumePercent() < kMinAudibleOutputVolumePercent
) {
1091 cras
->SetOutputVolumePercent(kMinAudibleOutputVolumePercent
);
1095 void WizardController::AutoLaunchKioskApp() {
1096 KioskAppManager::App app_data
;
1097 std::string app_id
= KioskAppManager::Get()->GetAutoLaunchApp();
1098 CHECK(KioskAppManager::Get()->GetApp(app_id
, &app_data
));
1100 // Wait for the |CrosSettings| to become either trusted or permanently
1102 const CrosSettingsProvider::TrustedStatus status
=
1103 CrosSettings::Get()->PrepareTrustedValues(base::Bind(
1104 &WizardController::AutoLaunchKioskApp
,
1105 weak_factory_
.GetWeakPtr()));
1106 if (status
== CrosSettingsProvider::TEMPORARILY_UNTRUSTED
)
1109 if (status
== CrosSettingsProvider::PERMANENTLY_UNTRUSTED
) {
1110 // If the |cros_settings_| are permanently untrusted, show an error message
1111 // and refuse to auto-launch the kiosk app.
1112 GetErrorScreen()->SetUIState(NetworkError::UI_STATE_LOCAL_STATE_ERROR
);
1113 SetStatusAreaVisible(false);
1118 bool device_disabled
= false;
1119 CrosSettings::Get()->GetBoolean(kDeviceDisabled
, &device_disabled
);
1120 if (device_disabled
&& system::DeviceDisablingManager::
1121 HonorDeviceDisablingDuringNormalOperation()) {
1122 // If the device is disabled, bail out. A device disabled screen will be
1123 // shown by the DeviceDisablingManager.
1127 const bool diagnostic_mode
= false;
1128 const bool auto_launch
= true;
1129 host_
->StartAppLaunch(app_id
, diagnostic_mode
, auto_launch
);
1133 void WizardController::SetZeroDelays() {
1135 zero_delay_enabled_
= true;
1139 bool WizardController::IsZeroDelayEnabled() {
1140 return zero_delay_enabled_
;
1144 bool WizardController::IsOOBEStepToTrack(const std::string
& screen_id
) {
1145 return (screen_id
== kHIDDetectionScreenName
||
1146 screen_id
== kNetworkScreenName
||
1147 screen_id
== kUpdateScreenName
||
1148 screen_id
== kUserImageScreenName
||
1149 screen_id
== kEulaScreenName
||
1150 screen_id
== kLoginScreenName
||
1151 screen_id
== kWrongHWIDScreenName
);
1155 void WizardController::SkipPostLoginScreensForTesting() {
1156 skip_post_login_screens_
= true;
1159 void WizardController::OnLocalStateInitialized(bool /* succeeded */) {
1160 if (GetLocalState()->GetInitializationStatus() !=
1161 PrefService::INITIALIZATION_STATUS_ERROR
) {
1164 GetErrorScreen()->SetUIState(NetworkError::UI_STATE_LOCAL_STATE_ERROR
);
1165 SetStatusAreaVisible(false);
1169 PrefService
* WizardController::GetLocalState() {
1170 if (local_state_for_testing_
)
1171 return local_state_for_testing_
;
1172 return g_browser_process
->local_state();
1175 void WizardController::OnTimezoneResolved(
1176 scoped_ptr
<TimeZoneResponseData
> timezone
,
1177 bool server_error
) {
1178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI
));
1179 DCHECK(timezone
.get());
1180 // To check that "this" is not destroyed try to access some member
1181 // (timezone_provider_) in this case. Expect crash here.
1182 DCHECK(timezone_provider_
.get());
1184 timezone_resolved_
= true;
1185 base::ScopedClosureRunner
inform_test(on_timezone_resolved_for_testing_
);
1186 on_timezone_resolved_for_testing_
.Reset();
1188 VLOG(1) << "Resolved local timezone={" << timezone
->ToStringForDebug()
1191 if (timezone
->status
!= TimeZoneResponseData::OK
) {
1192 LOG(WARNING
) << "Resolve TimeZone: failed to resolve timezone.";
1196 policy::BrowserPolicyConnectorChromeOS
* connector
=
1197 g_browser_process
->platform_part()->browser_policy_connector_chromeos();
1198 if (connector
->IsEnterpriseManaged()) {
1199 std::string policy_timezone
;
1200 if (CrosSettings::Get()->GetString(kSystemTimezonePolicy
,
1201 &policy_timezone
) &&
1202 !policy_timezone
.empty()) {
1203 VLOG(1) << "Resolve TimeZone: TimeZone settings are overridden"
1204 << " by DevicePolicy.";
1209 if (!timezone
->timeZoneId
.empty()) {
1210 VLOG(1) << "Resolve TimeZone: setting timezone to '" << timezone
->timeZoneId
1213 system::TimezoneSettings::GetInstance()->SetTimezoneFromID(
1214 base::UTF8ToUTF16(timezone
->timeZoneId
));
1218 TimeZoneProvider
* WizardController::GetTimezoneProvider() {
1219 if (!timezone_provider_
) {
1220 timezone_provider_
.reset(
1221 new TimeZoneProvider(g_browser_process
->system_request_context(),
1222 DefaultTimezoneProviderURL()));
1224 return timezone_provider_
.get();
1227 void WizardController::OnLocationResolved(const Geoposition
& position
,
1229 const base::TimeDelta elapsed
) {
1230 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI
));
1232 const base::TimeDelta timeout
=
1233 base::TimeDelta::FromSeconds(kResolveTimeZoneTimeoutSeconds
);
1234 // Ignore invalid position.
1235 if (!position
.Valid())
1238 if (elapsed
>= timeout
) {
1239 LOG(WARNING
) << "Resolve TimeZone: got location after timeout ("
1240 << elapsed
.InSecondsF() << " seconds elapsed). Ignored.";
1244 // WizardController owns TimezoneProvider, so timezone request is silently
1245 // cancelled on destruction.
1246 GetTimezoneProvider()->RequestTimezone(
1249 base::Bind(&WizardController::OnTimezoneResolved
,
1250 base::Unretained(this)));
1253 bool WizardController::SetOnTimeZoneResolvedForTesting(
1254 const base::Closure
& callback
) {
1255 if (timezone_resolved_
)
1258 on_timezone_resolved_for_testing_
= callback
;
1262 bool WizardController::IsHostPairingOobe() const {
1263 return IsRemoraRequisition() &&
1264 (base::CommandLine::ForCurrentProcess()->HasSwitch(
1265 switches::kHostPairingOobe
) ||
1266 shark_controller_detected_
);
1269 void WizardController::MaybeStartListeningForSharkConnection() {
1270 if (!IsRemoraRequisition())
1273 // We shouldn't be here if we are running pairing OOBE already.
1274 DCHECK(!IsHostPairingOobe());
1276 if (!shark_connection_listener_
) {
1277 shark_connection_listener_
.reset(
1278 new pairing_chromeos::SharkConnectionListener(
1279 base::Bind(&WizardController::OnSharkConnected
,
1280 weak_factory_
.GetWeakPtr())));
1284 void WizardController::OnSharkConnected(
1285 scoped_ptr
<pairing_chromeos::HostPairingController
> remora_controller
) {
1286 VLOG(1) << "OnSharkConnected";
1287 remora_controller_
= remora_controller
.Pass();
1288 base::MessageLoop::current()->DeleteSoon(
1289 FROM_HERE
, shark_connection_listener_
.release());
1290 shark_controller_detected_
= true;
1291 ShowHostPairingScreen();
1294 void WizardController::StartEnrollmentScreen() {
1295 VLOG(1) << "Showing enrollment screen.";
1297 // Determine the effective enrollment configuration. If there is a valid
1298 // prescribed configuration, use that. If not, figure out which variant of
1299 // manual enrollment is taking place.
1300 policy::EnrollmentConfig effective_config
= prescribed_enrollment_config_
;
1301 if (!effective_config
.should_enroll()) {
1302 effective_config
.mode
=
1303 prescribed_enrollment_config_
.management_domain
.empty()
1304 ? policy::EnrollmentConfig::MODE_MANUAL
1305 : policy::EnrollmentConfig::MODE_MANUAL_REENROLLMENT
;
1308 EnrollmentScreen
* screen
= EnrollmentScreen::Get(this);
1309 screen
->SetParameters(effective_config
, shark_controller_
.get(),
1310 remora_controller_
.get());
1311 SetStatusAreaVisible(true);
1312 SetCurrentScreen(screen
);
1315 } // namespace chromeos