diff options
author | bshe@chromium.org <bshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-04 21:38:45 +0000 |
---|---|---|
committer | bshe@chromium.org <bshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-04 21:38:45 +0000 |
commit | b6ba05d90aaa93a4e707bdec67ba2c043a3a533f (patch) | |
tree | 94f5cecc6e48a262db4049514e610ab34a63538d | |
parent | 88645e15d7743209f5babd5574e4e30f31f277a4 (diff) | |
download | chromium_src-b6ba05d90aaa93a4e707bdec67ba2c043a3a533f.zip chromium_src-b6ba05d90aaa93a4e707bdec67ba2c043a3a533f.tar.gz chromium_src-b6ba05d90aaa93a4e707bdec67ba2c043a3a533f.tar.bz2 |
Only show virtual keyboard on primary root window
In order to display virtual keyboard(VK) only on primary root window,
this CL did
1. Shell takes ownership of keyboard controller(KC) instead of
RootWindowController
2. keyboard container window is owned by KC instead of its parent
There should only be one KC and one keyboard container at any time after
this change. keyboard container can be dynamically enabled/disabled on a
RootWindowController at runtime. If you want to do that,
you should DisableKeyboard on the previous RootWindowController first and
then EnableKeyboard on the new RootWindowController.
BUG=297858
TEST=
1. enable virtual keyboard from about::/flags on a Chromebook
2. plug in an external monitor
verify only one virtual keyboard shows
Review URL: https://codereview.chromium.org/25111002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@227088 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ash/root_window_controller.cc | 60 | ||||
-rw-r--r-- | ash/root_window_controller.h | 15 | ||||
-rw-r--r-- | ash/root_window_controller_unittest.cc | 25 | ||||
-rw-r--r-- | ash/shell.cc | 732 | ||||
-rw-r--r-- | ash/shell.h | 13 | ||||
-rw-r--r-- | chrome/browser/extensions/api/input/input.cc | 3 | ||||
-rw-r--r-- | chrome/browser/ui/ash/ash_keyboard_controller_proxy.cc | 5 | ||||
-rw-r--r-- | ui/keyboard/keyboard_controller.cc | 27 | ||||
-rw-r--r-- | ui/keyboard/keyboard_controller.h | 7 | ||||
-rw-r--r-- | ui/keyboard/keyboard_controller_unittest.cc | 14 |
10 files changed, 484 insertions, 417 deletions
diff --git a/ash/root_window_controller.cc b/ash/root_window_controller.cc index 7f8d41c..066f06c 100644 --- a/ash/root_window_controller.cc +++ b/ash/root_window_controller.cc @@ -331,7 +331,6 @@ void RootWindowController::Init(bool first_run_after_boot) { CreateSystemBackground(first_run_after_boot); InitLayoutManagers(); - InitKeyboard(); InitTouchHuds(); if (Shell::GetPrimaryRootWindowController()-> @@ -407,6 +406,10 @@ void RootWindowController::OnWallpaperAnimationFinished(views::Widget* widget) { void RootWindowController::CloseChildWindows() { mouse_event_target_.reset(); + // Deactivate keyboard container before closing child windows and shutting + // down associated layout managers. + DeactivateKeyboard(Shell::GetInstance()->keyboard_controller()); + if (!shelf_.get()) return; // panel_layout_manager_ needs to be shut down before windows are destroyed. @@ -528,28 +531,39 @@ const aura::Window* RootWindowController::GetTopmostFullscreenWindow() const { return NULL; } -void RootWindowController::InitKeyboard() { - if (keyboard::IsKeyboardEnabled()) { - aura::Window* parent = root_window(); - - keyboard::KeyboardControllerProxy* proxy = - Shell::GetInstance()->delegate()->CreateKeyboardControllerProxy(); - keyboard_controller_.reset( - new keyboard::KeyboardController(proxy)); - - keyboard_controller_->AddObserver(shelf()->shelf_layout_manager()); - keyboard_controller_->AddObserver(panel_layout_manager_); - keyboard_controller_->AddObserver(docked_layout_manager_); - - // Deletes the old container since |keyboard_controller_| creates a - // new container window in GetContainerWindow(). - delete GetContainer(kShellWindowId_VirtualKeyboardContainer); +void RootWindowController::ActivateKeyboard( + keyboard::KeyboardController* keyboard_controller) { + if (!keyboard::IsKeyboardEnabled() || + GetContainer(kShellWindowId_VirtualKeyboardContainer)) { + return; + } + DCHECK(keyboard_controller); + keyboard_controller->AddObserver(shelf()->shelf_layout_manager()); + keyboard_controller->AddObserver(panel_layout_manager_); + keyboard_controller->AddObserver(docked_layout_manager_); + aura::Window* parent = root_window(); + aura::Window* keyboard_container = + keyboard_controller->GetContainerWindow(); + keyboard_container->set_id(kShellWindowId_VirtualKeyboardContainer); + parent->AddChild(keyboard_container); + // TODO(oshima): Bounds of keyboard container should be handled by + // RootWindowLayoutManager. Remove this after fixed RootWindowLayoutManager. + keyboard_container->SetBounds(parent->bounds()); +} + +void RootWindowController::DeactivateKeyboard( + keyboard::KeyboardController* keyboard_controller) { + if (!keyboard::IsKeyboardEnabled()) + return; - aura::Window* keyboard_container = - keyboard_controller_->GetContainerWindow(); - keyboard_container->set_id(kShellWindowId_VirtualKeyboardContainer); - parent->AddChild(keyboard_container); - keyboard_container->SetBounds(parent->bounds()); + DCHECK(keyboard_controller); + aura::Window* keyboard_container = + keyboard_controller->GetContainerWindow(); + if (keyboard_container->GetRootWindow() == root_window()) { + root_window()->RemoveChild(keyboard_container); + keyboard_controller->RemoveObserver(shelf()->shelf_layout_manager()); + keyboard_controller->RemoveObserver(panel_layout_manager_); + keyboard_controller->RemoveObserver(docked_layout_manager_); } } @@ -827,8 +841,6 @@ void RootWindowController::DisableTouchHudProjection() { } void RootWindowController::OnLoginStateChanged(user::LoginStatus status) { - if (status != user::LOGGED_IN_NONE) - InitKeyboard(); shelf_->shelf_layout_manager()->UpdateVisibilityState(); } diff --git a/ash/root_window_controller.h b/ash/root_window_controller.h index 49ce6b8..7820434 100644 --- a/ash/root_window_controller.h +++ b/ash/root_window_controller.h @@ -102,10 +102,6 @@ class ASH_EXPORT RootWindowController : public ShellObserver { return always_on_top_controller_.get(); } - keyboard::KeyboardController* keyboard_controller() { - return keyboard_controller_.get(); - } - ScreenDimmer* screen_dimmer() { return screen_dimmer_.get(); } // Access the shelf associated with this root window controller, @@ -214,6 +210,12 @@ class ASH_EXPORT RootWindowController : public ShellObserver { // windows are in fullscreen state, the topmost one is preferred. const aura::Window* GetTopmostFullscreenWindow() const; + // Activate virtual keyboard on current root window controller. + void ActivateKeyboard(keyboard::KeyboardController* keyboard_controller); + + // Deactivate virtual keyboard on current root window controller. + void DeactivateKeyboard(keyboard::KeyboardController* keyboard_controller); + private: void InitLayoutManagers(); @@ -225,9 +227,6 @@ class ASH_EXPORT RootWindowController : public ShellObserver { // types in the shell UI. void CreateContainersInRootWindow(aura::RootWindow* root_window); - // Initializes the virtual keyboard. - void InitKeyboard(); - // Enables projection touch HUD. void EnableTouchHudProjection(); @@ -243,8 +242,6 @@ class ASH_EXPORT RootWindowController : public ShellObserver { scoped_ptr<StackingController> stacking_controller_; - scoped_ptr<keyboard::KeyboardController> keyboard_controller_; - // The shelf for managing the launcher and the status widget. scoped_ptr<ShelfWidget> shelf_; diff --git a/ash/root_window_controller_unittest.cc b/ash/root_window_controller_unittest.cc index cfab428..70d9146 100644 --- a/ash/root_window_controller_unittest.cc +++ b/ash/root_window_controller_unittest.cc @@ -626,11 +626,34 @@ class VirtualKeyboardRootWindowControllerTest : public test::AshTestBase { DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardRootWindowControllerTest); }; +// Test for http://crbug.com/297858. Virtual keyboard container should only show +// on primary root window. +TEST_F(VirtualKeyboardRootWindowControllerTest, + VirtualKeyboardOnPrimaryRootWindowOnly) { + if (!SupportsMultipleDisplays()) + return; + + UpdateDisplay("500x500,500x500"); + + Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); + aura::RootWindow* primary_root_window = Shell::GetPrimaryRootWindow(); + aura::RootWindow* secondary_root_window = + root_windows[0] == primary_root_window ? + root_windows[1] : root_windows[0]; + + ASSERT_TRUE(Shell::GetContainer( + primary_root_window, + internal::kShellWindowId_VirtualKeyboardContainer)); + ASSERT_FALSE(Shell::GetContainer( + secondary_root_window, + internal::kShellWindowId_VirtualKeyboardContainer)); +} + // Test for http://crbug.com/263599. Virtual keyboard should be able to receive // events at blocked user session. TEST_F(VirtualKeyboardRootWindowControllerTest, ClickVirtualKeyboardInBlockedWindow) { - aura::RootWindow* root_window = ash::Shell::GetPrimaryRootWindow(); + aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); aura::Window* keyboard_container = Shell::GetContainer(root_window, internal::kShellWindowId_VirtualKeyboardContainer); ASSERT_TRUE(keyboard_container); diff --git a/ash/shell.cc b/ash/shell.cc index 85740f8..cc6442a 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -92,6 +92,7 @@ #include "ui/gfx/screen.h" #include "ui/gfx/size.h" #include "ui/keyboard/keyboard.h" +#include "ui/keyboard/keyboard_controller.h" #include "ui/keyboard/keyboard_util.h" #include "ui/message_center/message_center.h" #include "ui/views/corewm/compound_event_filter.h" @@ -157,150 +158,6 @@ bool Shell::initially_hide_cursor_ = false; //////////////////////////////////////////////////////////////////////////////// // Shell, public: -Shell::Shell(ShellDelegate* delegate) - : screen_(new ScreenAsh), - target_root_window_(NULL), - scoped_target_root_window_(NULL), - delegate_(delegate), - window_positioner_(new WindowPositioner), - activation_client_(NULL), -#if defined(OS_CHROMEOS) && defined(USE_X11) - output_configurator_(new chromeos::OutputConfigurator()), -#endif // defined(OS_CHROMEOS) - native_cursor_manager_(new AshNativeCursorManager), - cursor_manager_(scoped_ptr<views::corewm::NativeCursorManager>( - native_cursor_manager_)), - browser_context_(NULL), - simulate_modal_window_open_for_testing_(false), - is_touch_hud_projection_enabled_(false) { - DCHECK(delegate_.get()); - display_manager_.reset(new internal::DisplayManager); - - ANNOTATE_LEAKING_OBJECT_PTR(screen_); // see crbug.com/156466 - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_ALTERNATE, screen_); - if (!gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE)) - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_); - display_controller_.reset(new DisplayController); -#if defined(OS_CHROMEOS) && defined(USE_X11) - bool is_panel_fitting_disabled = - content::GpuDataManager::GetInstance()->IsFeatureBlacklisted( - gpu::GPU_FEATURE_TYPE_PANEL_FITTING); - - output_configurator_->Init(!is_panel_fitting_disabled); - - base::MessagePumpX11::Current()->AddDispatcherForRootWindow( - output_configurator()); - // We can't do this with a root window listener because XI_HierarchyChanged - // messages don't have a target window. - base::MessagePumpX11::Current()->AddObserver(output_configurator()); -#endif // defined(OS_CHROMEOS) - -#if defined(OS_CHROMEOS) - internal::PowerStatus::Initialize(); -#endif -} - -Shell::~Shell() { - TRACE_EVENT0("shutdown", "ash::Shell::Destructor"); - - views::FocusManagerFactory::Install(NULL); - - // Remove the focus from any window. This will prevent overhead and side - // effects (e.g. crashes) from changing focus during shutdown. - // See bug crbug.com/134502. - aura::client::GetFocusClient(GetPrimaryRootWindow())->FocusWindow(NULL); - - // Please keep in same order as in Init() because it's easy to miss one. - if (window_modality_controller_) - window_modality_controller_.reset(); - RemovePreTargetHandler(event_rewriter_filter_.get()); - RemovePreTargetHandler(user_activity_detector_.get()); - RemovePreTargetHandler(overlay_filter_.get()); - RemovePreTargetHandler(input_method_filter_.get()); - if (mouse_cursor_filter_) - RemovePreTargetHandler(mouse_cursor_filter_.get()); - RemovePreTargetHandler(system_gesture_filter_.get()); - RemovePreTargetHandler(keyboard_metrics_filter_.get()); - RemovePreTargetHandler(event_transformation_handler_.get()); - RemovePreTargetHandler(accelerator_filter_.get()); - - // TooltipController is deleted with the Shell so removing its references. - RemovePreTargetHandler(tooltip_controller_.get()); - - // AppList needs to be released before shelf layout manager, which is - // destroyed with launcher container in the loop below. However, app list - // container is now on top of launcher container and released after it. - // TODO(xiyuan): Move it back when app list container is no longer needed. - app_list_controller_.reset(); - - // Destroy SystemTrayDelegate before destroying the status area(s). - system_tray_delegate_->Shutdown(); - system_tray_delegate_.reset(); - - locale_notification_controller_.reset(); - - // Drag-and-drop must be canceled prior to close all windows. - drag_drop_controller_.reset(); - - // Destroy all child windows including widgets. - display_controller_->CloseChildWindows(); - - // Destroy SystemTrayNotifier after destroying SystemTray as TrayItems - // needs to remove observers from it. - system_tray_notifier_.reset(); - - // These need a valid Shell instance to clean up properly, so explicitly - // delete them before invalidating the instance. - // Alphabetical. TODO(oshima): sort. - magnification_controller_.reset(); - partial_magnification_controller_.reset(); - resize_shadow_controller_.reset(); - shadow_controller_.reset(); - tooltip_controller_.reset(); - event_client_.reset(); - window_cycle_controller_.reset(); - nested_dispatcher_controller_.reset(); - user_action_client_.reset(); - visibility_controller_.reset(); - launcher_delegate_.reset(); - launcher_model_.reset(); - video_detector_.reset(); - - power_button_controller_.reset(); - lock_state_controller_.reset(); - mru_window_tracker_.reset(); - - resolution_notification_controller_.reset(); - desktop_background_controller_.reset(); - - // This also deletes all RootWindows. Note that we invoke Shutdown() on - // DisplayController before resetting |display_controller_|, since destruction - // of its owned RootWindowControllers relies on the value. - display_controller_->Shutdown(); - display_controller_.reset(); - screen_position_controller_.reset(); - -#if defined(OS_CHROMEOS) && defined(USE_X11) - if (display_change_observer_) - output_configurator_->RemoveObserver(display_change_observer_.get()); - if (output_configurator_animation_) - output_configurator_->RemoveObserver(output_configurator_animation_.get()); - if (display_error_observer_) - output_configurator_->RemoveObserver(display_error_observer_.get()); - base::MessagePumpX11::Current()->RemoveDispatcherForRootWindow( - output_configurator()); - base::MessagePumpX11::Current()->RemoveObserver(output_configurator()); - display_change_observer_.reset(); -#endif // defined(OS_CHROMEOS) - -#if defined(OS_CHROMEOS) - internal::PowerStatus::Shutdown(); -#endif - - DCHECK(instance_ == this); - instance_ = NULL; -} - // static Shell* Shell::CreateInstance(ShellDelegate* delegate) { CHECK(!instance_); @@ -398,212 +255,6 @@ bool Shell::IsForcedMaximizeMode() { return command_line->HasSwitch(switches::kForcedMaximizeMode); } -void Shell::Init() { - CommandLine* command_line = CommandLine::ForCurrentProcess(); - - delegate_->PreInit(); - bool display_initialized = false; -#if defined(OS_CHROMEOS) && defined(USE_X11) - output_configurator_animation_.reset( - new internal::OutputConfiguratorAnimation()); - output_configurator_->AddObserver(output_configurator_animation_.get()); - if (base::SysInfo::IsRunningOnChromeOS()) { - display_change_observer_.reset(new internal::DisplayChangeObserver); - // Register |display_change_observer_| first so that the rest of - // observer gets invoked after the root windows are configured. - output_configurator_->AddObserver(display_change_observer_.get()); - display_error_observer_.reset(new internal::DisplayErrorObserver()); - output_configurator_->AddObserver(display_error_observer_.get()); - output_configurator_->set_state_controller(display_change_observer_.get()); - if (!command_line->HasSwitch(ash::switches::kAshDisableSoftwareMirroring)) - output_configurator_->set_mirroring_controller(display_manager_.get()); - output_configurator_->Start( - delegate_->IsFirstRunAfterBoot() ? kChromeOsBootColor : 0); - display_initialized = true; - } -#endif // defined(OS_CHROMEOS) && defined(USE_X11) - if (!display_initialized) - display_manager_->InitFromCommandLine(); - - // Install the custom factory first so that views::FocusManagers for Tray, - // Launcher, and WallPaper could be created by the factory. - views::FocusManagerFactory::Install(new AshFocusManagerFactory); - - // The WindowModalityController needs to be at the front of the input event - // pretarget handler list to ensure that it processes input events when modal - // windows are active. - window_modality_controller_.reset( - new views::corewm::WindowModalityController(this)); - - AddPreTargetHandler(this); - - env_filter_.reset(new views::corewm::CompoundEventFilter); - AddPreTargetHandler(env_filter_.get()); - - // Env creates the compositor. Historically it seems to have been implicitly - // initialized first by the ActivationController, but now that FocusController - // no longer does this we need to do it explicitly. - aura::Env::GetInstance(); - views::corewm::FocusController* focus_controller = - new views::corewm::FocusController(new wm::AshFocusRules); - focus_client_.reset(focus_controller); - activation_client_ = focus_controller; - activation_client_->AddObserver(this); - focus_cycler_.reset(new internal::FocusCycler()); - - screen_position_controller_.reset(new internal::ScreenPositionController); - root_window_host_factory_.reset(delegate_->CreateRootWindowHostFactory()); - - display_controller_->Start(); - display_controller_->InitPrimaryDisplay(); - aura::RootWindow* root_window = display_controller_->GetPrimaryRootWindow(); - target_root_window_ = root_window; - - resolution_notification_controller_.reset( - new internal::ResolutionNotificationController); - - cursor_manager_.SetDisplay(DisplayController::GetPrimaryDisplay()); - - nested_dispatcher_controller_.reset(new NestedDispatcherController); - accelerator_controller_.reset(new AcceleratorController); - - // The order in which event filters are added is significant. - event_rewriter_filter_.reset(new internal::EventRewriterEventFilter); - AddPreTargetHandler(event_rewriter_filter_.get()); - - // UserActivityDetector passes events to observers, so let them get - // rewritten first. - user_activity_detector_.reset(new UserActivityDetector); - AddPreTargetHandler(user_activity_detector_.get()); - - overlay_filter_.reset(new internal::OverlayEventFilter); - AddPreTargetHandler(overlay_filter_.get()); - AddShellObserver(overlay_filter_.get()); - - input_method_filter_.reset(new views::corewm::InputMethodEventFilter( - root_window->GetAcceleratedWidget())); - AddPreTargetHandler(input_method_filter_.get()); - - accelerator_filter_.reset(new internal::AcceleratorFilter); - AddPreTargetHandler(accelerator_filter_.get()); - - event_transformation_handler_.reset(new internal::EventTransformationHandler); - AddPreTargetHandler(event_transformation_handler_.get()); - - system_gesture_filter_.reset(new internal::SystemGestureEventFilter); - AddPreTargetHandler(system_gesture_filter_.get()); - - keyboard_metrics_filter_.reset(new internal::KeyboardUMAEventFilter); - AddPreTargetHandler(keyboard_metrics_filter_.get()); - - // The keyboard system must be initialized before the RootWindowController is - // created. - if (keyboard::IsKeyboardEnabled()) - keyboard::InitializeKeyboard(); - - lock_state_controller_.reset(new LockStateController); - power_button_controller_.reset(new PowerButtonController( - lock_state_controller_.get())); - AddShellObserver(lock_state_controller_.get()); - - drag_drop_controller_.reset(new internal::DragDropController); - mouse_cursor_filter_.reset(new internal::MouseCursorEventFilter()); - PrependPreTargetHandler(mouse_cursor_filter_.get()); - - // Create Controllers that may need root window. - // TODO(oshima): Move as many controllers before creating - // RootWindowController as possible. - visibility_controller_.reset(new AshVisibilityController); - user_action_client_.reset(delegate_->CreateUserActionClient()); - - magnification_controller_.reset( - MagnificationController::CreateInstance()); - mru_window_tracker_.reset(new MruWindowTracker(activation_client_)); - - partial_magnification_controller_.reset( - new PartialMagnificationController()); - - high_contrast_controller_.reset(new HighContrastController); - video_detector_.reset(new VideoDetector); - window_cycle_controller_.reset(new WindowCycleController()); - window_selector_controller_.reset(new WindowSelectorController()); - - tooltip_controller_.reset(new views::corewm::TooltipController( - gfx::SCREEN_TYPE_ALTERNATE)); - AddPreTargetHandler(tooltip_controller_.get()); - - event_client_.reset(new internal::EventClientImpl); - - // This controller needs to be set before SetupManagedWindowMode. - desktop_background_controller_.reset(new DesktopBackgroundController()); - user_wallpaper_delegate_.reset(delegate_->CreateUserWallpaperDelegate()); - - // StatusAreaWidget uses Shell's CapsLockDelegate. - caps_lock_delegate_.reset(delegate_->CreateCapsLockDelegate()); - - session_state_delegate_.reset(delegate_->CreateSessionStateDelegate()); - - if (!command_line->HasSwitch(views::corewm::switches::kNoDropShadows)) { - resize_shadow_controller_.reset(new internal::ResizeShadowController()); - shadow_controller_.reset( - new views::corewm::ShadowController(activation_client_)); - } - - // Create system_tray_notifier_ before the delegate. - system_tray_notifier_.reset(new ash::SystemTrayNotifier()); - - // Initialize system_tray_delegate_ before initializing StatusAreaWidget. - system_tray_delegate_.reset(delegate()->CreateSystemTrayDelegate()); - DCHECK(system_tray_delegate_.get()); - - internal::RootWindowController* root_window_controller = - new internal::RootWindowController(root_window); - InitRootWindowController(root_window_controller, - delegate_->IsFirstRunAfterBoot()); - - locale_notification_controller_.reset( - new internal::LocaleNotificationController); - - // Initialize system_tray_delegate_ after StatusAreaWidget is created. - system_tray_delegate_->Initialize(); - - display_controller_->InitSecondaryDisplays(); - - // Force Layout - root_window_controller->root_window_layout()->OnWindowResized(); - - // It needs to be created after OnWindowResized has been called, otherwise the - // widget will not paint when restoring after a browser crash. Also it needs - // to be created after InitSecondaryDisplays() to initialize the wallpapers in - // the correct size. - user_wallpaper_delegate_->InitializeWallpaper(); - - if (initially_hide_cursor_) - cursor_manager_.HideCursor(); - cursor_manager_.SetCursor(ui::kCursorPointer); - - if (!cursor_manager_.IsCursorVisible()) { - // Cursor might have been hidden by something other than chrome. - // Let the first mouse event show the cursor. - env_filter_->set_cursor_hidden_by_filter(true); - } - - // Set accelerator controller delegates. -#if defined(OS_CHROMEOS) - accelerator_controller_->SetBrightnessControlDelegate( - scoped_ptr<ash::BrightnessControlDelegate>( - new ash::system::BrightnessControllerChromeos).Pass()); -#endif - - // The compositor thread and main message loop have to be running in - // order to create mirror window. Run it after the main message loop - // is started. - base::MessageLoopForUI::current()->PostTask( - FROM_HERE, - base::Bind(&internal::DisplayManager::CreateMirrorWindowIfAny, - base::Unretained(display_manager_.get()))); -} - void Shell::ShowContextMenu(const gfx::Point& location_in_screen, ui::MenuSourceType source_type) { // No context menus if there is no session with an active user. @@ -687,6 +338,11 @@ void Shell::SetDisplayWorkAreaInsets(Window* contains, } void Shell::OnLoginStateChanged(user::LoginStatus status) { + if (status != user::LOGGED_IN_NONE) { + // TODO(bshe): Primary root window controller may not be the controller to + // attach virtual keyboard. See http://crbug.com/303429 + InitKeyboard(GetPrimaryRootWindowController()); + } FOR_EACH_OBSERVER(ShellObserver, observers_, OnLoginStateChanged(status)); } @@ -876,6 +532,379 @@ void Shell::DoInitialWorkspaceAnimation() { DoInitialAnimation(); } +//////////////////////////////////////////////////////////////////////////////// +// Shell, private: + +Shell::Shell(ShellDelegate* delegate) + : screen_(new ScreenAsh), + target_root_window_(NULL), + scoped_target_root_window_(NULL), + delegate_(delegate), + window_positioner_(new WindowPositioner), + activation_client_(NULL), +#if defined(OS_CHROMEOS) && defined(USE_X11) + output_configurator_(new chromeos::OutputConfigurator()), +#endif // defined(OS_CHROMEOS) + native_cursor_manager_(new AshNativeCursorManager), + cursor_manager_(scoped_ptr<views::corewm::NativeCursorManager>( + native_cursor_manager_)), + browser_context_(NULL), + simulate_modal_window_open_for_testing_(false), + is_touch_hud_projection_enabled_(false) { + DCHECK(delegate_.get()); + display_manager_.reset(new internal::DisplayManager); + + ANNOTATE_LEAKING_OBJECT_PTR(screen_); // see crbug.com/156466 + gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_ALTERNATE, screen_); + if (!gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE)) + gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_); + display_controller_.reset(new DisplayController); +#if defined(OS_CHROMEOS) && defined(USE_X11) + bool is_panel_fitting_disabled = + content::GpuDataManager::GetInstance()->IsFeatureBlacklisted( + gpu::GPU_FEATURE_TYPE_PANEL_FITTING); + + output_configurator_->Init(!is_panel_fitting_disabled); + + base::MessagePumpX11::Current()->AddDispatcherForRootWindow( + output_configurator()); + // We can't do this with a root window listener because XI_HierarchyChanged + // messages don't have a target window. + base::MessagePumpX11::Current()->AddObserver(output_configurator()); +#endif // defined(OS_CHROMEOS) + +#if defined(OS_CHROMEOS) + internal::PowerStatus::Initialize(); +#endif +} + +Shell::~Shell() { + TRACE_EVENT0("shutdown", "ash::Shell::Destructor"); + + views::FocusManagerFactory::Install(NULL); + + // Remove the focus from any window. This will prevent overhead and side + // effects (e.g. crashes) from changing focus during shutdown. + // See bug crbug.com/134502. + aura::client::GetFocusClient(GetPrimaryRootWindow())->FocusWindow(NULL); + + // Please keep in same order as in Init() because it's easy to miss one. + if (window_modality_controller_) + window_modality_controller_.reset(); + RemovePreTargetHandler(event_rewriter_filter_.get()); + RemovePreTargetHandler(user_activity_detector_.get()); + RemovePreTargetHandler(overlay_filter_.get()); + RemovePreTargetHandler(input_method_filter_.get()); + if (mouse_cursor_filter_) + RemovePreTargetHandler(mouse_cursor_filter_.get()); + RemovePreTargetHandler(system_gesture_filter_.get()); + RemovePreTargetHandler(keyboard_metrics_filter_.get()); + RemovePreTargetHandler(event_transformation_handler_.get()); + RemovePreTargetHandler(accelerator_filter_.get()); + + // TooltipController is deleted with the Shell so removing its references. + RemovePreTargetHandler(tooltip_controller_.get()); + + // AppList needs to be released before shelf layout manager, which is + // destroyed with launcher container in the loop below. However, app list + // container is now on top of launcher container and released after it. + // TODO(xiyuan): Move it back when app list container is no longer needed. + app_list_controller_.reset(); + + // Destroy SystemTrayDelegate before destroying the status area(s). + system_tray_delegate_->Shutdown(); + system_tray_delegate_.reset(); + + locale_notification_controller_.reset(); + + // Drag-and-drop must be canceled prior to close all windows. + drag_drop_controller_.reset(); + + // Destroy all child windows including widgets. + display_controller_->CloseChildWindows(); + + // Destroy SystemTrayNotifier after destroying SystemTray as TrayItems + // needs to remove observers from it. + system_tray_notifier_.reset(); + + // These need a valid Shell instance to clean up properly, so explicitly + // delete them before invalidating the instance. + // Alphabetical. TODO(oshima): sort. + magnification_controller_.reset(); + partial_magnification_controller_.reset(); + resize_shadow_controller_.reset(); + shadow_controller_.reset(); + tooltip_controller_.reset(); + event_client_.reset(); + window_cycle_controller_.reset(); + nested_dispatcher_controller_.reset(); + user_action_client_.reset(); + visibility_controller_.reset(); + launcher_delegate_.reset(); + launcher_model_.reset(); + video_detector_.reset(); + + power_button_controller_.reset(); + lock_state_controller_.reset(); + mru_window_tracker_.reset(); + + resolution_notification_controller_.reset(); + desktop_background_controller_.reset(); + + // This also deletes all RootWindows. Note that we invoke Shutdown() on + // DisplayController before resetting |display_controller_|, since destruction + // of its owned RootWindowControllers relies on the value. + display_controller_->Shutdown(); + display_controller_.reset(); + screen_position_controller_.reset(); + + keyboard_controller_.reset(); + +#if defined(OS_CHROMEOS) && defined(USE_X11) + if (display_change_observer_) + output_configurator_->RemoveObserver(display_change_observer_.get()); + if (output_configurator_animation_) + output_configurator_->RemoveObserver(output_configurator_animation_.get()); + if (display_error_observer_) + output_configurator_->RemoveObserver(display_error_observer_.get()); + base::MessagePumpX11::Current()->RemoveDispatcherForRootWindow( + output_configurator()); + base::MessagePumpX11::Current()->RemoveObserver(output_configurator()); + display_change_observer_.reset(); +#endif // defined(OS_CHROMEOS) + +#if defined(OS_CHROMEOS) + internal::PowerStatus::Shutdown(); +#endif + + DCHECK(instance_ == this); + instance_ = NULL; +} + +void Shell::Init() { + CommandLine* command_line = CommandLine::ForCurrentProcess(); + + delegate_->PreInit(); + bool display_initialized = false; +#if defined(OS_CHROMEOS) && defined(USE_X11) + output_configurator_animation_.reset( + new internal::OutputConfiguratorAnimation()); + output_configurator_->AddObserver(output_configurator_animation_.get()); + if (base::SysInfo::IsRunningOnChromeOS()) { + display_change_observer_.reset(new internal::DisplayChangeObserver); + // Register |display_change_observer_| first so that the rest of + // observer gets invoked after the root windows are configured. + output_configurator_->AddObserver(display_change_observer_.get()); + display_error_observer_.reset(new internal::DisplayErrorObserver()); + output_configurator_->AddObserver(display_error_observer_.get()); + output_configurator_->set_state_controller(display_change_observer_.get()); + if (!command_line->HasSwitch(ash::switches::kAshDisableSoftwareMirroring)) + output_configurator_->set_mirroring_controller(display_manager_.get()); + output_configurator_->Start( + delegate_->IsFirstRunAfterBoot() ? kChromeOsBootColor : 0); + display_initialized = true; + } +#endif // defined(OS_CHROMEOS) && defined(USE_X11) + if (!display_initialized) + display_manager_->InitFromCommandLine(); + + // Install the custom factory first so that views::FocusManagers for Tray, + // Launcher, and WallPaper could be created by the factory. + views::FocusManagerFactory::Install(new AshFocusManagerFactory); + + // The WindowModalityController needs to be at the front of the input event + // pretarget handler list to ensure that it processes input events when modal + // windows are active. + window_modality_controller_.reset( + new views::corewm::WindowModalityController(this)); + + AddPreTargetHandler(this); + + env_filter_.reset(new views::corewm::CompoundEventFilter); + AddPreTargetHandler(env_filter_.get()); + + // Env creates the compositor. Historically it seems to have been implicitly + // initialized first by the ActivationController, but now that FocusController + // no longer does this we need to do it explicitly. + aura::Env::GetInstance(); + views::corewm::FocusController* focus_controller = + new views::corewm::FocusController(new wm::AshFocusRules); + focus_client_.reset(focus_controller); + activation_client_ = focus_controller; + activation_client_->AddObserver(this); + focus_cycler_.reset(new internal::FocusCycler()); + + screen_position_controller_.reset(new internal::ScreenPositionController); + root_window_host_factory_.reset(delegate_->CreateRootWindowHostFactory()); + + display_controller_->Start(); + display_controller_->InitPrimaryDisplay(); + aura::RootWindow* root_window = display_controller_->GetPrimaryRootWindow(); + target_root_window_ = root_window; + + resolution_notification_controller_.reset( + new internal::ResolutionNotificationController); + + cursor_manager_.SetDisplay(DisplayController::GetPrimaryDisplay()); + + nested_dispatcher_controller_.reset(new NestedDispatcherController); + accelerator_controller_.reset(new AcceleratorController); + + // The order in which event filters are added is significant. + event_rewriter_filter_.reset(new internal::EventRewriterEventFilter); + AddPreTargetHandler(event_rewriter_filter_.get()); + + // UserActivityDetector passes events to observers, so let them get + // rewritten first. + user_activity_detector_.reset(new UserActivityDetector); + AddPreTargetHandler(user_activity_detector_.get()); + + overlay_filter_.reset(new internal::OverlayEventFilter); + AddPreTargetHandler(overlay_filter_.get()); + AddShellObserver(overlay_filter_.get()); + + input_method_filter_.reset(new views::corewm::InputMethodEventFilter( + root_window->GetAcceleratedWidget())); + AddPreTargetHandler(input_method_filter_.get()); + + accelerator_filter_.reset(new internal::AcceleratorFilter); + AddPreTargetHandler(accelerator_filter_.get()); + + event_transformation_handler_.reset(new internal::EventTransformationHandler); + AddPreTargetHandler(event_transformation_handler_.get()); + + system_gesture_filter_.reset(new internal::SystemGestureEventFilter); + AddPreTargetHandler(system_gesture_filter_.get()); + + keyboard_metrics_filter_.reset(new internal::KeyboardUMAEventFilter); + AddPreTargetHandler(keyboard_metrics_filter_.get()); + + // The keyboard system must be initialized before the RootWindowController is + // created. + if (keyboard::IsKeyboardEnabled()) + keyboard::InitializeKeyboard(); + + lock_state_controller_.reset(new LockStateController); + power_button_controller_.reset(new PowerButtonController( + lock_state_controller_.get())); + AddShellObserver(lock_state_controller_.get()); + + drag_drop_controller_.reset(new internal::DragDropController); + mouse_cursor_filter_.reset(new internal::MouseCursorEventFilter()); + PrependPreTargetHandler(mouse_cursor_filter_.get()); + + // Create Controllers that may need root window. + // TODO(oshima): Move as many controllers before creating + // RootWindowController as possible. + visibility_controller_.reset(new AshVisibilityController); + user_action_client_.reset(delegate_->CreateUserActionClient()); + + magnification_controller_.reset( + MagnificationController::CreateInstance()); + mru_window_tracker_.reset(new MruWindowTracker(activation_client_)); + + partial_magnification_controller_.reset( + new PartialMagnificationController()); + + high_contrast_controller_.reset(new HighContrastController); + video_detector_.reset(new VideoDetector); + window_cycle_controller_.reset(new WindowCycleController()); + window_selector_controller_.reset(new WindowSelectorController()); + + tooltip_controller_.reset(new views::corewm::TooltipController( + gfx::SCREEN_TYPE_ALTERNATE)); + AddPreTargetHandler(tooltip_controller_.get()); + + event_client_.reset(new internal::EventClientImpl); + + // This controller needs to be set before SetupManagedWindowMode. + desktop_background_controller_.reset(new DesktopBackgroundController()); + user_wallpaper_delegate_.reset(delegate_->CreateUserWallpaperDelegate()); + + // StatusAreaWidget uses Shell's CapsLockDelegate. + caps_lock_delegate_.reset(delegate_->CreateCapsLockDelegate()); + + session_state_delegate_.reset(delegate_->CreateSessionStateDelegate()); + + if (!command_line->HasSwitch(views::corewm::switches::kNoDropShadows)) { + resize_shadow_controller_.reset(new internal::ResizeShadowController()); + shadow_controller_.reset( + new views::corewm::ShadowController(activation_client_)); + } + + // Create system_tray_notifier_ before the delegate. + system_tray_notifier_.reset(new ash::SystemTrayNotifier()); + + // Initialize system_tray_delegate_ before initializing StatusAreaWidget. + system_tray_delegate_.reset(delegate()->CreateSystemTrayDelegate()); + DCHECK(system_tray_delegate_.get()); + + internal::RootWindowController* root_window_controller = + new internal::RootWindowController(root_window); + InitRootWindowController(root_window_controller, + delegate_->IsFirstRunAfterBoot()); + InitKeyboard(root_window_controller); + + locale_notification_controller_.reset( + new internal::LocaleNotificationController); + + // Initialize system_tray_delegate_ after StatusAreaWidget is created. + system_tray_delegate_->Initialize(); + + display_controller_->InitSecondaryDisplays(); + + // Force Layout + root_window_controller->root_window_layout()->OnWindowResized(); + + // It needs to be created after OnWindowResized has been called, otherwise the + // widget will not paint when restoring after a browser crash. Also it needs + // to be created after InitSecondaryDisplays() to initialize the wallpapers in + // the correct size. + user_wallpaper_delegate_->InitializeWallpaper(); + + if (initially_hide_cursor_) + cursor_manager_.HideCursor(); + cursor_manager_.SetCursor(ui::kCursorPointer); + + if (!cursor_manager_.IsCursorVisible()) { + // Cursor might have been hidden by something other than chrome. + // Let the first mouse event show the cursor. + env_filter_->set_cursor_hidden_by_filter(true); + } + + // Set accelerator controller delegates. +#if defined(OS_CHROMEOS) + accelerator_controller_->SetBrightnessControlDelegate( + scoped_ptr<ash::BrightnessControlDelegate>( + new ash::system::BrightnessControllerChromeos).Pass()); +#endif + + // The compositor thread and main message loop have to be running in + // order to create mirror window. Run it after the main message loop + // is started. + base::MessageLoopForUI::current()->PostTask( + FROM_HERE, + base::Bind(&internal::DisplayManager::CreateMirrorWindowIfAny, + base::Unretained(display_manager_.get()))); +} + +void Shell::InitKeyboard(internal::RootWindowController* root) { + if (keyboard::IsKeyboardEnabled()) { + if (keyboard_controller_.get()) { + RootWindowControllerList controllers = GetAllRootWindowControllers(); + for (RootWindowControllerList::iterator iter = controllers.begin(); + iter != controllers.end(); ++iter) { + (*iter)->DeactivateKeyboard(keyboard_controller_.get()); + } + } + keyboard::KeyboardControllerProxy* proxy = + delegate_->CreateKeyboardControllerProxy(); + keyboard_controller_.reset( + new keyboard::KeyboardController(proxy)); + root->ActivateKeyboard(keyboard_controller_.get()); + } +} + void Shell::InitRootWindowController( internal::RootWindowController* controller, bool first_run_after_boot) { @@ -910,9 +939,6 @@ void Shell::InitRootWindowController( controller->Init(first_run_after_boot); } -//////////////////////////////////////////////////////////////////////////////// -// Shell, private: - bool Shell::CanWindowReceiveEvents(aura::Window* window) { RootWindowControllerList controllers = GetAllRootWindowControllers(); for (RootWindowControllerList::iterator iter = controllers.begin(); diff --git a/ash/shell.h b/ash/shell.h index f3d47e8..d7a6632 100644 --- a/ash/shell.h +++ b/ash/shell.h @@ -49,6 +49,11 @@ class ImageSkia; class Point; class Rect; } + +namespace keyboard { +class KeyboardController; +} + namespace ui { class Layer; } @@ -276,6 +281,10 @@ class ASH_EXPORT Shell void AddShellObserver(ShellObserver* observer); void RemoveShellObserver(ShellObserver* observer); + keyboard::KeyboardController* keyboard_controller() { + return keyboard_controller_.get(); + } + AcceleratorController* accelerator_controller() { return accelerator_controller_.get(); } @@ -502,6 +511,9 @@ class ASH_EXPORT Shell void Init(); + // Initializes virtual keyboard controller and attaches it to |root|. + void InitKeyboard(internal::RootWindowController* root); + // Initializes the root window and root window controller so that it // can host browser windows. |first_run_after_boot| is true for the // primary display only first time after boot. @@ -540,6 +552,7 @@ class ASH_EXPORT Shell std::vector<WindowAndBoundsPair> to_restore_; + scoped_ptr<keyboard::KeyboardController> keyboard_controller_; scoped_ptr<NestedDispatcherController> nested_dispatcher_controller_; scoped_ptr<AcceleratorController> accelerator_controller_; scoped_ptr<ShellDelegate> delegate_; diff --git a/chrome/browser/extensions/api/input/input.cc b/chrome/browser/extensions/api/input/input.cc index c695bf1..627dcc2 100644 --- a/chrome/browser/extensions/api/input/input.cc +++ b/chrome/browser/extensions/api/input/input.cc @@ -87,8 +87,7 @@ bool VirtualKeyboardPrivateHideKeyboardFunction::RunImpl() { #if defined(USE_ASH) DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); - ash::Shell::GetPrimaryRootWindowController()->keyboard_controller()-> - HideKeyboard(); + ash::Shell::GetInstance()->keyboard_controller()->HideKeyboard(); return true; #endif diff --git a/chrome/browser/ui/ash/ash_keyboard_controller_proxy.cc b/chrome/browser/ui/ash/ash_keyboard_controller_proxy.cc index dfa012a..2b5c833 100644 --- a/chrome/browser/ui/ash/ash_keyboard_controller_proxy.cc +++ b/chrome/browser/ui/ash/ash_keyboard_controller_proxy.cc @@ -140,6 +140,11 @@ bool AshKeyboardControllerProxy::OnMessageReceived( void AshKeyboardControllerProxy::ShowKeyboardContainer( aura::Window* container) { + // TODO(bshe): Implement logic to decide which root window should display + // virtual keyboard. http://crbug.com/303429 + if (container->GetRootWindow() != ash::Shell::GetPrimaryRootWindow()) + NOTIMPLEMENTED(); + KeyboardControllerProxy::ShowKeyboardContainer(container); gfx::Rect showing_area = ash::DisplayController::GetPrimaryDisplay().work_area(); diff --git a/ui/keyboard/keyboard_controller.cc b/ui/keyboard/keyboard_controller.cc index 83e7f32..bcf6e13 100644 --- a/ui/keyboard/keyboard_controller.cc +++ b/ui/keyboard/keyboard_controller.cc @@ -122,7 +122,6 @@ class KeyboardLayoutManager : public aura::LayoutManager { KeyboardController::KeyboardController(KeyboardControllerProxy* proxy) : proxy_(proxy), - container_(NULL), input_method_(NULL), keyboard_visible_(false), weak_factory_(this) { @@ -132,21 +131,22 @@ KeyboardController::KeyboardController(KeyboardControllerProxy* proxy) } KeyboardController::~KeyboardController() { - if (container_) + if (container_.get()) container_->RemoveObserver(this); if (input_method_) input_method_->RemoveObserver(this); } aura::Window* KeyboardController::GetContainerWindow() { - if (!container_) { - container_ = new aura::Window(new KeyboardWindowDelegate()); + if (!container_.get()) { + container_.reset(new aura::Window(new KeyboardWindowDelegate())); container_->SetName("KeyboardContainer"); + container_->set_owned_by_parent(false); container_->Init(ui::LAYER_NOT_DRAWN); container_->AddObserver(this); - container_->SetLayoutManager(new KeyboardLayoutManager(container_)); + container_->SetLayoutManager(new KeyboardLayoutManager(container_.get())); } - return container_; + return container_.get(); } void KeyboardController::HideKeyboard() { @@ -156,7 +156,7 @@ void KeyboardController::HideKeyboard() { observer_list_, OnKeyboardBoundsChanging(gfx::Rect())); - proxy_->HideKeyboardContainer(container_); + proxy_->HideKeyboardContainer(container_.get()); } void KeyboardController::AddObserver(KeyboardControllerObserver* observer) { @@ -169,18 +169,13 @@ void KeyboardController::RemoveObserver(KeyboardControllerObserver* observer) { void KeyboardController::OnWindowHierarchyChanged( const HierarchyChangeParams& params) { - if (params.new_parent && params.target == container_) + if (params.new_parent && params.target == container_.get()) OnTextInputStateChanged(proxy_->GetInputMethod()->GetTextInputClient()); } -void KeyboardController::OnWindowDestroying(aura::Window* window) { - DCHECK_EQ(container_, window); - container_ = NULL; -} - void KeyboardController::OnTextInputStateChanged( const ui::TextInputClient* client) { - if (!container_) + if (!container_.get()) return; bool was_showing = keyboard_visible_; @@ -197,7 +192,7 @@ void KeyboardController::OnTextInputStateChanged( container_->layout_manager()->OnWindowResized(); } proxy_->SetUpdateInputType(type); - container_->parent()->StackChildAtTop(container_); + container_->parent()->StackChildAtTop(container_.get()); should_show = true; } @@ -212,7 +207,7 @@ void KeyboardController::OnTextInputStateChanged( KeyboardControllerObserver, observer_list_, OnKeyboardBoundsChanging(container_->children()[0]->bounds())); - proxy_->ShowKeyboardContainer(container_); + proxy_->ShowKeyboardContainer(container_.get()); } else { // Set the visibility state here so that any queries for visibility // before the timer fires returns the correct future value. diff --git a/ui/keyboard/keyboard_controller.h b/ui/keyboard/keyboard_controller.h index e9e5890..dd044dc 100644 --- a/ui/keyboard/keyboard_controller.h +++ b/ui/keyboard/keyboard_controller.h @@ -39,8 +39,8 @@ class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver, explicit KeyboardController(KeyboardControllerProxy* proxy); virtual ~KeyboardController(); - // Returns the container for the keyboard, which is then owned by the caller. - // It is the responsibility of the caller to Show() the returned window. + // Returns the container for the keyboard, which is owned by + // KeyboardController. aura::Window* GetContainerWindow(); // Hides virtual keyboard and notifies observer bounds change. @@ -59,7 +59,6 @@ class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver, // aura::WindowObserver overrides virtual void OnWindowHierarchyChanged( const HierarchyChangeParams& params) OVERRIDE; - virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; // InputMethodObserver overrides virtual void OnTextInputTypeChanged( @@ -80,7 +79,7 @@ class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver, bool WillHideKeyboard() const; scoped_ptr<KeyboardControllerProxy> proxy_; - aura::Window* container_; + scoped_ptr<aura::Window> container_; ui::InputMethod* input_method_; bool keyboard_visible_; base::WeakPtrFactory<KeyboardController> weak_factory_; diff --git a/ui/keyboard/keyboard_controller_unittest.cc b/ui/keyboard/keyboard_controller_unittest.cc index 1d46116..3650520 100644 --- a/ui/keyboard/keyboard_controller_unittest.cc +++ b/ui/keyboard/keyboard_controller_unittest.cc @@ -227,7 +227,7 @@ class KeyboardControllerTest : public testing::Test { }; TEST_F(KeyboardControllerTest, KeyboardSize) { - scoped_ptr<aura::Window> container(controller()->GetContainerWindow()); + aura::Window* container(controller()->GetContainerWindow()); gfx::Rect bounds(0, 0, 100, 100); container->SetBounds(bounds); @@ -252,11 +252,10 @@ TEST_F(KeyboardControllerTest, ClickDoesNotFocusKeyboard) { window->Show(); window->Focus(); - scoped_ptr<aura::Window> keyboard_container( - controller()->GetContainerWindow()); + aura::Window* keyboard_container(controller()->GetContainerWindow()); keyboard_container->SetBounds(root_bounds); - root_window()->AddChild(keyboard_container.get()); + root_window()->AddChild(keyboard_container); keyboard_container->Show(); ShowKeyboard(); @@ -297,12 +296,11 @@ TEST_F(KeyboardControllerTest, VisibilityChangeWithTextInputTypeChange) { TestTextInputClient no_input_client_1(ui::TEXT_INPUT_TYPE_NONE); input_method->SetFocusedTextInputClient(&input_client_0); - scoped_ptr<aura::Window> keyboard_container( - controller()->GetContainerWindow()); + aura::Window* keyboard_container(controller()->GetContainerWindow()); scoped_ptr<KeyboardContainerObserver> keyboard_container_observer( - new KeyboardContainerObserver(keyboard_container.get())); + new KeyboardContainerObserver(keyboard_container)); keyboard_container->SetBounds(root_bounds); - root_window()->AddChild(keyboard_container.get()); + root_window()->AddChild(keyboard_container); EXPECT_TRUE(keyboard_container->IsVisible()); |