Skip to content

Commit

Permalink
mash: Convert virtual keyboard system tray item to wm common types
Browse files Browse the repository at this point in the history
This moves another dependency of StatusAreaWidget.

* Move KeyboardUI ownership from Shell to WmShell
* Move files to //ash/common

BUG=619636
TEST=ash_unittests

Review-Url: https://codereview.chromium.org/2103053004
Cr-Commit-Position: refs/heads/master@{#402741}
  • Loading branch information
jamescook authored and Commit bot committed Jun 29, 2016
1 parent 19ae39f commit c3fbf09
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 23 deletions.
4 changes: 2 additions & 2 deletions ash/ash.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@
'common/system/chromeos/tray_tracing.cc',
'common/system/chromeos/tray_tracing.h',
'common/system/chromeos/virtual_keyboard/virtual_keyboard_observer.h',
'common/system/chromeos/virtual_keyboard/virtual_keyboard_tray.cc',
'common/system/chromeos/virtual_keyboard/virtual_keyboard_tray.h',
'common/system/date/clock_observer.h',
'common/system/date/date_default_view.cc',
'common/system/date/date_default_view.h',
Expand Down Expand Up @@ -612,8 +614,6 @@
'system/chromeos/tray_caps_lock.h',
'system/chromeos/tray_display.cc',
'system/chromeos/tray_display.h',
'system/chromeos/virtual_keyboard/virtual_keyboard_tray.cc',
'system/chromeos/virtual_keyboard/virtual_keyboard_tray.h',
'system/keyboard_brightness/keyboard_brightness_control_delegate.h',
'system/overview/overview_button_tray.cc',
'system/overview/overview_button_tray.h',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/system/chromeos/virtual_keyboard/virtual_keyboard_tray.h"
#include "ash/common/system/chromeos/virtual_keyboard/virtual_keyboard_tray.h"

#include <algorithm>

#include "ash/common/keyboard/keyboard_ui.h"
#include "ash/common/material_design/material_design_controller.h"
#include "ash/common/shelf/shelf_constants.h"
#include "ash/common/shelf/wm_shelf_util.h"
#include "ash/common/system/tray/tray_constants.h"
#include "ash/common/system/tray/tray_utils.h"
#include "ash/shell.h"
#include "ash/common/wm_shell.h"
#include "grit/ash_resources.h"
#include "grit/ash_strings.h"
#include "ui/base/l10n/l10n_util.h"
Expand Down Expand Up @@ -43,14 +45,14 @@ VirtualKeyboardTray::VirtualKeyboardTray(WmShelf* wm_shelf)
button_->SetFocusBehavior(FocusBehavior::NEVER);
SetContentsBackground();
// The Shell may not exist in some unit tests.
if (Shell::HasInstance())
Shell::GetInstance()->keyboard_ui()->AddObserver(this);
if (WmShell::HasInstance())
WmShell::Get()->keyboard_ui()->AddObserver(this);
}

VirtualKeyboardTray::~VirtualKeyboardTray() {
// The Shell may not exist in some unit tests.
if (Shell::HasInstance())
Shell::GetInstance()->keyboard_ui()->RemoveObserver(this);
if (WmShell::HasInstance())
WmShell::Get()->keyboard_ui()->RemoveObserver(this);
}

void VirtualKeyboardTray::SetShelfAlignment(ShelfAlignment alignment) {
Expand Down Expand Up @@ -86,7 +88,7 @@ void VirtualKeyboardTray::HideBubbleWithView(
void VirtualKeyboardTray::ClickedOutsideBubble() {}

bool VirtualKeyboardTray::PerformAction(const ui::Event& event) {
Shell::GetInstance()->keyboard_ui()->Show();
WmShell::Get()->keyboard_ui()->Show();
return true;
}

Expand All @@ -97,7 +99,7 @@ void VirtualKeyboardTray::ButtonPressed(views::Button* sender,
}

void VirtualKeyboardTray::OnKeyboardEnabledStateChanged(bool new_value) {
SetVisible(Shell::GetInstance()->keyboard_ui()->IsEnabled());
SetVisible(WmShell::Get()->keyboard_ui()->IsEnabled());
}

} // namespace ash
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_SYSTEM_CHROMEOS_VIRTUAL_KEYBOARD_VIRTUAL_KEYBOARD_TRAY_H_
#define ASH_SYSTEM_CHROMEOS_VIRTUAL_KEYBOARD_VIRTUAL_KEYBOARD_TRAY_H_
#ifndef ASH_COMMON_SYSTEM_CHROMEOS_VIRTUAL_KEYBOARD_VIRTUAL_KEYBOARD_TRAY_H_
#define ASH_COMMON_SYSTEM_CHROMEOS_VIRTUAL_KEYBOARD_VIRTUAL_KEYBOARD_TRAY_H_

#include "ash/common/keyboard/keyboard_ui_observer.h"
#include "ash/common/system/tray/tray_background_view.h"
Expand Down Expand Up @@ -45,4 +45,4 @@ class VirtualKeyboardTray : public TrayBackgroundView,

} // namespace ash

