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

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

Issue 2935623003: Merge "cros: Move wallpaper after login screen is gone" (Closed)
Patch Set: Created 3 years, 6 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/public/cpp/shell_window_ids.h" 10 #include "ash/public/cpp/shell_window_ids.h"
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 void DisableKeyboardOverscroll() { 285 void DisableKeyboardOverscroll() {
286 keyboard::SetKeyboardOverscrollOverride( 286 keyboard::SetKeyboardOverscrollOverride(
287 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_DISABLED); 287 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_DISABLED);
288 } 288 }
289 289
290 void ResetKeyboardOverscrollOverride() { 290 void ResetKeyboardOverscrollOverride() {
291 keyboard::SetKeyboardOverscrollOverride( 291 keyboard::SetKeyboardOverscrollOverride(
292 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_NONE); 292 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_NONE);
293 } 293 }
294 294
295 void ScheduleCompletionCallbacks(std::vector<base::OnceClosure>&& callbacks) {
296 for (auto& callback : callbacks) {
297 if (callback.is_null())
298 continue;
299
300 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
301 std::move(callback));
302 }
303 }
304
295 } // namespace 305 } // namespace
296 306
297 namespace chromeos { 307 namespace chromeos {
298 308
299 // static 309 // static
300 const int LoginDisplayHostImpl::kShowLoginWebUIid = 0x1111; 310 const int LoginDisplayHostImpl::kShowLoginWebUIid = 0x1111;
301 311
302 // A class to handle special menu key for keyboard driven OOBE. 312 // A class to handle special menu key for keyboard driven OOBE.
303 class LoginDisplayHostImpl::KeyboardDrivenOobeKeyHandler 313 class LoginDisplayHostImpl::KeyboardDrivenOobeKeyHandler
304 : public ui::EventHandler { 314 : public ui::EventHandler {
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 // MultiUserWindowManager instance might be null if no user is logged in - or 524 // MultiUserWindowManager instance might be null if no user is logged in - or
515 // in a unit test. 525 // in a unit test.
516 if (window_manager) 526 if (window_manager)
517 window_manager->RemoveObserver(this); 527 window_manager->RemoveObserver(this);
518 528
519 ResetKeyboardOverscrollOverride(); 529 ResetKeyboardOverscrollOverride();
520 530
521 views::FocusManager::set_arrow_key_traversal_enabled(false); 531 views::FocusManager::set_arrow_key_traversal_enabled(false);
522 ResetLoginWindowAndView(); 532 ResetLoginWindowAndView();
523 533
534 ScheduleCompletionCallbacks(std::move(completion_callbacks_));
535
524 keep_alive_.reset(); 536 keep_alive_.reset();
525 537
526 default_host_ = nullptr; 538 default_host_ = nullptr;
527 // TODO(tengs): This should be refactored. See crbug.com/314934. 539 // TODO(tengs): This should be refactored. See crbug.com/314934.
528 if (user_manager::UserManager::Get()->IsCurrentUserNew()) { 540 if (user_manager::UserManager::Get()->IsCurrentUserNew()) {
529 // DriveOptInController will delete itself when finished. 541 // DriveOptInController will delete itself when finished.
530 (new DriveFirstRunController( 542 (new DriveFirstRunController(
531 ProfileManager::GetActiveUserProfile()))->EnableOfflineMode(); 543 ProfileManager::GetActiveUserProfile()))->EnableOfflineMode();
532 } 544 }
533 } 545 }
(...skipping 13 matching lines...) Expand all
547 } 559 }
548 560
549 WebUILoginView* LoginDisplayHostImpl::GetWebUILoginView() const { 561 WebUILoginView* LoginDisplayHostImpl::GetWebUILoginView() const {
550 return login_view_; 562 return login_view_;
551 } 563 }
552 564
553 void LoginDisplayHostImpl::BeforeSessionStart() { 565 void LoginDisplayHostImpl::BeforeSessionStart() {
554 session_starting_ = true; 566 session_starting_ = true;
555 } 567 }
556 568
557 void LoginDisplayHostImpl::Finalize() { 569 void LoginDisplayHostImpl::Finalize(base::OnceClosure completion_callback) {
558 DVLOG(1) << "Session starting"; 570 DVLOG(1) << "Finalizing LoginDisplayHost. User session starting";
571
559 // When adding another user into the session, we defer the wallpaper's 572 // When adding another user into the session, we defer the wallpaper's
560 // animation in order to prevent the flashing of the previous user's windows. 573 // animation in order to prevent the flashing of the previous user's windows.
561 // See crbug.com/541864. 574 // See crbug.com/541864.
562 if (ash::ShellPort::HasInstance() && 575 if (ash::ShellPort::HasInstance() &&
563 finalize_animation_type_ != ANIMATION_ADD_USER) { 576 finalize_animation_type_ != ANIMATION_ADD_USER) {
564 ash::Shell::Get()->wallpaper_controller()->MoveToUnlockedContainer(); 577 ash::Shell::Get()->wallpaper_controller()->MoveToUnlockedContainer();
565 } 578 }
566 579
580 completion_callbacks_.push_back(std::move(completion_callback));
581
567 switch (finalize_animation_type_) { 582 switch (finalize_animation_type_) {
568 case ANIMATION_NONE: 583 case ANIMATION_NONE:
569 ShutdownDisplayHost(false); 584 ShutdownDisplayHost(false);
570 break; 585 break;
571 case ANIMATION_WORKSPACE: 586 case ANIMATION_WORKSPACE:
572 if (ash::Shell::HasInstance()) 587 if (ash::Shell::HasInstance())
573 ScheduleWorkspaceAnimation(); 588 ScheduleWorkspaceAnimation();
574 589
575 ShutdownDisplayHost(false); 590 ShutdownDisplayHost(false);
576 break; 591 break;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 664
650 WizardController* LoginDisplayHostImpl::GetWizardController() { 665 WizardController* LoginDisplayHostImpl::GetWizardController() {
651 return wizard_controller_.get(); 666 return wizard_controller_.get();
652 } 667 }
653 668
654 AppLaunchController* LoginDisplayHostImpl::GetAppLaunchController() { 669 AppLaunchController* LoginDisplayHostImpl::GetAppLaunchController() {
655 return app_launch_controller_.get(); 670 return app_launch_controller_.get();
656 } 671 }
657 672
658 void LoginDisplayHostImpl::StartUserAdding( 673 void LoginDisplayHostImpl::StartUserAdding(
659 const base::Closure& completion_callback) { 674 base::OnceClosure completion_callback) {
660 DisableKeyboardOverscroll(); 675 DisableKeyboardOverscroll();
661 676
662 restore_path_ = RESTORE_ADD_USER_INTO_SESSION; 677 restore_path_ = RESTORE_ADD_USER_INTO_SESSION;
663 completion_callback_ = completion_callback; 678 completion_callbacks_.push_back(std::move(completion_callback));
664 // Animation is not supported in Mash 679 // Animation is not supported in Mash
665 if (!ash_util::IsRunningInMash()) 680 if (!ash_util::IsRunningInMash())
666 finalize_animation_type_ = ANIMATION_ADD_USER; 681 finalize_animation_type_ = ANIMATION_ADD_USER;
667 // Observe the user switch animation and defer the deletion of itself only 682 // Observe the user switch animation and defer the deletion of itself only
668 // after the animation is finished. 683 // after the animation is finished.
669 chrome::MultiUserWindowManager* window_manager = 684 chrome::MultiUserWindowManager* window_manager =
670 chrome::MultiUserWindowManager::GetInstance(); 685 chrome::MultiUserWindowManager::GetInstance();
671 // MultiUserWindowManager instance might be nullptr in a unit test. 686 // MultiUserWindowManager instance might be nullptr in a unit test.
672 if (window_manager) 687 if (window_manager)
673 window_manager->AddObserver(this); 688 window_manager->AddObserver(this);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 webui_login_display_, 722 webui_login_display_,
708 webui_login_display_); 723 webui_login_display_);
709 } 724 }
710 725
711 void LoginDisplayHostImpl::CancelUserAdding() { 726 void LoginDisplayHostImpl::CancelUserAdding() {
712 // ANIMATION_ADD_USER observes UserSwitchAnimatorChromeOS to shutdown the 727 // ANIMATION_ADD_USER observes UserSwitchAnimatorChromeOS to shutdown the
713 // login display host. However, the animation does not run when user adding is 728 // login display host. However, the animation does not run when user adding is
714 // canceled. Changing to ANIMATION_NONE so that Finalize() shuts down the host 729 // canceled. Changing to ANIMATION_NONE so that Finalize() shuts down the host
715 // immediately. 730 // immediately.
716 finalize_animation_type_ = ANIMATION_NONE; 731 finalize_animation_type_ = ANIMATION_NONE;
717 Finalize(); 732 Finalize(base::OnceClosure());
718 } 733 }
719 734
720 void LoginDisplayHostImpl::StartSignInScreen( 735 void LoginDisplayHostImpl::StartSignInScreen(
721 const LoginScreenContext& context) { 736 const LoginScreenContext& context) {
722 DisableKeyboardOverscroll(); 737 DisableKeyboardOverscroll();
723 738
724 startup_sound_honors_spoken_feedback_ = true; 739 startup_sound_honors_spoken_feedback_ = true;
725 TryToPlayStartupSound(); 740 TryToPlayStartupSound();
726 741
727 restore_path_ = RESTORE_SIGN_IN; 742 restore_path_ = RESTORE_SIGN_IN;
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 void LoginDisplayHostImpl::ShutdownDisplayHost(bool post_quit_task) { 1121 void LoginDisplayHostImpl::ShutdownDisplayHost(bool post_quit_task) {
1107 if (shutting_down_) 1122 if (shutting_down_)
1108 return; 1123 return;
1109 1124
1110 shutting_down_ = true; 1125 shutting_down_ = true;
1111 registrar_.RemoveAll(); 1126 registrar_.RemoveAll();
1112 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); 1127 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this);
1113 if (post_quit_task) 1128 if (post_quit_task)
1114 base::MessageLoop::current()->QuitWhenIdle(); 1129 base::MessageLoop::current()->QuitWhenIdle();
1115 1130
1116 if (!completion_callback_.is_null())
1117 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
1118 completion_callback_);
1119
1120 if (ash::Shell::HasInstance() && 1131 if (ash::Shell::HasInstance() &&
1121 finalize_animation_type_ == ANIMATION_ADD_USER) { 1132 finalize_animation_type_ == ANIMATION_ADD_USER) {
1122 if (!ash_util::IsRunningInMash()) { 1133 if (!ash_util::IsRunningInMash()) {
1123 ash::Shell::Get()->wallpaper_controller()->MoveToUnlockedContainer(); 1134 ash::Shell::Get()->wallpaper_controller()->MoveToUnlockedContainer();
1124 } else { 1135 } else {
1125 NOTIMPLEMENTED(); 1136 NOTIMPLEMENTED();
1126 } 1137 }
1127 } 1138 }
1128 } 1139 }
1129 1140
1130 void LoginDisplayHostImpl::ScheduleWorkspaceAnimation() { 1141 void LoginDisplayHostImpl::ScheduleWorkspaceAnimation() {
1131 if (ash_util::IsRunningInMash()) { 1142 if (ash_util::IsRunningInMash()) {
1132 NOTIMPLEMENTED(); 1143 NOTIMPLEMENTED();
1133 return; 1144 return;
1134 } 1145 }
1135 if (ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(),
1136 ash::kShellWindowId_WallpaperContainer)
1137 ->children()
1138 .empty()) {
1139 // If there is no wallpaper window, don't perform any animation on the
1140 // default and wallpaper layer because there is nothing behind it.
1141 return;
1142 }
1143 1146
1144 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 1147 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
1145 switches::kDisableLoginAnimations)) 1148 switches::kDisableLoginAnimations)) {
1146 ash::Shell::Get()->DoInitialWorkspaceAnimation(); 1149 ash::Shell::Get()->DoInitialWorkspaceAnimation();
1150 }
1147 } 1151 }
1148 1152
1149 void LoginDisplayHostImpl::ScheduleFadeOutAnimation(int animation_speed_ms) { 1153 void LoginDisplayHostImpl::ScheduleFadeOutAnimation(int animation_speed_ms) {
1150 // login window might have been closed by OnBrowserCreated() at this moment. 1154 // login window might have been closed by OnBrowserCreated() at this moment.
1151 // This may happen when adding another user into the session, and a browser 1155 // This may happen when adding another user into the session, and a browser
1152 // is created before session start, which triggers the close of the login 1156 // is created before session start, which triggers the close of the login
1153 // window. In this case, we should shut down the display host directly. 1157 // window. In this case, we should shut down the display host directly.
1154 if (!login_window_) { 1158 if (!login_window_) {
1155 ShutdownDisplayHost(false); 1159 ShutdownDisplayHost(false);
1156 return; 1160 return;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 } 1208 }
1205 1209
1206 switch (restore_path_) { 1210 switch (restore_path_) {
1207 case RESTORE_WIZARD: 1211 case RESTORE_WIZARD:
1208 StartWizard(first_screen_); 1212 StartWizard(first_screen_);
1209 break; 1213 break;
1210 case RESTORE_SIGN_IN: 1214 case RESTORE_SIGN_IN:
1211 StartSignInScreen(LoginScreenContext()); 1215 StartSignInScreen(LoginScreenContext());
1212 break; 1216 break;
1213 case RESTORE_ADD_USER_INTO_SESSION: 1217 case RESTORE_ADD_USER_INTO_SESSION:
1214 StartUserAdding(completion_callback_); 1218 StartUserAdding(base::OnceClosure());
1215 break; 1219 break;
1216 default: 1220 default:
1217 NOTREACHED(); 1221 NOTREACHED();
1218 break; 1222 break;
1219 } 1223 }
1220 } 1224 }
1221 1225
1222 void LoginDisplayHostImpl::InitLoginWindowAndView() { 1226 void LoginDisplayHostImpl::InitLoginWindowAndView() {
1223 if (login_window_) 1227 if (login_window_)
1224 return; 1228 return;
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 // Chrome locale. Otherwise it will be lost if Chrome restarts. 1488 // Chrome locale. Otherwise it will be lost if Chrome restarts.
1485 // Don't need to schedule pref save because setting initial local 1489 // Don't need to schedule pref save because setting initial local
1486 // will enforce preference saving. 1490 // will enforce preference saving.
1487 prefs->SetString(prefs::kApplicationLocale, locale); 1491 prefs->SetString(prefs::kApplicationLocale, locale);
1488 StartupUtils::SetInitialLocale(locale); 1492 StartupUtils::SetInitialLocale(locale);
1489 1493
1490 TriggerShowLoginWizardFinish(locale, std::move(data)); 1494 TriggerShowLoginWizardFinish(locale, std::move(data));
1491 } 1495 }
1492 1496
1493 } // namespace chromeos 1497 } // 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