Skip to content

Commit

Permalink
Remove usage of kDisableNewVirtualKeyboardBehavior
Browse files Browse the repository at this point in the history
This is part II of The kDisableNewVirtualKeyboardBehavior Removal
Trilogy.

Part I: Unit tests [DONE!]
Part II: Remove usage [this CL]
Part III: Removal of the flag definition [Fall 2017]

Bug: 755460
Change-Id: I17dee62334c1687d6647ea62d1eadf210b0f8e5a
Reviewed-on: https://chromium-review.googlesource.com/686027
Commit-Queue: Blake O'Hare <blakeo@chromium.org>
Reviewed-by: Sadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: Yuichiro Hanada <yhanada@chromium.org>
Reviewed-by: Mitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#506995}
  • Loading branch information
Blake O'Hare authored and Commit Bot committed Oct 6, 2017
1 parent e96b493 commit b634070
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 40 deletions.
1 change: 0 additions & 1 deletion ash/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1411,7 +1411,6 @@ test("ash_unittests") {
"wm/workspace/magnetism_matcher_unittest.cc",
"wm/workspace/multi_window_resize_controller_unittest.cc",
"wm/workspace/workspace_event_handler_unittest.cc",
"wm/workspace/workspace_layout_manager_keyboard_unittest.cc",
"wm/workspace/workspace_layout_manager_unittest.cc",
"wm/workspace/workspace_window_resizer_unittest.cc",
"wm/workspace_controller_unittest.cc",
Expand Down
9 changes: 3 additions & 6 deletions ash/shelf/shelf_layout_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -450,13 +450,10 @@ void ShelfLayoutManager::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) {
bool keyboard_is_about_to_hide = false;
if (new_bounds.IsEmpty() && !keyboard_bounds_.IsEmpty())
keyboard_is_about_to_hide = true;
// If new window behavior flag enabled and in non-sticky mode, do not change
// the work area.
// If in non-sticky mode, do not change the work area.
bool change_work_area =
(base::CommandLine::ForCurrentProcess()->HasSwitch(
::switches::kDisableNewVirtualKeyboardBehavior) ||
(keyboard::KeyboardController::GetInstance() &&
keyboard::KeyboardController::GetInstance()->keyboard_locked()));
keyboard::KeyboardController::GetInstance() &&
keyboard::KeyboardController::GetInstance()->keyboard_locked();

keyboard_bounds_ = new_bounds;
LayoutShelfAndUpdateBounds(change_work_area);
Expand Down
9 changes: 3 additions & 6 deletions ash/wm/workspace/workspace_layout_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,10 @@ void WorkspaceLayoutManager::SetChildBounds(aura::Window* child,

void WorkspaceLayoutManager::OnKeyboardBoundsChanging(
const gfx::Rect& new_bounds) {
// If new window behavior is disable or the keyboard is in sticky mode, change
// the work area.
// If the keyboard is in sticky mode, change the work area.
const bool change_work_area =
(base::CommandLine::ForCurrentProcess()->HasSwitch(
::switches::kDisableNewVirtualKeyboardBehavior) ||
(keyboard::KeyboardController::GetInstance() &&
keyboard::KeyboardController::GetInstance()->keyboard_locked()));
keyboard::KeyboardController::GetInstance() &&
keyboard::KeyboardController::GetInstance()->keyboard_locked();
if (!change_work_area)
return;

Expand Down
20 changes: 11 additions & 9 deletions ash/wm/workspace/workspace_layout_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
#include "ui/events/base_event_utils.h"
#include "ui/events/test/event_generator.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/keyboard/keyboard_controller.h"
#include "ui/keyboard/keyboard_test_util.h"
#include "ui/keyboard/keyboard_ui.h"
#include "ui/keyboard/keyboard_util.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
#include "ui/wm/core/window_util.h"
Expand Down Expand Up @@ -115,9 +119,10 @@ display::Display GetDisplayNearestWindow(aura::Window* window) {
return display::Screen::GetScreen()->GetDisplayNearestWindow(window);
}

void DisableNewVKMode() {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
command_line->AppendSwitch(::switches::kDisableNewVirtualKeyboardBehavior);
void EnableStickyKeyboard() {
keyboard::KeyboardController::ResetInstance(new keyboard::KeyboardController(
base::MakeUnique<keyboard::FakeKeyboardUI>(), nullptr));
keyboard::KeyboardController::GetInstance()->set_keyboard_locked(true);
}

} // namespace
Expand Down Expand Up @@ -1566,8 +1571,7 @@ class WorkspaceLayoutManagerKeyboardTest : public AshTestBase {
// Tests that when a child window gains focus the top level window containing it
// is resized to fit the remaining workspace area.
TEST_F(WorkspaceLayoutManagerKeyboardTest, ChildWindowFocused) {
// Append the flag to cause work area change in non-sticky mode.
DisableNewVKMode();
EnableStickyKeyboard();

// See comment at top of file for why this is needed.
CustomFrameViewAshSizeLock min_size_lock;
Expand Down Expand Up @@ -1599,8 +1603,7 @@ TEST_F(WorkspaceLayoutManagerKeyboardTest, ChildWindowFocused) {
}

TEST_F(WorkspaceLayoutManagerKeyboardTest, AdjustWindowForA11yKeyboard) {
// Append the flag to cause work area change in non-sticky mode.
DisableNewVKMode();
EnableStickyKeyboard();

// See comment at top of file for why this is needed.
CustomFrameViewAshSizeLock min_size_lock;
Expand Down Expand Up @@ -1652,8 +1655,7 @@ TEST_F(WorkspaceLayoutManagerKeyboardTest, AdjustWindowForA11yKeyboard) {
}

TEST_F(WorkspaceLayoutManagerKeyboardTest, IgnoreKeyboardBoundsChange) {
// Append the flag to cause work area change in non-sticky mode.
DisableNewVKMode();
EnableStickyKeyboard();
InitKeyboardBounds();

std::unique_ptr<aura::Window> window(CreateTestWindow(keyboard_bounds()));
Expand Down
8 changes: 2 additions & 6 deletions ui/keyboard/keyboard_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,8 @@ void KeyboardUI::EnsureCaretInWorkArea() {
contents_window->IsVisible() ? contents_window->GetBoundsInScreen()
: gfx::Rect();

// Use new virtual keyboard behavior only if the flag enabled and in
// non-sticky mode.
const bool new_vk_behavior =
(!base::CommandLine::ForCurrentProcess()->HasSwitch(
::switches::kDisableNewVirtualKeyboardBehavior) &&
!keyboard_controller_->keyboard_locked());
// Use new virtual keyboard behavior only if in non-sticky mode.
const bool new_vk_behavior = !keyboard_controller_->keyboard_locked();

if (new_vk_behavior) {
GetInputMethod()->SetOnScreenKeyboardBounds(keyboard_bounds_in_screen);
Expand Down
6 changes: 2 additions & 4 deletions ui/keyboard/keyboard_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,8 @@ bool IsKeyboardOverscrollEnabled() {

// Users of the sticky accessibility on-screen keyboard are likely to be using
// mouse input, which may interfere with overscrolling.
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
::switches::kDisableNewVirtualKeyboardBehavior) ||
(keyboard::KeyboardController::GetInstance() &&
keyboard::KeyboardController::GetInstance()->keyboard_locked())) {
if (keyboard::KeyboardController::GetInstance() &&
keyboard::KeyboardController::GetInstance()->keyboard_locked()) {
return false;
}

Expand Down
8 changes: 0 additions & 8 deletions ui/wm/core/ime_util_chromeos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(gfx::Rect,
nullptr);

void RestoreWindowBoundsOnClientFocusLost(aura::Window* window) {
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
::switches::kDisableNewVirtualKeyboardBehavior))
return;

// Get restore bounds of the window
gfx::Rect* vk_restore_bounds =
window->GetProperty(kVirtualKeyboardRestoreBoundsKey);
Expand All @@ -75,10 +71,6 @@ void RestoreWindowBoundsOnClientFocusLost(aura::Window* window) {

void EnsureWindowNotInRect(aura::Window* window,
const gfx::Rect& rect_in_screen) {
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
::switches::kDisableNewVirtualKeyboardBehavior))
return;

gfx::Rect original_window_bounds = window->GetBoundsInScreen();
if (window->GetProperty(wm::kVirtualKeyboardRestoreBoundsKey)) {
original_window_bounds =
Expand Down

0 comments on commit b634070

Please sign in to comment.