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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <tuple> | 9 #include <tuple> |
10 | 10 |
11 #include "base/auto_reset.h" | 11 #include "base/auto_reset.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/i18n/case_conversion.h" | 14 #include "base/i18n/case_conversion.h" |
15 #include "base/location.h" | 15 #include "base/location.h" |
16 #include "base/metrics/field_trial.h" | 16 #include "base/metrics/field_trial.h" |
17 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
18 #include "base/strings/string_split.h" | 18 #include "base/strings/string_split.h" |
19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
20 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
21 #include "base/threading/thread_task_runner_handle.h" | 21 #include "base/threading/thread_task_runner_handle.h" |
22 #include "base/time/time.h" | 22 #include "base/time/time.h" |
23 #include "build/build_config.h" | 23 #include "build/build_config.h" |
24 #include "components/autofill/content/common/autofill_messages.h" | 24 #include "components/autofill/content/common/autofill_messages.h" |
25 #include "components/autofill/content/renderer/form_autofill_util.h" | 25 #include "components/autofill/content/renderer/form_autofill_util.h" |
26 #include "components/autofill/content/renderer/page_click_tracker.h" | 26 #include "components/autofill/content/renderer/page_click_tracker.h" |
27 #include "components/autofill/content/renderer/password_autofill_agent.h" | 27 #include "components/autofill/content/renderer/password_autofill_agent.h" |
28 #include "components/autofill/content/renderer/password_generation_agent.h" | 28 #include "components/autofill/content/renderer/password_generation_agent.h" |
| 29 #include "components/autofill/content/renderer/renderer_save_password_progress_l
ogger.h" |
29 #include "components/autofill/core/common/autofill_constants.h" | 30 #include "components/autofill/core/common/autofill_constants.h" |
30 #include "components/autofill/core/common/autofill_data_validation.h" | 31 #include "components/autofill/core/common/autofill_data_validation.h" |
31 #include "components/autofill/core/common/autofill_switches.h" | 32 #include "components/autofill/core/common/autofill_switches.h" |
32 #include "components/autofill/core/common/autofill_util.h" | 33 #include "components/autofill/core/common/autofill_util.h" |
33 #include "components/autofill/core/common/form_data.h" | 34 #include "components/autofill/core/common/form_data.h" |
34 #include "components/autofill/core/common/form_data_predictions.h" | 35 #include "components/autofill/core/common/form_data_predictions.h" |
35 #include "components/autofill/core/common/form_field_data.h" | 36 #include "components/autofill/core/common/form_field_data.h" |
36 #include "components/autofill/core/common/password_form.h" | 37 #include "components/autofill/core/common/password_form.h" |
| 38 #include "components/autofill/core/common/password_form_fill_data.h" |
| 39 #include "components/autofill/core/common/save_password_progress_logger.h" |
37 #include "content/public/common/content_switches.h" | 40 #include "content/public/common/content_switches.h" |
38 #include "content/public/common/service_registry.h" | 41 #include "content/public/common/service_registry.h" |
39 #include "content/public/common/ssl_status.h" | 42 #include "content/public/common/ssl_status.h" |
40 #include "content/public/common/url_constants.h" | 43 #include "content/public/common/url_constants.h" |
41 #include "content/public/renderer/render_frame.h" | 44 #include "content/public/renderer/render_frame.h" |
42 #include "content/public/renderer/render_view.h" | 45 #include "content/public/renderer/render_view.h" |
43 #include "net/cert/cert_status_flags.h" | 46 #include "net/cert/cert_status_flags.h" |
44 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 47 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
45 #include "third_party/WebKit/public/web/WebConsoleMessage.h" | 48 #include "third_party/WebKit/public/web/WebConsoleMessage.h" |
46 #include "third_party/WebKit/public/web/WebDataSource.h" | 49 #include "third_party/WebKit/public/web/WebDataSource.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 IPC_MESSAGE_HANDLER(AutofillMsg_ClearPreviewedForm, OnClearPreviewedForm) | 216 IPC_MESSAGE_HANDLER(AutofillMsg_ClearPreviewedForm, OnClearPreviewedForm) |
214 IPC_MESSAGE_HANDLER(AutofillMsg_FillFieldWithValue, OnFillFieldWithValue) | 217 IPC_MESSAGE_HANDLER(AutofillMsg_FillFieldWithValue, OnFillFieldWithValue) |
215 IPC_MESSAGE_HANDLER(AutofillMsg_PreviewFieldWithValue, | 218 IPC_MESSAGE_HANDLER(AutofillMsg_PreviewFieldWithValue, |
216 OnPreviewFieldWithValue) | 219 OnPreviewFieldWithValue) |
217 IPC_MESSAGE_HANDLER(AutofillMsg_AcceptDataListSuggestion, | 220 IPC_MESSAGE_HANDLER(AutofillMsg_AcceptDataListSuggestion, |
218 OnAcceptDataListSuggestion) | 221 OnAcceptDataListSuggestion) |
219 IPC_MESSAGE_HANDLER(AutofillMsg_FillPasswordSuggestion, | 222 IPC_MESSAGE_HANDLER(AutofillMsg_FillPasswordSuggestion, |
220 OnFillPasswordSuggestion) | 223 OnFillPasswordSuggestion) |
221 IPC_MESSAGE_HANDLER(AutofillMsg_PreviewPasswordSuggestion, | 224 IPC_MESSAGE_HANDLER(AutofillMsg_PreviewPasswordSuggestion, |
222 OnPreviewPasswordSuggestion) | 225 OnPreviewPasswordSuggestion) |
| 226 IPC_MESSAGE_HANDLER(AutofillMsg_ShowInitialPasswordAccountSuggestions, |
| 227 OnShowInitialPasswordAccountSuggestions); |
223 IPC_MESSAGE_UNHANDLED(handled = false) | 228 IPC_MESSAGE_UNHANDLED(handled = false) |
224 IPC_END_MESSAGE_MAP() | 229 IPC_END_MESSAGE_MAP() |
225 return handled; | 230 return handled; |
226 } | 231 } |
227 | 232 |
228 void AutofillAgent::DidCommitProvisionalLoad(bool is_new_navigation, | 233 void AutofillAgent::DidCommitProvisionalLoad(bool is_new_navigation, |
229 bool is_same_page_navigation) { | 234 bool is_same_page_navigation) { |
230 blink::WebFrame* frame = render_frame()->GetWebFrame(); | 235 blink::WebFrame* frame = render_frame()->GetWebFrame(); |
231 // TODO(dvadym): check if we need to check if it is main frame navigation | 236 // TODO(dvadym): check if we need to check if it is main frame navigation |
232 // http://crbug.com/443155 | 237 // http://crbug.com/443155 |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 void AutofillAgent::OnPreviewPasswordSuggestion( | 593 void AutofillAgent::OnPreviewPasswordSuggestion( |
589 const base::string16& username, | 594 const base::string16& username, |
590 const base::string16& password) { | 595 const base::string16& password) { |
591 bool handled = password_autofill_agent_->PreviewSuggestion( | 596 bool handled = password_autofill_agent_->PreviewSuggestion( |
592 element_, | 597 element_, |
593 username, | 598 username, |
594 password); | 599 password); |
595 DCHECK(handled); | 600 DCHECK(handled); |
596 } | 601 } |
597 | 602 |
| 603 void AutofillAgent::OnShowInitialPasswordAccountSuggestions( |
| 604 int key, |
| 605 const PasswordFormFillData& form_data) { |
| 606 std::vector<blink::WebInputElement> elements; |
| 607 std::unique_ptr<RendererSavePasswordProgressLogger> logger; |
| 608 if (password_autofill_agent_->logging_state_active()) { |
| 609 logger.reset(new RendererSavePasswordProgressLogger(this, routing_id())); |
| 610 logger->LogMessage(SavePasswordProgressLogger:: |
| 611 STRING_ON_SHOW_INITIAL_PASSWORD_ACCOUNT_SUGGESTIONS); |
| 612 } |
| 613 password_autofill_agent_->GetFillableElementFromFormData( |
| 614 key, form_data, logger.get(), &elements); |
| 615 |
| 616 // If wait_for_username is true, we don't want to initially show form options |
| 617 // until the user types in a valid username. |
| 618 if (form_data.wait_for_username) |
| 619 return; |
| 620 |
| 621 ShowSuggestionsOptions options; |
| 622 options.autofill_on_empty_values = true; |
| 623 options.show_full_suggestion_list = true; |
| 624 for (auto element : elements) |
| 625 ShowSuggestions(element, options); |
| 626 } |
| 627 |
598 void AutofillAgent::OnSamePageNavigationCompleted() { | 628 void AutofillAgent::OnSamePageNavigationCompleted() { |
599 if (!last_interacted_form_.isNull()) { | 629 if (!last_interacted_form_.isNull()) { |
600 // Assume form submission only if the form is now gone, either invisible or | 630 // Assume form submission only if the form is now gone, either invisible or |
601 // removed from the DOM. | 631 // removed from the DOM. |
602 if (form_util::AreFormContentsVisible(last_interacted_form_)) | 632 if (form_util::AreFormContentsVisible(last_interacted_form_)) |
603 return; | 633 return; |
604 | 634 |
605 FireHostSubmitEvents(last_interacted_form_, /*form_submitted=*/true); | 635 FireHostSubmitEvents(last_interacted_form_, /*form_submitted=*/true); |
606 last_interacted_form_.reset(); | 636 last_interacted_form_.reset(); |
607 } | 637 } |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { | 827 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { |
798 // No-op. Don't delete |this|. | 828 // No-op. Don't delete |this|. |
799 } | 829 } |
800 | 830 |
801 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { | 831 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { |
802 if (agent_) | 832 if (agent_) |
803 agent_->FocusChangeComplete(); | 833 agent_->FocusChangeComplete(); |
804 } | 834 } |
805 | 835 |
806 } // namespace autofill | 836 } // namespace autofill |
OLD | NEW |