[Passwords] Suppress Soft Keyboard for Touch To Fill
This change implements the necessary change to the renderer to suppress
the soft keyboard in case the Touch To Fill UI should be shown. It does
so by adding an always_hide_ime field to RenderWidget and TextInputState
and modifying ImeAdapterImpl.java to always hide the IME if this flag is
set.
Bug: 957532
Change-Id: I835f89991aeca931c8c963ce6e8e165187188ed5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1619788
Commit-Queue: Jan Wilken Dörrie <[email protected]>
Reviewed-by: Avi Drissman <[email protected]>
Reviewed-by: Changwan Ryu <[email protected]>
Reviewed-by: Daniel Cheng <[email protected]>
Cr-Commit-Position: refs/heads/master@{#683581}
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index 799cc64..09ef4066 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -6,7 +6,6 @@
#include <cmath>
#include <limits>
-#include <memory>
#include <utility>
#include "base/auto_reset.h"
@@ -129,10 +128,6 @@
#include "third_party/skia/include/core/SkPixelRef.h"
#endif // defined(OS_POSIX)
-#if defined(OS_MACOSX)
-#include "content/renderer/text_input_client_observer.h"
-#endif
-
using blink::WebImeTextSpan;
using blink::WebCursorInfo;
using blink::WebDeviceEmulationParams;
@@ -446,33 +441,13 @@
mojom::WidgetRequest widget_request)
: routing_id_(widget_routing_id),
compositor_deps_(compositor_deps),
- webwidget_internal_(nullptr),
- auto_resize_mode_(false),
is_hidden_(hidden),
compositor_never_visible_(never_visible),
- is_fullscreen_granted_(false),
display_mode_(display_mode),
- ime_event_guard_(nullptr),
is_frozen_(is_frozen),
- text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
- text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT),
- text_input_flags_(0),
next_previous_flags_(kInvalidNextPreviousFlagsValue),
- can_compose_inline_(true),
- composition_range_(gfx::Range::InvalidRange()),
- pending_window_rect_count_(0),
screen_info_(screen_info),
- monitor_composition_info_(false),
- popup_origin_scale_for_emulation_(0.f),
frame_swap_message_queue_(new FrameSwapMessageQueue(routing_id_)),
- has_host_context_menu_location_(false),
- has_focus_(false),
- for_child_local_root_frame_(false),
-#if defined(OS_MACOSX)
- text_input_client_observer_(new TextInputClientObserver(this)),
-#endif
- first_update_visual_state_after_hidden_(false),
- was_shown_time_(base::TimeTicks::Now()),
widget_binding_(this, std::move(widget_request)) {
DCHECK_NE(routing_id_, MSG_ROUTING_NONE);
DCHECK(RenderThread::IsMainThread());
@@ -1493,12 +1468,19 @@
bool new_can_compose_inline = CanComposeInline();
+ // Check whether the keyboard should always be hidden for the currently
+ // focused element.
+ auto* focused_frame = GetFocusedWebLocalFrameInWidget();
+ bool always_hide_ime =
+ focused_frame && focused_frame->ShouldSuppressKeyboardForFocusedElement();
+
// Only sends text input params if they are changed or if the ime should be
// shown.
if (show_virtual_keyboard || reply_to_request ||
text_input_type_ != new_type || text_input_mode_ != new_mode ||
text_input_info_ != new_info ||
- can_compose_inline_ != new_can_compose_inline) {
+ can_compose_inline_ != new_can_compose_inline ||
+ always_hide_ime_ != always_hide_ime) {
TextInputState params;
params.type = new_type;
params.mode = new_mode;
@@ -1532,6 +1514,7 @@
// TODO(changwan): change instances of show_ime_if_needed to
// show_virtual_keyboard.
params.show_ime_if_needed = show_virtual_keyboard;
+ params.always_hide_ime = always_hide_ime;
params.reply_to_request = reply_to_request;
Send(new WidgetHostMsg_TextInputStateChanged(routing_id(), params));
@@ -1539,6 +1522,7 @@
text_input_type_ = new_type;
text_input_mode_ = new_mode;
can_compose_inline_ = new_can_compose_inline;
+ always_hide_ime_ = always_hide_ime;
text_input_flags_ = new_info.flags;
#if defined(OS_ANDROID)