| 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/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 password_autofill_agent_->TextFieldDidEndEditing(element); | 381 password_autofill_agent_->TextFieldDidEndEditing(element); |
| 382 has_shown_autofill_popup_for_current_edit_ = false; | 382 has_shown_autofill_popup_for_current_edit_ = false; |
| 383 Send(new AutofillHostMsg_DidEndTextFieldEditing(routing_id())); | 383 Send(new AutofillHostMsg_DidEndTextFieldEditing(routing_id())); |
| 384 } | 384 } |
| 385 | 385 |
| 386 void AutofillAgent::textFieldDidChange(const WebFormControlElement& element) { | 386 void AutofillAgent::textFieldDidChange(const WebFormControlElement& element) { |
| 387 DCHECK(toWebInputElement(&element) || IsTextAreaElement(element)); | 387 DCHECK(toWebInputElement(&element) || IsTextAreaElement(element)); |
| 388 if (ignore_text_changes_) | 388 if (ignore_text_changes_) |
| 389 return; | 389 return; |
| 390 | 390 |
| 391 if (!WebUserGestureIndicator::isProcessingUserGesture()) | 391 if (!IsUserGesture()) |
| 392 return; | 392 return; |
| 393 | 393 |
| 394 // We post a task for doing the Autofill as the caret position is not set | 394 // We post a task for doing the Autofill as the caret position is not set |
| 395 // properly at this point (http://bugs.webkit.org/show_bug.cgi?id=16976) and | 395 // properly at this point (http://bugs.webkit.org/show_bug.cgi?id=16976) and |
| 396 // it is needed to trigger autofill. | 396 // it is needed to trigger autofill. |
| 397 weak_ptr_factory_.InvalidateWeakPtrs(); | 397 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 398 base::MessageLoop::current()->PostTask( | 398 base::MessageLoop::current()->PostTask( |
| 399 FROM_HERE, | 399 FROM_HERE, |
| 400 base::Bind(&AutofillAgent::TextFieldDidChangeImpl, | 400 base::Bind(&AutofillAgent::TextFieldDidChangeImpl, |
| 401 weak_ptr_factory_.GetWeakPtr(), | 401 weak_ptr_factory_.GetWeakPtr(), |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 } | 745 } |
| 746 } | 746 } |
| 747 | 747 |
| 748 void AutofillAgent::HidePopup() { | 748 void AutofillAgent::HidePopup() { |
| 749 if (!is_popup_possibly_visible_) | 749 if (!is_popup_possibly_visible_) |
| 750 return; | 750 return; |
| 751 is_popup_possibly_visible_ = false; | 751 is_popup_possibly_visible_ = false; |
| 752 Send(new AutofillHostMsg_HidePopup(routing_id())); | 752 Send(new AutofillHostMsg_HidePopup(routing_id())); |
| 753 } | 753 } |
| 754 | 754 |
| 755 bool AutofillAgent::IsUserGesture() const { |
| 756 return WebUserGestureIndicator::isProcessingUserGesture(); |
| 757 } |
| 758 |
| 755 void AutofillAgent::didAssociateFormControls(const WebVector<WebNode>& nodes) { | 759 void AutofillAgent::didAssociateFormControls(const WebVector<WebNode>& nodes) { |
| 756 for (size_t i = 0; i < nodes.size(); ++i) { | 760 for (size_t i = 0; i < nodes.size(); ++i) { |
| 757 WebLocalFrame* frame = nodes[i].document().frame(); | 761 WebLocalFrame* frame = nodes[i].document().frame(); |
| 758 // Only monitors dynamic forms created in the top frame. Dynamic forms | 762 // Only monitors dynamic forms created in the top frame. Dynamic forms |
| 759 // inserted in iframes are not captured yet. Frame is only processed | 763 // inserted in iframes are not captured yet. Frame is only processed |
| 760 // if it has finished loading, otherwise you can end up with a partially | 764 // if it has finished loading, otherwise you can end up with a partially |
| 761 // parsed form. | 765 // parsed form. |
| 762 if (frame && !frame->isLoading()) { | 766 if (frame && !frame->isLoading()) { |
| 763 ProcessForms(); | 767 ProcessForms(); |
| 764 password_autofill_agent_->OnDynamicFormsSeen(); | 768 password_autofill_agent_->OnDynamicFormsSeen(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 786 | 790 |
| 787 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { | 791 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { |
| 788 // No-op. Don't delete |this|. | 792 // No-op. Don't delete |this|. |
| 789 } | 793 } |
| 790 | 794 |
| 791 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { | 795 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { |
| 792 agent_->FocusChangeComplete(); | 796 agent_->FocusChangeComplete(); |
| 793 } | 797 } |
| 794 | 798 |
| 795 } // namespace autofill | 799 } // namespace autofill |
| OLD | NEW |