Commit e13b5cad authored by Tao Bai's avatar Tao Bai Committed by Commit Bot

Add AutofillAgent::SetUserGestureRequired

This new method is only used in Android platform autofill which
requires to report actual text field change.

BUG=734702

Change-Id: I0487132d998bfc2f7244c534712b7ab24a3206d1
Reviewed-on: https://chromium-review.googlesource.com/540099
Commit-Queue: Tao Bai <michaelbai@chromium.org>
Reviewed-by: default avatarRoger McFarlane <rogerm@chromium.org>
Reviewed-by: default avatarSelim Gurun <sgurun@chromium.org>
Reviewed-by: default avatarWill Harris <wfh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#481941}
parent 5967a1d7
...@@ -40,9 +40,10 @@ ContentAutofillDriver::ContentAutofillDriver( ...@@ -40,9 +40,10 @@ ContentAutofillDriver::ContentAutofillDriver(
key_press_handler_manager_(this), key_press_handler_manager_(this),
binding_(this) { binding_(this) {
// AutofillManager isn't used if provider is valid, Autofill provider is // AutofillManager isn't used if provider is valid, Autofill provider is
// currently used by Android only. // currently used by Android WebView only.
if (provider) { if (provider) {
autofill_handler_ = base::MakeUnique<AutofillHandlerProxy>(this, provider); autofill_handler_ = base::MakeUnique<AutofillHandlerProxy>(this, provider);
GetAutofillAgent()->SetUserGestureRequired(false);
} else { } else {
autofill_handler_ = base::MakeUnique<AutofillManager>( autofill_handler_ = base::MakeUnique<AutofillManager>(
this, client, app_locale, enable_download_manager); this, client, app_locale, enable_download_manager);
......
...@@ -201,6 +201,8 @@ class FakeAutofillAgent : public mojom::AutofillAgent { ...@@ -201,6 +201,8 @@ class FakeAutofillAgent : public mojom::AutofillAgent {
int32_t key, int32_t key,
const PasswordFormFillData& form_data) override {} const PasswordFormFillData& form_data) override {}
void SetUserGestureRequired(bool required) override {}
mojo::BindingSet<mojom::AutofillAgent> bindings_; mojo::BindingSet<mojom::AutofillAgent> bindings_;
base::Closure quit_closure_; base::Closure quit_closure_;
......
...@@ -8,7 +8,7 @@ import "components/autofill/content/common/autofill_types.mojom"; ...@@ -8,7 +8,7 @@ import "components/autofill/content/common/autofill_types.mojom";
import "mojo/common/string16.mojom"; import "mojo/common/string16.mojom";
// There is one instance of this interface per render frame in the render // There is one instance of this interface per render frame in the render
// process. // process. All methods are called by browser on renderer.
interface AutofillAgent { interface AutofillAgent {
// Instructs the renderer to fill the active form with the given form data. // Instructs the renderer to fill the active form with the given form data.
// Please refer AutofillDriver.QueryFormFieldAutofill comments about the |id|. // Please refer AutofillDriver.QueryFormFieldAutofill comments about the |id|.
...@@ -51,6 +51,15 @@ interface AutofillAgent { ...@@ -51,6 +51,15 @@ interface AutofillAgent {
// |key| is the unique id associated with the password form fill data. // |key| is the unique id associated with the password form fill data.
ShowInitialPasswordAccountSuggestions(int32 key, ShowInitialPasswordAccountSuggestions(int32 key,
PasswordFormFillData form_data); PasswordFormFillData form_data);
// Configures the render to require, or not, a user gesture before notifying
// the autofill agent of a field change. The default is true. Bypassing the
// user gesture check should only used for Android Webview, which needs to
// be notified of every change to the field.
// Note: The Android platform autofill framework only sends values to the
// autofill service with the user's consent, so the gesture check is
// redundant there anyway.
SetUserGestureRequired(bool required);
}; };
// There is one instance of this interface per render frame in the render // There is one instance of this interface per render frame in the render
......
...@@ -152,6 +152,7 @@ AutofillAgent::AutofillAgent(content::RenderFrame* render_frame, ...@@ -152,6 +152,7 @@ AutofillAgent::AutofillAgent(content::RenderFrame* render_frame,
ignore_text_changes_(false), ignore_text_changes_(false),
is_popup_possibly_visible_(false), is_popup_possibly_visible_(false),
is_generation_popup_possibly_visible_(false), is_generation_popup_possibly_visible_(false),
is_user_gesture_required_(true),
page_click_tracker_(new PageClickTracker(render_frame, this)), page_click_tracker_(new PageClickTracker(render_frame, this)),
binding_(this), binding_(this),
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
...@@ -316,6 +317,10 @@ void AutofillAgent::TextFieldDidEndEditing(const WebInputElement& element) { ...@@ -316,6 +317,10 @@ void AutofillAgent::TextFieldDidEndEditing(const WebInputElement& element) {
GetAutofillDriver()->DidEndTextFieldEditing(); GetAutofillDriver()->DidEndTextFieldEditing();
} }
void AutofillAgent::SetUserGestureRequired(bool required) {
is_user_gesture_required_ = required;
}
void AutofillAgent::TextFieldDidChange(const WebFormControlElement& element) { void AutofillAgent::TextFieldDidChange(const WebFormControlElement& element) {
DCHECK(ToWebInputElement(&element) || form_util::IsTextAreaElement(element)); DCHECK(ToWebInputElement(&element) || form_util::IsTextAreaElement(element));
...@@ -325,7 +330,8 @@ void AutofillAgent::TextFieldDidChange(const WebFormControlElement& element) { ...@@ -325,7 +330,8 @@ void AutofillAgent::TextFieldDidChange(const WebFormControlElement& element) {
// Disregard text changes that aren't caused by user gestures or pastes. Note // Disregard text changes that aren't caused by user gestures or pastes. Note
// that pastes aren't necessarily user gestures because Blink's conception of // that pastes aren't necessarily user gestures because Blink's conception of
// user gestures is centered around creating new windows/tabs. // user gestures is centered around creating new windows/tabs.
if (!IsUserGesture() && !render_frame()->IsPasting()) if (is_user_gesture_required_ && !IsUserGesture() &&
!render_frame()->IsPasting())
return; return;
// We post a task for doing the Autofill as the caret position is not set // We post a task for doing the Autofill as the caret position is not set
......
...@@ -83,6 +83,7 @@ class AutofillAgent : public content::RenderFrameObserver, ...@@ -83,6 +83,7 @@ class AutofillAgent : public content::RenderFrameObserver,
void ShowInitialPasswordAccountSuggestions( void ShowInitialPasswordAccountSuggestions(
int32_t key, int32_t key,
const PasswordFormFillData& form_data) override; const PasswordFormFillData& form_data) override;
void SetUserGestureRequired(bool required) override;
void ShowNotSecureWarning(const blink::WebInputElement& element); void ShowNotSecureWarning(const blink::WebInputElement& element);
...@@ -278,6 +279,10 @@ class AutofillAgent : public content::RenderFrameObserver, ...@@ -278,6 +279,10 @@ class AutofillAgent : public content::RenderFrameObserver,
// for the password manager. TODO(gcasto): Have both UIs show on focus. // for the password manager. TODO(gcasto): Have both UIs show on focus.
bool is_generation_popup_possibly_visible_; bool is_generation_popup_possibly_visible_;
// Whether or not a user gesture is required before notification of a text
// field change. Default to true.
bool is_user_gesture_required_;
std::unique_ptr<PageClickTracker> page_click_tracker_; std::unique_ptr<PageClickTracker> page_click_tracker_;
mojo::Binding<mojom::AutofillAgent> binding_; mojo::Binding<mojom::AutofillAgent> binding_;
......
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