OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/autofill/content/renderer/autofill_agent.h" | 5 #include "components/autofill/content/renderer/autofill_agent.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 #include "third_party/WebKit/public/web/WebDataSource.h" | 36 #include "third_party/WebKit/public/web/WebDataSource.h" |
37 #include "third_party/WebKit/public/web/WebDocument.h" | 37 #include "third_party/WebKit/public/web/WebDocument.h" |
38 #include "third_party/WebKit/public/web/WebElementCollection.h" | 38 #include "third_party/WebKit/public/web/WebElementCollection.h" |
39 #include "third_party/WebKit/public/web/WebFormControlElement.h" | 39 #include "third_party/WebKit/public/web/WebFormControlElement.h" |
40 #include "third_party/WebKit/public/web/WebFormElement.h" | 40 #include "third_party/WebKit/public/web/WebFormElement.h" |
41 #include "third_party/WebKit/public/web/WebInputEvent.h" | 41 #include "third_party/WebKit/public/web/WebInputEvent.h" |
42 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 42 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
43 #include "third_party/WebKit/public/web/WebNode.h" | 43 #include "third_party/WebKit/public/web/WebNode.h" |
44 #include "third_party/WebKit/public/web/WebOptionElement.h" | 44 #include "third_party/WebKit/public/web/WebOptionElement.h" |
45 #include "third_party/WebKit/public/web/WebTextAreaElement.h" | 45 #include "third_party/WebKit/public/web/WebTextAreaElement.h" |
| 46 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" |
46 #include "third_party/WebKit/public/web/WebView.h" | 47 #include "third_party/WebKit/public/web/WebView.h" |
47 #include "ui/base/l10n/l10n_util.h" | 48 #include "ui/base/l10n/l10n_util.h" |
48 #include "ui/events/keycodes/keyboard_codes.h" | 49 #include "ui/events/keycodes/keyboard_codes.h" |
49 | 50 |
50 using blink::WebAutofillClient; | 51 using blink::WebAutofillClient; |
51 using blink::WebConsoleMessage; | 52 using blink::WebConsoleMessage; |
52 using blink::WebDocument; | 53 using blink::WebDocument; |
53 using blink::WebElement; | 54 using blink::WebElement; |
54 using blink::WebElementCollection; | 55 using blink::WebElementCollection; |
55 using blink::WebFormControlElement; | 56 using blink::WebFormControlElement; |
56 using blink::WebFormElement; | 57 using blink::WebFormElement; |
57 using blink::WebFrame; | 58 using blink::WebFrame; |
58 using blink::WebInputElement; | 59 using blink::WebInputElement; |
59 using blink::WebKeyboardEvent; | 60 using blink::WebKeyboardEvent; |
60 using blink::WebLocalFrame; | 61 using blink::WebLocalFrame; |
61 using blink::WebNode; | 62 using blink::WebNode; |
62 using blink::WebOptionElement; | 63 using blink::WebOptionElement; |
63 using blink::WebString; | 64 using blink::WebString; |
64 using blink::WebTextAreaElement; | 65 using blink::WebTextAreaElement; |
| 66 using blink::WebUserGestureIndicator; |
65 using blink::WebVector; | 67 using blink::WebVector; |
66 | 68 |
67 namespace autofill { | 69 namespace autofill { |
68 | 70 |
69 namespace { | 71 namespace { |
70 | 72 |
71 // Gets all the data list values (with corresponding label) for the given | 73 // Gets all the data list values (with corresponding label) for the given |
72 // element. | 74 // element. |
73 void GetDataListSuggestions(const WebInputElement& element, | 75 void GetDataListSuggestions(const WebInputElement& element, |
74 bool ignore_current_value, | 76 bool ignore_current_value, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 password_autofill_agent_(password_autofill_agent), | 149 password_autofill_agent_(password_autofill_agent), |
148 password_generation_agent_(password_generation_agent), | 150 password_generation_agent_(password_generation_agent), |
149 legacy_(render_frame->GetRenderView(), this), | 151 legacy_(render_frame->GetRenderView(), this), |
150 autofill_query_id_(0), | 152 autofill_query_id_(0), |
151 display_warning_if_disabled_(false), | 153 display_warning_if_disabled_(false), |
152 was_query_node_autofilled_(false), | 154 was_query_node_autofilled_(false), |
153 has_shown_autofill_popup_for_current_edit_(false), | 155 has_shown_autofill_popup_for_current_edit_(false), |
154 did_set_node_text_(false), | 156 did_set_node_text_(false), |
155 ignore_text_changes_(false), | 157 ignore_text_changes_(false), |
156 is_popup_possibly_visible_(false), | 158 is_popup_possibly_visible_(false), |
| 159 disable_user_gesture_check_(false), |
157 weak_ptr_factory_(this) { | 160 weak_ptr_factory_(this) { |
158 render_frame->GetWebFrame()->setAutofillClient(this); | 161 render_frame->GetWebFrame()->setAutofillClient(this); |
159 | 162 |
160 // This owns itself, and will delete itself when |render_frame| is destructed | 163 // This owns itself, and will delete itself when |render_frame| is destructed |
161 // (same as AutofillAgent). | 164 // (same as AutofillAgent). |
162 new PageClickTracker(render_frame, this); | 165 new PageClickTracker(render_frame, this); |
163 } | 166 } |
164 | 167 |
165 AutofillAgent::~AutofillAgent() {} | 168 AutofillAgent::~AutofillAgent() {} |
166 | 169 |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 void AutofillAgent::textFieldDidEndEditing(const WebInputElement& element) { | 381 void AutofillAgent::textFieldDidEndEditing(const WebInputElement& element) { |
379 password_autofill_agent_->TextFieldDidEndEditing(element); | 382 password_autofill_agent_->TextFieldDidEndEditing(element); |
380 has_shown_autofill_popup_for_current_edit_ = false; | 383 has_shown_autofill_popup_for_current_edit_ = false; |
381 Send(new AutofillHostMsg_DidEndTextFieldEditing(routing_id())); | 384 Send(new AutofillHostMsg_DidEndTextFieldEditing(routing_id())); |
382 } | 385 } |
383 | 386 |
384 void AutofillAgent::textFieldDidChange(const WebFormControlElement& element) { | 387 void AutofillAgent::textFieldDidChange(const WebFormControlElement& element) { |
385 if (ignore_text_changes_) | 388 if (ignore_text_changes_) |
386 return; | 389 return; |
387 | 390 |
| 391 if (!WebUserGestureIndicator::isProcessingUserGesture() && |
| 392 !disable_user_gesture_check_) { |
| 393 return; |
| 394 } |
| 395 |
388 DCHECK(toWebInputElement(&element) || IsTextAreaElement(element)); | 396 DCHECK(toWebInputElement(&element) || IsTextAreaElement(element)); |
389 | 397 |
390 if (did_set_node_text_) { | 398 if (did_set_node_text_) { |
391 did_set_node_text_ = false; | 399 did_set_node_text_ = false; |
392 return; | 400 return; |
393 } | 401 } |
394 | 402 |
395 // We post a task for doing the Autofill as the caret position is not set | 403 // We post a task for doing the Autofill as the caret position is not set |
396 // properly at this point (http://bugs.webkit.org/show_bug.cgi?id=16976) and | 404 // properly at this point (http://bugs.webkit.org/show_bug.cgi?id=16976) and |
397 // it is needed to trigger autofill. | 405 // it is needed to trigger autofill. |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 | 833 |
826 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { | 834 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { |
827 // No-op. Don't delete |this|. | 835 // No-op. Don't delete |this|. |
828 } | 836 } |
829 | 837 |
830 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { | 838 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { |
831 agent_->FocusChangeComplete(); | 839 agent_->FocusChangeComplete(); |
832 } | 840 } |
833 | 841 |
834 } // namespace autofill | 842 } // namespace autofill |
OLD | NEW |