Chromium Code Reviews| 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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 void AutofillAgent::textFieldDidEndEditing(const WebInputElement& element) { | 376 void AutofillAgent::textFieldDidEndEditing(const WebInputElement& element) { |
| 375 password_autofill_agent_->TextFieldDidEndEditing(element); | 377 password_autofill_agent_->TextFieldDidEndEditing(element); |
| 376 has_shown_autofill_popup_for_current_edit_ = false; | 378 has_shown_autofill_popup_for_current_edit_ = false; |
| 377 Send(new AutofillHostMsg_DidEndTextFieldEditing(routing_id())); | 379 Send(new AutofillHostMsg_DidEndTextFieldEditing(routing_id())); |
| 378 } | 380 } |
| 379 | 381 |
| 380 void AutofillAgent::textFieldDidChange(const WebFormControlElement& element) { | 382 void AutofillAgent::textFieldDidChange(const WebFormControlElement& element) { |
| 381 if (ignore_text_changes_) | 383 if (ignore_text_changes_) |
| 382 return; | 384 return; |
| 383 | 385 |
| 386 if (!WebUserGestureIndicator::isProcessingUserGesture()) | |
| 387 return; | |
| 388 | |
| 389 #if !defined(OS_ANDROID) | |
| 390 // IME composition on desktop is used for CJK, which will conflict with | |
| 391 // autofill popup near the input field. | |
| 392 if (render_frame()->GetWebFrame()->hasComposition()) | |
| 393 return; | |
| 394 #endif | |
| 395 | |
| 384 DCHECK(toWebInputElement(&element) || IsTextAreaElement(element)); | 396 DCHECK(toWebInputElement(&element) || IsTextAreaElement(element)); |
| 385 | 397 |
| 386 if (did_set_node_text_) { | 398 if (did_set_node_text_) { |
|
Evan Stade
2015/04/16 13:58:59
there are a lot of early returns here. Can we make
| |
| 387 did_set_node_text_ = false; | 399 did_set_node_text_ = false; |
| 388 return; | 400 return; |
| 389 } | 401 } |
| 390 | 402 |
| 391 // 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 |
| 392 // 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 |
| 393 // it is needed to trigger autofill. | 405 // it is needed to trigger autofill. |
| 394 weak_ptr_factory_.InvalidateWeakPtrs(); | 406 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 395 base::MessageLoop::current()->PostTask( | 407 base::MessageLoop::current()->PostTask( |
| 396 FROM_HERE, | 408 FROM_HERE, |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 783 | 795 |
| 784 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { | 796 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { |
| 785 // No-op. Don't delete |this|. | 797 // No-op. Don't delete |this|. |
| 786 } | 798 } |
| 787 | 799 |
| 788 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { | 800 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { |
| 789 agent_->FocusChangeComplete(); | 801 agent_->FocusChangeComplete(); |
| 790 } | 802 } |
| 791 | 803 |
| 792 } // namespace autofill | 804 } // namespace autofill |
| OLD | NEW |