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

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

Issue 13264002: Requery the autofill server when forms and input fields are dynamically added. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fun with merging Created 7 years, 7 months 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
« no previous file with comments | « components/autofill/renderer/autofill_agent.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/renderer/autofill_agent.h" 5 #include "components/autofill/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.h" 9 #include "base/message_loop.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 password_autofill_agent_(password_autofill_agent), 144 password_autofill_agent_(password_autofill_agent),
145 autofill_query_id_(0), 145 autofill_query_id_(0),
146 autofill_action_(AUTOFILL_NONE), 146 autofill_action_(AUTOFILL_NONE),
147 topmost_frame_(NULL), 147 topmost_frame_(NULL),
148 web_view_(render_view->GetWebView()), 148 web_view_(render_view->GetWebView()),
149 display_warning_if_disabled_(false), 149 display_warning_if_disabled_(false),
150 was_query_node_autofilled_(false), 150 was_query_node_autofilled_(false),
151 has_shown_autofill_popup_for_current_edit_(false), 151 has_shown_autofill_popup_for_current_edit_(false),
152 did_set_node_text_(false), 152 did_set_node_text_(false),
153 autocheckout_click_in_progress_(false), 153 autocheckout_click_in_progress_(false),
154 is_autocheckout_supported_(false),
155 has_new_forms_for_browser_(false),
154 try_to_show_autocheckout_bubble_(false), 156 try_to_show_autocheckout_bubble_(false),
155 ignore_text_changes_(false), 157 ignore_text_changes_(false),
156 weak_ptr_factory_(this) { 158 weak_ptr_factory_(this) {
157 render_view->GetWebView()->setAutofillClient(this); 159 render_view->GetWebView()->setAutofillClient(this);
158 160
159 // The PageClickTracker is a RenderViewObserver, and hence will be freed when 161 // The PageClickTracker is a RenderViewObserver, and hence will be freed when
160 // the RenderView is destroyed. 162 // the RenderView is destroyed.
161 new PageClickTracker(render_view, this); 163 new PageClickTracker(render_view, this);
162 } 164 }
163 165
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 bool has_more_forms = false; 209 bool has_more_forms = false;
208 if (!frame->parent()) { 210 if (!frame->parent()) {
209 topmost_frame_ = frame; 211 topmost_frame_ = frame;
210 form_elements_.clear(); 212 form_elements_.clear();
211 has_more_forms = form_cache_.ExtractFormsAndFormElements( 213 has_more_forms = form_cache_.ExtractFormsAndFormElements(
212 *frame, kRequiredAutofillFields, &forms, &form_elements_); 214 *frame, kRequiredAutofillFields, &forms, &form_elements_);
213 } else { 215 } else {
214 form_cache_.ExtractForms(*frame, &forms); 216 form_cache_.ExtractForms(*frame, &forms);
215 } 217 }
216 218
219 autofill::FormsSeenState state = has_more_forms ?
220 autofill::PARTIAL_FORMS_SEEN : autofill::NO_SPECIAL_FORMS_SEEN;
221
217 // Always communicate to browser process for topmost frame. 222 // Always communicate to browser process for topmost frame.
218 if (!forms.empty() || !frame->parent()) { 223 if (!forms.empty() || !frame->parent()) {
219 Send(new AutofillHostMsg_FormsSeen(routing_id(), forms, 224 Send(new AutofillHostMsg_FormsSeen(routing_id(), forms,
220 forms_seen_timestamp_, 225 forms_seen_timestamp_,
221 has_more_forms)); 226 state));
222 } 227 }
223 } 228 }
224 229
225 void AutofillAgent::DidStartProvisionalLoad(WebFrame* frame) { 230 void AutofillAgent::DidStartProvisionalLoad(WebFrame* frame) {
226 if (!frame->parent()) { 231 if (!frame->parent()) {
227 try_to_show_autocheckout_bubble_ = false; 232 try_to_show_autocheckout_bubble_ = false;
228 topmost_frame_ = NULL; 233 topmost_frame_ = NULL;
229 if (click_timer_.IsRunning()) { 234 if (click_timer_.IsRunning()) {
230 click_timer_.Stop(); 235 click_timer_.Stop();
231 autocheckout_click_in_progress_ = true; 236 autocheckout_click_in_progress_ = true;
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 std::vector<FormData> forms; 734 std::vector<FormData> forms;
730 form_cache_.ExtractFormsAndFormElements( 735 form_cache_.ExtractFormsAndFormElements(
731 *topmost_frame_, 0, &forms, &form_elements_); 736 *topmost_frame_, 0, &forms, &form_elements_);
732 737
733 // OnGetAllForms should only be called if AutofillAgent reported to 738 // OnGetAllForms should only be called if AutofillAgent reported to
734 // AutofillManager that there are more forms 739 // AutofillManager that there are more forms
735 DCHECK(!forms.empty()); 740 DCHECK(!forms.empty());
736 741
737 // Report to AutofillManager that all forms are being sent. 742 // Report to AutofillManager that all forms are being sent.
738 Send(new AutofillHostMsg_FormsSeen(routing_id(), forms, 743 Send(new AutofillHostMsg_FormsSeen(routing_id(), forms,
739 forms_seen_timestamp_, false)); 744 forms_seen_timestamp_,
745 NO_SPECIAL_FORMS_SEEN));
740 } 746 }
741 747
742 void AutofillAgent::OnRequestAutocompleteResult( 748 void AutofillAgent::OnRequestAutocompleteResult(
743 WebFormElement::AutocompleteResult result, const FormData& form_data) { 749 WebFormElement::AutocompleteResult result, const FormData& form_data) {
744 if (in_flight_request_form_.isNull()) 750 if (in_flight_request_form_.isNull())
745 return; 751 return;
746 752
747 if (result == WebFormElement::AutocompleteResultSuccess) 753 if (result == WebFormElement::AutocompleteResultSuccess)
748 FillFormIncludingNonFocusableElements(form_data, in_flight_request_form_); 754 FillFormIncludingNonFocusableElements(form_data, in_flight_request_form_);
749 755
(...skipping 26 matching lines...) Expand all
776 &AutofillAgent::ClickFailed); 782 &AutofillAgent::ClickFailed);
777 if (!ClickElement(topmost_frame_->document(), 783 if (!ClickElement(topmost_frame_->document(),
778 click_element_descriptor)) { 784 click_element_descriptor)) {
779 click_timer_.Stop(); 785 click_timer_.Stop();
780 Send(new AutofillHostMsg_ClickFailed(routing_id(), 786 Send(new AutofillHostMsg_ClickFailed(routing_id(),
781 MISSING_ADVANCE)); 787 MISSING_ADVANCE));
782 } 788 }
783 } 789 }
784 790
785 void AutofillAgent::OnAutocheckoutSupported() { 791 void AutofillAgent::OnAutocheckoutSupported() {
792 is_autocheckout_supported_ = true;
786 try_to_show_autocheckout_bubble_ = true; 793 try_to_show_autocheckout_bubble_ = true;
794 if (has_new_forms_for_browser_)
795 MaybeSendDynamicFormsSeen();
787 MaybeShowAutocheckoutBubble(); 796 MaybeShowAutocheckoutBubble();
788 } 797 }
789 798
790 void AutofillAgent::ClickFailed() { 799 void AutofillAgent::ClickFailed() {
791 Send(new AutofillHostMsg_ClickFailed(routing_id(), 800 Send(new AutofillHostMsg_ClickFailed(routing_id(),
792 CANNOT_PROCEED)); 801 CANNOT_PROCEED));
793 } 802 }
794 803
795 void AutofillAgent::ShowSuggestions(const WebInputElement& element, 804 void AutofillAgent::ShowSuggestions(const WebInputElement& element,
796 bool autofill_on_empty_values, 805 bool autofill_on_empty_values,
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 if (web_view) 947 if (web_view)
939 web_view->hidePopups(); 948 web_view->hidePopups();
940 949
941 HideHostAutofillUi(); 950 HideHostAutofillUi();
942 } 951 }
943 952
944 void AutofillAgent::HideHostAutofillUi() { 953 void AutofillAgent::HideHostAutofillUi() {
945 Send(new AutofillHostMsg_HideAutofillUi(routing_id())); 954 Send(new AutofillHostMsg_HideAutofillUi(routing_id()));
946 } 955 }
947 956
957 void AutofillAgent::didAssociateFormControls(
958 const WebKit::WebVector<WebKit::WebNode>& nodes) {
959 for (size_t i = 0; i < nodes.size(); ++i) {
960 WebKit::WebNode node = nodes[i];
961 if (node.document().frame() == topmost_frame_) {
962 forms_seen_timestamp_ = base::TimeTicks::Now();
963 has_new_forms_for_browser_ = true;
964 break;
965 }
966 }
967
968 if (has_new_forms_for_browser_ && is_autocheckout_supported_)
969 MaybeSendDynamicFormsSeen();
970 }
971
972 void AutofillAgent::MaybeSendDynamicFormsSeen() {
973 has_new_forms_for_browser_ = false;
974 form_elements_.clear();
975 std::vector<FormData> forms;
976 // This will only be called for Autocheckout flows, so send all forms to
977 // save an IPC.
978 form_cache_.ExtractFormsAndFormElements(
979 *topmost_frame_, 0, &forms, &form_elements_);
980 autofill::FormsSeenState state = autofill::DYNAMIC_FORMS_SEEN;
981
982 if (!forms.empty()) {
983 if (click_timer_.IsRunning())
984 click_timer_.Stop();
985 Send(new AutofillHostMsg_FormsSeen(routing_id(), forms,
986 forms_seen_timestamp_,
987 state));
988 }
989 }
990
948 } // namespace autofill 991 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/renderer/autofill_agent.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698