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/location.h" |
| 11 #include "base/single_thread_task_runner.h" |
11 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
12 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/thread_task_runner_handle.h" |
14 #include "base/time/time.h" | 16 #include "base/time/time.h" |
15 #include "components/autofill/content/common/autofill_messages.h" | 17 #include "components/autofill/content/common/autofill_messages.h" |
16 #include "components/autofill/content/renderer/form_autofill_util.h" | 18 #include "components/autofill/content/renderer/form_autofill_util.h" |
17 #include "components/autofill/content/renderer/page_click_tracker.h" | 19 #include "components/autofill/content/renderer/page_click_tracker.h" |
18 #include "components/autofill/content/renderer/password_autofill_agent.h" | 20 #include "components/autofill/content/renderer/password_autofill_agent.h" |
19 #include "components/autofill/content/renderer/password_generation_agent.h" | 21 #include "components/autofill/content/renderer/password_generation_agent.h" |
20 #include "components/autofill/core/common/autofill_constants.h" | 22 #include "components/autofill/core/common/autofill_constants.h" |
21 #include "components/autofill/core/common/autofill_data_validation.h" | 23 #include "components/autofill/core/common/autofill_data_validation.h" |
22 #include "components/autofill/core/common/autofill_switches.h" | 24 #include "components/autofill/core/common/autofill_switches.h" |
23 #include "components/autofill/core/common/form_data.h" | 25 #include "components/autofill/core/common/form_data.h" |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 if (ignore_text_changes_) | 390 if (ignore_text_changes_) |
389 return; | 391 return; |
390 | 392 |
391 if (!IsUserGesture()) | 393 if (!IsUserGesture()) |
392 return; | 394 return; |
393 | 395 |
394 // 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 is not set |
395 // properly at this point (http://bugs.webkit.org/show_bug.cgi?id=16976) and | 397 // properly at this point (http://bugs.webkit.org/show_bug.cgi?id=16976) and |
396 // it is needed to trigger autofill. | 398 // it is needed to trigger autofill. |
397 weak_ptr_factory_.InvalidateWeakPtrs(); | 399 weak_ptr_factory_.InvalidateWeakPtrs(); |
398 base::MessageLoop::current()->PostTask( | 400 base::ThreadTaskRunnerHandle::Get()->PostTask( |
399 FROM_HERE, | 401 FROM_HERE, base::Bind(&AutofillAgent::TextFieldDidChangeImpl, |
400 base::Bind(&AutofillAgent::TextFieldDidChangeImpl, | 402 weak_ptr_factory_.GetWeakPtr(), element)); |
401 weak_ptr_factory_.GetWeakPtr(), | |
402 element)); | |
403 } | 403 } |
404 | 404 |
405 void AutofillAgent::TextFieldDidChangeImpl( | 405 void AutofillAgent::TextFieldDidChangeImpl( |
406 const WebFormControlElement& element) { | 406 const WebFormControlElement& element) { |
407 // If the element isn't focused then the changes don't matter. This check is | 407 // If the element isn't focused then the changes don't matter. This check is |
408 // required to properly handle IME interactions. | 408 // required to properly handle IME interactions. |
409 if (!element.focused()) | 409 if (!element.focused()) |
410 return; | 410 return; |
411 | 411 |
412 const WebInputElement* input_element = toWebInputElement(&element); | 412 const WebInputElement* input_element = toWebInputElement(&element); |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 | 790 |
791 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { | 791 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { |
792 // No-op. Don't delete |this|. | 792 // No-op. Don't delete |this|. |
793 } | 793 } |
794 | 794 |
795 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { | 795 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { |
796 agent_->FocusChangeComplete(); | 796 agent_->FocusChangeComplete(); |
797 } | 797 } |
798 | 798 |
799 } // namespace autofill | 799 } // namespace autofill |
OLD | NEW |