Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(698)

Unified Diff: components/autofill/content/renderer/autofill_agent.cc

Issue 1026493002: Allow only a user gesture to trigger autofill popup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Hide popup. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/autofill/content/renderer/autofill_agent.h ('k') | content/public/test/render_view_test.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/content/renderer/autofill_agent.cc
diff --git a/components/autofill/content/renderer/autofill_agent.cc b/components/autofill/content/renderer/autofill_agent.cc
index 31068330ae94793b6238892e9bc27b57bc7ca8d7..bccf1b266ff3539c8874c4bac311463239e03541 100644
--- a/components/autofill/content/renderer/autofill_agent.cc
+++ b/components/autofill/content/renderer/autofill_agent.cc
@@ -43,6 +43,7 @@
#include "third_party/WebKit/public/web/WebNode.h"
#include "third_party/WebKit/public/web/WebOptionElement.h"
#include "third_party/WebKit/public/web/WebTextAreaElement.h"
+#include "third_party/WebKit/public/web/WebUserGestureIndicator.h"
#include "third_party/WebKit/public/web/WebView.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/events/keycodes/keyboard_codes.h"
@@ -62,6 +63,7 @@ using blink::WebNode;
using blink::WebOptionElement;
using blink::WebString;
using blink::WebTextAreaElement;
+using blink::WebUserGestureIndicator;
using blink::WebVector;
namespace autofill {
@@ -149,7 +151,6 @@ AutofillAgent::AutofillAgent(content::RenderFrame* render_frame,
autofill_query_id_(0),
was_query_node_autofilled_(false),
has_shown_autofill_popup_for_current_edit_(false),
- did_set_node_text_(false),
ignore_text_changes_(false),
is_popup_possibly_visible_(false),
weak_ptr_factory_(this) {
@@ -378,19 +379,17 @@ void AutofillAgent::textFieldDidEndEditing(const WebInputElement& element) {
}
void AutofillAgent::textFieldDidChange(const WebFormControlElement& element) {
+ DCHECK(toWebInputElement(&element) || IsTextAreaElement(element));
if (ignore_text_changes_)
return;
- DCHECK(toWebInputElement(&element) || IsTextAreaElement(element));
-
- if (did_set_node_text_) {
- did_set_node_text_ = false;
+ if (!WebUserGestureIndicator::isProcessingUserGesture())
return;
- }
- // We post a task for doing the Autofill as the caret position is not set
- // properly at this point (http://bugs.webkit.org/show_bug.cgi?id=16976) and
- // it is needed to trigger autofill.
+ // We post a task for doing the Autofill as the caret position
+ // (http://bugs.webkit.org/show_bug.cgi?id=16976) and IME composition are not
+ // set properly at this point and this information is needed to trigger
+ // autofill.
weak_ptr_factory_.InvalidateWeakPtrs();
base::MessageLoop::current()->PostTask(
FROM_HERE,
@@ -406,6 +405,15 @@ void AutofillAgent::TextFieldDidChangeImpl(
if (!element.focused())
return;
+#if !defined(OS_ANDROID)
+ // IME composition on desktop is used for CJK, which will overlap with
+ // autofill popup near the input field.
+ if (render_frame()->GetWebFrame()->hasMarkedText()) {
+ HidePopup();
Evan Stade 2015/04/20 22:40:30 as per offline convo I think we should show autofi
please use gerrit instead 2015/04/20 23:51:27 Done.
+ return;
+ }
+#endif
+
const WebInputElement* input_element = toWebInputElement(&element);
if (input_element) {
if (password_generation_agent_ &&
@@ -714,8 +722,9 @@ void AutofillAgent::QueryAutofillSuggestions(
void AutofillAgent::FillFieldWithValue(const base::string16& value,
WebInputElement* node) {
- did_set_node_text_ = true;
+ ignore_text_changes_ = true;
node->setEditingValue(value.substr(0, node->maxLength()));
+ ignore_text_changes_ = false;
Evan Stade 2015/04/20 22:40:30 use base::AutoReset for this
please use gerrit instead 2015/04/20 23:51:27 Done.
}
void AutofillAgent::PreviewFieldWithValue(const base::string16& value,
« no previous file with comments | « components/autofill/content/renderer/autofill_agent.h ('k') | content/public/test/render_view_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698