Commit b4634b3b authored by Steven Bennetts's avatar Steven Bennetts Committed by Commit Bot

KeyboardController: OnKeyboardDisabled -> OnKeyboardEnabledChanged

ChromeKeyboardControllerClient is going to need to keep track of
when the KeyboardController is (actually) enabled and disabled. This CL:

* Replaces the KeyboardControllerObserver::OnKeyboardDisabled with
  a more generalized OnKeyboardEnabledChanged.
* Replaces the (poorly named) mojom::KeyboardControllerObserver::
  OnKeyboardWindowDestroyed with OnKeyboardEnabledChanged.
* Eliminates the now redundant VirtualKeyboardControllerObserver with
  KeyboardControllerObservers, reducing overall complexity.
* Modifies exo/keyboard.cc to directly observe
  keyboard::KeyboardController instead of ash::VirtualKeyboardController
  and ash::AccessibilityController.

For minor change to test_suites.pyl:
TBR=bpastene@chromium.org

Bug: 843332
Change-Id: I808c1f4ca3e732aa9b606810caa12533b9da8158
Reviewed-on: https://chromium-review.googlesource.com/c/1285329Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarYuichiro Hanada <yhanada@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Reviewed-by: default avatarDarren Shen <shend@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Commit-Queue: Steven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600783}
parent cccd8b08
...@@ -393,7 +393,6 @@ component("ash") { ...@@ -393,7 +393,6 @@ component("ash") {
"keyboard/virtual_keyboard_container_layout_manager.h", "keyboard/virtual_keyboard_container_layout_manager.h",
"keyboard/virtual_keyboard_controller.cc", "keyboard/virtual_keyboard_controller.cc",
"keyboard/virtual_keyboard_controller.h", "keyboard/virtual_keyboard_controller.h",
"keyboard/virtual_keyboard_controller_observer.h",
"laser/laser_pointer_controller.cc", "laser/laser_pointer_controller.cc",
"laser/laser_pointer_controller.h", "laser/laser_pointer_controller.h",
"laser/laser_pointer_view.cc", "laser/laser_pointer_view.cc",
......
...@@ -193,7 +193,7 @@ void TouchExplorationManager::OnKeyboardVisibleBoundsChanged( ...@@ -193,7 +193,7 @@ void TouchExplorationManager::OnKeyboardVisibleBoundsChanged(
UpdateTouchExplorationState(); UpdateTouchExplorationState();
} }
void TouchExplorationManager::OnKeyboardDisabled() { void TouchExplorationManager::OnKeyboardEnabledChanged(bool is_enabled) {
UpdateTouchExplorationState(); UpdateTouchExplorationState();
} }
......
...@@ -87,7 +87,7 @@ class ASH_EXPORT TouchExplorationManager ...@@ -87,7 +87,7 @@ class ASH_EXPORT TouchExplorationManager
private: private:
// keyboard::KeyboardControllerObserver overrides: // keyboard::KeyboardControllerObserver overrides:
void OnKeyboardVisibleBoundsChanged(const gfx::Rect& new_bounds) override; void OnKeyboardVisibleBoundsChanged(const gfx::Rect& new_bounds) override;
void OnKeyboardDisabled() override; void OnKeyboardEnabledChanged(bool is_enabled) override;
void UpdateTouchExplorationState(); void UpdateTouchExplorationState();
bool VolumeAdjustSoundEnabled(); bool VolumeAdjustSoundEnabled();
......
...@@ -150,10 +150,11 @@ void AshKeyboardController::OnKeyboardVisibleBoundsChanged( ...@@ -150,10 +150,11 @@ void AshKeyboardController::OnKeyboardVisibleBoundsChanged(
}); });
} }
void AshKeyboardController::OnKeyboardDisabled() { void AshKeyboardController::OnKeyboardEnabledChanged(bool is_enabled) {
observers_.ForAllPtrs([](mojom::KeyboardControllerObserver* observer) { observers_.ForAllPtrs(
observer->OnKeyboardWindowDestroyed(); [is_enabled](mojom::KeyboardControllerObserver* observer) {
}); observer->OnKeyboardEnabledChanged(is_enabled);
});
} }
} // namespace ash } // namespace ash
...@@ -71,7 +71,7 @@ class ASH_EXPORT AshKeyboardController ...@@ -71,7 +71,7 @@ class ASH_EXPORT AshKeyboardController
void OnKeyboardConfigChanged() override; void OnKeyboardConfigChanged() override;
void OnKeyboardVisibilityStateChanged(bool is_visible) override; void OnKeyboardVisibilityStateChanged(bool is_visible) override;
void OnKeyboardVisibleBoundsChanged(const gfx::Rect& bounds) override; void OnKeyboardVisibleBoundsChanged(const gfx::Rect& bounds) override;
void OnKeyboardDisabled() override; void OnKeyboardEnabledChanged(bool is_enabled) override;
SessionController* session_controller_; // unowned SessionController* session_controller_; // unowned
std::unique_ptr<keyboard::KeyboardController> keyboard_controller_; std::unique_ptr<keyboard::KeyboardController> keyboard_controller_;
......
...@@ -32,7 +32,7 @@ class TestObserver : public mojom::KeyboardControllerObserver { ...@@ -32,7 +32,7 @@ class TestObserver : public mojom::KeyboardControllerObserver {
~TestObserver() override = default; ~TestObserver() override = default;
// mojom::KeyboardControllerObserver: // mojom::KeyboardControllerObserver:
void OnKeyboardWindowDestroyed() override {} void OnKeyboardEnabledChanged(bool enabled) override {}
void OnKeyboardVisibilityChanged(bool visible) override {} void OnKeyboardVisibilityChanged(bool visible) override {}
void OnKeyboardVisibleBoundsChanged(const gfx::Rect& bounds) override {} void OnKeyboardVisibleBoundsChanged(const gfx::Rect& bounds) override {}
void OnKeyboardConfigChanged(KeyboardConfigPtr config) override { void OnKeyboardConfigChanged(KeyboardConfigPtr config) override {
......
...@@ -257,8 +257,6 @@ void VirtualKeyboardController::SetKeyboardEnabled(bool enabled) { ...@@ -257,8 +257,6 @@ void VirtualKeyboardController::SetKeyboardEnabled(bool enabled) {
} else { } else {
Shell::Get()->DisableKeyboard(); Shell::Get()->DisableKeyboard();
} }
for (VirtualKeyboardControllerObserver& observer : observers_)
observer.OnVirtualKeyboardStateChanged(is_enabled);
} }
void VirtualKeyboardController::ForceShowKeyboard() { void VirtualKeyboardController::ForceShowKeyboard() {
...@@ -276,9 +274,13 @@ void VirtualKeyboardController::ForceShowKeyboard() { ...@@ -276,9 +274,13 @@ void VirtualKeyboardController::ForceShowKeyboard() {
keyboard_controller->ShowKeyboard(false); keyboard_controller->ShowKeyboard(false);
} }
void VirtualKeyboardController::OnKeyboardDisabled() { void VirtualKeyboardController::OnKeyboardEnabledChanged(bool is_enabled) {
Shell::Get()->ime_controller()->OverrideKeyboardKeyset( if (!is_enabled) {
chromeos::input_method::mojom::ImeKeyset::kNone); // TODO(shend/shuchen): Consider moving this logic to ImeController.
// https://crbug.com/896284.
Shell::Get()->ime_controller()->OverrideKeyboardKeyset(
chromeos::input_method::mojom::ImeKeyset::kNone);
}
} }
void VirtualKeyboardController::OnKeyboardHidden(bool is_temporary_hide) { void VirtualKeyboardController::OnKeyboardHidden(bool is_temporary_hide) {
...@@ -299,16 +301,6 @@ void VirtualKeyboardController::OnActiveUserSessionChanged( ...@@ -299,16 +301,6 @@ void VirtualKeyboardController::OnActiveUserSessionChanged(
Shell::Get()->EnableKeyboard(); Shell::Get()->EnableKeyboard();
} }
void VirtualKeyboardController::AddObserver(
VirtualKeyboardControllerObserver* observer) {
observers_.AddObserver(observer);
}
void VirtualKeyboardController::RemoveObserver(
VirtualKeyboardControllerObserver* observer) {
observers_.RemoveObserver(observer);
}
void VirtualKeyboardController::UpdateBluetoothDevice( void VirtualKeyboardController::UpdateBluetoothDevice(
device::BluetoothDevice* device) { device::BluetoothDevice* device) {
// We only care about keyboard type bluetooth device change. // We only care about keyboard type bluetooth device change.
......
...@@ -9,11 +9,9 @@ ...@@ -9,11 +9,9 @@
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "ash/bluetooth_devices_observer.h" #include "ash/bluetooth_devices_observer.h"
#include "ash/keyboard/virtual_keyboard_controller_observer.h"
#include "ash/session/session_observer.h" #include "ash/session/session_observer.h"
#include "ash/wm/tablet_mode/tablet_mode_observer.h" #include "ash/wm/tablet_mode/tablet_mode_observer.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/observer_list.h"
#include "ui/base/ime/chromeos/public/interfaces/ime_keyset.mojom.h" #include "ui/base/ime/chromeos/public/interfaces/ime_keyset.mojom.h"
#include "ui/events/devices/input_device_event_observer.h" #include "ui/events/devices/input_device_event_observer.h"
#include "ui/keyboard/keyboard_controller_observer.h" #include "ui/keyboard/keyboard_controller_observer.h"
...@@ -56,16 +54,12 @@ class ASH_EXPORT VirtualKeyboardController ...@@ -56,16 +54,12 @@ class ASH_EXPORT VirtualKeyboardController
void MoveKeyboardToTouchableDisplay() override; void MoveKeyboardToTouchableDisplay() override;
// keyboard::KeyboardControllerObserver: // keyboard::KeyboardControllerObserver:
void OnKeyboardDisabled() override; void OnKeyboardEnabledChanged(bool is_enabled) override;
void OnKeyboardHidden(bool is_temporary_hide) override; void OnKeyboardHidden(bool is_temporary_hide) override;
// SessionObserver: // SessionObserver:
void OnActiveUserSessionChanged(const AccountId& account_id) override; void OnActiveUserSessionChanged(const AccountId& account_id) override;
// Management of the observer list.
void AddObserver(VirtualKeyboardControllerObserver* observer);
void RemoveObserver(VirtualKeyboardControllerObserver* observer);
private: private:
// Updates the list of active input devices. // Updates the list of active input devices.
void UpdateDevices(); void UpdateDevices();
...@@ -95,8 +89,6 @@ class ASH_EXPORT VirtualKeyboardController ...@@ -95,8 +89,6 @@ class ASH_EXPORT VirtualKeyboardController
// Observer to observe the bluetooth devices. // Observer to observe the bluetooth devices.
std::unique_ptr<BluetoothDevicesObserver> bluetooth_devices_observer_; std::unique_ptr<BluetoothDevicesObserver> bluetooth_devices_observer_;
base::ObserverList<VirtualKeyboardControllerObserver> observers_;
DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardController); DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardController);
}; };
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_KEYBOARD_VIRTUAL_KEYBOARD_CONTROLLER_OBSERVER_H_
#define ASH_KEYBOARD_VIRTUAL_KEYBOARD_CONTROLLER_OBSERVER_H_
#include "base/observer_list.h"
namespace ash {
class VirtualKeyboardControllerObserver : public base::CheckedObserver {
public:
virtual void OnVirtualKeyboardStateChanged(bool enabled) = 0;
protected:
~VirtualKeyboardControllerObserver() override = default;
};
} // namespace ash
#endif // ASH_KEYBOARD_VIRTUAL_KEYBOARD_CONTROLLER_OBSERVER_H_
...@@ -8,17 +8,18 @@ import "ui/gfx/geometry/mojo/geometry.mojom"; ...@@ -8,17 +8,18 @@ import "ui/gfx/geometry/mojo/geometry.mojom";
import "ui/keyboard/public/keyboard_config.mojom"; import "ui/keyboard/public/keyboard_config.mojom";
interface KeyboardControllerObserver { interface KeyboardControllerObserver {
// Called when the virtual keyboard window is destroyed, e.g. a change from // Called when the keyboard is enabled or disabled. If the keyboard is enabled
// tablet mode to laptop mode. This is not called when the keyboard is hidden. // while already enabled, this will be called twice, once when the keyboard is
OnKeyboardWindowDestroyed(); // disabled and again when it is re-enabled.
OnKeyboardEnabledChanged(bool is_enabled);
// Called when the virtual keyboard configuration changes.
OnKeyboardConfigChanged(keyboard.mojom.KeyboardConfig config);
// Called when the visibility of the virtual keyboard changes, e.g. an input // Called when the visibility of the virtual keyboard changes, e.g. an input
// field is focused or blurred, or the user hides the keyboard. // field is focused or blurred, or the user hides the keyboard.
OnKeyboardVisibilityChanged(bool visible); OnKeyboardVisibilityChanged(bool visible);
// Called when the virtual keyboard configuration changes.
OnKeyboardConfigChanged(keyboard.mojom.KeyboardConfig config);
// Called when the keyboard bounds change. // Called when the keyboard bounds change.
OnKeyboardVisibleBoundsChanged(gfx.mojom.Rect new_bounds); OnKeyboardVisibleBoundsChanged(gfx.mojom.Rect new_bounds);
}; };
......
...@@ -100,32 +100,12 @@ void ChromeKeyboardControllerClient::OnGetInitialKeyboardConfig( ...@@ -100,32 +100,12 @@ void ChromeKeyboardControllerClient::OnGetInitialKeyboardConfig(
keyboard_controller_ptr_->AddObserver(std::move(ptr_info)); keyboard_controller_ptr_->AddObserver(std::move(ptr_info));
} }
void ChromeKeyboardControllerClient::OnKeyboardVisibleBoundsChanged( void ChromeKeyboardControllerClient::OnKeyboardEnabledChanged(bool enabled) {
const gfx::Rect& bounds) { if (enabled)
Profile* profile = GetProfile();
extensions::EventRouter* router = extensions::EventRouter::Get(profile);
if (!router->HasEventListener(
virtual_keyboard_private::OnBoundsChanged::kEventName)) {
return; return;
}
auto event_args = std::make_unique<base::ListValue>();
auto new_bounds = std::make_unique<base::DictionaryValue>();
new_bounds->SetInteger("left", bounds.x());
new_bounds->SetInteger("top", bounds.y());
new_bounds->SetInteger("width", bounds.width());
new_bounds->SetInteger("height", bounds.height());
event_args->Append(std::move(new_bounds));
auto event = std::make_unique<extensions::Event>( // When the keyboard becomes disabled, send the onKeyboardClosed event.
extensions::events::VIRTUAL_KEYBOARD_PRIVATE_ON_BOUNDS_CHANGED,
virtual_keyboard_private::OnBoundsChanged::kEventName,
std::move(event_args), profile);
router->BroadcastEvent(std::move(event));
}
void ChromeKeyboardControllerClient::OnKeyboardWindowDestroyed() {
Profile* profile = GetProfile(); Profile* profile = GetProfile();
extensions::EventRouter* router = extensions::EventRouter::Get(profile); extensions::EventRouter* router = extensions::EventRouter::Get(profile);
...@@ -154,3 +134,28 @@ void ChromeKeyboardControllerClient::OnKeyboardVisibilityChanged(bool visible) { ...@@ -154,3 +134,28 @@ void ChromeKeyboardControllerClient::OnKeyboardVisibilityChanged(bool visible) {
for (auto& observer : observers_) for (auto& observer : observers_)
observer.OnKeyboardVisibilityChanged(visible); observer.OnKeyboardVisibilityChanged(visible);
} }
void ChromeKeyboardControllerClient::OnKeyboardVisibleBoundsChanged(
const gfx::Rect& bounds) {
Profile* profile = GetProfile();
extensions::EventRouter* router = extensions::EventRouter::Get(profile);
if (!router->HasEventListener(
virtual_keyboard_private::OnBoundsChanged::kEventName)) {
return;
}
auto event_args = std::make_unique<base::ListValue>();
auto new_bounds = std::make_unique<base::DictionaryValue>();
new_bounds->SetInteger("left", bounds.x());
new_bounds->SetInteger("top", bounds.y());
new_bounds->SetInteger("width", bounds.width());
new_bounds->SetInteger("height", bounds.height());
event_args->Append(std::move(new_bounds));
auto event = std::make_unique<extensions::Event>(
extensions::events::VIRTUAL_KEYBOARD_PRIVATE_ON_BOUNDS_CHANGED,
virtual_keyboard_private::OnBoundsChanged::kEventName,
std::move(event_args), profile);
router->BroadcastEvent(std::move(event));
}
...@@ -48,11 +48,11 @@ class ChromeKeyboardControllerClient ...@@ -48,11 +48,11 @@ class ChromeKeyboardControllerClient
void OnGetInitialKeyboardConfig(keyboard::mojom::KeyboardConfigPtr config); void OnGetInitialKeyboardConfig(keyboard::mojom::KeyboardConfigPtr config);
// keyboard::mojom::KeyboardControllerObserver: // keyboard::mojom::KeyboardControllerObserver:
void OnKeyboardWindowDestroyed() override; void OnKeyboardEnabledChanged(bool enabled) override;
void OnKeyboardVisibilityChanged(bool visible) override;
void OnKeyboardVisibleBoundsChanged(const gfx::Rect& bounds) override;
void OnKeyboardConfigChanged( void OnKeyboardConfigChanged(
keyboard::mojom::KeyboardConfigPtr config) override; keyboard::mojom::KeyboardConfigPtr config) override;
void OnKeyboardVisibilityChanged(bool visible) override;
void OnKeyboardVisibleBoundsChanged(const gfx::Rect& bounds) override;
ash::mojom::KeyboardControllerPtr keyboard_controller_ptr_; ash::mojom::KeyboardControllerPtr keyboard_controller_ptr_;
mojo::AssociatedBinding<ash::mojom::KeyboardControllerObserver> mojo::AssociatedBinding<ash::mojom::KeyboardControllerObserver>
......
...@@ -227,6 +227,7 @@ test("exo_unittests") { ...@@ -227,6 +227,7 @@ test("exo_unittests") {
"//ash/strings:ash_test_strings", "//ash/strings:ash_test_strings",
"//ash/resources:ash_test_resources_100_percent", "//ash/resources:ash_test_resources_100_percent",
"//ash/resources:ash_test_resources_200_percent", "//ash/resources:ash_test_resources_200_percent",
"//testing/buildbot/filters:exo_unittests_filters",
] ]
if (is_linux) { if (is_linux) {
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "ui/base/ime/input_method.h" #include "ui/base/ime/input_method.h"
#include "ui/events/base_event_utils.h" #include "ui/events/base_event_utils.h"
#include "ui/events/event.h" #include "ui/events/event.h"
#include "ui/keyboard/keyboard_controller.h"
#include "ui/keyboard/keyboard_util.h" #include "ui/keyboard/keyboard_util.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
...@@ -112,7 +113,7 @@ bool ConsumedByIme(Surface* focus, const ui::KeyEvent* event) { ...@@ -112,7 +113,7 @@ bool ConsumedByIme(Surface* focus, const ui::KeyEvent* event) {
} }
bool IsVirtualKeyboardEnabled() { bool IsVirtualKeyboardEnabled() {
return WMHelper::GetInstance()->IsAccessibilityKeyboardEnabled() || return keyboard::GetAccessibilityKeyboardEnabled() ||
keyboard::GetTouchKeyboardEnabled(); keyboard::GetTouchKeyboardEnabled();
} }
...@@ -156,11 +157,9 @@ Keyboard::Keyboard(KeyboardDelegate* delegate, Seat* seat) ...@@ -156,11 +157,9 @@ Keyboard::Keyboard(KeyboardDelegate* delegate, Seat* seat)
expiration_delay_for_pending_key_acks_(base::TimeDelta::FromMilliseconds( expiration_delay_for_pending_key_acks_(base::TimeDelta::FromMilliseconds(
kExpirationDelayForPendingKeyAcksMs)), kExpirationDelayForPendingKeyAcksMs)),
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
auto* helper = WMHelper::GetInstance();
AddEventHandler(); AddEventHandler();
seat_->AddObserver(this); seat_->AddObserver(this);
helper->AddAccessibilityObserver(this); keyboard::KeyboardController::Get()->AddObserver(this);
helper->AddVirtualKeyboardControllerObserver(this);
OnSurfaceFocused(seat_->GetFocusedSurface()); OnSurfaceFocused(seat_->GetFocusedSurface());
} }
...@@ -169,11 +168,9 @@ Keyboard::~Keyboard() { ...@@ -169,11 +168,9 @@ Keyboard::~Keyboard() {
observer.OnKeyboardDestroying(this); observer.OnKeyboardDestroying(this);
if (focus_) if (focus_)
focus_->RemoveSurfaceObserver(this); focus_->RemoveSurfaceObserver(this);
auto* helper = WMHelper::GetInstance();
RemoveEventHandler(); RemoveEventHandler();
seat_->RemoveObserver(this); seat_->RemoveObserver(this);
helper->RemoveVirtualKeyboardControllerObserver(this); keyboard::KeyboardController::Get()->RemoveObserver(this);
helper->RemoveAccessibilityObserver(this);
} }
bool Keyboard::HasDeviceConfigurationDelegate() const { bool Keyboard::HasDeviceConfigurationDelegate() const {
...@@ -183,7 +180,7 @@ bool Keyboard::HasDeviceConfigurationDelegate() const { ...@@ -183,7 +180,7 @@ bool Keyboard::HasDeviceConfigurationDelegate() const {
void Keyboard::SetDeviceConfigurationDelegate( void Keyboard::SetDeviceConfigurationDelegate(
KeyboardDeviceConfigurationDelegate* delegate) { KeyboardDeviceConfigurationDelegate* delegate) {
device_configuration_delegate_ = delegate; device_configuration_delegate_ = delegate;
OnAccessibilityStatusChanged(); OnKeyboardEnabledChanged(IsVirtualKeyboardEnabled());
} }
void Keyboard::AddObserver(KeyboardObserver* observer) { void Keyboard::AddObserver(KeyboardObserver* observer) {
...@@ -336,19 +333,9 @@ void Keyboard::OnSurfaceFocused(Surface* gained_focus) { ...@@ -336,19 +333,9 @@ void Keyboard::OnSurfaceFocused(Surface* gained_focus) {
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// AccessibilityObserver overrides: // keyboard::KeyboardControllerObserver overrides:
void Keyboard::OnAccessibilityStatusChanged() {
if (device_configuration_delegate_) {
device_configuration_delegate_->OnKeyboardTypeChanged(
!IsVirtualKeyboardEnabled());
}
}
////////////////////////////////////////////////////////////////////////////////
// VirtualKeyboardController::Observer overrides:
void Keyboard::OnVirtualKeyboardStateChanged(bool enabled) { void Keyboard::OnKeyboardEnabledChanged(bool enabled) {
if (device_configuration_delegate_) if (device_configuration_delegate_)
device_configuration_delegate_->OnKeyboardTypeChanged(!enabled); device_configuration_delegate_->OnKeyboardTypeChanged(!enabled);
} }
......
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
#include <vector> #include <vector>
#include "ash/accessibility/accessibility_observer.h"
#include "ash/keyboard/virtual_keyboard_controller_observer.h"
#include "base/containers/flat_map.h" #include "base/containers/flat_map.h"
#include "base/containers/flat_set.h" #include "base/containers/flat_set.h"
#include "base/macros.h" #include "base/macros.h"
...@@ -18,6 +16,7 @@ ...@@ -18,6 +16,7 @@
#include "components/exo/surface_observer.h" #include "components/exo/surface_observer.h"
#include "ui/events/event.h" #include "ui/events/event.h"
#include "ui/events/event_handler.h" #include "ui/events/event_handler.h"
#include "ui/keyboard/keyboard_controller_observer.h"
namespace ui { namespace ui {
enum class DomCode; enum class DomCode;
...@@ -35,8 +34,7 @@ class Surface; ...@@ -35,8 +34,7 @@ class Surface;
class Keyboard : public ui::EventHandler, class Keyboard : public ui::EventHandler,
public SurfaceObserver, public SurfaceObserver,
public SeatObserver, public SeatObserver,
public ash::AccessibilityObserver, public keyboard::KeyboardControllerObserver {
public ash::VirtualKeyboardControllerObserver {
public: public:
Keyboard(KeyboardDelegate* delegate, Seat* seat); Keyboard(KeyboardDelegate* delegate, Seat* seat);
~Keyboard() override; ~Keyboard() override;
...@@ -67,11 +65,8 @@ class Keyboard : public ui::EventHandler, ...@@ -67,11 +65,8 @@ class Keyboard : public ui::EventHandler,
void OnSurfaceFocusing(Surface* gaining_focus) override; void OnSurfaceFocusing(Surface* gaining_focus) override;
void OnSurfaceFocused(Surface* gained_focus) override; void OnSurfaceFocused(Surface* gained_focus) override;
// Overridden from AccessibilityObserver: // Overridden from keyboard::KeyboardControllerObserver
void OnAccessibilityStatusChanged() override; void OnKeyboardEnabledChanged(bool is_enabled) override;
// Overridden from VirtualKeyboardController::Observer
void OnVirtualKeyboardStateChanged(bool enabled) override;
private: private:
// Change keyboard focus to |surface|. // Change keyboard focus to |surface|.
......
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
#include "components/exo/wm_helper.h" #include "components/exo/wm_helper.h"
#include "ash/accessibility/accessibility_controller.h"
#include "ash/keyboard/virtual_keyboard_controller.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/wm/tablet_mode/tablet_mode_controller.h" #include "ash/wm/tablet_mode/tablet_mode_controller.h"
#include "base/memory/singleton.h" #include "base/memory/singleton.h"
...@@ -54,15 +52,6 @@ bool WMHelper::HasInstance() { ...@@ -54,15 +52,6 @@ bool WMHelper::HasInstance() {
return !!g_instance; return !!g_instance;
} }
void WMHelper::AddAccessibilityObserver(ash::AccessibilityObserver* observer) {
ash::Shell::Get()->accessibility_controller()->AddObserver(observer);
}
void WMHelper::RemoveAccessibilityObserver(
ash::AccessibilityObserver* observer) {
ash::Shell::Get()->accessibility_controller()->RemoveObserver(observer);
}
void WMHelper::AddActivationObserver(wm::ActivationChangeObserver* observer) { void WMHelper::AddActivationObserver(wm::ActivationChangeObserver* observer) {
ash::Shell::Get()->activation_client()->AddObserver(observer); ash::Shell::Get()->activation_client()->AddObserver(observer);
} }
...@@ -89,16 +78,6 @@ void WMHelper::RemoveTabletModeObserver(ash::TabletModeObserver* observer) { ...@@ -89,16 +78,6 @@ void WMHelper::RemoveTabletModeObserver(ash::TabletModeObserver* observer) {
ash::Shell::Get()->tablet_mode_controller()->RemoveObserver(observer); ash::Shell::Get()->tablet_mode_controller()->RemoveObserver(observer);
} }
void WMHelper::AddVirtualKeyboardControllerObserver(
ash::VirtualKeyboardControllerObserver* observer) {
ash::Shell::Get()->virtual_keyboard_controller()->AddObserver(observer);
}
void WMHelper::RemoveVirtualKeyboardControllerObserver(
ash::VirtualKeyboardControllerObserver* observer) {
ash::Shell::Get()->virtual_keyboard_controller()->RemoveObserver(observer);
}
void WMHelper::AddDisplayConfigurationObserver( void WMHelper::AddDisplayConfigurationObserver(
ash::WindowTreeHostManager::Observer* observer) { ash::WindowTreeHostManager::Observer* observer) {
ash::Shell::Get()->window_tree_host_manager()->AddObserver(observer); ash::Shell::Get()->window_tree_host_manager()->AddObserver(observer);
...@@ -241,10 +220,4 @@ double WMHelper::GetDefaultDeviceScaleFactor() const { ...@@ -241,10 +220,4 @@ double WMHelper::GetDefaultDeviceScaleFactor() const {
return display_info.display_modes()[0].device_scale_factor(); return display_info.display_modes()[0].device_scale_factor();
} }
bool WMHelper::IsAccessibilityKeyboardEnabled() const {
return ash::Shell::Get()
->accessibility_controller()
->IsVirtualKeyboardEnabled();
}
} // namespace exo } // namespace exo
...@@ -15,9 +15,7 @@ ...@@ -15,9 +15,7 @@
#include "ui/compositor/compositor_vsync_manager.h" #include "ui/compositor/compositor_vsync_manager.h"
namespace ash { namespace ash {
class AccessibilityObserver;
class TabletModeObserver; class TabletModeObserver;
class VirtualKeyboardControllerObserver;
} }
namespace aura { namespace aura {
...@@ -71,18 +69,12 @@ class WMHelper : public aura::client::DragDropDelegate { ...@@ -71,18 +69,12 @@ class WMHelper : public aura::client::DragDropDelegate {
aura::Env* env() { return env_; } aura::Env* env() { return env_; }
void AddAccessibilityObserver(ash::AccessibilityObserver* observer);
void RemoveAccessibilityObserver(ash::AccessibilityObserver* observer);
void AddActivationObserver(wm::ActivationChangeObserver* observer); void AddActivationObserver(wm::ActivationChangeObserver* observer);
void RemoveActivationObserver(wm::ActivationChangeObserver* observer); void RemoveActivationObserver(wm::ActivationChangeObserver* observer);
void AddFocusObserver(aura::client::FocusChangeObserver* observer); void AddFocusObserver(aura::client::FocusChangeObserver* observer);
void RemoveFocusObserver(aura::client::FocusChangeObserver* observer); void RemoveFocusObserver(aura::client::FocusChangeObserver* observer);
void AddTabletModeObserver(ash::TabletModeObserver* observer); void AddTabletModeObserver(ash::TabletModeObserver* observer);
void RemoveTabletModeObserver(ash::TabletModeObserver* observer); void RemoveTabletModeObserver(ash::TabletModeObserver* observer);
void AddVirtualKeyboardControllerObserver(
ash::VirtualKeyboardControllerObserver* observer);
void RemoveVirtualKeyboardControllerObserver(
ash::VirtualKeyboardControllerObserver* observer);
void AddDisplayConfigurationObserver( void AddDisplayConfigurationObserver(
ash::WindowTreeHostManager::Observer* observer); ash::WindowTreeHostManager::Observer* observer);
...@@ -110,7 +102,6 @@ class WMHelper : public aura::client::DragDropDelegate { ...@@ -110,7 +102,6 @@ class WMHelper : public aura::client::DragDropDelegate {
void RemovePostTargetHandler(ui::EventHandler* handler); void RemovePostTargetHandler(ui::EventHandler* handler);
bool IsTabletModeWindowManagerEnabled() const; bool IsTabletModeWindowManagerEnabled() const;
double GetDefaultDeviceScaleFactor() const; double GetDefaultDeviceScaleFactor() const;
bool IsAccessibilityKeyboardEnabled() const;
// Overridden from aura::client::DragDropDelegate: // Overridden from aura::client::DragDropDelegate:
void OnDragEntered(const ui::DropTargetEvent& event) override; void OnDragEntered(const ui::DropTargetEvent& event) override;
......
...@@ -751,7 +751,8 @@ ...@@ -751,7 +751,8 @@
}, },
{ {
"args": [ "args": [
"--enable-features=SingleProcessMash" "--enable-features=SingleProcessMash",
"--test-launcher-filter-file=../../testing/buildbot/filters/chromeos.single_process_mash.exo_unittests.filter"
], ],
"name": "single_process_mash_exo_unittests", "name": "single_process_mash_exo_unittests",
"swarming": { "swarming": {
...@@ -1456,7 +1457,8 @@ ...@@ -1456,7 +1457,8 @@
}, },
{ {
"args": [ "args": [
"--enable-features=SingleProcessMash" "--enable-features=SingleProcessMash",
"--test-launcher-filter-file=../../testing/buildbot/filters/chromeos.single_process_mash.exo_unittests.filter"
], ],
"name": "single_process_mash_exo_unittests", "name": "single_process_mash_exo_unittests",
"swarming": { "swarming": {
......
...@@ -4549,6 +4549,7 @@ ...@@ -4549,6 +4549,7 @@
{ {
"args": [ "args": [
"--enable-features=SingleProcessMash", "--enable-features=SingleProcessMash",
"--test-launcher-filter-file=../../testing/buildbot/filters/chromeos.single_process_mash.exo_unittests.filter",
"--test-launcher-print-test-stdio=always" "--test-launcher-print-test-stdio=always"
], ],
"name": "single_process_mash_exo_unittests", "name": "single_process_mash_exo_unittests",
...@@ -5807,6 +5808,7 @@ ...@@ -5807,6 +5808,7 @@
{ {
"args": [ "args": [
"--enable-features=SingleProcessMash", "--enable-features=SingleProcessMash",
"--test-launcher-filter-file=../../testing/buildbot/filters/chromeos.single_process_mash.exo_unittests.filter",
"--test-launcher-print-test-stdio=always" "--test-launcher-print-test-stdio=always"
], ],
"name": "single_process_mash_exo_unittests", "name": "single_process_mash_exo_unittests",
......
...@@ -72,6 +72,14 @@ source_set("content_browsertests_filters") { ...@@ -72,6 +72,14 @@ source_set("content_browsertests_filters") {
] ]
} }
source_set("exo_unittests_filters") {
testonly = true
data = [
"//testing/buildbot/filters/chromeos.single_process_mash.exo_unittests.filter",
]
}
source_set("fuchsia_filters") { source_set("fuchsia_filters") {
data = [ data = [
"//testing/buildbot/filters/fuchsia.content_unittests.filter", "//testing/buildbot/filters/fuchsia.content_unittests.filter",
......
...@@ -87,6 +87,11 @@ Please use the following conventions when naming the new file: ...@@ -87,6 +87,11 @@ Please use the following conventions when naming the new file:
- Feel free to add other relevant things into the file name (e.g. the mode the - Feel free to add other relevant things into the file name (e.g. the mode the
file applies to - for example `site-per-process`). file applies to - for example `site-per-process`).
When adding a new file, please update `//testing/buildbot/filters/BUILD.gn`. When adding a new filter file, you will need to:
- Update `//testing/buildbot/filters/BUILD.gn`.
- Add `//testing/buildbot/filters:foo_filters` to the appropriate test target.
- Add `'--test-launcher-filter-file=../../testing/buildbot/filters/foo.filter'`
to the desired test suite(s) in `test_suites.pyl`.
- Run `testing/buildbot/generate_buildbot_json.py` to update .json files.
[gtest_filter]: https://github.com/google/googletest/blob/master/googletest/docs/advanced.md#running-a-subset-of-the-tests [gtest_filter]: https://github.com/google/googletest/blob/master/googletest/docs/advanced.md#running-a-subset-of-the-tests
# These will fail until KeyboardController is enabled on SingleProcessMash.
# https://crbug.com/843332
-KeyboardTest.OnKeyboardTypeChanged*
...@@ -1754,6 +1754,7 @@ ...@@ -1754,6 +1754,7 @@
'test': 'exo_unittests', 'test': 'exo_unittests',
'args': [ 'args': [
'--enable-features=SingleProcessMash', '--enable-features=SingleProcessMash',
'--test-launcher-filter-file=../../testing/buildbot/filters/chromeos.single_process_mash.exo_unittests.filter',
], ],
}, },
'ui_chromeos_unittests': {}, 'ui_chromeos_unittests': {},
......
...@@ -221,6 +221,9 @@ void KeyboardController::EnableKeyboard(std::unique_ptr<KeyboardUI> ui, ...@@ -221,6 +221,9 @@ void KeyboardController::EnableKeyboard(std::unique_ptr<KeyboardUI> ui,
visual_bounds_in_screen_ = gfx::Rect(); visual_bounds_in_screen_ = gfx::Rect();
time_of_last_blur_ = base::Time::UnixEpoch(); time_of_last_blur_ = base::Time::UnixEpoch();
UpdateInputMethodObserver(); UpdateInputMethodObserver();
for (KeyboardControllerObserver& observer : observer_list_)
observer.OnKeyboardEnabledChanged(true);
} }
void KeyboardController::DisableKeyboard() { void KeyboardController::DisableKeyboard() {
...@@ -244,7 +247,7 @@ void KeyboardController::DisableKeyboard() { ...@@ -244,7 +247,7 @@ void KeyboardController::DisableKeyboard() {
ime_observer_.RemoveAll(); ime_observer_.RemoveAll();
for (KeyboardControllerObserver& observer : observer_list_) for (KeyboardControllerObserver& observer : observer_list_)
observer.OnKeyboardDisabled(); observer.OnKeyboardEnabledChanged(false);
ui_->SetController(nullptr); ui_->SetController(nullptr);
ui_.reset(); ui_.reset();
} }
......
...@@ -67,10 +67,10 @@ class KEYBOARD_EXPORT KeyboardControllerObserver { ...@@ -67,10 +67,10 @@ class KEYBOARD_EXPORT KeyboardControllerObserver {
virtual void OnKeyboardAppearanceChanged( virtual void OnKeyboardAppearanceChanged(
const KeyboardStateDescriptor& state) {} const KeyboardStateDescriptor& state) {}
// Called when the keyboard is effectively disabled (i.e. when the UI / window // Called when the keyboard is enabled or disabled. NOTE: This is called
// is destroyed, not when keyboard::IsKeyboardEnabled() changes), e.g. when // when Enabled() or Disabled() is called, not when the requested enabled
// user switches convertible to laptop mode or the active user changes. // state (IsEnableRequested) changes.
virtual void OnKeyboardDisabled() {} virtual void OnKeyboardEnabledChanged(bool is_enabled) {}
// Called when the keyboard has been hidden and the hiding animation finished // Called when the keyboard has been hidden and the hiding animation finished
// successfully. This is same as |state| == HIDDEN on OnStateChanged. // successfully. This is same as |state| == HIDDEN on OnStateChanged.
......
...@@ -215,7 +215,9 @@ class KeyboardControllerTest : public aura::test::AuraTestBase, ...@@ -215,7 +215,9 @@ class KeyboardControllerTest : public aura::test::AuraTestBase,
is_visible_ = is_visible; is_visible_ = is_visible;
is_visible_number_of_calls_++; is_visible_number_of_calls_++;
} }
void OnKeyboardDisabled() override { keyboard_disabled_ = true; } void OnKeyboardEnabledChanged(bool is_enabled) override {
keyboard_disabled_ = !is_enabled;
}
void ClearKeyboardDisabled() { keyboard_disabled_ = false; } void ClearKeyboardDisabled() { keyboard_disabled_ = false; }
int visible_bounds_number_of_calls() const { int visible_bounds_number_of_calls() const {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment