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

Add SetKeyboardLocked and bounds setters to ash.mojom.KeyboardController

This CL updates the remaining ChromeVirtualKeyboardDelegate calls to use
ChromeKeyboardControllerClient instead of direct calls to
keyboard::KeyboardController.

This also adds OnKeyboardEnableFlagsChanged to ensure that the enable
flags are cached accurately on the chrome side.

Bug: 876138
Change-Id: I3022fa78df7c589c22579b4b4e3b2a3279622f81
Reviewed-on: https://chromium-review.googlesource.com/c/1330894Reviewed-by: default avatarDarren Shen <shend@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Commit-Queue: Steven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608618}
parent 891067b2
...@@ -164,6 +164,27 @@ void AshKeyboardController::SetContainerType( ...@@ -164,6 +164,27 @@ void AshKeyboardController::SetContainerType(
std::move(callback)); std::move(callback));
} }
void AshKeyboardController::SetKeyboardLocked(bool locked) {
keyboard_controller_->set_keyboard_locked(locked);
}
void AshKeyboardController::SetOccludedBounds(
const std::vector<gfx::Rect>& bounds) {
// TODO(https://crbug.com/826617): Support occluded bounds with multiple
// rectangles.
keyboard_controller_->SetOccludedBounds(bounds.empty() ? gfx::Rect()
: bounds[0]);
}
void AshKeyboardController::SetHitTestBounds(
const std::vector<gfx::Rect>& bounds) {
keyboard_controller_->SetHitTestBounds(bounds);
}
void AshKeyboardController::SetDraggableArea(const gfx::Rect& bounds) {
keyboard_controller_->SetDraggableArea(bounds);
}
void AshKeyboardController::OnSessionStateChanged( void AshKeyboardController::OnSessionStateChanged(
session_manager::SessionState state) { session_manager::SessionState state) {
if (!keyboard_controller_->IsKeyboardEnableRequested()) if (!keyboard_controller_->IsKeyboardEnableRequested())
...@@ -248,6 +269,15 @@ void AshKeyboardController::OnKeyboardVisibleBoundsChanged( ...@@ -248,6 +269,15 @@ void AshKeyboardController::OnKeyboardVisibleBoundsChanged(
}); });
} }
void AshKeyboardController::OnKeyboardEnableFlagsChanged(
std::set<keyboard::mojom::KeyboardEnableFlag>& keyboard_enable_flags) {
std::vector<keyboard::mojom::KeyboardEnableFlag> flags(
keyboard_enable_flags.begin(), keyboard_enable_flags.end());
observers_.ForAllPtrs([&flags](mojom::KeyboardControllerObserver* observer) {
observer->OnKeyboardEnableFlagsChanged(flags);
});
}
void AshKeyboardController::OnKeyboardEnabledChanged(bool is_enabled) { void AshKeyboardController::OnKeyboardEnabledChanged(bool is_enabled) {
observers_.ForAllPtrs( observers_.ForAllPtrs(
[is_enabled](mojom::KeyboardControllerObserver* observer) { [is_enabled](mojom::KeyboardControllerObserver* observer) {
......
...@@ -73,6 +73,10 @@ class ASH_EXPORT AshKeyboardController ...@@ -73,6 +73,10 @@ class ASH_EXPORT AshKeyboardController
void SetContainerType(keyboard::mojom::ContainerType container_type, void SetContainerType(keyboard::mojom::ContainerType container_type,
const base::Optional<gfx::Rect>& target_bounds, const base::Optional<gfx::Rect>& target_bounds,
SetContainerTypeCallback callback) override; SetContainerTypeCallback callback) override;
void SetKeyboardLocked(bool locked) override;
void SetOccludedBounds(const std::vector<gfx::Rect>& bounds) override;
void SetHitTestBounds(const std::vector<gfx::Rect>& bounds) override;
void SetDraggableArea(const gfx::Rect& bounds) override;
void AddObserver( void AddObserver(
mojom::KeyboardControllerObserverAssociatedPtrInfo observer) override; mojom::KeyboardControllerObserverAssociatedPtrInfo observer) override;
...@@ -105,6 +109,9 @@ class ASH_EXPORT AshKeyboardController ...@@ -105,6 +109,9 @@ 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 OnKeyboardEnableFlagsChanged(
std::set<keyboard::mojom::KeyboardEnableFlag>& keyboard_enable_flags)
override;
void OnKeyboardEnabledChanged(bool is_enabled) override; void OnKeyboardEnabledChanged(bool is_enabled) override;
SessionController* session_controller_; // unowned SessionController* session_controller_; // unowned
......
...@@ -18,6 +18,9 @@ enum HideReason { ...@@ -18,6 +18,9 @@ enum HideReason {
}; };
interface KeyboardControllerObserver { interface KeyboardControllerObserver {
// Called when a keyboard enable flag changes.
OnKeyboardEnableFlagsChanged(array<keyboard.mojom.KeyboardEnableFlag> flags);
// Called when the keyboard is enabled or disabled. If ReloadKeyboard() is // Called when the keyboard is enabled or disabled. If ReloadKeyboard() is
// called or other code enables the keyboard while already enabled, this will // called or other code enables the keyboard while already enabled, this will
// be called twice, once when the keyboard is disabled and again when it is // be called twice, once when the keyboard is disabled and again when it is
...@@ -53,7 +56,7 @@ interface KeyboardController { ...@@ -53,7 +56,7 @@ interface KeyboardController {
// changes, enables or disables the keyboard to match the new state. // changes, enables or disables the keyboard to match the new state.
ClearEnableFlag(keyboard.mojom.KeyboardEnableFlag flag); ClearEnableFlag(keyboard.mojom.KeyboardEnableFlag flag);
// Gets the current set of keyboard enabled flags. // Gets the current set of keyboard enable flags.
GetEnableFlags() => (array<keyboard.mojom.KeyboardEnableFlag> flags); GetEnableFlags() => (array<keyboard.mojom.KeyboardEnableFlag> flags);
// Reloads the virtual keyboard if it is enabled and the URL has changed, e.g. // Reloads the virtual keyboard if it is enabled and the URL has changed, e.g.
...@@ -80,6 +83,19 @@ interface KeyboardController { ...@@ -80,6 +83,19 @@ interface KeyboardController {
SetContainerType(keyboard.mojom.ContainerType container_type, SetContainerType(keyboard.mojom.ContainerType container_type,
gfx.mojom.Rect? target_bounds) => (bool result); gfx.mojom.Rect? target_bounds) => (bool result);
// If |locked| is true, the keyboard remains visible even when no window has
// input focus.
SetKeyboardLocked(bool locked);
// Sets the regions of the keyboard window that occlude whatever is behind it.
SetOccludedBounds(array<gfx.mojom.Rect> bounds);
// Sets the regions of the keyboard window where events should be handled.
SetHitTestBounds(array<gfx.mojom.Rect> bounds);
// Sets the region of the keyboard window that can be used as a drag handle.
SetDraggableArea(gfx.mojom.Rect bounds);
// Adds a KeyboardControllerObserver. // Adds a KeyboardControllerObserver.
AddObserver(associated KeyboardControllerObserver observer); AddObserver(associated KeyboardControllerObserver observer);
}; };
...@@ -2,12 +2,3 @@ include_rules = [ ...@@ -2,12 +2,3 @@ include_rules = [
"+media/audio" "+media/audio"
"+services/audio/public/cpp" "+services/audio/public/cpp"
] ]
specific_include_rules = {
# TODO(mash): Fix. https://crbug.com/646565
"chrome_virtual_keyboard_delegate\.cc": [
"+ash/shell.h",
# TODO(stevenjb): Fix this for Mash. https://crbug.com/876138.
"+ui/keyboard",
]
}
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include <string> #include <string>
#include <utility> #include <utility>
#include "ash/shell.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/feature_list.h" #include "base/feature_list.h"
...@@ -43,8 +42,6 @@ ...@@ -43,8 +42,6 @@
#include "ui/events/keycodes/dom/dom_key.h" #include "ui/events/keycodes/dom/dom_key.h"
#include "ui/events/keycodes/dom/keycode_converter.h" #include "ui/events/keycodes/dom/keycode_converter.h"
#include "ui/events/keycodes/keyboard_code_conversion.h" #include "ui/events/keycodes/keyboard_code_conversion.h"
#include "ui/keyboard/keyboard_controller.h"
#include "ui/keyboard/keyboard_util.h"
#include "ui/keyboard/public/keyboard_controller_types.mojom.h" #include "ui/keyboard/public/keyboard_controller_types.mojom.h"
#include "ui/keyboard/public/keyboard_switches.h" #include "ui/keyboard/public/keyboard_switches.h"
...@@ -187,13 +184,13 @@ void ChromeVirtualKeyboardDelegate::OnKeyboardConfigChanged() { ...@@ -187,13 +184,13 @@ void ChromeVirtualKeyboardDelegate::OnKeyboardConfigChanged() {
bool ChromeVirtualKeyboardDelegate::HideKeyboard() { bool ChromeVirtualKeyboardDelegate::HideKeyboard() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
auto* controller = keyboard::KeyboardController::Get(); auto* keyboard_client = ChromeKeyboardControllerClient::Get();
if (!controller->IsEnabled()) if (!keyboard_client->is_keyboard_enabled())
return false; return false;
// Pass HIDE_REASON_MANUAL since calls to HideKeyboard as part of this API // Pass HIDE_REASON_MANUAL since calls to HideKeyboard as part of this API
// would be user generated. // would be user generated.
controller->HideKeyboardByUser(); keyboard_client->HideKeyboard(ash::mojom::HideReason::kUser);
return true; return true;
} }
...@@ -232,11 +229,11 @@ void ChromeVirtualKeyboardDelegate::SetHotrodKeyboard(bool enable) { ...@@ -232,11 +229,11 @@ void ChromeVirtualKeyboardDelegate::SetHotrodKeyboard(bool enable) {
bool ChromeVirtualKeyboardDelegate::LockKeyboard(bool state) { bool ChromeVirtualKeyboardDelegate::LockKeyboard(bool state) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
auto* controller = keyboard::KeyboardController::Get(); auto* keyboard_client = ChromeKeyboardControllerClient::Get();
if (!controller->IsEnabled()) if (!keyboard_client->is_keyboard_enabled())
return false; return false;
controller->set_keyboard_locked(state); keyboard_client->SetKeyboardLocked(state);
return true; return true;
} }
...@@ -254,9 +251,9 @@ bool ChromeVirtualKeyboardDelegate::SendKeyEvent(const std::string& type, ...@@ -254,9 +251,9 @@ bool ChromeVirtualKeyboardDelegate::SendKeyEvent(const std::string& type,
bool ChromeVirtualKeyboardDelegate::ShowLanguageSettings() { bool ChromeVirtualKeyboardDelegate::ShowLanguageSettings() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
auto* controller = keyboard::KeyboardController::Get(); auto* keyboard_client = ChromeKeyboardControllerClient::Get();
if (controller->IsEnabled()) if (keyboard_client->is_keyboard_enabled())
controller->DismissVirtualKeyboard(); keyboard_client->HideKeyboard(ash::mojom::HideReason::kUser);
base::RecordAction(base::UserMetricsAction("OpenLanguageOptionsDialog")); base::RecordAction(base::UserMetricsAction("OpenLanguageOptionsDialog"));
chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(), chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(),
...@@ -280,37 +277,35 @@ bool ChromeVirtualKeyboardDelegate::SetVirtualKeyboardMode( ...@@ -280,37 +277,35 @@ bool ChromeVirtualKeyboardDelegate::SetVirtualKeyboardMode(
bool ChromeVirtualKeyboardDelegate::SetOccludedBounds( bool ChromeVirtualKeyboardDelegate::SetOccludedBounds(
const std::vector<gfx::Rect>& bounds) { const std::vector<gfx::Rect>& bounds) {
keyboard::KeyboardController* controller = auto* keyboard_client = ChromeKeyboardControllerClient::Get();
keyboard::KeyboardController::Get(); if (!keyboard_client->is_keyboard_enabled())
if (!controller->IsEnabled())
return false; return false;
// TODO(https://crbug.com/826617): Support occluded bounds with multiple keyboard_client->SetOccludedBounds(bounds);
// rectangles.
controller->SetOccludedBounds(bounds.empty() ? gfx::Rect() : bounds[0]);
return true; return true;
} }
bool ChromeVirtualKeyboardDelegate::SetHitTestBounds( bool ChromeVirtualKeyboardDelegate::SetHitTestBounds(
const std::vector<gfx::Rect>& bounds) { const std::vector<gfx::Rect>& bounds) {
keyboard::KeyboardController* controller = auto* keyboard_client = ChromeKeyboardControllerClient::Get();
keyboard::KeyboardController::Get(); if (!keyboard_client->is_keyboard_enabled())
if (!controller->IsEnabled())
return false; return false;
controller->SetHitTestBounds(bounds); keyboard_client->SetHitTestBounds(bounds);
return true; return true;
} }
bool ChromeVirtualKeyboardDelegate::SetDraggableArea( bool ChromeVirtualKeyboardDelegate::SetDraggableArea(
const api::virtual_keyboard_private::Bounds& rect) { const api::virtual_keyboard_private::Bounds& rect) {
auto* controller = keyboard::KeyboardController::Get(); auto* keyboard_client = ChromeKeyboardControllerClient::Get();
// Since controller will be destroyed when system switch from VK to // Since controller will be destroyed when system switch from VK to
// physical keyboard, return true to avoid unneccessary exception. // physical keyboard, return true to avoid unneccessary exception.
if (!controller->IsEnabled()) if (!keyboard_client->is_keyboard_enabled())
return true; return true;
return controller->SetDraggableArea(
keyboard_client->SetDraggableArea(
gfx::Rect(rect.left, rect.top, rect.width, rect.height)); gfx::Rect(rect.left, rect.top, rect.width, rect.height));
return true;
} }
bool ChromeVirtualKeyboardDelegate::SetRequestedKeyboardState(int state_enum) { bool ChromeVirtualKeyboardDelegate::SetRequestedKeyboardState(int state_enum) {
...@@ -345,12 +340,17 @@ void ChromeVirtualKeyboardDelegate::OnHasInputDevices( ...@@ -345,12 +340,17 @@ void ChromeVirtualKeyboardDelegate::OnHasInputDevices(
OnKeyboardSettingsCallback on_settings_callback, OnKeyboardSettingsCallback on_settings_callback,
bool has_audio_input_devices) { bool has_audio_input_devices) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
auto* keyboard_client = ChromeKeyboardControllerClient::Get();
std::unique_ptr<base::DictionaryValue> results(new base::DictionaryValue()); std::unique_ptr<base::DictionaryValue> results(new base::DictionaryValue());
results->SetString("layout", GetKeyboardLayout()); results->SetString("layout", GetKeyboardLayout());
// TODO(bshe): Consolidate a11y, hotrod and normal mode into a mode enum. See // TODO(bshe): Consolidate a11y, hotrod and normal mode into a mode enum. See
// crbug.com/529474. // crbug.com/529474.
results->SetBoolean("a11ymode", keyboard::GetAccessibilityKeyboardEnabled()); results->SetBoolean(
"a11ymode",
keyboard_client->IsEnableFlagSet(
keyboard::mojom::KeyboardEnableFlag::kAccessibilityEnabled));
results->SetBoolean("hotrodmode", g_hotrod_keyboard_enabled); results->SetBoolean("hotrodmode", g_hotrod_keyboard_enabled);
std::unique_ptr<base::ListValue> features(new base::ListValue()); std::unique_ptr<base::ListValue> features(new base::ListValue());
...@@ -388,7 +388,7 @@ void ChromeVirtualKeyboardDelegate::OnHasInputDevices( ...@@ -388,7 +388,7 @@ void ChromeVirtualKeyboardDelegate::OnHasInputDevices(
"imeservice", base::FeatureList::IsEnabled( "imeservice", base::FeatureList::IsEnabled(
chromeos::features::kImeServiceConnectable))); chromeos::features::kImeServiceConnectable)));
auto config = ChromeKeyboardControllerClient::Get()->GetKeyboardConfig(); keyboard::mojom::KeyboardConfig config = keyboard_client->GetKeyboardConfig();
// TODO(oka): Change this to use config.voice_input. // TODO(oka): Change this to use config.voice_input.
features->AppendString(GenerateFeatureFlag( features->AppendString(GenerateFeatureFlag(
"voiceinput", has_audio_input_devices && config.voice_input && "voiceinput", has_audio_input_devices && config.voice_input &&
......
...@@ -72,9 +72,9 @@ ChromeKeyboardControllerClient::ChromeKeyboardControllerClient( ...@@ -72,9 +72,9 @@ ChromeKeyboardControllerClient::ChromeKeyboardControllerClient(
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
// Request the initial set of enable flags. // Request the initial set of enable flags.
keyboard_controller_ptr_->GetEnableFlags( keyboard_controller_ptr_->GetEnableFlags(base::BindOnce(
base::BindOnce(&ChromeKeyboardControllerClient::OnGetEnableFlags, &ChromeKeyboardControllerClient::OnKeyboardEnableFlagsChanged,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
// Request the initial visible state. // Request the initial visible state.
keyboard_controller_ptr_->IsKeyboardVisible(base::BindOnce( keyboard_controller_ptr_->IsKeyboardVisible(base::BindOnce(
...@@ -125,17 +125,11 @@ void ChromeKeyboardControllerClient::GetKeyboardEnabled( ...@@ -125,17 +125,11 @@ void ChromeKeyboardControllerClient::GetKeyboardEnabled(
void ChromeKeyboardControllerClient::SetEnableFlag( void ChromeKeyboardControllerClient::SetEnableFlag(
const keyboard::mojom::KeyboardEnableFlag& flag) { const keyboard::mojom::KeyboardEnableFlag& flag) {
keyboard_controller_ptr_->SetEnableFlag(flag); keyboard_controller_ptr_->SetEnableFlag(flag);
keyboard_controller_ptr_->GetEnableFlags(
base::BindOnce(&ChromeKeyboardControllerClient::OnGetEnableFlags,
weak_ptr_factory_.GetWeakPtr()));
} }
void ChromeKeyboardControllerClient::ClearEnableFlag( void ChromeKeyboardControllerClient::ClearEnableFlag(
const keyboard::mojom::KeyboardEnableFlag& flag) { const keyboard::mojom::KeyboardEnableFlag& flag) {
keyboard_controller_ptr_->ClearEnableFlag(flag); keyboard_controller_ptr_->ClearEnableFlag(flag);
keyboard_controller_ptr_->GetEnableFlags(
base::BindOnce(&ChromeKeyboardControllerClient::OnGetEnableFlags,
weak_ptr_factory_.GetWeakPtr()));
} }
bool ChromeKeyboardControllerClient::IsEnableFlagSet( bool ChromeKeyboardControllerClient::IsEnableFlagSet(
...@@ -168,6 +162,24 @@ void ChromeKeyboardControllerClient::SetContainerType( ...@@ -168,6 +162,24 @@ void ChromeKeyboardControllerClient::SetContainerType(
std::move(callback)); std::move(callback));
} }
void ChromeKeyboardControllerClient::SetKeyboardLocked(bool locked) {
keyboard_controller_ptr_->SetKeyboardLocked(locked);
}
void ChromeKeyboardControllerClient::SetOccludedBounds(
const std::vector<gfx::Rect>& bounds) {
keyboard_controller_ptr_->SetOccludedBounds(bounds);
}
void ChromeKeyboardControllerClient::SetHitTestBounds(
const std::vector<gfx::Rect>& bounds) {
keyboard_controller_ptr_->SetHitTestBounds(bounds);
}
void ChromeKeyboardControllerClient::SetDraggableArea(const gfx::Rect& bounds) {
keyboard_controller_ptr_->SetDraggableArea(bounds);
}
bool ChromeKeyboardControllerClient::IsKeyboardOverscrollEnabled() { bool ChromeKeyboardControllerClient::IsKeyboardOverscrollEnabled() {
DCHECK(cached_keyboard_config_); DCHECK(cached_keyboard_config_);
if (cached_keyboard_config_->overscroll_behavior != if (cached_keyboard_config_->overscroll_behavior !=
...@@ -214,6 +226,12 @@ void ChromeKeyboardControllerClient::FlushForTesting() { ...@@ -214,6 +226,12 @@ void ChromeKeyboardControllerClient::FlushForTesting() {
keyboard_controller_ptr_.FlushForTesting(); keyboard_controller_ptr_.FlushForTesting();
} }
void ChromeKeyboardControllerClient::OnKeyboardEnableFlagsChanged(
const std::vector<keyboard::mojom::KeyboardEnableFlag>& flags) {
keyboard_enable_flags_ =
std::set<keyboard::mojom::KeyboardEnableFlag>(flags.begin(), flags.end());
}
void ChromeKeyboardControllerClient::OnKeyboardEnabledChanged(bool enabled) { void ChromeKeyboardControllerClient::OnKeyboardEnabledChanged(bool enabled) {
bool was_enabled = is_keyboard_enabled_; bool was_enabled = is_keyboard_enabled_;
is_keyboard_enabled_ = enabled; is_keyboard_enabled_ = enabled;
...@@ -281,12 +299,6 @@ void ChromeKeyboardControllerClient::OnKeyboardVisibleBoundsChanged( ...@@ -281,12 +299,6 @@ void ChromeKeyboardControllerClient::OnKeyboardVisibleBoundsChanged(
router->BroadcastEvent(std::move(event)); router->BroadcastEvent(std::move(event));
} }
void ChromeKeyboardControllerClient::OnGetEnableFlags(
const std::vector<keyboard::mojom::KeyboardEnableFlag>& flags) {
keyboard_enable_flags_ =
std::set<keyboard::mojom::KeyboardEnableFlag>(flags.begin(), flags.end());
}
Profile* ChromeKeyboardControllerClient::GetProfile() { Profile* ChromeKeyboardControllerClient::GetProfile() {
if (profile_for_test_) if (profile_for_test_)
return profile_for_test_; return profile_for_test_;
......
...@@ -79,6 +79,10 @@ class ChromeKeyboardControllerClient ...@@ -79,6 +79,10 @@ class ChromeKeyboardControllerClient
void SetContainerType(keyboard::mojom::ContainerType container_type, void SetContainerType(keyboard::mojom::ContainerType container_type,
const base::Optional<gfx::Rect>& target_bounds, const base::Optional<gfx::Rect>& target_bounds,
base::OnceCallback<void(bool)> callback); base::OnceCallback<void(bool)> callback);
void SetKeyboardLocked(bool locked);
void SetOccludedBounds(const std::vector<gfx::Rect>& bounds);
void SetHitTestBounds(const std::vector<gfx::Rect>& bounds);
void SetDraggableArea(const gfx::Rect& bounds);
// Returns true if overscroll is enabled by the config or command line. // Returns true if overscroll is enabled by the config or command line.
bool IsKeyboardOverscrollEnabled(); bool IsKeyboardOverscrollEnabled();
...@@ -101,15 +105,14 @@ class ChromeKeyboardControllerClient ...@@ -101,15 +105,14 @@ class ChromeKeyboardControllerClient
private: private:
// keyboard::mojom::KeyboardControllerObserver: // keyboard::mojom::KeyboardControllerObserver:
void OnKeyboardEnableFlagsChanged(
const std::vector<keyboard::mojom::KeyboardEnableFlag>& flags) override;
void OnKeyboardEnabledChanged(bool enabled) override; void OnKeyboardEnabledChanged(bool enabled) override;
void OnKeyboardConfigChanged( void OnKeyboardConfigChanged(
keyboard::mojom::KeyboardConfigPtr config) override; keyboard::mojom::KeyboardConfigPtr config) 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 OnGetEnableFlags(
const std::vector<keyboard::mojom::KeyboardEnableFlag>& flags);
// Returns either the test profile or the active user profile. // Returns either the test profile or the active user profile.
Profile* GetProfile(); Profile* GetProfile();
......
...@@ -59,6 +59,10 @@ class ChromeKeyboardControllerClientTestHelper::FakeKeyboardController ...@@ -59,6 +59,10 @@ class ChromeKeyboardControllerClientTestHelper::FakeKeyboardController
SetContainerTypeCallback callback) override { SetContainerTypeCallback callback) override {
std::move(callback).Run(true); std::move(callback).Run(true);
} }
void SetKeyboardLocked(bool locked) override {}
void SetOccludedBounds(const std::vector<gfx::Rect>& bounds) override {}
void SetHitTestBounds(const std::vector<gfx::Rect>& bounds) override {}
void SetDraggableArea(const gfx::Rect& bounds) override {}
void AddObserver(ash::mojom::KeyboardControllerObserverAssociatedPtrInfo void AddObserver(ash::mojom::KeyboardControllerObserverAssociatedPtrInfo
observer) override {} observer) override {}
......
...@@ -115,7 +115,7 @@ class KEYBOARD_EXPORT ContainerBehavior { ...@@ -115,7 +115,7 @@ class KEYBOARD_EXPORT ContainerBehavior {
virtual bool OccludedBoundsAffectWorkspaceLayout() const = 0; virtual bool OccludedBoundsAffectWorkspaceLayout() const = 0;
// Sets floating keyboard drggable rect. // Sets floating keyboard drggable rect.
virtual bool SetDraggableArea(const gfx::Rect& rect) = 0; virtual void SetDraggableArea(const gfx::Rect& rect) = 0;
protected: protected:
Delegate* delegate_; Delegate* delegate_;
......
...@@ -309,9 +309,8 @@ bool ContainerFloatingBehavior::OccludedBoundsAffectWorkspaceLayout() const { ...@@ -309,9 +309,8 @@ bool ContainerFloatingBehavior::OccludedBoundsAffectWorkspaceLayout() const {
return false; return false;
} }
bool ContainerFloatingBehavior::SetDraggableArea(const gfx::Rect& rect) { void ContainerFloatingBehavior::SetDraggableArea(const gfx::Rect& rect) {
draggable_area_ = rect; draggable_area_ = rect;
return true;
} }
} // namespace keyboard } // namespace keyboard
...@@ -48,7 +48,7 @@ class KEYBOARD_EXPORT ContainerFloatingBehavior : public ContainerBehavior { ...@@ -48,7 +48,7 @@ class KEYBOARD_EXPORT ContainerFloatingBehavior : public ContainerBehavior {
gfx::Rect GetOccludedBounds( gfx::Rect GetOccludedBounds(
const gfx::Rect& visual_bounds_in_screen) const override; const gfx::Rect& visual_bounds_in_screen) const override;
bool OccludedBoundsAffectWorkspaceLayout() const override; bool OccludedBoundsAffectWorkspaceLayout() const override;
bool SetDraggableArea(const gfx::Rect& rect) override; void SetDraggableArea(const gfx::Rect& rect) override;
// Calculate the position of the keyboard for when it is being shown. // Calculate the position of the keyboard for when it is being shown.
gfx::Point GetPositionForShowingKeyboard( gfx::Point GetPositionForShowingKeyboard(
......
...@@ -126,11 +126,8 @@ bool ContainerFullWidthBehavior::OccludedBoundsAffectWorkspaceLayout() const { ...@@ -126,11 +126,8 @@ bool ContainerFullWidthBehavior::OccludedBoundsAffectWorkspaceLayout() const {
return delegate_->IsKeyboardLocked(); return delegate_->IsKeyboardLocked();
} }
bool ContainerFullWidthBehavior::SetDraggableArea(const gfx::Rect& rect) { void ContainerFullWidthBehavior::SetDraggableArea(const gfx::Rect& rect) {
// Allow extension to call this function but does nothing here. // Allow extension to call this function but does nothing here.
// To avoid unnecessary exception when VK calls this function to
// clear draggable area in full width mode.
return true;
} }
} // namespace keyboard } // namespace keyboard
...@@ -45,7 +45,7 @@ class KEYBOARD_EXPORT ContainerFullWidthBehavior : public ContainerBehavior { ...@@ -45,7 +45,7 @@ class KEYBOARD_EXPORT ContainerFullWidthBehavior : public ContainerBehavior {
gfx::Rect GetOccludedBounds( gfx::Rect GetOccludedBounds(
const gfx::Rect& visual_bounds_in_screen) const override; const gfx::Rect& visual_bounds_in_screen) const override;
bool OccludedBoundsAffectWorkspaceLayout() const override; bool OccludedBoundsAffectWorkspaceLayout() const override;
bool SetDraggableArea(const gfx::Rect& rect) override; void SetDraggableArea(const gfx::Rect& rect) override;
private: private:
gfx::Rect occluded_bounds_in_window_; gfx::Rect occluded_bounds_in_window_;
......
...@@ -398,10 +398,14 @@ void KeyboardController::SetEnableFlag(mojom::KeyboardEnableFlag flag) { ...@@ -398,10 +398,14 @@ void KeyboardController::SetEnableFlag(mojom::KeyboardEnableFlag flag) {
default: default:
break; break;
} }
for (KeyboardControllerObserver& observer : observer_list_)
observer.OnKeyboardEnableFlagsChanged(keyboard_enable_flags_);
} }
void KeyboardController::ClearEnableFlag(mojom::KeyboardEnableFlag flag) { void KeyboardController::ClearEnableFlag(mojom::KeyboardEnableFlag flag) {
keyboard_enable_flags_.erase(flag); keyboard_enable_flags_.erase(flag);
for (KeyboardControllerObserver& observer : observer_list_)
observer.OnKeyboardEnableFlagsChanged(keyboard_enable_flags_);
} }
bool KeyboardController::IsEnableFlagSet(mojom::KeyboardEnableFlag flag) const { bool KeyboardController::IsEnableFlagSet(mojom::KeyboardEnableFlag flag) const {
...@@ -1033,8 +1037,8 @@ void KeyboardController::RecordUkmKeyboardShown() { ...@@ -1033,8 +1037,8 @@ void KeyboardController::RecordUkmKeyboardShown() {
text_input_client->GetTextInputType()); text_input_client->GetTextInputType());
} }
bool KeyboardController::SetDraggableArea(const gfx::Rect& rect) { void KeyboardController::SetDraggableArea(const gfx::Rect& rect) {
return container_behavior_->SetDraggableArea(rect); container_behavior_->SetDraggableArea(rect);
} }
// InputMethodKeyboardController overrides: // InputMethodKeyboardController overrides:
......
...@@ -238,7 +238,7 @@ class KEYBOARD_EXPORT KeyboardController ...@@ -238,7 +238,7 @@ class KEYBOARD_EXPORT KeyboardController
base::OnceCallback<void(bool)> callback); base::OnceCallback<void(bool)> callback);
// Sets floating keyboard draggable rect. // Sets floating keyboard draggable rect.
bool SetDraggableArea(const gfx::Rect& rect); void SetDraggableArea(const gfx::Rect& rect);
// InputMethodKeyboardController overrides: // InputMethodKeyboardController overrides:
bool DisplayVirtualKeyboard() override; bool DisplayVirtualKeyboard() override;
...@@ -252,6 +252,10 @@ class KEYBOARD_EXPORT KeyboardController ...@@ -252,6 +252,10 @@ class KEYBOARD_EXPORT KeyboardController
bool keyboard_locked() const { return keyboard_locked_; } bool keyboard_locked() const { return keyboard_locked_; }
void set_keyboard_locked(bool lock) { keyboard_locked_ = lock; } void set_keyboard_locked(bool lock) { keyboard_locked_ = lock; }
void set_container_behavior_for_test(
std::unique_ptr<ContainerBehavior> container_behavior) {
container_behavior_ = std::move(container_behavior);
}
KeyboardControllerState GetStateForTest() const { return state_; } KeyboardControllerState GetStateForTest() const { return state_; }
ui::InputMethod* GetInputMethodForTest(); ui::InputMethod* GetInputMethodForTest();
void EnsureCaretInWorkAreaForTest(const gfx::Rect& occluded_bounds); void EnsureCaretInWorkAreaForTest(const gfx::Rect& occluded_bounds);
......
...@@ -67,6 +67,10 @@ class KEYBOARD_EXPORT KeyboardControllerObserver { ...@@ -67,6 +67,10 @@ class KEYBOARD_EXPORT KeyboardControllerObserver {
virtual void OnKeyboardAppearanceChanged( virtual void OnKeyboardAppearanceChanged(
const KeyboardStateDescriptor& state) {} const KeyboardStateDescriptor& state) {}
// Called when an enable flag affecting the requested enabled state changes.
virtual void OnKeyboardEnableFlagsChanged(
std::set<mojom::KeyboardEnableFlag>& keyboard_enable_flags) {}
// Called when the keyboard is enabled or disabled. NOTE: This is called // Called when the keyboard is enabled or disabled. NOTE: This is called
// when Enabled() or Disabled() is called, not when the requested enabled // when Enabled() or Disabled() is called, not when the requested enabled
// state (IsEnableRequested) changes. // state (IsEnableRequested) changes.
......
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