Chromium Code Reviews| Index: components/autofill/content/renderer/autofill_agent.cc |
| diff --git a/components/autofill/content/renderer/autofill_agent.cc b/components/autofill/content/renderer/autofill_agent.cc |
| index 4a9e7bdcdb0e1cde06bfa2e5b5237d058db0241f..70c9e7e59c8c36aeca84b8714169b7c36ba679da 100644 |
| --- a/components/autofill/content/renderer/autofill_agent.cc |
| +++ b/components/autofill/content/renderer/autofill_agent.cc |
| @@ -136,6 +136,7 @@ AutofillAgent::AutofillAgent(content::RenderView* render_view, |
| has_new_forms_for_browser_(false), |
| ignore_text_changes_(false), |
| is_popup_possibly_visible_(false), |
| + main_frame_processed_(false), |
| weak_ptr_factory_(this) { |
| render_view->GetWebView()->setAutofillClient(this); |
| @@ -170,31 +171,11 @@ bool AutofillAgent::OnMessageReceived(const IPC::Message& message) { |
| } |
| void AutofillAgent::DidFinishDocumentLoad(WebLocalFrame* frame) { |
| - // Record timestamp on document load. This is used to record overhead of |
| - // Autofill feature. |
| - forms_seen_timestamp_ = base::TimeTicks::Now(); |
| + // If the main frame just finished loading we should process it. |
|
Ilya Sherman
2014/04/23 05:51:36
nit: "finished loading we should" -> "finished loa
Garrett Casto
2014/04/23 21:51:14
Done.
|
| + if (!frame->parent()) |
| + main_frame_processed_ = false; |
| - // The document has now been fully loaded. Scan for forms to be sent up to |
| - // the browser. |
| - std::vector<FormData> forms; |
| - bool has_more_forms = false; |
| - if (!frame->parent()) { |
| - form_elements_.clear(); |
| - has_more_forms = form_cache_.ExtractFormsAndFormElements( |
| - *frame, kRequiredAutofillFields, &forms, &form_elements_); |
| - } else { |
| - 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_, |
| - state)); |
| - } |
| + ProcessForms(*frame); |
| } |
| void AutofillAgent::FrameDetached(WebFrame* frame) { |
| @@ -672,6 +653,27 @@ void AutofillAgent::PreviewFieldWithValue(const base::string16& value, |
| node->suggestedValue().length()); |
| } |
| +void AutofillAgent::ProcessForms(const WebLocalFrame& frame) { |
| + // Record timestamp on document load. This is used to record overhead of |
|
Ilya Sherman
2014/04/23 05:51:36
nit: "record overhead of Autofill feature" -> "mea
Garrett Casto
2014/04/23 21:51:14
Done.
|
| + // Autofill feature. |
| + base::TimeTicks forms_seen_timestamp = base::TimeTicks::Now(); |
| + |
| + // The document has now been fully loaded. Scan for forms to be sent up to |
|
Ilya Sherman
2014/04/23 05:51:36
This comment is somewhat misleading, as the method
Garrett Casto
2014/04/23 21:51:14
Removed. I don't think that it adds much anymore.
|
| + // the browser. |
| + std::vector<FormData> forms; |
| + form_cache_.ExtractNewForms(frame, &forms); |
| + |
| + // Always communicate to browser process for topmost frame. |
| + if (!forms.empty() || |
| + (!frame.parent() && !main_frame_processed_)) { |
| + Send(new AutofillHostMsg_FormsSeen(routing_id(), forms, |
| + forms_seen_timestamp)); |
| + } |
| + |
| + if (!frame.parent()) |
| + main_frame_processed_ = true; |
| +} |
| + |
| void AutofillAgent::HidePopup() { |
| if (!is_popup_possibly_visible_) |
| return; |
| @@ -683,13 +685,13 @@ void AutofillAgent::HidePopup() { |
| Send(new AutofillHostMsg_HidePopup(routing_id())); |
| } |
| -// TODO(isherman): Decide if we want to support non-password autofill with AJAX. |
| void AutofillAgent::didAssociateFormControls(const WebVector<WebNode>& nodes) { |
| for (size_t i = 0; i < nodes.size(); ++i) { |
| - WebFrame* frame = nodes[i].document().frame(); |
| + WebLocalFrame* frame = nodes[i].document().frame(); |
| // Only monitors dynamic forms created in the top frame. Dynamic forms |
| // inserted in iframes are not captured yet. |
| if (frame && !frame->parent()) { |
| + ProcessForms(*frame); |
| password_autofill_agent_->OnDynamicFormsSeen(frame); |
| return; |
| } |