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

Side by Side Diff: chrome/browser/chromeos/login/ui/login_display_host_impl.cc

Issue 2566443005: cros: Replace WizardController string constants with OobeScreen values. (Closed)
Patch Set: Address comments Created 3 years, 11 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/ui/login_display_host_impl.h" 5 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/common/wallpaper/wallpaper_controller.h" 10 #include "ash/common/wallpaper/wallpaper_controller.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 165
166 base::Closure callback_; 166 base::Closure callback_;
167 167
168 DISALLOW_COPY_AND_ASSIGN(AnimationObserver); 168 DISALLOW_COPY_AND_ASSIGN(AnimationObserver);
169 }; 169 };
170 170
171 // ShowLoginWizard is split into two parts. This function is sometimes called 171 // ShowLoginWizard is split into two parts. This function is sometimes called
172 // from ShowLoginWizard(), and sometimes from OnLanguageSwitchedCallback() 172 // from ShowLoginWizard(), and sometimes from OnLanguageSwitchedCallback()
173 // (if locale was updated). 173 // (if locale was updated).
174 void ShowLoginWizardFinish( 174 void ShowLoginWizardFinish(
175 const std::string& first_screen_name, 175 chromeos::OobeScreen first_screen,
176 const chromeos::StartupCustomizationDocument* startup_manifest, 176 const chromeos::StartupCustomizationDocument* startup_manifest,
177 chromeos::LoginDisplayHost* display_host) { 177 chromeos::LoginDisplayHost* display_host) {
178 TRACE_EVENT0("chromeos", "ShowLoginWizard::ShowLoginWizardFinish"); 178 TRACE_EVENT0("chromeos", "ShowLoginWizard::ShowLoginWizardFinish");
179 179
180 display_host->StartWizard(first_screen_name); 180 display_host->StartWizard(first_screen);
181 181
182 // Set initial timezone if specified by customization. 182 // Set initial timezone if specified by customization.
183 const std::string timezone_name = startup_manifest->initial_timezone(); 183 const std::string timezone_name = startup_manifest->initial_timezone();
184 VLOG(1) << "Initial time zone: " << timezone_name; 184 VLOG(1) << "Initial time zone: " << timezone_name;
185 // Apply locale customizations only once to preserve whatever locale 185 // Apply locale customizations only once to preserve whatever locale
186 // user has changed to during OOBE. 186 // user has changed to during OOBE.
187 if (!timezone_name.empty()) { 187 if (!timezone_name.empty()) {
188 chromeos::system::TimezoneSettings::GetInstance()->SetTimezoneFromID( 188 chromeos::system::TimezoneSettings::GetInstance()->SetTimezoneFromID(
189 base::UTF8ToUTF16(timezone_name)); 189 base::UTF8ToUTF16(timezone_name));
190 } 190 }
191 } 191 }
192 192
193 struct ShowLoginWizardSwitchLanguageCallbackData { 193 struct ShowLoginWizardSwitchLanguageCallbackData {
194 explicit ShowLoginWizardSwitchLanguageCallbackData( 194 explicit ShowLoginWizardSwitchLanguageCallbackData(
195 const std::string& first_screen_name, 195 chromeos::OobeScreen first_screen,
196 const chromeos::StartupCustomizationDocument* startup_manifest, 196 const chromeos::StartupCustomizationDocument* startup_manifest,
197 chromeos::LoginDisplayHost* display_host) 197 chromeos::LoginDisplayHost* display_host)
198 : first_screen_name(first_screen_name), 198 : first_screen(first_screen),
199 startup_manifest(startup_manifest), 199 startup_manifest(startup_manifest),
200 display_host(display_host) {} 200 display_host(display_host) {}
201 201
202 const std::string first_screen_name; 202 const chromeos::OobeScreen first_screen;
203 const chromeos::StartupCustomizationDocument* const startup_manifest; 203 const chromeos::StartupCustomizationDocument* const startup_manifest;
204 chromeos::LoginDisplayHost* const display_host; 204 chromeos::LoginDisplayHost* const display_host;
205 205
206 // lock UI while resource bundle is being reloaded. 206 // lock UI while resource bundle is being reloaded.
207 chromeos::InputEventsBlocker events_blocker; 207 chromeos::InputEventsBlocker events_blocker;
208 }; 208 };
209 209
210 void OnLanguageSwitchedCallback( 210 void OnLanguageSwitchedCallback(
211 std::unique_ptr<ShowLoginWizardSwitchLanguageCallbackData> self, 211 std::unique_ptr<ShowLoginWizardSwitchLanguageCallbackData> self,
212 const chromeos::locale_util::LanguageSwitchResult& result) { 212 const chromeos::locale_util::LanguageSwitchResult& result) {
213 if (!result.success) 213 if (!result.success)
214 LOG(WARNING) << "Locale could not be found for '" << result.requested_locale 214 LOG(WARNING) << "Locale could not be found for '" << result.requested_locale
215 << "'"; 215 << "'";
216 216
217 ShowLoginWizardFinish( 217 ShowLoginWizardFinish(self->first_screen, self->startup_manifest,
218 self->first_screen_name, self->startup_manifest, self->display_host); 218 self->display_host);
219 } 219 }
220 220
221 void EnableSystemSoundsForAccessibility() { 221 void EnableSystemSoundsForAccessibility() {
222 chromeos::AccessibilityManager::Get()->EnableSystemSounds(true); 222 chromeos::AccessibilityManager::Get()->EnableSystemSounds(true);
223 } 223 }
224 224
225 // A login implementation of WidgetDelegate. 225 // A login implementation of WidgetDelegate.
226 class LoginWidgetDelegate : public views::WidgetDelegate { 226 class LoginWidgetDelegate : public views::WidgetDelegate {
227 public: 227 public:
228 explicit LoginWidgetDelegate(views::Widget* widget) : widget_(widget) { 228 explicit LoginWidgetDelegate(views::Widget* widget) : widget_(widget) {
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 else if (login_view_) 523 else if (login_view_)
524 login_view_->SetStatusAreaVisible(visible); 524 login_view_->SetStatusAreaVisible(visible);
525 } 525 }
526 526
527 AutoEnrollmentController* LoginDisplayHostImpl::GetAutoEnrollmentController() { 527 AutoEnrollmentController* LoginDisplayHostImpl::GetAutoEnrollmentController() {
528 if (!auto_enrollment_controller_) 528 if (!auto_enrollment_controller_)
529 auto_enrollment_controller_.reset(new AutoEnrollmentController()); 529 auto_enrollment_controller_.reset(new AutoEnrollmentController());
530 return auto_enrollment_controller_.get(); 530 return auto_enrollment_controller_.get();
531 } 531 }
532 532
533 void LoginDisplayHostImpl::StartWizard(const std::string& first_screen_name) { 533 void LoginDisplayHostImpl::StartWizard(OobeScreen first_screen) {
534 DisableKeyboardOverscroll(); 534 DisableKeyboardOverscroll();
535 535
536 startup_sound_honors_spoken_feedback_ = false; 536 startup_sound_honors_spoken_feedback_ = false;
537 TryToPlayStartupSound(); 537 TryToPlayStartupSound();
538 538
539 // Keep parameters to restore if renderer crashes. 539 // Keep parameters to restore if renderer crashes.
540 restore_path_ = RESTORE_WIZARD; 540 restore_path_ = RESTORE_WIZARD;
541 first_screen_name_ = first_screen_name; 541 first_screen_ = first_screen;
542 is_showing_login_ = false; 542 is_showing_login_ = false;
543 543
544 if (waiting_for_wallpaper_load_ && !initialize_webui_hidden_) { 544 if (waiting_for_wallpaper_load_ && !initialize_webui_hidden_) {
545 VLOG(1) << "Login WebUI >> wizard postponed"; 545 VLOG(1) << "Login WebUI >> wizard postponed";
546 return; 546 return;
547 } 547 }
548 VLOG(1) << "Login WebUI >> wizard"; 548 VLOG(1) << "Login WebUI >> wizard";
549 549
550 if (!login_window_) 550 if (!login_window_)
551 LoadURL(GURL(kOobeURL)); 551 LoadURL(GURL(kOobeURL));
552 552
553 DVLOG(1) << "Starting wizard, first_screen_name: " << first_screen_name; 553 DVLOG(1) << "Starting wizard, first_screen: "
554 << GetOobeScreenName(first_screen);
554 // Create and show the wizard. 555 // Create and show the wizard.
555 // Note, dtor of the old WizardController should be called before ctor of the 556 // Note, dtor of the old WizardController should be called before ctor of the
556 // new one, because "default_controller()" is updated there. So pure "reset()" 557 // new one, because "default_controller()" is updated there. So pure "reset()"
557 // is done before new controller creation. 558 // is done before new controller creation.
558 wizard_controller_.reset(); 559 wizard_controller_.reset();
559 wizard_controller_.reset(CreateWizardController()); 560 wizard_controller_.reset(CreateWizardController());
560 561
561 oobe_progress_bar_visible_ = !StartupUtils::IsDeviceRegistered(); 562 oobe_progress_bar_visible_ = !StartupUtils::IsDeviceRegistered();
562 SetOobeProgressBarVisible(oobe_progress_bar_visible_); 563 SetOobeProgressBarVisible(oobe_progress_bar_visible_);
563 wizard_controller_->Init(first_screen_name); 564 wizard_controller_->Init(first_screen);
564 } 565 }
565 566
566 WizardController* LoginDisplayHostImpl::GetWizardController() { 567 WizardController* LoginDisplayHostImpl::GetWizardController() {
567 return wizard_controller_.get(); 568 return wizard_controller_.get();
568 } 569 }
569 570
570 AppLaunchController* LoginDisplayHostImpl::GetAppLaunchController() { 571 AppLaunchController* LoginDisplayHostImpl::GetAppLaunchController() {
571 return app_launch_controller_.get(); 572 return app_launch_controller_.get();
572 } 573 }
573 574
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 // Wallpaper has finished loading before StartWizard/StartSignInScreen has 1088 // Wallpaper has finished loading before StartWizard/StartSignInScreen has
1088 // been called. In general this should not happen. 1089 // been called. In general this should not happen.
1089 // Let go through normal code path when one of those will be called. 1090 // Let go through normal code path when one of those will be called.
1090 if (restore_path_ == RESTORE_UNKNOWN) { 1091 if (restore_path_ == RESTORE_UNKNOWN) {
1091 NOTREACHED(); 1092 NOTREACHED();
1092 return; 1093 return;
1093 } 1094 }
1094 1095
1095 switch (restore_path_) { 1096 switch (restore_path_) {
1096 case RESTORE_WIZARD: 1097 case RESTORE_WIZARD:
1097 StartWizard(first_screen_name_); 1098 StartWizard(first_screen_);
1098 break; 1099 break;
1099 case RESTORE_SIGN_IN: 1100 case RESTORE_SIGN_IN:
1100 StartSignInScreen(LoginScreenContext()); 1101 StartSignInScreen(LoginScreenContext());
1101 break; 1102 break;
1102 case RESTORE_ADD_USER_INTO_SESSION: 1103 case RESTORE_ADD_USER_INTO_SESSION:
1103 StartUserAdding(completion_callback_); 1104 StartUserAdding(completion_callback_);
1104 break; 1105 break;
1105 default: 1106 default:
1106 NOTREACHED(); 1107 NOTREACHED();
1107 break; 1108 break;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 ->GetOobeUI() 1240 ->GetOobeUI()
1240 ->GetGaiaScreenActor() 1241 ->GetGaiaScreenActor()
1241 ->DisableRestrictiveProxyCheckForTest(); 1242 ->DisableRestrictiveProxyCheckForTest();
1242 } 1243 }
1243 1244
1244 //////////////////////////////////////////////////////////////////////////////// 1245 ////////////////////////////////////////////////////////////////////////////////
1245 // external 1246 // external
1246 1247
1247 // Declared in login_wizard.h so that others don't need to depend on our .h. 1248 // Declared in login_wizard.h so that others don't need to depend on our .h.
1248 // TODO(nkostylev): Split this into a smaller functions. 1249 // TODO(nkostylev): Split this into a smaller functions.
1249 void ShowLoginWizard(const std::string& first_screen_name) { 1250 void ShowLoginWizard(OobeScreen first_screen) {
1250 if (browser_shutdown::IsTryingToQuit()) 1251 if (browser_shutdown::IsTryingToQuit())
1251 return; 1252 return;
1252 1253
1253 VLOG(1) << "Showing OOBE screen: " << first_screen_name; 1254 VLOG(1) << "Showing OOBE screen: " << GetOobeScreenName(first_screen);
1254 1255
1255 chromeos::input_method::InputMethodManager* manager = 1256 chromeos::input_method::InputMethodManager* manager =
1256 chromeos::input_method::InputMethodManager::Get(); 1257 chromeos::input_method::InputMethodManager::Get();
1257 1258
1258 // Set up keyboards. For example, when |locale| is "en-US", enable US qwerty 1259 // Set up keyboards. For example, when |locale| is "en-US", enable US qwerty
1259 // and US dvorak keyboard layouts. 1260 // and US dvorak keyboard layouts.
1260 if (g_browser_process && g_browser_process->local_state()) { 1261 if (g_browser_process && g_browser_process->local_state()) {
1261 manager->GetActiveIMEState()->SetInputMethodLoginDefault(); 1262 manager->GetActiveIMEState()->SetInputMethodLoginDefault();
1262 1263
1263 PrefService* prefs = g_browser_process->local_state(); 1264 PrefService* prefs = g_browser_process->local_state();
(...skipping 11 matching lines...) Expand all
1275 gfx::Rect screen_bounds(chromeos::CalculateScreenBounds(gfx::Size())); 1276 gfx::Rect screen_bounds(chromeos::CalculateScreenBounds(gfx::Size()));
1276 1277
1277 session_manager::SessionManager::Get()->SetSessionState( 1278 session_manager::SessionManager::Get()->SetSessionState(
1278 StartupUtils::IsOobeCompleted() 1279 StartupUtils::IsOobeCompleted()
1279 ? session_manager::SessionState::LOGIN_PRIMARY 1280 ? session_manager::SessionState::LOGIN_PRIMARY
1280 : session_manager::SessionState::OOBE); 1281 : session_manager::SessionState::OOBE);
1281 1282
1282 LoginDisplayHostImpl* display_host = new LoginDisplayHostImpl(screen_bounds); 1283 LoginDisplayHostImpl* display_host = new LoginDisplayHostImpl(screen_bounds);
1283 1284
1284 bool show_app_launch_splash_screen = 1285 bool show_app_launch_splash_screen =
1285 (first_screen_name == WizardController::kAppLaunchSplashScreenName); 1286 (first_screen == OobeScreen::SCREEN_APP_LAUNCH_SPLASH);
1286 if (show_app_launch_splash_screen) { 1287 if (show_app_launch_splash_screen) {
1287 const std::string& auto_launch_app_id = 1288 const std::string& auto_launch_app_id =
1288 KioskAppManager::Get()->GetAutoLaunchApp(); 1289 KioskAppManager::Get()->GetAutoLaunchApp();
1289 const bool diagnostic_mode = false; 1290 const bool diagnostic_mode = false;
1290 const bool auto_launch = true; 1291 const bool auto_launch = true;
1291 display_host->StartAppLaunch(auto_launch_app_id, 1292 display_host->StartAppLaunch(auto_launch_app_id,
1292 diagnostic_mode, 1293 diagnostic_mode,
1293 auto_launch); 1294 auto_launch);
1294 return; 1295 return;
1295 } 1296 }
1296 1297
1297 // Check whether we need to execute OOBE flow. 1298 // Check whether we need to execute OOBE flow.
1298 const policy::EnrollmentConfig enrollment_config = 1299 const policy::EnrollmentConfig enrollment_config =
1299 g_browser_process->platform_part() 1300 g_browser_process->platform_part()
1300 ->browser_policy_connector_chromeos() 1301 ->browser_policy_connector_chromeos()
1301 ->GetPrescribedEnrollmentConfig(); 1302 ->GetPrescribedEnrollmentConfig();
1302 if (enrollment_config.should_enroll() && first_screen_name.empty()) { 1303 if (enrollment_config.should_enroll() &&
1304 first_screen == OobeScreen::SCREEN_UNKNOWN) {
1303 // Shows networks screen instead of enrollment screen to resume the 1305 // Shows networks screen instead of enrollment screen to resume the
1304 // interrupted auto start enrollment flow because enrollment screen does 1306 // interrupted auto start enrollment flow because enrollment screen does
1305 // not handle flaky network. See http://crbug.com/332572 1307 // not handle flaky network. See http://crbug.com/332572
1306 display_host->StartWizard(WizardController::kNetworkScreenName); 1308 display_host->StartWizard(OobeScreen::SCREEN_OOBE_NETWORK);
1307 return; 1309 return;
1308 } 1310 }
1309 1311
1310 if (StartupUtils::IsEulaAccepted()) { 1312 if (StartupUtils::IsEulaAccepted()) {
1311 DelayNetworkCall( 1313 DelayNetworkCall(
1312 base::TimeDelta::FromMilliseconds(kDefaultNetworkRetryDelayMS), 1314 base::TimeDelta::FromMilliseconds(kDefaultNetworkRetryDelayMS),
1313 ServicesCustomizationDocument::GetInstance() 1315 ServicesCustomizationDocument::GetInstance()
1314 ->EnsureCustomizationAppliedClosure()); 1316 ->EnsureCustomizationAppliedClosure());
1315 1317
1316 g_browser_process->platform_part() 1318 g_browser_process->platform_part()
1317 ->GetTimezoneResolverManager() 1319 ->GetTimezoneResolverManager()
1318 ->UpdateTimezoneResolver(); 1320 ->UpdateTimezoneResolver();
1319 } 1321 }
1320 1322
1321 bool show_login_screen = 1323 bool show_login_screen = (first_screen == OobeScreen::SCREEN_UNKNOWN &&
1322 (first_screen_name.empty() && StartupUtils::IsOobeCompleted()) || 1324 StartupUtils::IsOobeCompleted()) ||
1323 first_screen_name == WizardController::kLoginScreenName; 1325 first_screen == OobeScreen::SCREEN_SPECIAL_LOGIN;
1324 1326
1325 if (show_login_screen) { 1327 if (show_login_screen) {
1326 display_host->StartSignInScreen(LoginScreenContext()); 1328 display_host->StartSignInScreen(LoginScreenContext());
1327 return; 1329 return;
1328 } 1330 }
1329 1331
1330 // Load startup manifest. 1332 // Load startup manifest.
1331 const StartupCustomizationDocument* startup_manifest = 1333 const StartupCustomizationDocument* startup_manifest =
1332 StartupCustomizationDocument::GetInstance(); 1334 StartupCustomizationDocument::GetInstance();
1333 1335
1334 // Switch to initial locale if specified by customization 1336 // Switch to initial locale if specified by customization
1335 // and has not been set yet. We cannot call 1337 // and has not been set yet. We cannot call
1336 // LanguageSwitchMenu::SwitchLanguage here before 1338 // LanguageSwitchMenu::SwitchLanguage here before
1337 // EmitLoginPromptReady. 1339 // EmitLoginPromptReady.
1338 PrefService* prefs = g_browser_process->local_state(); 1340 PrefService* prefs = g_browser_process->local_state();
1339 const std::string& current_locale = 1341 const std::string& current_locale =
1340 prefs->GetString(prefs::kApplicationLocale); 1342 prefs->GetString(prefs::kApplicationLocale);
1341 VLOG(1) << "Current locale: " << current_locale; 1343 VLOG(1) << "Current locale: " << current_locale;
1342 const std::string& locale = startup_manifest->initial_locale_default(); 1344 const std::string& locale = startup_manifest->initial_locale_default();
1343 1345
1344 const std::string& layout = startup_manifest->keyboard_layout(); 1346 const std::string& layout = startup_manifest->keyboard_layout();
1345 VLOG(1) << "Initial locale: " << locale << "keyboard layout " << layout; 1347 VLOG(1) << "Initial locale: " << locale << "keyboard layout " << layout;
1346 1348
1347 // Determine keyboard layout from OEM customization (if provided) or 1349 // Determine keyboard layout from OEM customization (if provided) or
1348 // initial locale and save it in preferences. 1350 // initial locale and save it in preferences.
1349 manager->GetActiveIMEState()->SetInputMethodLoginDefaultFromVPD(locale, 1351 manager->GetActiveIMEState()->SetInputMethodLoginDefaultFromVPD(locale,
1350 layout); 1352 layout);
1351 1353
1352 if (!current_locale.empty() || locale.empty()) { 1354 if (!current_locale.empty() || locale.empty()) {
1353 ShowLoginWizardFinish(first_screen_name, startup_manifest, display_host); 1355 ShowLoginWizardFinish(first_screen, startup_manifest, display_host);
1354 return; 1356 return;
1355 } 1357 }
1356 1358
1357 // Save initial locale from VPD/customization manifest as current 1359 // Save initial locale from VPD/customization manifest as current
1358 // Chrome locale. Otherwise it will be lost if Chrome restarts. 1360 // Chrome locale. Otherwise it will be lost if Chrome restarts.
1359 // Don't need to schedule pref save because setting initial local 1361 // Don't need to schedule pref save because setting initial local
1360 // will enforce preference saving. 1362 // will enforce preference saving.
1361 prefs->SetString(prefs::kApplicationLocale, locale); 1363 prefs->SetString(prefs::kApplicationLocale, locale);
1362 StartupUtils::SetInitialLocale(locale); 1364 StartupUtils::SetInitialLocale(locale);
1363 1365
1364 std::unique_ptr<ShowLoginWizardSwitchLanguageCallbackData> data( 1366 std::unique_ptr<ShowLoginWizardSwitchLanguageCallbackData> data(
1365 new ShowLoginWizardSwitchLanguageCallbackData( 1367 new ShowLoginWizardSwitchLanguageCallbackData(
1366 first_screen_name, startup_manifest, display_host)); 1368 first_screen, startup_manifest, display_host));
1367 1369
1368 locale_util::SwitchLanguageCallback callback( 1370 locale_util::SwitchLanguageCallback callback(
1369 base::Bind(&OnLanguageSwitchedCallback, base::Passed(std::move(data)))); 1371 base::Bind(&OnLanguageSwitchedCallback, base::Passed(std::move(data))));
1370 1372
1371 // Load locale keyboards here. Hardware layout would be automatically enabled. 1373 // Load locale keyboards here. Hardware layout would be automatically enabled.
1372 locale_util::SwitchLanguage(locale, true, true /* login_layouts_only */, 1374 locale_util::SwitchLanguage(locale, true, true /* login_layouts_only */,
1373 callback, ProfileManager::GetActiveUserProfile()); 1375 callback, ProfileManager::GetActiveUserProfile());
1374 } 1376 }
1375 1377
1376 } // namespace chromeos 1378 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/ui/login_display_host_impl.h ('k') | chrome/browser/chromeos/login/ui/mock_login_display_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698