Chromium Code Reviews| 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/ash_switches.h" | 9 #include "ash/ash_switches.h" |
| 10 #include "ash/desktop_background/desktop_background_controller.h" | 10 #include "ash/desktop_background/desktop_background_controller.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 #include "ui/compositor/layer_animator.h" | 76 #include "ui/compositor/layer_animator.h" |
| 77 #include "ui/compositor/scoped_layer_animation_settings.h" | 77 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 78 #include "ui/gfx/rect.h" | 78 #include "ui/gfx/rect.h" |
| 79 #include "ui/gfx/transform.h" | 79 #include "ui/gfx/transform.h" |
| 80 #include "ui/views/focus/focus_manager.h" | 80 #include "ui/views/focus/focus_manager.h" |
| 81 #include "ui/views/widget/widget.h" | 81 #include "ui/views/widget/widget.h" |
| 82 | 82 |
| 83 namespace { | 83 namespace { |
| 84 | 84 |
| 85 // URL which corresponds to the login WebUI. | 85 // URL which corresponds to the login WebUI. |
| 86 const char kLoginURL[] = "chrome://oobe/login"; | 86 const char kLoginURL[] = "chrome://oobe/login#login"; |
| 87 | 87 |
| 88 // URL which corresponds to the OOBE WebUI. | 88 // URL which corresponds to the OOBE WebUI. |
| 89 const char kOobeURL[] = "chrome://oobe"; | 89 const char kOobeURL[] = "chrome://oobe#login"; |
| 90 | |
| 91 // URL which corresponds to the user adding WebUI. | |
| 92 const char kUserAddingURL[] = "chrome://oobe/login#user-adding"; | |
| 90 | 93 |
| 91 // Duration of sign-in transition animation. | 94 // Duration of sign-in transition animation. |
| 92 const int kLoginFadeoutTransitionDurationMs = 700; | 95 const int kLoginFadeoutTransitionDurationMs = 700; |
| 93 | 96 |
| 94 // Number of times we try to reload OOBE/login WebUI if it crashes. | 97 // Number of times we try to reload OOBE/login WebUI if it crashes. |
| 95 const int kCrashCountLimit = 5; | 98 const int kCrashCountLimit = 5; |
| 96 | 99 |
| 97 // Whether to enable tnitializing WebUI in hidden state (see | 100 // Whether to enable tnitializing WebUI in hidden state (see |
| 98 // |initialize_webui_hidden_|) by default. | 101 // |initialize_webui_hidden_|) by default. |
| 99 const bool kHiddenWebUIInitializationDefault = true; | 102 const bool kHiddenWebUIInitializationDefault = true; |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 } | 302 } |
| 300 | 303 |
| 301 views::Widget* LoginDisplayHostImpl::GetWidget() const { | 304 views::Widget* LoginDisplayHostImpl::GetWidget() const { |
| 302 return login_window_; | 305 return login_window_; |
| 303 } | 306 } |
| 304 | 307 |
| 305 void LoginDisplayHostImpl::BeforeSessionStart() { | 308 void LoginDisplayHostImpl::BeforeSessionStart() { |
| 306 session_starting_ = true; | 309 session_starting_ = true; |
| 307 } | 310 } |
| 308 | 311 |
| 309 void LoginDisplayHostImpl::OnSessionStart() { | 312 void LoginDisplayHostImpl::Finalize() { |
| 310 DVLOG(1) << "Session starting"; | 313 DVLOG(1) << "Session starting"; |
| 311 ash::Shell::GetInstance()-> | 314 ash::Shell::GetInstance()-> |
| 312 desktop_background_controller()->MoveDesktopToUnlockedContainer(); | 315 desktop_background_controller()->MoveDesktopToUnlockedContainer(); |
| 313 if (wizard_controller_.get()) | 316 if (wizard_controller_.get()) |
| 314 wizard_controller_->OnSessionStart(); | 317 wizard_controller_->OnSessionStart(); |
| 315 g_browser_process->platform_part()->profile_helper()->ClearSigninProfile( | 318 g_browser_process->platform_part()->profile_helper()->ClearSigninProfile( |
| 316 base::Closure()); | 319 base::Closure()); |
| 317 // Display host is deleted once animation is completed | 320 if (!IsRunningUserAdding()) { |
| 318 // since sign in screen widget has to stay alive. | 321 // Display host is deleted once animation is completed |
| 319 StartAnimation(); | 322 // since sign in screen widget has to stay alive. |
| 323 StartAnimation(); | |
| 324 } | |
| 320 ShutdownDisplayHost(false); | 325 ShutdownDisplayHost(false); |
| 321 } | 326 } |
| 322 | 327 |
| 323 void LoginDisplayHostImpl::OnCompleteLogin() { | 328 void LoginDisplayHostImpl::OnCompleteLogin() { |
| 324 // Cancelling the |auto_enrollment_client_| now allows it to determine whether | 329 // Cancelling the |auto_enrollment_client_| now allows it to determine whether |
| 325 // its protocol finished before login was complete. | 330 // its protocol finished before login was complete. |
| 326 if (auto_enrollment_client_.get()) | 331 if (auto_enrollment_client_.get()) |
| 327 auto_enrollment_client_.release()->CancelAndDeleteSoon(); | 332 auto_enrollment_client_.release()->CancelAndDeleteSoon(); |
| 328 } | 333 } |
| 329 | 334 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 394 | 399 |
| 395 oobe_progress_bar_visible_ = !StartupUtils::IsDeviceRegistered(); | 400 oobe_progress_bar_visible_ = !StartupUtils::IsDeviceRegistered(); |
| 396 SetOobeProgressBarVisible(oobe_progress_bar_visible_); | 401 SetOobeProgressBarVisible(oobe_progress_bar_visible_); |
| 397 wizard_controller_->Init(first_screen_name, screen_parameters.Pass()); | 402 wizard_controller_->Init(first_screen_name, screen_parameters.Pass()); |
| 398 } | 403 } |
| 399 | 404 |
| 400 WizardController* LoginDisplayHostImpl::GetWizardController() { | 405 WizardController* LoginDisplayHostImpl::GetWizardController() { |
| 401 return wizard_controller_.get(); | 406 return wizard_controller_.get(); |
| 402 } | 407 } |
| 403 | 408 |
| 409 void LoginDisplayHostImpl::StartUserAdding( | |
| 410 const base::Closure& completion_callback) { | |
| 411 restore_path_ = RESTORE_USER_ADDING; | |
| 412 completion_callback_ = completion_callback; | |
| 413 if (waiting_for_wallpaper_load_ && !initialize_webui_hidden_) { | |
|
Nikita (slow)
2013/05/28 11:34:22
Please remove this as I think that is not needed f
dzhioev (left Google)
2013/05/29 13:05:04
Done.
| |
| 414 LOG(INFO) << "Login WebUI >> user adding postponed"; | |
| 415 return; | |
| 416 } | |
| 417 LOG(INFO) << "Login WebUI >> user adding"; | |
| 418 if (!login_window_) { | |
| 419 LoadURL(GURL(kUserAddingURL)); | |
| 420 } | |
|
Nikita (slow)
2013/05/28 11:34:22
nit: drop {}
dzhioev (left Google)
2013/05/29 13:05:04
Done.
| |
| 421 | |
| 422 // Lock container can be transparent after lock screen animation. | |
| 423 aura::Window* lock_container = ash::Shell::GetContainer( | |
| 424 ash::Shell::GetPrimaryRootWindow(), | |
| 425 ash::internal::kShellWindowId_LockScreenContainersContainer); | |
| 426 lock_container->layer()->SetOpacity(1.0); | |
| 427 | |
| 428 ash::Shell::GetInstance()-> | |
| 429 desktop_background_controller()->MoveDesktopToLockedContainer(); | |
| 430 | |
| 431 sign_in_controller_.reset(); // Only one controller in a time. | |
| 432 sign_in_controller_.reset(new chromeos::ExistingUserController(this)); | |
| 433 SetOobeProgressBarVisible(oobe_progress_bar_visible_ = false); | |
| 434 SetStatusAreaVisible(true); | |
| 435 SetShutdownButtonEnabled(true); | |
| 436 sign_in_controller_->Init( | |
| 437 chromeos::UserManager::Get()->GetUsersAdmittedForMultiProfile()); | |
| 438 CHECK(webui_login_display_); | |
| 439 GetOobeUI()->ShowSigninScreen(webui_login_display_, webui_login_display_); | |
| 440 } | |
| 441 | |
| 404 void LoginDisplayHostImpl::StartSignInScreen() { | 442 void LoginDisplayHostImpl::StartSignInScreen() { |
| 405 restore_path_ = RESTORE_SIGN_IN; | 443 restore_path_ = RESTORE_SIGN_IN; |
| 406 is_showing_login_ = true; | 444 is_showing_login_ = true; |
| 407 | 445 |
| 408 if (waiting_for_wallpaper_load_ && !initialize_webui_hidden_) { | 446 if (waiting_for_wallpaper_load_ && !initialize_webui_hidden_) { |
| 409 LOG(INFO) << "Login WebUI >> sign in postponed"; | 447 LOG(INFO) << "Login WebUI >> sign in postponed"; |
| 410 return; | 448 return; |
| 411 } | 449 } |
| 412 LOG(INFO) << "Login WebUI >> sign in"; | 450 LOG(INFO) << "Login WebUI >> sign in"; |
| 413 | 451 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 585 | 623 |
| 586 void LoginDisplayHostImpl::ShutdownDisplayHost(bool post_quit_task) { | 624 void LoginDisplayHostImpl::ShutdownDisplayHost(bool post_quit_task) { |
| 587 if (shutting_down_) | 625 if (shutting_down_) |
| 588 return; | 626 return; |
| 589 | 627 |
| 590 shutting_down_ = true; | 628 shutting_down_ = true; |
| 591 registrar_.RemoveAll(); | 629 registrar_.RemoveAll(); |
| 592 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 630 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 593 if (post_quit_task) | 631 if (post_quit_task) |
| 594 MessageLoop::current()->Quit(); | 632 MessageLoop::current()->Quit(); |
| 633 | |
| 634 if (!completion_callback_.is_null()) { | |
|
Nikita (slow)
2013/05/28 11:34:22
nit: drop {}
dzhioev (left Google)
2013/05/29 13:05:04
Done.
| |
| 635 completion_callback_.Run(); | |
| 636 } | |
| 595 } | 637 } |
| 596 | 638 |
| 597 void LoginDisplayHostImpl::StartAnimation() { | 639 void LoginDisplayHostImpl::StartAnimation() { |
| 598 if (ash::Shell::GetContainer( | 640 if (ash::Shell::GetContainer( |
| 599 ash::Shell::GetPrimaryRootWindow(), | 641 ash::Shell::GetPrimaryRootWindow(), |
| 600 ash::internal::kShellWindowId_DesktopBackgroundContainer)-> | 642 ash::internal::kShellWindowId_DesktopBackgroundContainer)-> |
| 601 children().empty()) { | 643 children().empty()) { |
| 602 // If there is no background window, don't perform any animation on the | 644 // If there is no background window, don't perform any animation on the |
| 603 // default and background layer because there is nothing behind it. | 645 // default and background layer because there is nothing behind it. |
| 604 return; | 646 return; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 691 } | 733 } |
| 692 | 734 |
| 693 switch (restore_path_) { | 735 switch (restore_path_) { |
| 694 case RESTORE_WIZARD: | 736 case RESTORE_WIZARD: |
| 695 StartWizard(wizard_first_screen_name_, | 737 StartWizard(wizard_first_screen_name_, |
| 696 wizard_screen_parameters_.Pass()); | 738 wizard_screen_parameters_.Pass()); |
| 697 break; | 739 break; |
| 698 case RESTORE_SIGN_IN: | 740 case RESTORE_SIGN_IN: |
| 699 StartSignInScreen(); | 741 StartSignInScreen(); |
| 700 break; | 742 break; |
| 743 case RESTORE_USER_ADDING: | |
| 744 StartUserAdding(completion_callback_); | |
| 745 break; | |
| 701 default: | 746 default: |
| 702 NOTREACHED(); | 747 NOTREACHED(); |
| 703 break; | 748 break; |
| 704 } | 749 } |
| 705 } | 750 } |
| 706 | 751 |
| 707 void LoginDisplayHostImpl::InitLoginWindowAndView() { | 752 void LoginDisplayHostImpl::InitLoginWindowAndView() { |
| 708 if (login_window_) | 753 if (login_window_) |
| 709 return; | 754 return; |
| 710 | 755 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 767 if (root) { | 812 if (root) { |
| 768 root->SetProperty(ash::internal::kIgnoreSoloWindowFramePainterPolicy, | 813 root->SetProperty(ash::internal::kIgnoreSoloWindowFramePainterPolicy, |
| 769 old_ignore_solo_window_frame_painter_policy_value_); | 814 old_ignore_solo_window_frame_painter_policy_value_); |
| 770 } | 815 } |
| 771 } | 816 } |
| 772 login_window_->Close(); | 817 login_window_->Close(); |
| 773 login_window_ = NULL; | 818 login_window_ = NULL; |
| 774 login_view_ = NULL; | 819 login_view_ = NULL; |
| 775 } | 820 } |
| 776 | 821 |
| 822 bool LoginDisplayHostImpl::IsRunningUserAdding() { | |
| 823 return restore_path_ == RESTORE_USER_ADDING; | |
| 824 } | |
| 825 | |
| 777 //////////////////////////////////////////////////////////////////////////////// | 826 //////////////////////////////////////////////////////////////////////////////// |
| 778 // external | 827 // external |
| 779 | 828 |
| 780 // Declared in login_wizard.h so that others don't need to depend on our .h. | 829 // Declared in login_wizard.h so that others don't need to depend on our .h. |
| 781 // TODO(nkostylev): Split this into a smaller functions. | 830 // TODO(nkostylev): Split this into a smaller functions. |
| 782 void ShowLoginWizard(const std::string& first_screen_name, | 831 void ShowLoginWizard(const std::string& first_screen_name, |
| 783 const gfx::Size& size) { | 832 const gfx::Size& size) { |
| 784 if (browser_shutdown::IsTryingToQuit()) | 833 if (browser_shutdown::IsTryingToQuit()) |
| 785 return; | 834 return; |
| 786 | 835 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 830 LoginState::Get()->SetLoggedInState( | 879 LoginState::Get()->SetLoggedInState( |
| 831 LoginState::LOGGED_IN_OOBE, LoginState::LOGGED_IN_USER_NONE); | 880 LoginState::LOGGED_IN_OOBE, LoginState::LOGGED_IN_USER_NONE); |
| 832 } else { | 881 } else { |
| 833 LoginState::Get()->SetLoggedInState( | 882 LoginState::Get()->SetLoggedInState( |
| 834 LoginState::LOGGED_IN_NONE, LoginState::LOGGED_IN_USER_NONE); | 883 LoginState::LOGGED_IN_NONE, LoginState::LOGGED_IN_USER_NONE); |
| 835 } | 884 } |
| 836 bool show_login_screen = | 885 bool show_login_screen = |
| 837 (first_screen_name.empty() && oobe_complete) || | 886 (first_screen_name.empty() && oobe_complete) || |
| 838 first_screen_name == chromeos::WizardController::kLoginScreenName; | 887 first_screen_name == chromeos::WizardController::kLoginScreenName; |
| 839 | 888 |
| 840 chromeos::LoginDisplayHost* display_host; | 889 chromeos::LoginDisplayHost* display_host = |
| 841 display_host = new chromeos::LoginDisplayHostImpl(screen_bounds); | 890 new chromeos::LoginDisplayHostImpl(screen_bounds); |
| 842 | 891 |
| 843 if (show_login_screen) { | 892 if (show_login_screen) { |
| 844 // R11 > R12 migration fix. See http://crosbug.com/p/4898. | 893 // R11 > R12 migration fix. See http://crosbug.com/p/4898. |
| 845 // If user has manually changed locale during R11 OOBE, locale will be set. | 894 // If user has manually changed locale during R11 OOBE, locale will be set. |
| 846 // On R12 > R12|R13 etc. this fix won't get activated since | 895 // On R12 > R12|R13 etc. this fix won't get activated since |
| 847 // OOBE process has set kApplicationLocale to non-default value. | 896 // OOBE process has set kApplicationLocale to non-default value. |
| 848 PrefService* prefs = g_browser_process->local_state(); | 897 PrefService* prefs = g_browser_process->local_state(); |
| 849 if (!prefs->HasPrefPath(prefs::kApplicationLocale)) { | 898 if (!prefs->HasPrefPath(prefs::kApplicationLocale)) { |
| 850 std::string locale = chromeos::StartupUtils::GetInitialLocale(); | 899 std::string locale = chromeos::StartupUtils::GetInitialLocale(); |
| 851 prefs->SetString(prefs::kApplicationLocale, locale); | 900 prefs->SetString(prefs::kApplicationLocale, locale); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 919 VLOG(1) << "Initial time zone: " << timezone_name; | 968 VLOG(1) << "Initial time zone: " << timezone_name; |
| 920 // Apply locale customizations only once to preserve whatever locale | 969 // Apply locale customizations only once to preserve whatever locale |
| 921 // user has changed to during OOBE. | 970 // user has changed to during OOBE. |
| 922 if (!timezone_name.empty()) { | 971 if (!timezone_name.empty()) { |
| 923 chromeos::system::TimezoneSettings::GetInstance()->SetTimezoneFromID( | 972 chromeos::system::TimezoneSettings::GetInstance()->SetTimezoneFromID( |
| 924 UTF8ToUTF16(timezone_name)); | 973 UTF8ToUTF16(timezone_name)); |
| 925 } | 974 } |
| 926 } | 975 } |
| 927 | 976 |
| 928 } // namespace chromeos | 977 } // namespace chromeos |
| OLD | NEW |