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