Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: components/autofill/content/renderer/autofill_agent.cc

Issue 803673002: Autofill: one FormCache per WebFrame. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 node->setSelectionRange(node->value().length(), 753 node->setSelectionRange(node->value().length(),
754 node->suggestedValue().length()); 754 node->suggestedValue().length());
755 } 755 }
756 756
757 void AutofillAgent::ProcessForms() { 757 void AutofillAgent::ProcessForms() {
758 // Record timestamp of when the forms are first seen. This is used to 758 // Record timestamp of when the forms are first seen. This is used to
759 // measure the overhead of the Autofill feature. 759 // measure the overhead of the Autofill feature.
760 base::TimeTicks forms_seen_timestamp = base::TimeTicks::Now(); 760 base::TimeTicks forms_seen_timestamp = base::TimeTicks::Now();
761 761
762 WebLocalFrame* frame = render_frame()->GetWebFrame(); 762 WebLocalFrame* frame = render_frame()->GetWebFrame();
763 std::vector<FormData> forms = form_cache_.ExtractNewForms(*frame); 763 std::vector<FormData> forms = form_cache_.ExtractNewForms();
764 764
765 // Always communicate to browser process for topmost frame. 765 // Always communicate to browser process for topmost frame.
766 if (!forms.empty() || !frame->parent()) { 766 if (!forms.empty() || !frame->parent()) {
767 Send(new AutofillHostMsg_FormsSeen(routing_id(), forms, 767 Send(new AutofillHostMsg_FormsSeen(routing_id(), forms,
768 forms_seen_timestamp)); 768 forms_seen_timestamp));
769 } 769 }
770 } 770 }
771 771
772 void AutofillAgent::HidePopup() { 772 void AutofillAgent::HidePopup() {
773 if (!is_popup_possibly_visible_) 773 if (!is_popup_possibly_visible_)
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 void AutofillAgent::LegacyAutofillAgent::Resized() { 839 void AutofillAgent::LegacyAutofillAgent::Resized() {
840 agent_->Resized(); 840 agent_->Resized();
841 } 841 }
842 842
843 void AutofillAgent::LegacyAutofillAgent::FrameWillClose( 843 void AutofillAgent::LegacyAutofillAgent::FrameWillClose(
844 blink::WebFrame* frame) { 844 blink::WebFrame* frame) {
845 agent_->LegacyFrameWillClose(frame); 845 agent_->LegacyFrameWillClose(frame);
846 } 846 }
847 847
848 } // namespace autofill 848 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/renderer/autofill/form_autofill_browsertest.cc ('k') | components/autofill/content/renderer/form_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698