0

ImeController observe KeyboardController directly

Bug: 40598530
Change-Id: I18cf53bb27d8b93b5c34f413224a8638926b93c2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5644424
Commit-Queue: Jaewon Jung <jw.jung@navercorp.com>
Reviewed-by: Darren Shen <shend@chromium.org>
Reviewed-by: Ahmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1320146}
This commit is contained in:
Jaewon Jung
2024-06-27 02:32:24 +00:00
committed by Chromium LUCI CQ
parent 5fcaeba090
commit 8d7c55d653
5 changed files with 12 additions and 11 deletions

@ -183,6 +183,12 @@ void ImeControllerImpl::OnKeyboardLayoutNameChanged(
observer.OnKeyboardLayoutNameChanged(layout_name);
}
void ImeControllerImpl::OnKeyboardEnabledChanged(bool is_enabled) {
if (!is_enabled) {
OverrideKeyboardKeyset(input_method::ImeKeyset::kNone);
}
}
void ImeControllerImpl::SetExtraInputOptionsEnabledState(
bool is_extra_input_options_enabled,
bool is_emoji_enabled,

@ -9,6 +9,7 @@
#include <vector>
#include "ash/ash_export.h"
#include "ash/keyboard/keyboard_controller_impl.h"
#include "ash/public/cpp/ime_controller.h"
#include "ash/public/cpp/ime_controller_client.h"
#include "ash/public/cpp/ime_info.h"
@ -30,7 +31,8 @@ class ModeIndicatorObserver;
// Connects ash IME users (e.g. the system tray) to the IME implementation,
// which might live in Chrome browser or in a separate mojo service.
class ASH_EXPORT ImeControllerImpl : public ImeController {
class ASH_EXPORT ImeControllerImpl : public ImeController,
public KeyboardControllerObserver {
public:
class Observer {
public:
@ -103,6 +105,7 @@ class ASH_EXPORT ImeControllerImpl : public ImeController {
void ShowImeMenuOnShelf(bool show) override;
void UpdateCapsLockState(bool caps_enabled) override;
void OnKeyboardLayoutNameChanged(const std::string& layout_name) override;
void OnKeyboardEnabledChanged(bool is_enabled) override;
void SetExtraInputOptionsEnabledState(bool is_extra_input_options_enabled,
bool is_emoji_enabled,

@ -154,15 +154,6 @@ void VirtualKeyboardController::ForceShowKeyboard() {
keyboard_controller->ShowKeyboard(false);
}
void VirtualKeyboardController::OnKeyboardEnabledChanged(bool is_enabled) {
if (!is_enabled) {
// TODO(shend/shuchen): Consider moving this logic to ImeController.
// https://crbug.com/896284.
Shell::Get()->ime_controller()->OverrideKeyboardKeyset(
input_method::ImeKeyset::kNone);
}
}
void VirtualKeyboardController::OnKeyboardHidden(bool is_temporary_hide) {
// The keyboard may temporarily hide (e.g. to change container behaviors).
// The keyset should not be reset in this case.

@ -53,7 +53,6 @@ class ASH_EXPORT VirtualKeyboardController
void ToggleIgnoreExternalKeyboard();
// KeyboardControllerObserver:
void OnKeyboardEnabledChanged(bool is_enabled) override;
void OnKeyboardHidden(bool is_temporary_hide) override;
// SessionObserver:

@ -712,6 +712,7 @@ Shell::Shell(std::unique_ptr<ShellDelegate> shell_delegate)
PowerStatus::Initialize();
session_controller_->AddObserver(this);
keyboard_controller_->AddObserver(ime_controller_.get());
}
Shell::~Shell() {
@ -819,6 +820,7 @@ Shell::~Shell() {
screen_orientation_controller_.reset();
screen_layout_observer_.reset();
keyboard_controller_->RemoveObserver(ime_controller_.get());
// Destroy the virtual keyboard controller before the tablet mode controller
// since the latters destructor triggers events that the former is listening
// to but no longer cares about.