| 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 73b25ffaa29fb3fc7f9f950844aac1e4d7b62d63..4a9e7bdcdb0e1cde06bfa2e5b5237d058db0241f 100644
|
| --- a/components/autofill/content/renderer/autofill_agent.cc
|
| +++ b/components/autofill/content/renderer/autofill_agent.cc
|
| @@ -136,7 +136,6 @@
|
| 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);
|
|
|
| @@ -171,11 +170,31 @@
|
| }
|
|
|
| void AutofillAgent::DidFinishDocumentLoad(WebLocalFrame* frame) {
|
| - // If the main frame just finished loading, we should process it.
|
| - if (!frame->parent())
|
| - main_frame_processed_ = false;
|
| -
|
| - ProcessForms(*frame);
|
| + // Record timestamp on document load. This is used to record overhead of
|
| + // Autofill feature.
|
| + forms_seen_timestamp_ = base::TimeTicks::Now();
|
| +
|
| + // 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));
|
| + }
|
| }
|
|
|
| void AutofillAgent::FrameDetached(WebFrame* frame) {
|
| @@ -653,25 +672,6 @@
|
| node->suggestedValue().length());
|
| }
|
|
|
| -void AutofillAgent::ProcessForms(const WebLocalFrame& frame) {
|
| - // Record timestamp of when the forms are first seen. This is used to
|
| - // measure the overhead of the Autofill feature.
|
| - base::TimeTicks forms_seen_timestamp = base::TimeTicks::Now();
|
| -
|
| - 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 +683,13 @@
|
| 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) {
|
| - WebLocalFrame* frame = nodes[i].document().frame();
|
| + WebFrame* 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;
|
| }
|
|
|