| 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 <tuple> | 7 #include <tuple> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 } | 379 } |
| 380 | 380 |
| 381 void AutofillAgent::textFieldDidEndEditing(const WebInputElement& element) { | 381 void AutofillAgent::textFieldDidEndEditing(const WebInputElement& element) { |
| 382 password_autofill_agent_->TextFieldDidEndEditing(element); | 382 password_autofill_agent_->TextFieldDidEndEditing(element); |
| 383 has_shown_autofill_popup_for_current_edit_ = false; | 383 has_shown_autofill_popup_for_current_edit_ = false; |
| 384 Send(new AutofillHostMsg_DidEndTextFieldEditing(routing_id())); | 384 Send(new AutofillHostMsg_DidEndTextFieldEditing(routing_id())); |
| 385 } | 385 } |
| 386 | 386 |
| 387 void AutofillAgent::textFieldDidChange(const WebFormControlElement& element) { | 387 void AutofillAgent::textFieldDidChange(const WebFormControlElement& element) { |
| 388 DCHECK(toWebInputElement(&element) || form_util::IsTextAreaElement(element)); | 388 DCHECK(toWebInputElement(&element) || form_util::IsTextAreaElement(element)); |
| 389 |
| 389 if (ignore_text_changes_) | 390 if (ignore_text_changes_) |
| 390 return; | 391 return; |
| 391 | 392 |
| 392 if (!IsUserGesture()) | 393 // Disregard text changes that aren't caused by user gestures or pastes. Note |
| 394 // that pastes aren't necessarily user gestures because Blink's conception of |
| 395 // user gestures is centered around creating new windows/tabs. |
| 396 if (!IsUserGesture() && !render_frame()->IsPasting()) |
| 393 return; | 397 return; |
| 394 | 398 |
| 395 // We post a task for doing the Autofill as the caret position is not set | 399 // 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 | 400 // properly at this point (http://bugs.webkit.org/show_bug.cgi?id=16976) and |
| 397 // it is needed to trigger autofill. | 401 // it is needed to trigger autofill. |
| 398 weak_ptr_factory_.InvalidateWeakPtrs(); | 402 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 399 base::ThreadTaskRunnerHandle::Get()->PostTask( | 403 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 400 FROM_HERE, base::Bind(&AutofillAgent::TextFieldDidChangeImpl, | 404 FROM_HERE, base::Bind(&AutofillAgent::TextFieldDidChangeImpl, |
| 401 weak_ptr_factory_.GetWeakPtr(), element)); | 405 weak_ptr_factory_.GetWeakPtr(), element)); |
| 402 } | 406 } |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 | 819 |
| 816 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { | 820 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { |
| 817 // No-op. Don't delete |this|. | 821 // No-op. Don't delete |this|. |
| 818 } | 822 } |
| 819 | 823 |
| 820 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { | 824 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { |
| 821 agent_->FocusChangeComplete(); | 825 agent_->FocusChangeComplete(); |
| 822 } | 826 } |
| 823 | 827 |
| 824 } // namespace autofill | 828 } // namespace autofill |
| OLD | NEW |