Commit e876159e authored by azurewei's avatar azurewei Committed by Commit bot

Post the task of disabling virtual keyboard

When show emoji/voice/handwriting vk with opt-in IME menu with virtual
keyboard disabled, the virtual keyboard will be forced shown once.
Thus, after the virtual keyboard hidden, the menu will disable the vk
to make sure it won't automatically brown.
The menu listens on KeyboardController::OnKeyboardHidden() event to
disable the vk, where SIGSEGV will cause.

Fix the issue by posting the task of disabling virtual keyboard.

BUG=721673
TEST=Verified on local build

Review-Url: https://codereview.chromium.org/2884873002
Cr-Commit-Position: refs/heads/master@{#472300}
parent 517cdca4
......@@ -287,7 +287,8 @@ ImeMenuTray::ImeMenuTray(WmShelf* wm_shelf)
show_keyboard_(false),
force_show_keyboard_(false),
keyboard_suppressed_(false),
show_bubble_after_keyboard_hidden_(false) {
show_bubble_after_keyboard_hidden_(false),
weak_ptr_factory_(this) {
SetInkDropMode(InkDropMode::ON);
SetupLabelForTray(label_);
label_->SetElideBehavior(gfx::TRUNCATE);
......@@ -531,8 +532,10 @@ void ImeMenuTray::OnKeyboardHidden() {
if (!force_show_keyboard_)
return;
Shell::Get()->accessibility_delegate()->SetVirtualKeyboardEnabled(false);
force_show_keyboard_ = false;
// Posts a task to disable the virtual keyboard.
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(&ImeMenuTray::DisableVirtualKeyboard,
weak_ptr_factory_.GetWeakPtr()));
}
void ImeMenuTray::OnKeyboardSuppressionChanged(bool suppressed) {
......@@ -551,4 +554,9 @@ void ImeMenuTray::UpdateTrayLabel() {
label_->SetText(current_ime_.short_name);
}
void ImeMenuTray::DisableVirtualKeyboard() {
Shell::Get()->accessibility_delegate()->SetVirtualKeyboardEnabled(false);
force_show_keyboard_ = false;
}
} // namespace ash
......@@ -96,6 +96,9 @@ class ASH_EXPORT ImeMenuTray : public TrayBackgroundView,
// Updates the text of the label on the tray.
void UpdateTrayLabel();
// Disables the virtual keyboard.
void DisableVirtualKeyboard();
// Bubble for default and detailed views.
std::unique_ptr<TrayBubbleWrapper> bubble_;
ImeListView* ime_list_view_;
......@@ -107,6 +110,8 @@ class ASH_EXPORT ImeMenuTray : public TrayBackgroundView,
bool keyboard_suppressed_;
bool show_bubble_after_keyboard_hidden_;
base::WeakPtrFactory<ImeMenuTray> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(ImeMenuTray);
};
......
......@@ -14,6 +14,7 @@
#include "ash/test/ash_test_base.h"
#include "ash/test/status_area_widget_test_helper.h"
#include "ash/test/test_system_tray_delegate.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/base/ime/chromeos/input_method_manager.h"
......@@ -297,7 +298,8 @@ TEST_F(ImeMenuTrayTest, ForceToShowEmojiKeyset) {
// Hides the keyboard.
GetTray()->OnKeyboardHidden();
// The keyboard should still be disabled.
// The keyboard should still be disabled, which is a posted task.
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(accessibility_delegate->IsVirtualKeyboardEnabled());
}
......
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