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

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

Issue 1411363003: [Autofill] Always show available data when encountering autocomplete attributes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed mathp's comments Created 5 years, 2 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
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/form_cache.h" 5 #include "components/autofill/content/renderer/form_cache.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "components/autofill/content/renderer/form_autofill_util.h" 10 #include "components/autofill/content/renderer/form_autofill_util.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 WebString(base::ASCIIToUTF16(msg))); 57 WebString(base::ASCIIToUTF16(msg)));
58 element.document().frame()->addMessageToConsole(console_message); 58 element.document().frame()->addMessageToConsole(console_message);
59 } 59 }
60 } 60 }
61 61
62 // To avoid overly expensive computation, we impose a minimum number of 62 // To avoid overly expensive computation, we impose a minimum number of
63 // allowable fields. The corresponding maximum number of allowable fields 63 // allowable fields. The corresponding maximum number of allowable fields
64 // is imposed by WebFormElementToFormData(). 64 // is imposed by WebFormElementToFormData().
65 bool ShouldIgnoreForm(size_t num_editable_elements, 65 bool ShouldIgnoreForm(size_t num_editable_elements,
66 size_t num_control_elements) { 66 size_t num_control_elements) {
67 return (num_editable_elements < kRequiredAutofillFields && 67 return (!num_editable_elements && num_control_elements);
68 num_control_elements > 0);
69 } 68 }
70 69
71 } // namespace 70 } // namespace
72 71
73 FormCache::FormCache(const WebFrame& frame) : frame_(frame) { 72 FormCache::FormCache(const WebFrame& frame) : frame_(frame) {
74 } 73 }
75 74
76 FormCache::~FormCache() { 75 FormCache::~FormCache() {
77 } 76 }
78 77
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 FormData form; 109 FormData form;
111 if (!WebFormElementToFormData(form_element, WebFormControlElement(), 110 if (!WebFormElementToFormData(form_element, WebFormControlElement(),
112 extract_mask, &form, nullptr)) { 111 extract_mask, &form, nullptr)) {
113 continue; 112 continue;
114 } 113 }
115 114
116 num_fields_seen += form.fields.size(); 115 num_fields_seen += form.fields.size();
117 if (num_fields_seen > form_util::kMaxParseableFields) 116 if (num_fields_seen > form_util::kMaxParseableFields)
118 return forms; 117 return forms;
119 118
120 if (form.fields.size() >= kRequiredAutofillFields && 119 if (!form.fields.empty() && !ContainsKey(parsed_forms_, form)) {
Evan Stade 2015/10/21 19:12:31 Why are we changing the point at which forms might
sebsg 2015/10/26 15:57:55 This is the point where we filtered out forms with
Evan Stade 2015/10/27 17:08:37 only if they actually have that attribute
Mathieu 2015/10/28 12:50:48 I don't think it makes sense to move FormStructure
Evan Stade 2015/10/28 18:51:53 IsFormInteresting?
sebsg 2015/11/02 19:55:12 Acknowledged.
sebsg 2015/11/02 19:55:12 Acknowledged.
sebsg 2015/11/02 19:55:12 Done.
121 !ContainsKey(parsed_forms_, form)) {
122 for (auto it = parsed_forms_.begin(); it != parsed_forms_.end(); ++it) { 120 for (auto it = parsed_forms_.begin(); it != parsed_forms_.end(); ++it) {
123 if (it->SameFormAs(form)) { 121 if (it->SameFormAs(form)) {
124 parsed_forms_.erase(it); 122 parsed_forms_.erase(it);
125 break; 123 break;
126 } 124 }
127 } 125 }
128 126
129 SaveInitialValues(control_elements); 127 SaveInitialValues(control_elements);
130 forms.push_back(form); 128 forms.push_back(form);
131 parsed_forms_.insert(form); 129 parsed_forms_.insert(form);
(...skipping 16 matching lines...) Expand all
148 if (!UnownedCheckoutFormElementsAndFieldSetsToFormData( 146 if (!UnownedCheckoutFormElementsAndFieldSetsToFormData(
149 fieldsets, control_elements, nullptr, document, extract_mask, 147 fieldsets, control_elements, nullptr, document, extract_mask,
150 &synthetic_form, nullptr)) { 148 &synthetic_form, nullptr)) {
151 return forms; 149 return forms;
152 } 150 }
153 151
154 num_fields_seen += synthetic_form.fields.size(); 152 num_fields_seen += synthetic_form.fields.size();
155 if (num_fields_seen > form_util::kMaxParseableFields) 153 if (num_fields_seen > form_util::kMaxParseableFields)
156 return forms; 154 return forms;
157 155
158 if (synthetic_form.fields.size() >= kRequiredAutofillFields && 156 if (!synthetic_form.fields.empty() && !parsed_forms_.count(synthetic_form)) {
159 !parsed_forms_.count(synthetic_form)) {
160 SaveInitialValues(control_elements); 157 SaveInitialValues(control_elements);
161 forms.push_back(synthetic_form); 158 forms.push_back(synthetic_form);
162 parsed_forms_.insert(synthetic_form); 159 parsed_forms_.insert(synthetic_form);
163 parsed_forms_.erase(synthetic_form_); 160 parsed_forms_.erase(synthetic_form_);
164 synthetic_form_ = synthetic_form; 161 synthetic_form_ = synthetic_form;
165 } 162 }
166 return forms; 163 return forms;
167 } 164 }
168 165
169 void FormCache::Reset() { 166 void FormCache::Reset() {
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 const WebInputElement* input_element = toWebInputElement(&element); 340 const WebInputElement* input_element = toWebInputElement(&element);
344 if (form_util::IsCheckableElement(input_element)) { 341 if (form_util::IsCheckableElement(input_element)) {
345 initial_checked_state_.insert( 342 initial_checked_state_.insert(
346 std::make_pair(*input_element, input_element->isChecked())); 343 std::make_pair(*input_element, input_element->isChecked()));
347 } 344 }
348 } 345 }
349 } 346 }
350 } 347 }
351 348
352 } // namespace autofill 349 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698