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

Unified 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: And a bit of cleanup Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/autofill/renderer/autofill_agent.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/renderer/autofill_agent.cc
diff --git a/components/autofill/renderer/autofill_agent.cc b/components/autofill/renderer/autofill_agent.cc
index 4c975fd856ed34cd3003c400713f324a3eff09ed..6e5103ab17417de49bb217deb5742ed08b4e47bf 100644
--- a/components/autofill/renderer/autofill_agent.cc
+++ b/components/autofill/renderer/autofill_agent.cc
@@ -152,6 +152,7 @@ AutofillAgent::AutofillAgent(content::RenderView* render_view,
did_set_node_text_(false),
autocheckout_click_in_progress_(false),
is_whitelisted_for_autocheckout_(false),
+ has_new_forms_for_browser_(false),
ignore_text_changes_(false),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
render_view->GetWebView()->setAutofillClient(this);
@@ -215,11 +216,14 @@ void AutofillAgent::DidFinishDocumentLoad(WebFrame* frame) {
form_cache_.ExtractForms(*frame, &forms);
}
+ autofill::FormsSeenState state = has_more_forms ?
+ autofill::PARTIAL_FORMS_SEEN : autofill::NO_SPECIAL_FORMS_SEEN;
+
// Always communicate to browser process for topmost frame.
if (!forms.empty() || !frame->parent()) {
Send(new AutofillHostMsg_FormsSeen(routing_id(), forms,
forms_seen_timestamp_,
- has_more_forms));
+ state));
}
}
@@ -728,7 +732,8 @@ void AutofillAgent::OnGetAllForms() {
// Report to AutofillManager that all forms are being sent.
Send(new AutofillHostMsg_FormsSeen(routing_id(), forms,
- forms_seen_timestamp_, false));
+ forms_seen_timestamp_,
+ NO_SPECIAL_FORMS_SEEN));
}
void AutofillAgent::OnRequestAutocompleteResult(
@@ -776,6 +781,8 @@ void AutofillAgent::OnFillFormsAndClick(
void AutofillAgent::OnWhitelistedForAutocheckout() {
is_whitelisted_for_autocheckout_ = true;
+ if (has_new_forms_for_browser_)
+ MaybeSendDynamicFormsSeen();
}
void AutofillAgent::ClickFailed() {
@@ -936,4 +943,39 @@ void AutofillAgent::HideHostAutofillUi() {
Send(new AutofillHostMsg_HideAutofillUi(routing_id()));
}
+void AutofillAgent::didAssociateFormControls(
+ const WebKit::WebVector<WebKit::WebNode>& nodes) {
+ for (size_t i = 0; i < nodes.size(); ++i) {
+ WebKit::WebNode node = nodes[i];
+ if (node.document().frame() == topmost_frame_) {
+ forms_seen_timestamp_ = base::TimeTicks::Now();
+ has_new_forms_for_browser_ = true;
+ break;
+ }
+ }
+
+ if (has_new_forms_for_browser_ && is_whitelisted_for_autocheckout_)
+ MaybeSendDynamicFormsSeen();
+}
+
+void AutofillAgent::MaybeSendDynamicFormsSeen() {
+ has_new_forms_for_browser_ = false;
+ form_elements_.clear();
+ std::vector<FormData> forms;
+ // This will only be called for Autocheckout flows, so send all forms to
+ // save an IPC
Ilya Sherman 2013/04/18 22:19:08 nit: Please end the sentence with a period.
Dane Wallinga 2013/04/18 23:56:44 Done.
+ bool has_more_forms = form_cache_.ExtractFormsAndFormElements(
+ *topmost_frame_, 0, &forms, &form_elements_);
Ilya Sherman 2013/04/18 22:19:08 Can calling this method with a threshold of 0 ever
Dane Wallinga 2013/04/18 23:56:44 gah, knew I missed something.
+ autofill::FormsSeenState state = has_more_forms ?
+ autofill::PARTIAL_AND_DYNAMIC_FORMS_SEEN : autofill::DYNAMIC_FORMS_SEEN;
Ilya Sherman 2013/04/19 01:38:42 Is the PARTIAL_AND_DYNAMIC_FORMS_SEEN case reachab
Dane Wallinga 2013/04/19 18:19:53 Not presently. It would be applicable if you ever
+
+ if (!forms.empty()) {
+ if (click_timer_.IsRunning())
+ click_timer_.Stop();
Ilya Sherman 2013/04/18 22:19:08 Why is this part MaybeSendDynamicFormsSeen() and n
Dane Wallinga 2013/04/18 23:56:44 I don't want to clear the timer until I know that
Ilya Sherman 2013/04/19 01:38:42 That doesn't match how the logic in DidStartProvis
Dane Wallinga 2013/04/19 18:19:53 If the provisional load fails, we'll call ClickFai
+ Send(new AutofillHostMsg_FormsSeen(routing_id(), forms,
+ forms_seen_timestamp_,
+ state));
+ }
+}
+
} // namespace autofill
« 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