Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: chrome/browser/chromeos/login/wizard_controller.cc

Issue 2347703002: Limit the Material Design OOBE in a way that is less fragile. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/chromeos/login/wizard_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/login/wizard_controller.h" 5 #include "chrome/browser/chromeos/login/wizard_controller.h"
6 6
7 #include <signal.h> 7 #include <signal.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <sys/types.h> 10 #include <sys/types.h>
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 histogram->AddTime(step_time); 139 histogram->AddTime(step_time);
140 } 140 }
141 141
142 bool IsRemoraRequisition() { 142 bool IsRemoraRequisition() {
143 return g_browser_process->platform_part() 143 return g_browser_process->platform_part()
144 ->browser_policy_connector_chromeos() 144 ->browser_policy_connector_chromeos()
145 ->GetDeviceCloudPolicyManager() 145 ->GetDeviceCloudPolicyManager()
146 ->IsRemoraRequisition(); 146 ->IsRemoraRequisition();
147 } 147 }
148 148
149 bool IsSharkRequisition() {
150 return g_browser_process->platform_part()
151 ->browser_policy_connector_chromeos()
152 ->GetDeviceCloudPolicyManager()
153 ->IsSharkRequisition();
154 }
155
149 // Checks if a controller device ("Master") is detected during the bootstrapping 156 // Checks if a controller device ("Master") is detected during the bootstrapping
150 // or shark/remora setup process. 157 // or shark/remora setup process.
151 bool IsControllerDetected() { 158 bool IsControllerDetected() {
152 return g_browser_process->local_state()->GetBoolean( 159 return g_browser_process->local_state()->GetBoolean(
153 prefs::kOobeControllerDetected); 160 prefs::kOobeControllerDetected);
154 } 161 }
155 162
156 void SetControllerDetectedPref(bool value) { 163 void SetControllerDetectedPref(bool value) {
157 PrefService* prefs = g_browser_process->local_state(); 164 PrefService* prefs = g_browser_process->local_state();
158 prefs->SetBoolean(prefs::kOobeControllerDetected, value); 165 prefs->SetBoolean(prefs::kOobeControllerDetected, value);
(...skipping 18 matching lines...) Expand all
177 } 184 }
178 185
179 #if defined(GOOGLE_CHROME_BUILD) 186 #if defined(GOOGLE_CHROME_BUILD)
180 void InitializeCrashReporter() { 187 void InitializeCrashReporter() {
181 // The crash reporter initialization needs IO to complete. 188 // The crash reporter initialization needs IO to complete.
182 DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); 189 DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
183 breakpad::InitCrashReporter(std::string()); 190 breakpad::InitCrashReporter(std::string());
184 } 191 }
185 #endif 192 #endif
186 193
187 bool UseMDOobe() {
188 return !base::CommandLine::ForCurrentProcess()->HasSwitch(
189 chromeos::switches::kDisableMdOobe);
190 }
191
192 } // namespace 194 } // namespace
193 195
194 namespace chromeos { 196 namespace chromeos {
195 197
196 const char WizardController::kNetworkScreenName[] = "network"; 198 const char WizardController::kNetworkScreenName[] = "network";
197 const char WizardController::kLoginScreenName[] = "login"; 199 const char WizardController::kLoginScreenName[] = "login";
198 const char WizardController::kUpdateScreenName[] = "update"; 200 const char WizardController::kUpdateScreenName[] = "update";
199 const char WizardController::kUserImageScreenName[] = "image"; 201 const char WizardController::kUserImageScreenName[] = "image";
200 const char WizardController::kEulaScreenName[] = "eula"; 202 const char WizardController::kEulaScreenName[] = "eula";
201 const char WizardController::kEnableDebuggingScreenName[] = "debugging"; 203 const char WizardController::kEnableDebuggingScreenName[] = "debugging";
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 !IsControllerDetected() && 314 !IsControllerDetected() &&
313 (first_screen_name.empty() || 315 (first_screen_name.empty() ||
314 first_screen_name == WizardController::kTestNoScreenName)) { 316 first_screen_name == WizardController::kTestNoScreenName)) {
315 first_screen_name_ = screen_pref; 317 first_screen_name_ = screen_pref;
316 } 318 }
317 // We need to reset the kOobeControllerDetected pref to allow the user to have 319 // We need to reset the kOobeControllerDetected pref to allow the user to have
318 // the choice to setup the device manually. The pref will be set properly if 320 // the choice to setup the device manually. The pref will be set properly if
319 // an eligible controller is detected later. 321 // an eligible controller is detected later.
320 SetControllerDetectedPref(false); 322 SetControllerDetectedPref(false);
321 323
322 // If flag disappeared after restart, disable. 324 // Show Material Design unless explicitly disabled or for an untested UX,
323 if (!UseMDOobe()) 325 // or when resuming an OOBE that had it disabled or unset. We use an if/else
324 GetLocalState()->SetBoolean(prefs::kOobeMdMode, false); 326 // here to try and not set state when it is the default value so it can
327 // change and affect the OOBE again.
328 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
329 chromeos::switches::kDisableMdOobe))
Alexander Alekseev 2016/09/18 11:50:45 Please, add {} as we have more than one branch her
330 SetShowMdOobe(false);
331 else if ((screen_pref.empty() ||
332 GetLocalState()->HasPrefPath(prefs::kOobeMdMode)) ||
333 GetLocalState()->GetBoolean(prefs::kOobeMdMode))
334 SetShowMdOobe(true);
335
336 // TODO(drcrash): Remove this after testing (http://crbug.com/647411).
337 if (IsRemoraPairingOobe() || IsSharkRequisition() || IsRemoraRequisition()) {
338 SetShowMdOobe(false);
339 }
325 340
326 AdvanceToScreen(first_screen_name_); 341 AdvanceToScreen(first_screen_name_);
327 if (!IsMachineHWIDCorrect() && !StartupUtils::IsDeviceRegistered() && 342 if (!IsMachineHWIDCorrect() && !StartupUtils::IsDeviceRegistered() &&
328 first_screen_name_.empty()) 343 first_screen_name_.empty())
329 ShowWrongHWIDScreen(); 344 ShowWrongHWIDScreen();
330 } 345 }
331 346
332 ErrorScreen* WizardController::GetErrorScreen() { 347 ErrorScreen* WizardController::GetErrorScreen() {
333 return oobe_ui_->GetErrorScreen(); 348 return oobe_ui_->GetErrorScreen();
334 } 349 }
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 } 549 }
535 550
536 void WizardController::ShowSupervisedUserCreationScreen() { 551 void WizardController::ShowSupervisedUserCreationScreen() {
537 VLOG(1) << "Showing Locally managed user creation screen screen."; 552 VLOG(1) << "Showing Locally managed user creation screen screen.";
538 SetStatusAreaVisible(true); 553 SetStatusAreaVisible(true);
539 SetCurrentScreen(GetScreen(kSupervisedUserCreationScreenName)); 554 SetCurrentScreen(GetScreen(kSupervisedUserCreationScreenName));
540 } 555 }
541 556
542 void WizardController::ShowHIDDetectionScreen() { 557 void WizardController::ShowHIDDetectionScreen() {
543 VLOG(1) << "Showing HID discovery screen."; 558 VLOG(1) << "Showing HID discovery screen.";
559 // TODO(drcrash): Remove this after testing (http://crbug.com/647411).
560 SetShowMdOobe(false); // Disable the MD OOBE from there on.
544 SetStatusAreaVisible(true); 561 SetStatusAreaVisible(true);
545 SetCurrentScreen(GetScreen(kHIDDetectionScreenName)); 562 SetCurrentScreen(GetScreen(kHIDDetectionScreenName));
546 MaybeStartListeningForSharkConnection(); 563 MaybeStartListeningForSharkConnection();
547 } 564 }
548 565
549 void WizardController::ShowControllerPairingScreen() { 566 void WizardController::ShowControllerPairingScreen() {
550 VLOG(1) << "Showing controller pairing screen."; 567 VLOG(1) << "Showing controller pairing screen.";
551 SetStatusAreaVisible(false); 568 SetStatusAreaVisible(false);
552 SetCurrentScreen(GetScreen(kControllerPairingScreenName)); 569 SetCurrentScreen(GetScreen(kControllerPairingScreenName));
553 } 570 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 // should report some error message here and stay on the same screen. 639 // should report some error message here and stay on the same screen.
623 ShowLoginScreen(LoginScreenContext()); 640 ShowLoginScreen(LoginScreenContext());
624 } 641 }
625 642
626 void WizardController::OnConnectionFailed() { 643 void WizardController::OnConnectionFailed() {
627 // TODO(dpolukhin): show error message after login screen is displayed. 644 // TODO(dpolukhin): show error message after login screen is displayed.
628 ShowLoginScreen(LoginScreenContext()); 645 ShowLoginScreen(LoginScreenContext());
629 } 646 }
630 647
631 void WizardController::OnUpdateCompleted() { 648 void WizardController::OnUpdateCompleted() {
632 const bool is_shark = g_browser_process->platform_part() 649 if (IsSharkRequisition() || IsBootstrappingMaster()) {
633 ->browser_policy_connector_chromeos()
634 ->GetDeviceCloudPolicyManager()
635 ->IsSharkRequisition();
636 if (is_shark || IsBootstrappingMaster()) {
637 ShowControllerPairingScreen(); 650 ShowControllerPairingScreen();
638 } else if (IsControllerDetected()) { 651 } else if (IsControllerDetected()) {
639 ShowHostPairingScreen(); 652 ShowHostPairingScreen();
640 } else { 653 } else {
641 ShowAutoEnrollmentCheckScreen(); 654 ShowAutoEnrollmentCheckScreen();
642 } 655 }
643 } 656 }
644 657
645 void WizardController::OnEulaAccepted() { 658 void WizardController::OnEulaAccepted() {
646 time_eula_accepted_ = base::Time::Now(); 659 time_eula_accepted_ = base::Time::Now();
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 &WizardController::ShowCurrentScreen); 932 &WizardController::ShowCurrentScreen);
920 } else { 933 } else {
921 ShowCurrentScreen(); 934 ShowCurrentScreen();
922 } 935 }
923 } 936 }
924 937
925 void WizardController::SetStatusAreaVisible(bool visible) { 938 void WizardController::SetStatusAreaVisible(bool visible) {
926 host_->SetStatusAreaVisible(visible); 939 host_->SetStatusAreaVisible(visible);
927 } 940 }
928 941
942 void WizardController::SetShowMdOobe(bool show) {
943 GetLocalState()->SetBoolean(prefs::kOobeMdMode, show);
944 }
945
929 void WizardController::OnHIDScreenNecessityCheck(bool screen_needed) { 946 void WizardController::OnHIDScreenNecessityCheck(bool screen_needed) {
930 if (!oobe_ui_) 947 if (!oobe_ui_)
931 return; 948 return;
932 949
933 if (screen_needed) { 950 if (screen_needed) {
934 ShowHIDDetectionScreen(); 951 ShowHIDDetectionScreen();
935 } else { 952 } else {
936 if (UseMDOobe())
937 GetLocalState()->SetBoolean(prefs::kOobeMdMode, true);
938
939 ShowNetworkScreen(); 953 ShowNetworkScreen();
940 } 954 }
941 } 955 }
942 956
943 void WizardController::AdvanceToScreen(const std::string& screen_name) { 957 void WizardController::AdvanceToScreen(const std::string& screen_name) {
944 if (screen_name == kNetworkScreenName) { 958 if (screen_name == kNetworkScreenName) {
945 ShowNetworkScreen(); 959 ShowNetworkScreen();
946 } else if (screen_name == kLoginScreenName) { 960 } else if (screen_name == kLoginScreenName) {
947 ShowLoginScreen(LoginScreenContext()); 961 ShowLoginScreen(LoginScreenContext());
948 } else if (screen_name == kUpdateScreenName) { 962 } else if (screen_name == kUpdateScreenName) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 time_oobe_started_ = base::Time::Now(); 998 time_oobe_started_ = base::Time::Now();
985 if (IsRemoraPairingOobe() || IsControllerDetected()) { 999 if (IsRemoraPairingOobe() || IsControllerDetected()) {
986 ShowHostPairingScreen(); 1000 ShowHostPairingScreen();
987 } else if (CanShowHIDDetectionScreen()) { 1001 } else if (CanShowHIDDetectionScreen()) {
988 hid_screen_ = GetScreen(kHIDDetectionScreenName); 1002 hid_screen_ = GetScreen(kHIDDetectionScreenName);
989 base::Callback<void(bool)> on_check = base::Bind( 1003 base::Callback<void(bool)> on_check = base::Bind(
990 &WizardController::OnHIDScreenNecessityCheck, 1004 &WizardController::OnHIDScreenNecessityCheck,
991 weak_factory_.GetWeakPtr()); 1005 weak_factory_.GetWeakPtr());
992 oobe_ui_->GetHIDDetectionView()->CheckIsScreenRequired(on_check); 1006 oobe_ui_->GetHIDDetectionView()->CheckIsScreenRequired(on_check);
993 } else { 1007 } else {
994 if (UseMDOobe())
995 GetLocalState()->SetBoolean(prefs::kOobeMdMode, true);
996
997 ShowNetworkScreen(); 1008 ShowNetworkScreen();
998 } 1009 }
999 } else { 1010 } else {
1000 ShowLoginScreen(LoginScreenContext()); 1011 ShowLoginScreen(LoginScreenContext());
1001 } 1012 }
1002 } 1013 }
1003 } 1014 }
1004 1015
1005 /////////////////////////////////////////////////////////////////////////////// 1016 ///////////////////////////////////////////////////////////////////////////////
1006 // WizardController, BaseScreenDelegate overrides: 1017 // WizardController, BaseScreenDelegate overrides:
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
1421 : policy::EnrollmentConfig::MODE_MANUAL_REENROLLMENT; 1432 : policy::EnrollmentConfig::MODE_MANUAL_REENROLLMENT;
1422 } 1433 }
1423 1434
1424 EnrollmentScreen* screen = EnrollmentScreen::Get(this); 1435 EnrollmentScreen* screen = EnrollmentScreen::Get(this);
1425 screen->SetParameters(effective_config, shark_controller_.get()); 1436 screen->SetParameters(effective_config, shark_controller_.get());
1426 SetStatusAreaVisible(true); 1437 SetStatusAreaVisible(true);
1427 SetCurrentScreen(screen); 1438 SetCurrentScreen(screen);
1428 } 1439 }
1429 1440
1430 } // namespace chromeos 1441 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/wizard_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698