#endif // ASH_SYSTEM_CHROMEOS_VIRTUAL_KEYBOARD_VIRTUAL_KEYBOARD_TRAY_H_
#endif // ASH_COMMON_SYSTEM_CHROMEOS_VIRTUAL_KEYBOARD_VIRTUAL_KEYBOARD_TRAY_H_
5 changes: 5 additions & 0 deletions ash/common/wm_shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "ash/common/wm_shell.h"

#include "ash/common/focus_cycler.h"
#include "ash/common/keyboard/keyboard_ui.h"
#include "ash/common/shell_window_ids.h"
#include "ash/common/system/chromeos/session/logout_confirmation_controller.h"
#include "ash/common/system/tray/system_tray_delegate.h"
Expand Down Expand Up @@ -56,6 +57,10 @@ bool WmShell::IsSystemModalWindowOpen() {
return false;
}

void WmShell::SetKeyboardUI(std::unique_ptr<KeyboardUI> keyboard_ui) {
keyboard_ui_ = std::move(keyboard_ui);
}

void WmShell::SetSystemTrayDelegate(
std::unique_ptr<SystemTrayDelegate> delegate) {
DCHECK(delegate);
Expand Down
6 changes: 6 additions & 0 deletions ash/common/wm_shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace ash {
class AccessibilityDelegate;
class DisplayInfo;
class FocusCycler;
class KeyboardUI;
class MruWindowTracker;
class SessionStateDelegate;
class ShellObserver;
Expand Down Expand Up @@ -58,6 +59,8 @@ class ASH_EXPORT WmShell {

FocusCycler* focus_cycler() { return focus_cycler_.get(); }

KeyboardUI* keyboard_ui() { return keyboard_ui_.get(); }

SystemTrayNotifier* system_tray_notifier() {
return system_tray_notifier_.get();
}
Expand Down Expand Up @@ -178,6 +181,8 @@ class ASH_EXPORT WmShell {
WmShell();
virtual ~WmShell();

void SetKeyboardUI(std::unique_ptr<KeyboardUI> keyboard_ui);

// Sets and initializes the |delegate|.
void SetSystemTrayDelegate(std::unique_ptr<SystemTrayDelegate> delegate);
void DeleteSystemTrayDelegate();
Expand All @@ -190,6 +195,7 @@ class ASH_EXPORT WmShell {
static WmShell* instance_;

std::unique_ptr<FocusCycler> focus_cycler_;
std::unique_ptr<KeyboardUI> keyboard_ui_;
std::unique_ptr<SystemTrayNotifier> system_tray_notifier_;
std::unique_ptr<SystemTrayDelegate> system_tray_delegate_;
std::unique_ptr<WindowSelectorController> window_selector_controller_;
Expand Down
9 changes: 5 additions & 4 deletions ash/shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,8 @@ void Shell::CreateKeyboard() {
}

void Shell::DeactivateKeyboard() {
keyboard_ui_->Hide();
// TODO(jamescook): Move keyboard create and hide into WmShell.
wm_shell_->keyboard_ui()->Hide();
if (in_mus_)
return;
if (keyboard::KeyboardController::GetInstance()) {
Expand Down Expand Up @@ -1052,9 +1053,9 @@ void Shell::Init(const ShellInitParams& init_params) {
touch_transformer_controller_.reset(new TouchTransformerController());
#endif // defined(OS_CHROMEOS)

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

window_tree_host_manager_->InitHosts();

Expand Down
5 changes: 0 additions & 5 deletions ash/shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ class EventTransformationHandler;
class FirstRunHelper;
class GPUSupport;
class HighContrastController;
class KeyboardUI;
class KeyboardUMAEventFilter;
class LinkHandlerModelFactory;
class LocaleNotificationController;
Expand Down Expand Up @@ -521,8 +520,6 @@ class ASH_EXPORT Shell : public SystemModalContainerEventFilterDelegate,
return is_touch_hud_projection_enabled_;
}

KeyboardUI* keyboard_ui() { return keyboard_ui_.get(); }

// 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_; }
Expand Down Expand Up @@ -736,8 +733,6 @@ class ASH_EXPORT Shell : public SystemModalContainerEventFilterDelegate,

bool in_mus_ = false;

std::unique_ptr<KeyboardUI> keyboard_ui_;

DISALLOW_COPY_AND_ASSIGN(Shell);
};

Expand Down
2 changes: 1 addition & 1 deletion ash/system/status_area_widget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#if defined(OS_CHROMEOS)
#include "ash/common/system/chromeos/session/logout_button_tray.h"
#include "ash/system/chromeos/virtual_keyboard/virtual_keyboard_tray.h"
#include "ash/common/system/chromeos/virtual_keyboard/virtual_keyboard_tray.h"
#endif

namespace ash {
Expand Down

0 comments on commit c3fbf09

Please sign in to comment.