OLD | NEW |
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/login_display_host_impl.h" | 5 #include "chrome/browser/chromeos/login/login_display_host_impl.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/desktop_background/desktop_background_controller.h" | 9 #include "ash/desktop_background/desktop_background_controller.h" |
10 #include "ash/desktop_background/user_wallpaper_delegate.h" | 10 #include "ash/desktop_background/user_wallpaper_delegate.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 #include "ui/compositor/layer_animator.h" | 75 #include "ui/compositor/layer_animator.h" |
76 #include "ui/compositor/scoped_layer_animation_settings.h" | 76 #include "ui/compositor/scoped_layer_animation_settings.h" |
77 #include "ui/gfx/rect.h" | 77 #include "ui/gfx/rect.h" |
78 #include "ui/gfx/transform.h" | 78 #include "ui/gfx/transform.h" |
79 #include "ui/views/focus/focus_manager.h" | 79 #include "ui/views/focus/focus_manager.h" |
80 #include "ui/views/widget/widget.h" | 80 #include "ui/views/widget/widget.h" |
81 | 81 |
82 namespace { | 82 namespace { |
83 | 83 |
84 // URL which corresponds to the login WebUI. | 84 // URL which corresponds to the login WebUI. |
85 const char kLoginURL[] = "chrome://oobe/login"; | 85 const char kLoginURL[] = "chrome://oobe/login#login"; |
86 | 86 |
87 // URL which corresponds to the OOBE WebUI. | 87 // URL which corresponds to the OOBE WebUI. |
88 const char kOobeURL[] = "chrome://oobe"; | 88 const char kOobeURL[] = "chrome://oobe#login"; |
| 89 |
| 90 // URL which corresponds to the user adding WebUI. |
| 91 const char kUserAddingURL[] = "chrome://oobe/login#user-adding"; |
89 | 92 |
90 // Duration of sign-in transition animation. | 93 // Duration of sign-in transition animation. |
91 const int kLoginFadeoutTransitionDurationMs = 700; | 94 const int kLoginFadeoutTransitionDurationMs = 700; |
92 | 95 |
93 // Number of times we try to reload OOBE/login WebUI if it crashes. | 96 // Number of times we try to reload OOBE/login WebUI if it crashes. |
94 const int kCrashCountLimit = 5; | 97 const int kCrashCountLimit = 5; |
95 | 98 |
96 // Whether to enable tnitializing WebUI in hidden state (see | 99 // Whether to enable tnitializing WebUI in hidden state (see |
97 // |initialize_webui_hidden_|) by default. | 100 // |initialize_webui_hidden_|) by default. |
98 const bool kHiddenWebUIInitializationDefault = true; | 101 const bool kHiddenWebUIInitializationDefault = true; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 } | 297 } |
295 | 298 |
296 views::Widget* LoginDisplayHostImpl::GetWidget() const { | 299 views::Widget* LoginDisplayHostImpl::GetWidget() const { |
297 return login_window_; | 300 return login_window_; |
298 } | 301 } |
299 | 302 |
300 void LoginDisplayHostImpl::BeforeSessionStart() { | 303 void LoginDisplayHostImpl::BeforeSessionStart() { |
301 session_starting_ = true; | 304 session_starting_ = true; |
302 } | 305 } |
303 | 306 |
304 void LoginDisplayHostImpl::OnSessionStart() { | 307 void LoginDisplayHostImpl::Finalize() { |
305 DVLOG(1) << "Session starting"; | 308 DVLOG(1) << "Session starting"; |
306 ash::Shell::GetInstance()-> | 309 ash::Shell::GetInstance()-> |
307 desktop_background_controller()->MoveDesktopToUnlockedContainer(); | 310 desktop_background_controller()->MoveDesktopToUnlockedContainer(); |
308 if (wizard_controller_.get()) | 311 if (wizard_controller_.get()) |
309 wizard_controller_->OnSessionStart(); | 312 wizard_controller_->OnSessionStart(); |
310 g_browser_process->platform_part()->profile_helper()->ClearSigninProfile( | 313 g_browser_process->platform_part()->profile_helper()->ClearSigninProfile( |
311 base::Closure()); | 314 base::Closure()); |
312 // Display host is deleted once animation is completed | 315 if (!IsRunningUserAdding()) { |
313 // since sign in screen widget has to stay alive. | 316 // Display host is deleted once animation is completed |
314 StartAnimation(); | 317 // since sign in screen widget has to stay alive. |
| 318 StartAnimation(); |
| 319 } |
315 ShutdownDisplayHost(false); | 320 ShutdownDisplayHost(false); |
316 } | 321 } |
317 | 322 |
318 void LoginDisplayHostImpl::OnCompleteLogin() { | 323 void LoginDisplayHostImpl::OnCompleteLogin() { |
319 // Cancelling the |auto_enrollment_client_| now allows it to determine whether | 324 // Cancelling the |auto_enrollment_client_| now allows it to determine whether |
320 // its protocol finished before login was complete. | 325 // its protocol finished before login was complete. |
321 if (auto_enrollment_client_.get()) | 326 if (auto_enrollment_client_.get()) |
322 auto_enrollment_client_.release()->CancelAndDeleteSoon(); | 327 auto_enrollment_client_.release()->CancelAndDeleteSoon(); |
323 } | 328 } |
324 | 329 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 | 394 |
390 oobe_progress_bar_visible_ = !StartupUtils::IsDeviceRegistered(); | 395 oobe_progress_bar_visible_ = !StartupUtils::IsDeviceRegistered(); |
391 SetOobeProgressBarVisible(oobe_progress_bar_visible_); | 396 SetOobeProgressBarVisible(oobe_progress_bar_visible_); |
392 wizard_controller_->Init(first_screen_name, screen_parameters.Pass()); | 397 wizard_controller_->Init(first_screen_name, screen_parameters.Pass()); |
393 } | 398 } |
394 | 399 |
395 WizardController* LoginDisplayHostImpl::GetWizardController() { | 400 WizardController* LoginDisplayHostImpl::GetWizardController() { |
396 return wizard_controller_.get(); | 401 return wizard_controller_.get(); |
397 } | 402 } |
398 | 403 |
| 404 void LoginDisplayHostImpl::StartUserAdding( |
| 405 const base::Closure& completion_callback) { |
| 406 restore_path_ = RESTORE_ADD_USER_INTO_SESSION; |
| 407 completion_callback_ = completion_callback; |
| 408 LOG(INFO) << "Login WebUI >> user adding"; |
| 409 if (!login_window_) |
| 410 LoadURL(GURL(kUserAddingURL)); |
| 411 |
| 412 // Lock container can be transparent after lock screen animation. |
| 413 aura::Window* lock_container = ash::Shell::GetContainer( |
| 414 ash::Shell::GetPrimaryRootWindow(), |
| 415 ash::internal::kShellWindowId_LockScreenContainersContainer); |
| 416 lock_container->layer()->SetOpacity(1.0); |
| 417 |
| 418 ash::Shell::GetInstance()-> |
| 419 desktop_background_controller()->MoveDesktopToLockedContainer(); |
| 420 |
| 421 sign_in_controller_.reset(); // Only one controller in a time. |
| 422 sign_in_controller_.reset(new chromeos::ExistingUserController(this)); |
| 423 SetOobeProgressBarVisible(oobe_progress_bar_visible_ = false); |
| 424 SetStatusAreaVisible(true); |
| 425 SetShutdownButtonEnabled(true); |
| 426 sign_in_controller_->Init( |
| 427 chromeos::UserManager::Get()->GetUsersAdmittedForMultiProfile()); |
| 428 CHECK(webui_login_display_); |
| 429 GetOobeUI()->ShowSigninScreen(webui_login_display_, webui_login_display_); |
| 430 } |
| 431 |
399 void LoginDisplayHostImpl::StartSignInScreen() { | 432 void LoginDisplayHostImpl::StartSignInScreen() { |
400 restore_path_ = RESTORE_SIGN_IN; | 433 restore_path_ = RESTORE_SIGN_IN; |
401 is_showing_login_ = true; | 434 is_showing_login_ = true; |
402 | 435 |
403 if (waiting_for_wallpaper_load_ && !initialize_webui_hidden_) { | 436 if (waiting_for_wallpaper_load_ && !initialize_webui_hidden_) { |
404 LOG(INFO) << "Login WebUI >> sign in postponed"; | 437 LOG(INFO) << "Login WebUI >> sign in postponed"; |
405 return; | 438 return; |
406 } | 439 } |
407 LOG(INFO) << "Login WebUI >> sign in"; | 440 LOG(INFO) << "Login WebUI >> sign in"; |
408 | 441 |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 | 613 |
581 void LoginDisplayHostImpl::ShutdownDisplayHost(bool post_quit_task) { | 614 void LoginDisplayHostImpl::ShutdownDisplayHost(bool post_quit_task) { |
582 if (shutting_down_) | 615 if (shutting_down_) |
583 return; | 616 return; |
584 | 617 |
585 shutting_down_ = true; | 618 shutting_down_ = true; |
586 registrar_.RemoveAll(); | 619 registrar_.RemoveAll(); |
587 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 620 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
588 if (post_quit_task) | 621 if (post_quit_task) |
589 base::MessageLoop::current()->Quit(); | 622 base::MessageLoop::current()->Quit(); |
| 623 |
| 624 if (!completion_callback_.is_null()) |
| 625 completion_callback_.Run(); |
590 } | 626 } |
591 | 627 |
592 void LoginDisplayHostImpl::StartAnimation() { | 628 void LoginDisplayHostImpl::StartAnimation() { |
593 if (ash::Shell::GetContainer( | 629 if (ash::Shell::GetContainer( |
594 ash::Shell::GetPrimaryRootWindow(), | 630 ash::Shell::GetPrimaryRootWindow(), |
595 ash::internal::kShellWindowId_DesktopBackgroundContainer)-> | 631 ash::internal::kShellWindowId_DesktopBackgroundContainer)-> |
596 children().empty()) { | 632 children().empty()) { |
597 // If there is no background window, don't perform any animation on the | 633 // If there is no background window, don't perform any animation on the |
598 // default and background layer because there is nothing behind it. | 634 // default and background layer because there is nothing behind it. |
599 return; | 635 return; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 } | 722 } |
687 | 723 |
688 switch (restore_path_) { | 724 switch (restore_path_) { |
689 case RESTORE_WIZARD: | 725 case RESTORE_WIZARD: |
690 StartWizard(wizard_first_screen_name_, | 726 StartWizard(wizard_first_screen_name_, |
691 wizard_screen_parameters_.Pass()); | 727 wizard_screen_parameters_.Pass()); |
692 break; | 728 break; |
693 case RESTORE_SIGN_IN: | 729 case RESTORE_SIGN_IN: |
694 StartSignInScreen(); | 730 StartSignInScreen(); |
695 break; | 731 break; |
| 732 case RESTORE_ADD_USER_INTO_SESSION: |
| 733 StartUserAdding(completion_callback_); |
| 734 break; |
696 default: | 735 default: |
697 NOTREACHED(); | 736 NOTREACHED(); |
698 break; | 737 break; |
699 } | 738 } |
700 } | 739 } |
701 | 740 |
702 void LoginDisplayHostImpl::InitLoginWindowAndView() { | 741 void LoginDisplayHostImpl::InitLoginWindowAndView() { |
703 if (login_window_) | 742 if (login_window_) |
704 return; | 743 return; |
705 | 744 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 if (root) { | 801 if (root) { |
763 root->SetProperty(ash::internal::kIgnoreSoloWindowFramePainterPolicy, | 802 root->SetProperty(ash::internal::kIgnoreSoloWindowFramePainterPolicy, |
764 old_ignore_solo_window_frame_painter_policy_value_); | 803 old_ignore_solo_window_frame_painter_policy_value_); |
765 } | 804 } |
766 } | 805 } |
767 login_window_->Close(); | 806 login_window_->Close(); |
768 login_window_ = NULL; | 807 login_window_ = NULL; |
769 login_view_ = NULL; | 808 login_view_ = NULL; |
770 } | 809 } |
771 | 810 |
| 811 bool LoginDisplayHostImpl::IsRunningUserAdding() { |
| 812 return restore_path_ == RESTORE_ADD_USER_INTO_SESSION; |
| 813 } |
| 814 |
772 //////////////////////////////////////////////////////////////////////////////// | 815 //////////////////////////////////////////////////////////////////////////////// |
773 // external | 816 // external |
774 | 817 |
775 // Declared in login_wizard.h so that others don't need to depend on our .h. | 818 // Declared in login_wizard.h so that others don't need to depend on our .h. |
776 // TODO(nkostylev): Split this into a smaller functions. | 819 // TODO(nkostylev): Split this into a smaller functions. |
777 void ShowLoginWizard(const std::string& first_screen_name) { | 820 void ShowLoginWizard(const std::string& first_screen_name) { |
778 if (browser_shutdown::IsTryingToQuit()) | 821 if (browser_shutdown::IsTryingToQuit()) |
779 return; | 822 return; |
780 | 823 |
781 // Managed mode is defined as a machine-level setting so we have to reset it | 824 // Managed mode is defined as a machine-level setting so we have to reset it |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 LoginState::Get()->SetLoggedInState( | 867 LoginState::Get()->SetLoggedInState( |
825 LoginState::LOGGED_IN_OOBE, LoginState::LOGGED_IN_USER_NONE); | 868 LoginState::LOGGED_IN_OOBE, LoginState::LOGGED_IN_USER_NONE); |
826 } else { | 869 } else { |
827 LoginState::Get()->SetLoggedInState( | 870 LoginState::Get()->SetLoggedInState( |
828 LoginState::LOGGED_IN_NONE, LoginState::LOGGED_IN_USER_NONE); | 871 LoginState::LOGGED_IN_NONE, LoginState::LOGGED_IN_USER_NONE); |
829 } | 872 } |
830 bool show_login_screen = | 873 bool show_login_screen = |
831 (first_screen_name.empty() && oobe_complete) || | 874 (first_screen_name.empty() && oobe_complete) || |
832 first_screen_name == chromeos::WizardController::kLoginScreenName; | 875 first_screen_name == chromeos::WizardController::kLoginScreenName; |
833 | 876 |
834 chromeos::LoginDisplayHost* display_host; | 877 chromeos::LoginDisplayHost* display_host = |
835 display_host = new chromeos::LoginDisplayHostImpl(screen_bounds); | 878 new chromeos::LoginDisplayHostImpl(screen_bounds); |
836 | 879 |
837 if (show_login_screen) { | 880 if (show_login_screen) { |
838 // R11 > R12 migration fix. See http://crosbug.com/p/4898. | 881 // R11 > R12 migration fix. See http://crosbug.com/p/4898. |
839 // If user has manually changed locale during R11 OOBE, locale will be set. | 882 // If user has manually changed locale during R11 OOBE, locale will be set. |
840 // On R12 > R12|R13 etc. this fix won't get activated since | 883 // On R12 > R12|R13 etc. this fix won't get activated since |
841 // OOBE process has set kApplicationLocale to non-default value. | 884 // OOBE process has set kApplicationLocale to non-default value. |
842 PrefService* prefs = g_browser_process->local_state(); | 885 PrefService* prefs = g_browser_process->local_state(); |
843 if (!prefs->HasPrefPath(prefs::kApplicationLocale)) { | 886 if (!prefs->HasPrefPath(prefs::kApplicationLocale)) { |
844 std::string locale = chromeos::StartupUtils::GetInitialLocale(); | 887 std::string locale = chromeos::StartupUtils::GetInitialLocale(); |
845 prefs->SetString(prefs::kApplicationLocale, locale); | 888 prefs->SetString(prefs::kApplicationLocale, locale); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 VLOG(1) << "Initial time zone: " << timezone_name; | 956 VLOG(1) << "Initial time zone: " << timezone_name; |
914 // Apply locale customizations only once to preserve whatever locale | 957 // Apply locale customizations only once to preserve whatever locale |
915 // user has changed to during OOBE. | 958 // user has changed to during OOBE. |
916 if (!timezone_name.empty()) { | 959 if (!timezone_name.empty()) { |
917 chromeos::system::TimezoneSettings::GetInstance()->SetTimezoneFromID( | 960 chromeos::system::TimezoneSettings::GetInstance()->SetTimezoneFromID( |
918 UTF8ToUTF16(timezone_name)); | 961 UTF8ToUTF16(timezone_name)); |
919 } | 962 } |
920 } | 963 } |
921 | 964 |
922 } // namespace chromeos | 965 } // namespace chromeos |
OLD | NEW |