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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 display_warning_if_disabled(false), | 126 display_warning_if_disabled(false), |
127 datalist_only(false), | 127 datalist_only(false), |
128 show_full_suggestion_list(false), | 128 show_full_suggestion_list(false), |
129 show_password_suggestions_only(false) { | 129 show_password_suggestions_only(false) { |
130 } | 130 } |
131 | 131 |
132 AutofillAgent::AutofillAgent(content::RenderFrame* render_frame, | 132 AutofillAgent::AutofillAgent(content::RenderFrame* render_frame, |
133 PasswordAutofillAgent* password_autofill_agent, | 133 PasswordAutofillAgent* password_autofill_agent, |
134 PasswordGenerationAgent* password_generation_agent) | 134 PasswordGenerationAgent* password_generation_agent) |
135 : content::RenderFrameObserver(render_frame), | 135 : content::RenderFrameObserver(render_frame), |
| 136 form_cache_(*render_frame->GetWebFrame()), |
136 password_autofill_agent_(password_autofill_agent), | 137 password_autofill_agent_(password_autofill_agent), |
137 password_generation_agent_(password_generation_agent), | 138 password_generation_agent_(password_generation_agent), |
138 legacy_(render_frame->GetRenderView(), this), | 139 legacy_(render_frame->GetRenderView(), this), |
139 page_click_tracker_(render_frame->GetRenderView(), this), | 140 page_click_tracker_(render_frame->GetRenderView(), this), |
140 autofill_query_id_(0), | 141 autofill_query_id_(0), |
141 display_warning_if_disabled_(false), | 142 display_warning_if_disabled_(false), |
142 was_query_node_autofilled_(false), | 143 was_query_node_autofilled_(false), |
143 has_shown_autofill_popup_for_current_edit_(false), | 144 has_shown_autofill_popup_for_current_edit_(false), |
144 did_set_node_text_(false), | 145 did_set_node_text_(false), |
145 ignore_text_changes_(false), | 146 ignore_text_changes_(false), |
(...skipping 26 matching lines...) Expand all Loading... |
172 IPC_MESSAGE_HANDLER(AutofillMsg_PreviewPasswordSuggestion, | 173 IPC_MESSAGE_HANDLER(AutofillMsg_PreviewPasswordSuggestion, |
173 OnPreviewPasswordSuggestion) | 174 OnPreviewPasswordSuggestion) |
174 IPC_MESSAGE_HANDLER(AutofillMsg_RequestAutocompleteResult, | 175 IPC_MESSAGE_HANDLER(AutofillMsg_RequestAutocompleteResult, |
175 OnRequestAutocompleteResult) | 176 OnRequestAutocompleteResult) |
176 IPC_MESSAGE_UNHANDLED(handled = false) | 177 IPC_MESSAGE_UNHANDLED(handled = false) |
177 IPC_END_MESSAGE_MAP() | 178 IPC_END_MESSAGE_MAP() |
178 return handled; | 179 return handled; |
179 } | 180 } |
180 | 181 |
181 void AutofillAgent::DidCommitProvisionalLoad(bool is_new_navigation) { | 182 void AutofillAgent::DidCommitProvisionalLoad(bool is_new_navigation) { |
182 // TODO(estade): |form_cache_| shouldn't track multiple frames. | 183 form_cache_.Reset(); |
183 form_cache_.ResetFrame(*render_frame()->GetWebFrame()); | |
184 } | 184 } |
185 | 185 |
186 void AutofillAgent::DidFinishDocumentLoad() { | 186 void AutofillAgent::DidFinishDocumentLoad() { |
187 ProcessForms(); | 187 ProcessForms(); |
188 } | 188 } |
189 | 189 |
190 void AutofillAgent::FrameDetached(WebFrame* frame) { | 190 void AutofillAgent::FrameDetached(WebFrame* frame) { |
191 if (frame != render_frame()->GetWebFrame()) | 191 if (frame != render_frame()->GetWebFrame()) |
192 return; | 192 return; |
193 | 193 |
194 form_cache_.ResetFrame(*frame); | 194 form_cache_.Reset(); |
195 } | 195 } |
196 | 196 |
197 void AutofillAgent::WillSubmitForm(WebLocalFrame* frame, | 197 void AutofillAgent::WillSubmitForm(WebLocalFrame* frame, |
198 const WebFormElement& form) { | 198 const WebFormElement& form) { |
199 if (frame != render_frame()->GetWebFrame()) | 199 if (frame != render_frame()->GetWebFrame()) |
200 return; | 200 return; |
201 | 201 |
202 FormData form_data; | 202 FormData form_data; |
203 if (WebFormElementToFormData(form, | 203 if (WebFormElementToFormData(form, |
204 WebFormControlElement(), | 204 WebFormControlElement(), |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 node->setSelectionRange(node->value().length(), | 741 node->setSelectionRange(node->value().length(), |
742 node->suggestedValue().length()); | 742 node->suggestedValue().length()); |
743 } | 743 } |
744 | 744 |
745 void AutofillAgent::ProcessForms() { | 745 void AutofillAgent::ProcessForms() { |
746 // Record timestamp of when the forms are first seen. This is used to | 746 // Record timestamp of when the forms are first seen. This is used to |
747 // measure the overhead of the Autofill feature. | 747 // measure the overhead of the Autofill feature. |
748 base::TimeTicks forms_seen_timestamp = base::TimeTicks::Now(); | 748 base::TimeTicks forms_seen_timestamp = base::TimeTicks::Now(); |
749 | 749 |
750 WebLocalFrame* frame = render_frame()->GetWebFrame(); | 750 WebLocalFrame* frame = render_frame()->GetWebFrame(); |
751 std::vector<FormData> forms = form_cache_.ExtractNewForms(*frame); | 751 std::vector<FormData> forms = form_cache_.ExtractNewForms(); |
752 | 752 |
753 // Always communicate to browser process for topmost frame. | 753 // Always communicate to browser process for topmost frame. |
754 if (!forms.empty() || !frame->parent()) { | 754 if (!forms.empty() || !frame->parent()) { |
755 Send(new AutofillHostMsg_FormsSeen(routing_id(), forms, | 755 Send(new AutofillHostMsg_FormsSeen(routing_id(), forms, |
756 forms_seen_timestamp)); | 756 forms_seen_timestamp)); |
757 } | 757 } |
758 } | 758 } |
759 | 759 |
760 void AutofillAgent::HidePopup() { | 760 void AutofillAgent::HidePopup() { |
761 if (!is_popup_possibly_visible_) | 761 if (!is_popup_possibly_visible_) |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 void AutofillAgent::LegacyAutofillAgent::Resized() { | 827 void AutofillAgent::LegacyAutofillAgent::Resized() { |
828 agent_->Resized(); | 828 agent_->Resized(); |
829 } | 829 } |
830 | 830 |
831 void AutofillAgent::LegacyAutofillAgent::FrameWillClose( | 831 void AutofillAgent::LegacyAutofillAgent::FrameWillClose( |
832 blink::WebFrame* frame) { | 832 blink::WebFrame* frame) { |
833 agent_->LegacyFrameWillClose(frame); | 833 agent_->LegacyFrameWillClose(frame); |
834 } | 834 } |
835 | 835 |
836 } // namespace autofill | 836 } // namespace autofill |
OLD | NEW |