Skip to content

Commit

Permalink
mash: Port KeyboardUIMus to mojo:ash; remove sysui.
Browse files Browse the repository at this point in the history
Move ash/sysui/keyboard_ui_mus.* to ash/mus.
Instantiate KeyboardUIMus from WmShellMus.
Avoid null pointer access in mash_unittests.

Cleanup [AshWindowTreeHost|Shell]InitParams.
Remove Shell::in_mus_ and accessor.
Remove ash/sysui directory and contents.

BUG=616857
TEST=No ChromeOS keyboard changes.
R=sky@chromium.org
TBR=dpranke@chromium.org

Review-Url: https://codereview.chromium.org/2339633002
Cr-Commit-Position: refs/heads/master@{#418381}
  • Loading branch information
msw authored and Commit bot committed Sep 13, 2016
1 parent 6e0ec0d commit 15156bf
Show file tree
Hide file tree
Showing 25 changed files with 54 additions and 1,118 deletions.
2 changes: 0 additions & 2 deletions ash/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,6 @@ component("ash") {
"high_contrast/high_contrast_controller.h",
"host/ash_window_tree_host.cc",
"host/ash_window_tree_host.h",
"host/ash_window_tree_host_init_params.cc",
"host/ash_window_tree_host_init_params.h",
"host/ash_window_tree_host_platform.cc",
"host/ash_window_tree_host_platform.h",
Expand Down Expand Up @@ -693,7 +692,6 @@ component("ash") {
"shelf/shelf_window_targeter.h",
"shell.cc",
"shell.h",
"shell_init_params.cc",
"shell_init_params.h",
"snap_to_pixel_layout_manager.cc",
"snap_to_pixel_layout_manager.h",
Expand Down
20 changes: 0 additions & 20 deletions ash/host/ash_window_tree_host_init_params.cc

This file was deleted.

16 changes: 1 addition & 15 deletions ash/host/ash_window_tree_host_init_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,14 @@
#ifndef ASH_HOST_WINDOW_TREE_HOST_INIT_PARAMS_H_
#define ASH_HOST_WINDOW_TREE_HOST_INIT_PARAMS_H_

#include "build/build_config.h"

#if defined(OS_WIN)
#include <windows.h>
#endif

#include "ash/ash_export.h"
#include "ui/gfx/geometry/rect.h"

namespace ash {

struct ASH_EXPORT AshWindowTreeHostInitParams {
AshWindowTreeHostInitParams();
~AshWindowTreeHostInitParams();

gfx::Rect initial_bounds;

bool offscreen;

#if defined(OS_WIN)
HWND remote_hwnd;
#endif
bool offscreen = false;
};

} // namespace ash
Expand Down
3 changes: 3 additions & 0 deletions ash/mus/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ source_set("lib") {
"frame/detached_title_area_renderer.cc",
"frame/detached_title_area_renderer.h",
"frame/detached_title_area_renderer_host.h",
"keyboard_ui_mus.cc",
"keyboard_ui_mus.h",
"layout_manager.cc",
"layout_manager.h",
"move_event_handler.cc",
Expand Down Expand Up @@ -91,6 +93,7 @@ source_set("lib") {
"//components/wallpaper",
"//ui/app_list/presenter",
"//ui/app_list/presenter:mojom",
"//ui/keyboard:mojom",
"//ui/message_center",
]

Expand Down
7 changes: 3 additions & 4 deletions ash/mus/bridge/wm_shell_mus.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <utility>

#include "ash/common/accelerators/accelerator_controller.h"
#include "ash/common/keyboard/keyboard_ui.h"
#include "ash/common/session/session_state_delegate.h"
#include "ash/common/shell_delegate.h"
#include "ash/common/shell_observer.h"
Expand All @@ -28,6 +27,7 @@
#include "ash/mus/bridge/workspace_event_handler_mus.h"
#include "ash/mus/container_ids.h"
#include "ash/mus/drag_window_resizer.h"
#include "ash/mus/keyboard_ui_mus.h"
#include "ash/mus/root_window_controller.h"
#include "ash/mus/window_manager.h"
#include "ash/shared/immersive_fullscreen_controller.h"
Expand Down Expand Up @@ -135,10 +135,9 @@ WmShellMus::WmShellMus(

CreateMruWindowTracker();

SetSystemTrayDelegate(base::WrapUnique(new DefaultSystemTrayDelegate));
SetSystemTrayDelegate(base::MakeUnique<DefaultSystemTrayDelegate>());

// TODO(jamescook): Port ash::sysui::KeyboardUIMus and use it here.
SetKeyboardUI(KeyboardUI::Create());
SetKeyboardUI(KeyboardUIMus::Create(window_manager_->connector()));

wallpaper_delegate()->InitializeWallpaper();
}
Expand Down
12 changes: 7 additions & 5 deletions ash/sysui/keyboard_ui_mus.cc → ash/mus/keyboard_ui_mus.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/sysui/keyboard_ui_mus.h"
#include "ash/mus/keyboard_ui_mus.h"

#include "ash/common/keyboard/keyboard_ui_observer.h"
#include "base/memory/ptr_util.h"
Expand All @@ -12,17 +12,19 @@ namespace ash {

KeyboardUIMus::KeyboardUIMus(::shell::Connector* connector)
: is_enabled_(false), observer_binding_(this) {
// TODO(sky): should be something like mojo:keyboard, but need mapping.
connector->ConnectToInterface("exe:chrome", &keyboard_);
keyboard_->AddObserver(observer_binding_.CreateInterfacePtrAndBind());
if (connector) {
// TODO(sky): should be something like mojo:keyboard, but need mapping.
connector->ConnectToInterface("exe:chrome", &keyboard_);
keyboard_->AddObserver(observer_binding_.CreateInterfacePtrAndBind());
}
}

KeyboardUIMus::~KeyboardUIMus() {}

// static
std::unique_ptr<KeyboardUI> KeyboardUIMus::Create(
::shell::Connector* connector) {
return base::WrapUnique(new KeyboardUIMus(connector));
return base::MakeUnique<KeyboardUIMus>(connector);
}

void KeyboardUIMus::Hide() {
Expand Down
6 changes: 3 additions & 3 deletions ash/sysui/keyboard_ui_mus.h → ash/mus/keyboard_ui_mus.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ASH_SYSUI_KEYBOARD_UI_MUS_H_
#define ASH_SYSUI_KEYBOARD_UI_MUS_H_
#ifndef ASH_MUS_KEYBOARD_UI_MUS_H_
#define ASH_MUS_KEYBOARD_UI_MUS_H_

#include <memory>

Expand Down Expand Up @@ -48,4 +48,4 @@ class KeyboardUIMus : public KeyboardUI,

} // namespace ash

#endif // ASH_SYSUI_KEYBOARD_UI_MUS_H_
#endif // ASH_MUS_KEYBOARD_UI_MUS_H_
17 changes: 1 addition & 16 deletions ash/root_window_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -836,22 +836,7 @@ void RootWindowController::OnTouchHudProjectionToggled(bool enabled) {
}

RootWindowController* GetRootWindowController(const aura::Window* root_window) {
if (!root_window)
return nullptr;

if (Shell::GetInstance()->in_mus()) {
// On mus, like desktop aura, each top-level widget has its own root window,
// so |root_window| is not necessarily the display's root. For now, just
// the use the primary display root.
// TODO(jamescook): Multi-display support. This depends on how mus windows
// will be owned by displays.
aura::Window* primary_root_window = Shell::GetInstance()
->window_tree_host_manager()
->GetPrimaryRootWindow();
return GetRootWindowSettings(primary_root_window)->controller;
}

return GetRootWindowSettings(root_window)->controller;
return root_window ? GetRootWindowSettings(root_window)->controller : nullptr;
}

} // namespace ash
64 changes: 17 additions & 47 deletions ash/shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,6 @@ class AshVisibilityController : public ::wm::VisibilityController {
DISALLOW_COPY_AND_ASSIGN(AshVisibilityController);
};

AshWindowTreeHostInitParams ShellInitParamsToAshWindowTreeHostInitParams(
const ShellInitParams& shell_init_params) {
AshWindowTreeHostInitParams ash_init_params;
#if defined(OS_WIN)
ash_init_params.remote_hwnd = shell_init_params.remote_hwnd;
#endif
return ash_init_params;
}

} // namespace

// static
Expand Down Expand Up @@ -340,8 +331,6 @@ void Shell::CreateShelf() {
}

void Shell::CreateKeyboard() {
if (in_mus_)
return;
// TODO(bshe): Primary root window controller may not be the controller to
// attach virtual keyboard. See http://crbug.com/303429
InitKeyboard();
Expand All @@ -352,8 +341,6 @@ void Shell::CreateKeyboard() {
void Shell::DeactivateKeyboard() {
// TODO(jamescook): Move keyboard create and hide into WmShell.
wm_shell_->keyboard_ui()->Hide();
if (in_mus_)
return;
if (keyboard::KeyboardController::GetInstance()) {
RootWindowControllerList controllers = GetAllRootWindowControllers();
for (RootWindowControllerList::iterator iter = controllers.begin();
Expand Down Expand Up @@ -620,28 +607,24 @@ Shell::~Shell() {
void Shell::Init(const ShellInitParams& init_params) {
wm_shell_->Initialize(init_params.blocking_pool);

in_mus_ = init_params.in_mus;

immersive_handler_factory_ = base::MakeUnique<ImmersiveHandlerFactoryAsh>();

#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
DCHECK(in_mus_) << "linux desktop does not support ash.";
NOTREACHED() << "linux desktop does not support ash.";
#endif

scoped_overview_animation_settings_factory_.reset(
new ScopedOverviewAnimationSettingsFactoryAura);
window_positioner_.reset(new WindowPositioner(wm_shell_.get()));

if (!in_mus_) {
native_cursor_manager_ = new AshNativeCursorManager;
native_cursor_manager_ = new AshNativeCursorManager;
#if defined(OS_CHROMEOS)
cursor_manager_.reset(
new CursorManager(base::WrapUnique(native_cursor_manager_)));
cursor_manager_.reset(
new CursorManager(base::WrapUnique(native_cursor_manager_)));
#else
cursor_manager_.reset(
new ::wm::CursorManager(base::WrapUnique(native_cursor_manager_)));
cursor_manager_.reset(
new ::wm::CursorManager(base::WrapUnique(native_cursor_manager_)));
#endif
}

wm_shell_->delegate()->PreInit();
bool display_initialized = display_manager_->InitFromCommandLine();
Expand All @@ -650,21 +633,15 @@ void Shell::Init(const ShellInitParams& init_params) {
display_manager_.get(), window_tree_host_manager_.get()));

#if defined(OS_CHROMEOS)
// When running as part of mash display configuration is handled by the mus
// process, so we won't try to configure displays here.
if (in_mus_) {
display_configurator_->set_configure_display(false);
} else {

#if defined(USE_OZONE)
display_configurator_->Init(
ui::OzonePlatform::GetInstance()->CreateNativeDisplayDelegate(),
!gpu_support_->IsPanelFittingDisabled());
display_configurator_->Init(
ui::OzonePlatform::GetInstance()->CreateNativeDisplayDelegate(),
!gpu_support_->IsPanelFittingDisabled());
#elif defined(USE_X11)
display_configurator_->Init(
base::MakeUnique<ui::NativeDisplayDelegateX11>(),
!gpu_support_->IsPanelFittingDisabled());
display_configurator_->Init(base::MakeUnique<ui::NativeDisplayDelegateX11>(),
!gpu_support_->IsPanelFittingDisabled());
#endif
}

// The DBusThreadManager must outlive this Shell. See the DCHECK in ~Shell.
chromeos::DBusThreadManager* dbus_thread_manager =
Expand All @@ -674,8 +651,7 @@ void Shell::Init(const ShellInitParams& init_params) {
display_configurator_->AddObserver(projecting_observer_.get());
wm_shell_->AddShellObserver(projecting_observer_.get());

if (!in_mus_ && !display_initialized &&
base::SysInfo::IsRunningOnChromeOS()) {
if (!display_initialized && base::SysInfo::IsRunningOnChromeOS()) {
display_change_observer_.reset(new DisplayChangeObserver);
// Register |display_change_observer_| first so that the rest of
// observer gets invoked after the root windows are configured.
Expand Down Expand Up @@ -717,8 +693,8 @@ void Shell::Init(const ShellInitParams& init_params) {
screen_position_controller_.reset(new ScreenPositionController);

window_tree_host_manager_->Start();
window_tree_host_manager_->CreatePrimaryHost(
ShellInitParamsToAshWindowTreeHostInitParams(init_params));
AshWindowTreeHostInitParams ash_init_params;
window_tree_host_manager_->CreatePrimaryHost(ash_init_params);
aura::Window* root_window = window_tree_host_manager_->GetPrimaryRootWindow();
wm_shell_->set_root_window_for_new_windows(WmWindowAura::Get(root_window));

Expand Down Expand Up @@ -843,13 +819,10 @@ void Shell::Init(const ShellInitParams& init_params) {
// WindowTreeHostManager::InitDisplays()
// since TouchTransformerController listens on
// WindowTreeHostManager::Observer::OnDisplaysInitialized().
if (!in_mus_)
touch_transformer_controller_.reset(new TouchTransformerController());
touch_transformer_controller_.reset(new TouchTransformerController());
#endif // defined(OS_CHROMEOS)

wm_shell_->SetKeyboardUI(init_params.keyboard_factory.is_null()
? KeyboardUI::Create()
: init_params.keyboard_factory.Run());
wm_shell_->SetKeyboardUI(KeyboardUI::Create());

window_tree_host_manager_->InitHosts();

Expand Down Expand Up @@ -896,9 +869,6 @@ void Shell::Init(const ShellInitParams& init_params) {
}

void Shell::InitKeyboard() {
if (in_mus_)
return;

if (keyboard::IsKeyboardEnabled()) {
if (keyboard::KeyboardController::GetInstance()) {
RootWindowControllerList controllers = GetAllRootWindowControllers();
Expand Down
6 changes: 0 additions & 6 deletions ash/shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,6 @@ class ASH_EXPORT Shell : public SystemModalContainerEventFilterDelegate,
return is_touch_hud_projection_enabled_;
}

// TODO(sky): remove this. This was needed by sysui, but as sysui is going
// away it should no longer be needed.
bool in_mus() const { return in_mus_; }

#if defined(OS_CHROMEOS)
// Creates instance of FirstRunHelper. Caller is responsible for deleting
// returned object.
Expand Down Expand Up @@ -560,8 +556,6 @@ class ASH_EXPORT Shell : public SystemModalContainerEventFilterDelegate,

std::unique_ptr<ImmersiveHandlerFactoryAsh> immersive_handler_factory_;

bool in_mus_ = false;

DISALLOW_COPY_AND_ASSIGN(Shell);
};

Expand Down
22 changes: 0 additions & 22 deletions ash/shell_init_params.cc

This file was deleted.

Loading

0 comments on commit 15156bf

Please sign in to comment.