Commit e419ff3d authored by Blake O'Hare's avatar Blake O'Hare Committed by Commit Bot

Remove an ash::Shell access from ChromeLauncherController

ChromeLauncherController is resetting the virtual keyboard when the
active user changes. However, the SessionController (which is already
in ash) can have an observer that can listen to the same event. By
making the VirtualKeyboardController a SessionObserver, we can move
the keyboard reset to the other process to make it mustash-friendly.

Bug: 826391
Change-Id: I70b622105c3bf6dd415b1eee5f0521a38b6d1bf1
Reviewed-on: https://chromium-review.googlesource.com/1100672
Commit-Queue: Blake O'Hare <blakeo@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569926}
parent ad468cfb
......@@ -11,6 +11,7 @@
#include "ash/keyboard/keyboard_ui.h"
#include "ash/public/cpp/config.h"
#include "ash/root_window_controller.h"
#include "ash/session/session_controller.h"
#include "ash/shell.h"
#include "ash/system/tray/system_tray_notifier.h"
#include "ash/wm/tablet_mode/tablet_mode_controller.h"
......@@ -84,6 +85,7 @@ VirtualKeyboardController::VirtualKeyboardController()
has_touchscreen_(false),
ignore_external_keyboard_(false) {
Shell::Get()->tablet_mode_controller()->AddObserver(this);
Shell::Get()->session_controller()->AddObserver(this);
ui::InputDeviceManager::GetInstance()->AddObserver(this);
UpdateDevices();
......@@ -97,6 +99,8 @@ VirtualKeyboardController::VirtualKeyboardController()
VirtualKeyboardController::~VirtualKeyboardController() {
if (Shell::Get()->tablet_mode_controller())
Shell::Get()->tablet_mode_controller()->RemoveObserver(this);
if (Shell::Get()->session_controller())
Shell::Get()->session_controller()->RemoveObserver(this);
ui::InputDeviceManager::GetInstance()->RemoveObserver(this);
// Reset the emoji panel callback
......@@ -309,4 +313,11 @@ void VirtualKeyboardController::OnKeyboardHidden() {
}
}
void VirtualKeyboardController::OnActiveUserSessionChanged(
const AccountId& account_id) {
// Force on-screen keyboard to reset.
if (keyboard::IsKeyboardEnabled())
Shell::Get()->EnableKeyboard();
}
} // namespace ash
......@@ -8,6 +8,7 @@
#include <stdint.h>
#include "ash/ash_export.h"
#include "ash/session/session_observer.h"
#include "ash/wm/tablet_mode/tablet_mode_observer.h"
#include "base/macros.h"
#include "ui/base/ime/chromeos/public/interfaces/ime_keyset.mojom.h"
......@@ -25,7 +26,8 @@ class ASH_EXPORT VirtualKeyboardController
: public TabletModeObserver,
public ui::InputDeviceEventObserver,
public keyboard::KeyboardLayoutDelegate,
public keyboard::KeyboardControllerObserver {
public keyboard::KeyboardControllerObserver,
public SessionObserver {
public:
VirtualKeyboardController();
~VirtualKeyboardController() override;
......@@ -56,6 +58,9 @@ class ASH_EXPORT VirtualKeyboardController
void OnKeyboardClosed() override;
void OnKeyboardHidden() override;
// SessionObserver
void OnActiveUserSessionChanged(const AccountId& account_id) override;
private:
// Updates the list of active input devices.
void UpdateDevices();
......
......@@ -552,12 +552,6 @@ void ChromeLauncherController::ActiveUserChanged(
// Restore the order of running, but unpinned applications for the activated
// user.
RestoreUnpinnedRunningApplicationOrder(user_email);
// TODO(crbug.com/557406): Fix this interaction pattern in Mash.
if (features::IsAshInBrowserProcess()) {
// Force on-screen keyboard to reset.
if (keyboard::IsKeyboardEnabled())
ash::Shell::Get()->EnableKeyboard();
}
}
void ChromeLauncherController::AdditionalUserAddedToSession(Profile* profile) {
......
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