OLD | NEW |
---|---|
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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/audio/sounds.h" | 9 #include "ash/audio/sounds.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 "media/audio/sounds/sounds_manager.h" | 76 #include "media/audio/sounds/sounds_manager.h" |
77 #include "ui/aura/window.h" | 77 #include "ui/aura/window.h" |
78 #include "ui/base/resource/resource_bundle.h" | 78 #include "ui/base/resource/resource_bundle.h" |
79 #include "ui/compositor/layer.h" | 79 #include "ui/compositor/layer.h" |
80 #include "ui/compositor/layer_animation_observer.h" | 80 #include "ui/compositor/layer_animation_observer.h" |
81 #include "ui/compositor/scoped_layer_animation_settings.h" | 81 #include "ui/compositor/scoped_layer_animation_settings.h" |
82 #include "ui/events/event_utils.h" | 82 #include "ui/events/event_utils.h" |
83 #include "ui/gfx/rect.h" | 83 #include "ui/gfx/rect.h" |
84 #include "ui/gfx/transform.h" | 84 #include "ui/gfx/transform.h" |
85 #include "ui/keyboard/keyboard_controller.h" | 85 #include "ui/keyboard/keyboard_controller.h" |
86 #include "ui/keyboard/keyboard_util.h" | |
86 #include "ui/views/focus/focus_manager.h" | 87 #include "ui/views/focus/focus_manager.h" |
87 #include "ui/views/widget/widget.h" | 88 #include "ui/views/widget/widget.h" |
88 #include "ui/views/widget/widget_delegate.h" | 89 #include "ui/views/widget/widget_delegate.h" |
89 #include "ui/wm/core/window_animations.h" | 90 #include "ui/wm/core/window_animations.h" |
90 #include "url/gurl.h" | 91 #include "url/gurl.h" |
91 | 92 |
92 namespace { | 93 namespace { |
93 | 94 |
94 // Maximum delay for startup sound after 'loginPromptVisible' signal. | 95 // Maximum delay for startup sound after 'loginPromptVisible' signal. |
95 const int kStartupSoundMaxDelayMs = 2000; | 96 const int kStartupSoundMaxDelayMs = 2000; |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
275 virtual bool ShouldAdvanceFocusToTopLevelWidget() const OVERRIDE { | 276 virtual bool ShouldAdvanceFocusToTopLevelWidget() const OVERRIDE { |
276 return true; | 277 return true; |
277 } | 278 } |
278 | 279 |
279 private: | 280 private: |
280 views::Widget* widget_; | 281 views::Widget* widget_; |
281 | 282 |
282 DISALLOW_COPY_AND_ASSIGN(LoginWidgetDelegate); | 283 DISALLOW_COPY_AND_ASSIGN(LoginWidgetDelegate); |
283 }; | 284 }; |
284 | 285 |
286 // Returns true if login should scroll user pods into view itself when virtual | |
287 // keyboard is shown and disable vk overscroll. | |
288 bool LoginScrollIntoViewEnabled() { | |
289 return !CommandLine::ForCurrentProcess()->HasSwitch( | |
290 chromeos::switches::kDisableLoginScrollIntoView); | |
291 } | |
292 | |
293 // Disables virtual keyboard overscroll. Login UI will scroll user pods | |
294 // into view on JS side when virtual keyboard is shown. | |
295 void DisableKeyboardOverscroll() { | |
296 keyboard::SetKeyboardOverscrollEnabledOverrideValue(false); | |
297 keyboard::SetKeyboardOverscrollOverrideEnabled(true); | |
298 } | |
299 | |
300 void ResetKeyboardOverscrollOverride() { | |
301 keyboard::SetKeyboardOverscrollOverrideEnabled(false); | |
302 } | |
303 | |
285 } // namespace | 304 } // namespace |
286 | 305 |
287 namespace chromeos { | 306 namespace chromeos { |
288 | 307 |
289 // static | 308 // static |
290 LoginDisplayHost* LoginDisplayHostImpl::default_host_ = NULL; | 309 LoginDisplayHost* LoginDisplayHostImpl::default_host_ = NULL; |
291 | 310 |
292 // static | 311 // static |
293 const int LoginDisplayHostImpl::kShowLoginWebUIid = 0x1111; | 312 const int LoginDisplayHostImpl::kShowLoginWebUIid = 0x1111; |
294 | 313 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
428 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); | 447 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); |
429 CrasAudioHandler::Get()->RemoveAudioObserver(this); | 448 CrasAudioHandler::Get()->RemoveAudioObserver(this); |
430 if (keyboard::KeyboardController::GetInstance() && is_observing_keyboard_) { | 449 if (keyboard::KeyboardController::GetInstance() && is_observing_keyboard_) { |
431 keyboard::KeyboardController::GetInstance()->RemoveObserver(this); | 450 keyboard::KeyboardController::GetInstance()->RemoveObserver(this); |
432 is_observing_keyboard_ = false; | 451 is_observing_keyboard_ = false; |
433 } | 452 } |
434 | 453 |
435 ash::Shell::GetInstance()->delegate()-> | 454 ash::Shell::GetInstance()->delegate()-> |
436 RemoveVirtualKeyboardStateObserver(this); | 455 RemoveVirtualKeyboardStateObserver(this); |
437 | 456 |
457 if (LoginScrollIntoViewEnabled()) | |
458 ResetKeyboardOverscrollOverride(); | |
459 | |
438 views::FocusManager::set_arrow_key_traversal_enabled(false); | 460 views::FocusManager::set_arrow_key_traversal_enabled(false); |
439 ResetLoginWindowAndView(); | 461 ResetLoginWindowAndView(); |
440 | 462 |
441 // Let chrome process exit after login/oobe screen if needed. | 463 // Let chrome process exit after login/oobe screen if needed. |
442 chrome::DecrementKeepAliveCount(); | 464 chrome::DecrementKeepAliveCount(); |
443 | 465 |
444 default_host_ = NULL; | 466 default_host_ = NULL; |
445 // TODO(tengs): This should be refactored. See crbug.com/314934. | 467 // TODO(tengs): This should be refactored. See crbug.com/314934. |
446 if (UserManager::Get()->IsCurrentUserNew()) { | 468 if (UserManager::Get()->IsCurrentUserNew()) { |
447 // DriveOptInController will delete itself when finished. | 469 // DriveOptInController will delete itself when finished. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
523 auto_enrollment_controller_->RegisterProgressCallback( | 545 auto_enrollment_controller_->RegisterProgressCallback( |
524 base::Bind(&LoginDisplayHostImpl::OnAutoEnrollmentProgress, | 546 base::Bind(&LoginDisplayHostImpl::OnAutoEnrollmentProgress, |
525 base::Unretained(this))); | 547 base::Unretained(this))); |
526 } | 548 } |
527 return auto_enrollment_controller_.get(); | 549 return auto_enrollment_controller_.get(); |
528 } | 550 } |
529 | 551 |
530 void LoginDisplayHostImpl::StartWizard( | 552 void LoginDisplayHostImpl::StartWizard( |
531 const std::string& first_screen_name, | 553 const std::string& first_screen_name, |
532 scoped_ptr<base::DictionaryValue> screen_parameters) { | 554 scoped_ptr<base::DictionaryValue> screen_parameters) { |
555 if (LoginScrollIntoViewEnabled()) | |
556 DisableKeyboardOverscroll(); | |
557 | |
533 startup_sound_honors_spoken_feedback_ = true; | 558 startup_sound_honors_spoken_feedback_ = true; |
534 TryToPlayStartupSound(); | 559 TryToPlayStartupSound(); |
535 | 560 |
536 // Keep parameters to restore if renderer crashes. | 561 // Keep parameters to restore if renderer crashes. |
537 restore_path_ = RESTORE_WIZARD; | 562 restore_path_ = RESTORE_WIZARD; |
538 wizard_first_screen_name_ = first_screen_name; | 563 wizard_first_screen_name_ = first_screen_name; |
539 if (screen_parameters.get()) | 564 if (screen_parameters.get()) |
540 wizard_screen_parameters_.reset(screen_parameters->DeepCopy()); | 565 wizard_screen_parameters_.reset(screen_parameters->DeepCopy()); |
541 else | 566 else |
542 wizard_screen_parameters_.reset(); | 567 wizard_screen_parameters_.reset(); |
(...skipping 24 matching lines...) Expand all Loading... | |
567 WizardController* LoginDisplayHostImpl::GetWizardController() { | 592 WizardController* LoginDisplayHostImpl::GetWizardController() { |
568 return wizard_controller_.get(); | 593 return wizard_controller_.get(); |
569 } | 594 } |
570 | 595 |
571 AppLaunchController* LoginDisplayHostImpl::GetAppLaunchController() { | 596 AppLaunchController* LoginDisplayHostImpl::GetAppLaunchController() { |
572 return app_launch_controller_.get(); | 597 return app_launch_controller_.get(); |
573 } | 598 } |
574 | 599 |
575 void LoginDisplayHostImpl::StartUserAdding( | 600 void LoginDisplayHostImpl::StartUserAdding( |
576 const base::Closure& completion_callback) { | 601 const base::Closure& completion_callback) { |
602 if (LoginScrollIntoViewEnabled()) | |
603 DisableKeyboardOverscroll(); | |
604 | |
577 restore_path_ = RESTORE_ADD_USER_INTO_SESSION; | 605 restore_path_ = RESTORE_ADD_USER_INTO_SESSION; |
578 completion_callback_ = completion_callback; | 606 completion_callback_ = completion_callback; |
579 finalize_animation_type_ = ANIMATION_NONE; | 607 finalize_animation_type_ = ANIMATION_NONE; |
580 LOG(WARNING) << "Login WebUI >> user adding"; | 608 LOG(WARNING) << "Login WebUI >> user adding"; |
581 if (!login_window_) | 609 if (!login_window_) |
582 LoadURL(GURL(kUserAddingURL)); | 610 LoadURL(GURL(kUserAddingURL)); |
583 // We should emit this signal only at login screen (after reboot or sign out). | 611 // We should emit this signal only at login screen (after reboot or sign out). |
584 login_view_->set_should_emit_login_prompt_visible(false); | 612 login_view_->set_should_emit_login_prompt_visible(false); |
585 | 613 |
586 // Lock container can be transparent after lock screen animation. | 614 // Lock container can be transparent after lock screen animation. |
(...skipping 12 matching lines...) Expand all Loading... | |
599 sign_in_controller_->Init( | 627 sign_in_controller_->Init( |
600 chromeos::UserManager::Get()->GetUsersAdmittedForMultiProfile()); | 628 chromeos::UserManager::Get()->GetUsersAdmittedForMultiProfile()); |
601 CHECK(webui_login_display_); | 629 CHECK(webui_login_display_); |
602 GetOobeUI()->ShowSigninScreen(LoginScreenContext(), | 630 GetOobeUI()->ShowSigninScreen(LoginScreenContext(), |
603 webui_login_display_, | 631 webui_login_display_, |
604 webui_login_display_); | 632 webui_login_display_); |
605 } | 633 } |
606 | 634 |
607 void LoginDisplayHostImpl::StartSignInScreen( | 635 void LoginDisplayHostImpl::StartSignInScreen( |
608 const LoginScreenContext& context) { | 636 const LoginScreenContext& context) { |
637 if (LoginScrollIntoViewEnabled()) | |
638 DisableKeyboardOverscroll(); | |
639 | |
609 startup_sound_honors_spoken_feedback_ = true; | 640 startup_sound_honors_spoken_feedback_ = true; |
610 TryToPlayStartupSound(); | 641 TryToPlayStartupSound(); |
611 | 642 |
612 restore_path_ = RESTORE_SIGN_IN; | 643 restore_path_ = RESTORE_SIGN_IN; |
613 is_showing_login_ = true; | 644 is_showing_login_ = true; |
614 finalize_animation_type_ = ANIMATION_WORKSPACE; | 645 finalize_animation_type_ = ANIMATION_WORKSPACE; |
615 | 646 |
616 PrewarmAuthentication(); | 647 PrewarmAuthentication(); |
617 | 648 |
618 if (waiting_for_wallpaper_load_ && !initialize_webui_hidden_) { | 649 if (waiting_for_wallpaper_load_ && !initialize_webui_hidden_) { |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
869 } | 900 } |
870 | 901 |
871 //////////////////////////////////////////////////////////////////////////////// | 902 //////////////////////////////////////////////////////////////////////////////// |
872 // LoginDisplayHostImpl, keyboard::KeyboardControllerObserver: | 903 // LoginDisplayHostImpl, keyboard::KeyboardControllerObserver: |
873 // implementation: | 904 // implementation: |
874 | 905 |
875 void LoginDisplayHostImpl::OnKeyboardBoundsChanging( | 906 void LoginDisplayHostImpl::OnKeyboardBoundsChanging( |
876 const gfx::Rect& new_bounds) { | 907 const gfx::Rect& new_bounds) { |
877 if (new_bounds.IsEmpty() && !keyboard_bounds_.IsEmpty()) { | 908 if (new_bounds.IsEmpty() && !keyboard_bounds_.IsEmpty()) { |
878 // Keyboard has been hidden. | 909 // Keyboard has been hidden. |
879 if (webui_login_display_) | 910 if (webui_login_display_) { |
dzhioev (left Google)
2014/05/21 17:30:32
Shouldn't we also set keyboard state once webui_lo
Nikita (slow)
2014/05/22 15:11:50
When CreateLoginDisplay() is called neither handle
| |
880 webui_login_display_->ShowControlBar(true); | 911 webui_login_display_->ShowControlBar(true); |
912 if (LoginScrollIntoViewEnabled()) | |
913 webui_login_display_->SetKeyboardState(false); | |
914 } | |
881 } else if (!new_bounds.IsEmpty() && keyboard_bounds_.IsEmpty()) { | 915 } else if (!new_bounds.IsEmpty() && keyboard_bounds_.IsEmpty()) { |
882 // Keyboard has been shown. | 916 // Keyboard has been shown. |
883 if (webui_login_display_) | 917 if (webui_login_display_) { |
884 webui_login_display_->ShowControlBar(false); | 918 webui_login_display_->ShowControlBar(false); |
919 if (LoginScrollIntoViewEnabled()) | |
920 webui_login_display_->SetKeyboardState(true); | |
921 } | |
885 } | 922 } |
886 | 923 |
887 keyboard_bounds_ = new_bounds; | 924 keyboard_bounds_ = new_bounds; |
888 } | 925 } |
889 | 926 |
890 //////////////////////////////////////////////////////////////////////////////// | 927 //////////////////////////////////////////////////////////////////////////////// |
891 // LoginDisplayHostImpl, private | 928 // LoginDisplayHostImpl, private |
892 | 929 |
893 void LoginDisplayHostImpl::ShutdownDisplayHost(bool post_quit_task) { | 930 void LoginDisplayHostImpl::ShutdownDisplayHost(bool post_quit_task) { |
894 if (shutting_down_) | 931 if (shutting_down_) |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1242 scoped_ptr<locale_util::SwitchLanguageCallback> callback( | 1279 scoped_ptr<locale_util::SwitchLanguageCallback> callback( |
1243 new locale_util::SwitchLanguageCallback( | 1280 new locale_util::SwitchLanguageCallback( |
1244 base::Bind(&OnLanguageSwitchedCallback, base::Passed(data.Pass())))); | 1281 base::Bind(&OnLanguageSwitchedCallback, base::Passed(data.Pass())))); |
1245 | 1282 |
1246 // Load locale keyboards here. Hardware layout would be automatically enabled. | 1283 // Load locale keyboards here. Hardware layout would be automatically enabled. |
1247 locale_util::SwitchLanguage( | 1284 locale_util::SwitchLanguage( |
1248 locale, true, true /* login_layouts_only */, callback.Pass()); | 1285 locale, true, true /* login_layouts_only */, callback.Pass()); |
1249 } | 1286 } |
1250 | 1287 |
1251 } // namespace chromeos | 1288 } // namespace chromeos |
OLD | NEW |