Commit 42a4d4a9 authored by Steven Bennetts's avatar Steven Bennetts Committed by Commit Bot

Move KeyboardConfig to a separate keyboard_config.mojom

This also includes some cleanup of default values, renames
'override' -> 'behavior', and documents the
KeyboardOverscrollBehavior enum.

Bug: 843332
Change-Id: I5149d41701ff44606f2ce4dec3f74d263ed411d2
Reviewed-on: https://chromium-review.googlesource.com/c/1262958Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Reviewed-by: default avatarDarren Shen <shend@chromium.org>
Commit-Queue: Steven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#597227}
parent 30ba9b7b
......@@ -30,16 +30,16 @@ LockWindow::LockWindow() {
// login/lock content. See crbug.com/363635.
keyboard::mojom::KeyboardConfig config =
keyboard::KeyboardController::Get()->keyboard_config();
config.overscroll_override =
keyboard::mojom::KeyboardOverscrollOverride::kDisabled;
config.overscroll_behavior =
keyboard::mojom::KeyboardOverscrollBehavior::kDisabled;
keyboard::KeyboardController::Get()->UpdateKeyboardConfig(config);
}
LockWindow::~LockWindow() {
keyboard::mojom::KeyboardConfig config =
keyboard::KeyboardController::Get()->keyboard_config();
config.overscroll_override =
keyboard::mojom::KeyboardOverscrollOverride::kNone;
config.overscroll_behavior =
keyboard::mojom::KeyboardOverscrollBehavior::kDefault;
keyboard::KeyboardController::Get()->UpdateKeyboardConfig(config);
// We need to destroy the root view before destroying |data_dispatcher_|
......
......@@ -176,9 +176,9 @@ void MagnificationController::SetEnabled(bool enabled) {
// so it needs to be disabled when magnification is enabled.
// TODO(spqchan): Fix the keyboard overscroll issues.
auto config = keyboard::KeyboardController::Get()->keyboard_config();
config.overscroll_override =
is_enabled_ ? keyboard::mojom::KeyboardOverscrollOverride::kDisabled
: keyboard::mojom::KeyboardOverscrollOverride::kNone;
config.overscroll_behavior =
is_enabled_ ? keyboard::mojom::KeyboardOverscrollBehavior::kDisabled
: keyboard::mojom::KeyboardOverscrollBehavior::kDefault;
keyboard::KeyboardController::Get()->UpdateKeyboardConfig(config);
}
......
......@@ -106,10 +106,10 @@ class LockLayoutManagerTest : public AshTestBase {
DCHECK_EQ(show, keyboard->IsKeyboardVisible());
}
void SetKeyboardOverscrollOverride(
keyboard::mojom::KeyboardOverscrollOverride overscroll_override) {
void SetKeyboardOverscrollBehavior(
keyboard::mojom::KeyboardOverscrollBehavior overscroll_behavior) {
auto config = keyboard::KeyboardController::Get()->keyboard_config();
config.overscroll_override = overscroll_override;
config.overscroll_behavior = overscroll_behavior;
keyboard::KeyboardController::Get()->UpdateKeyboardConfig(config);
}
};
......@@ -240,8 +240,8 @@ TEST_F(LockLayoutManagerTest, KeyboardBounds) {
// When virtual keyboard overscroll is enabled keyboard bounds should not
// affect window bounds.
keyboard::KeyboardController* keyboard = keyboard::KeyboardController::Get();
SetKeyboardOverscrollOverride(
keyboard::mojom::KeyboardOverscrollOverride::kEnabled);
SetKeyboardOverscrollBehavior(
keyboard::mojom::KeyboardOverscrollBehavior::kEnabled);
ShowKeyboard(true);
EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString());
gfx::Rect keyboard_bounds = keyboard->visual_bounds_in_screen();
......@@ -251,10 +251,10 @@ TEST_F(LockLayoutManagerTest, KeyboardBounds) {
// When keyboard is hidden make sure that rotating the screen gives 100% of
// screen size to window.
// Repro steps for http://crbug.com/401667:
// 1. Set up login screen defaults: VK override disabled
// 1. Set up login screen defaults: VK overscroll disabled
// 2. Show/hide keyboard, make sure that no stale keyboard bounds are cached.
SetKeyboardOverscrollOverride(
keyboard::mojom::KeyboardOverscrollOverride::kDisabled);
SetKeyboardOverscrollBehavior(
keyboard::mojom::KeyboardOverscrollBehavior::kDisabled);
ShowKeyboard(true);
ShowKeyboard(false);
display_manager()->SetDisplayRotation(
......@@ -269,8 +269,8 @@ TEST_F(LockLayoutManagerTest, KeyboardBounds) {
// When virtual keyboard overscroll is disabled keyboard bounds do
// affect window bounds.
SetKeyboardOverscrollOverride(
keyboard::mojom::KeyboardOverscrollOverride::kDisabled);
SetKeyboardOverscrollBehavior(
keyboard::mojom::KeyboardOverscrollBehavior::kDisabled);
ShowKeyboard(true);
primary_display = display::Screen::GetScreen()->GetPrimaryDisplay();
......@@ -281,8 +281,8 @@ TEST_F(LockLayoutManagerTest, KeyboardBounds) {
EXPECT_EQ(target_bounds.ToString(), window->GetBoundsInScreen().ToString());
ShowKeyboard(false);
SetKeyboardOverscrollOverride(
keyboard::mojom::KeyboardOverscrollOverride::kNone);
SetKeyboardOverscrollBehavior(
keyboard::mojom::KeyboardOverscrollBehavior::kDefault);
keyboard->SetContainerType(keyboard::ContainerType::FLOATING,
base::nullopt /* target_bounds */,
......
......@@ -295,16 +295,16 @@ std::string GetManagedLoginScreenLocale() {
void DisableKeyboardOverscroll() {
auto* client = ChromeKeyboardControllerClient::Get();
keyboard::mojom::KeyboardConfig config = client->GetKeyboardConfig();
config.overscroll_override =
keyboard::mojom::KeyboardOverscrollOverride::kDisabled;
config.overscroll_behavior =
keyboard::mojom::KeyboardOverscrollBehavior::kDisabled;
client->SetKeyboardConfig(config);
}
void ResetKeyboardOverscrollOverride() {
void ResetKeyboardOverscrollBehavior() {
auto* client = ChromeKeyboardControllerClient::Get();
keyboard::mojom::KeyboardConfig config = client->GetKeyboardConfig();
config.overscroll_override =
keyboard::mojom::KeyboardOverscrollOverride::kNone;
config.overscroll_behavior =
keyboard::mojom::KeyboardOverscrollBehavior::kDefault;
client->SetKeyboardConfig(config);
}
......@@ -468,7 +468,7 @@ LoginDisplayHostWebUI::~LoginDisplayHostWebUI() {
if (window_manager)
window_manager->RemoveObserver(this);
ResetKeyboardOverscrollOverride();
ResetKeyboardOverscrollBehavior();
views::FocusManager::set_arrow_key_traversal_enabled(false);
ResetLoginWindowAndView();
......
......@@ -19,7 +19,6 @@
#include "services/service_manager/public/cpp/connector.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/keyboard/keyboard_controller.h"
#include "ui/keyboard/public/keyboard_config_util.h"
namespace virtual_keyboard_private = extensions::api::virtual_keyboard_private;
......@@ -76,7 +75,7 @@ ChromeKeyboardControllerClient::GetKeyboardConfig() {
if (!cached_keyboard_config_) {
// Unlikely edge case (called before the Ash mojo service replies to the
// initial GetKeyboardConfig request). Return the default value.
return keyboard::GetDefaultKeyboardConfig();
return keyboard::mojom::KeyboardConfig();
}
return *cached_keyboard_config_.get();
}
......
......@@ -46,7 +46,6 @@ jumbo_component("keyboard") {
"keyboard_util.h",
"notification_manager.cc",
"notification_manager.h",
"public/keyboard_config_util.h",
"queued_container_type.cc",
"queued_container_type.h",
"queued_display_change.cc",
......@@ -144,6 +143,7 @@ build_closure("inputview") {
mojom("mojom") {
sources = [
"public/keyboard_config.mojom",
"public/keyboard_controller.mojom",
]
deps = [
......
......@@ -406,12 +406,12 @@ bool KeyboardController::IsKeyboardOverscrollEnabled() const {
if (enabled() && !IsOverscrollAllowed())
return false;
// If overscroll enabled override is set, use it instead. Currently
// If overscroll enabled behavior is set, use it instead. Currently
// login / out-of-box disable keyboard overscroll. http://crbug.com/363635
if (keyboard_config_.overscroll_override !=
mojom::KeyboardOverscrollOverride::kNone) {
return keyboard_config_.overscroll_override ==
mojom::KeyboardOverscrollOverride::kEnabled;
if (keyboard_config_.overscroll_behavior !=
mojom::KeyboardOverscrollBehavior::kDefault) {
return keyboard_config_.overscroll_behavior ==
mojom::KeyboardOverscrollBehavior::kEnabled;
}
return !base::CommandLine::ForCurrentProcess()->HasSwitch(
......
......@@ -26,7 +26,7 @@
#include "ui/keyboard/keyboard_layout_delegate.h"
#include "ui/keyboard/keyboard_ukm_recorder.h"
#include "ui/keyboard/notification_manager.h"
#include "ui/keyboard/public/keyboard_config_util.h"
#include "ui/keyboard/public/keyboard_config.mojom.h"
#include "ui/keyboard/public/keyboard_controller.mojom.h"
#include "ui/keyboard/queued_container_type.h"
#include "ui/keyboard/queued_display_change.h"
......@@ -392,7 +392,7 @@ class KEYBOARD_EXPORT KeyboardController
KeyboardControllerState state_ = KeyboardControllerState::UNKNOWN;
// Keyboard configuration associated with the controller.
mojom::KeyboardConfig keyboard_config_ = keyboard::GetDefaultKeyboardConfig();
mojom::KeyboardConfig keyboard_config_;
NotificationManager notification_manager_;
......
......@@ -147,15 +147,15 @@ TEST_F(KeyboardUtilTest, IsOverscrollEnabled) {
keyboard::SetTouchKeyboardEnabled(true);
EXPECT_TRUE(keyboard_controller_.IsKeyboardOverscrollEnabled());
// Override overscroll enabled state.
// Set overscroll enabled state.
auto config = keyboard::KeyboardController::Get()->keyboard_config();
config.overscroll_override =
keyboard::mojom::KeyboardOverscrollOverride::kDisabled;
config.overscroll_behavior =
keyboard::mojom::KeyboardOverscrollBehavior::kDisabled;
keyboard::KeyboardController::Get()->UpdateKeyboardConfig(config);
EXPECT_FALSE(keyboard_controller_.IsKeyboardOverscrollEnabled());
config.overscroll_override =
keyboard::mojom::KeyboardOverscrollOverride::kNone;
config.overscroll_behavior =
keyboard::mojom::KeyboardOverscrollBehavior::kDefault;
keyboard::KeyboardController::Get()->UpdateKeyboardConfig(config);
EXPECT_TRUE(keyboard_controller_.IsKeyboardOverscrollEnabled());
......
// 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.
module keyboard.mojom;
// Determines how the keyboard overscroll enabled state is set,
enum KeyboardOverscrollBehavior {
// Use the default behavior.
kDefault,
// Enable keyboard overscroll if allowed.
kEnabled,
// Do not enable keyboard overscroll.
kDisabled,
};
struct KeyboardConfig {
// Whether the virtual keyboard can provide auto-complete.
bool auto_complete = true;
// Whether the virtual keyboard can provide auto-correct.
bool auto_correct = true;
// Whether the virtual keyboard can provide auto-capitalization.
bool auto_capitalize = true;
// Whether the virtual keyboard can provide input via handwriting recognition.
bool handwriting = true;
// Whether the virtual keyboard can provide spell-check.
bool spell_check = true;
// Whether the virtual keyboard can provide voice input.
bool voice_input = true;
// Whether overscroll is currently allowed by the active keyboard container.
KeyboardOverscrollBehavior overscroll_behavior = kDefault;
};
// 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 UI_KEYBOARD_PUBLIC_KEYBOARD_CONFIG_UTIL_H_
#define UI_KEYBOARD_PUBLIC_KEYBOARD_CONFIG_UTIL_H_
#include "ui/keyboard/public/keyboard_controller.mojom.h"
namespace keyboard {
inline mojom::KeyboardConfig GetDefaultKeyboardConfig() {
return mojom::KeyboardConfig(
true /* auto_complete */, true /* auto_correct */,
true /* auto_capitalize */, true /* handwriting */,
true /* spell_check */,
// It denotes the preferred value, and can be true even if there is no
// actual audio input device.
true /* voice_input */,
mojom::KeyboardOverscrollOverride::kNone /* overscroll_override */);
};
} // namespace keyboard
#endif // UI_KEYBOARD_PUBLIC_KEYBOARD_CONFIG_UTIL_H_
......@@ -5,35 +5,7 @@
module keyboard.mojom;
import "ui/gfx/geometry/mojo/geometry.mojom";
enum KeyboardOverscrollOverride {
kDisabled = 0,
kEnabled,
kNone,
};
struct KeyboardConfig {
// Whether the virtual keyboard can provide auto-complete.
bool auto_complete;
// Whether the virtual keyboard can provide auto-correct.
bool auto_correct;
// Whether the virtual keyboard can provide auto-capitalization.
bool auto_capitalize;
// Whether the virtual keyboard can provide input via handwriting recognition.
bool handwriting;
// Whether the virtual keyboard can provide spell-check.
bool spell_check;
// Whether the virtual keyboard can provide voice input.
bool voice_input;
// Whether overscroll is currently allowed by the active keyboard container.
KeyboardOverscrollOverride overscroll_override;
};
import "ui/keyboard/public/keyboard_config.mojom";
interface KeyboardControllerObserver {
// Called when the enabled state of the virtual keyboard 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