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 | |
| 384 DCHECK(toWebInputElement(&element) || IsTextAreaElement(element)); | 389 DCHECK(toWebInputElement(&element) || IsTextAreaElement(element)); |
| 385 | 390 |
| 386 if (did_set_node_text_) { | 391 if (did_set_node_text_) { |
| 387 did_set_node_text_ = false; | 392 did_set_node_text_ = false; |
| 388 return; | 393 return; |
| 389 } | 394 } |
| 390 | 395 |
| 391 // We post a task for doing the Autofill as the caret position is not set | 396 // We post a task for doing the Autofill as the caret position |
| 392 // properly at this point (http://bugs.webkit.org/show_bug.cgi?id=16976) and | 397 // (http://bugs.webkit.org/show_bug.cgi?id=16976) and IME composition are not |
| 393 // it is needed to trigger autofill. | 398 // set properly at this point and this information is needed to trigger |
| 399 // autofill. | |
| 394 weak_ptr_factory_.InvalidateWeakPtrs(); | 400 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 395 base::MessageLoop::current()->PostTask( | 401 base::MessageLoop::current()->PostTask( |
| 396 FROM_HERE, | 402 FROM_HERE, |
| 397 base::Bind(&AutofillAgent::TextFieldDidChangeImpl, | 403 base::Bind(&AutofillAgent::TextFieldDidChangeImpl, |
| 398 weak_ptr_factory_.GetWeakPtr(), | 404 weak_ptr_factory_.GetWeakPtr(), |
| 399 element)); | 405 element)); |
| 400 } | 406 } |
| 401 | 407 |
| 402 void AutofillAgent::TextFieldDidChangeImpl( | 408 void AutofillAgent::TextFieldDidChangeImpl( |
| 403 const WebFormControlElement& element) { | 409 const WebFormControlElement& element) { |
| 404 // If the element isn't focused then the changes don't matter. This check is | 410 // If the element isn't focused then the changes don't matter. This check is |
| 405 // required to properly handle IME interactions. | 411 // required to properly handle IME interactions. |
| 406 if (!element.focused()) | 412 if (!element.focused()) |
| 407 return; | 413 return; |
| 408 | 414 |
| 415 #if !defined(OS_ANDROID) | |
| 416 // IME composition on desktop is used for CJK, which will overlap with | |
|
Evan Stade
2015/04/17 20:58:58
hmm, wouldn't we need to hide any pre-existing pop
please use gerrit instead
2015/04/17 22:25:46
Done.
| |
| 417 // autofill popup near the input field. | |
| 418 if (render_frame()->GetWebFrame()->hasMarkedText()) | |
| 419 return; | |
| 420 #endif | |
| 421 | |
| 409 const WebInputElement* input_element = toWebInputElement(&element); | 422 const WebInputElement* input_element = toWebInputElement(&element); |
| 410 if (input_element) { | 423 if (input_element) { |
| 411 if (password_generation_agent_ && | 424 if (password_generation_agent_ && |
| 412 password_generation_agent_->TextDidChangeInTextField(*input_element)) { | 425 password_generation_agent_->TextDidChangeInTextField(*input_element)) { |
| 413 is_popup_possibly_visible_ = true; | 426 is_popup_possibly_visible_ = true; |
| 414 return; | 427 return; |
| 415 } | 428 } |
| 416 | 429 |
| 417 if (password_autofill_agent_->TextDidChangeInTextField(*input_element)) { | 430 if (password_autofill_agent_->TextDidChangeInTextField(*input_element)) { |
| 418 is_popup_possibly_visible_ = true; | 431 is_popup_possibly_visible_ = true; |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 783 | 796 |
| 784 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { | 797 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { |
| 785 // No-op. Don't delete |this|. | 798 // No-op. Don't delete |this|. |
| 786 } | 799 } |
| 787 | 800 |
| 788 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { | 801 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { |
| 789 agent_->FocusChangeComplete(); | 802 agent_->FocusChangeComplete(); |
| 790 } | 803 } |
| 791 | 804 |
| 792 } // namespace autofill | 805 } // namespace autofill |
| OLD | NEW |