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

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

Issue 1059393002: Remove --respect-autocomplete-off-autofill flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix last 3 tests Created 5 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 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 bool log_deprecation_messages = parsed_forms_.empty(); 89 bool log_deprecation_messages = parsed_forms_.empty();
90 90
91 const ExtractMask extract_mask = 91 const ExtractMask extract_mask =
92 static_cast<ExtractMask>(EXTRACT_VALUE | EXTRACT_OPTIONS); 92 static_cast<ExtractMask>(EXTRACT_VALUE | EXTRACT_OPTIONS);
93 93
94 size_t num_fields_seen = 0; 94 size_t num_fields_seen = 0;
95 for (size_t i = 0; i < web_forms.size(); ++i) { 95 for (size_t i = 0; i < web_forms.size(); ++i) {
96 const WebFormElement& form_element = web_forms[i]; 96 const WebFormElement& form_element = web_forms[i];
97 97
98 std::vector<WebFormControlElement> control_elements = 98 std::vector<WebFormControlElement> control_elements =
99 ExtractAutofillableElementsInForm(form_element, REQUIRE_NONE); 99 ExtractAutofillableElementsInForm(form_element);
100 size_t num_editable_elements = 100 size_t num_editable_elements =
101 ScanFormControlElements(control_elements, log_deprecation_messages); 101 ScanFormControlElements(control_elements, log_deprecation_messages);
102 102
103 if (ShouldIgnoreForm(num_editable_elements, control_elements.size())) 103 if (ShouldIgnoreForm(num_editable_elements, control_elements.size()))
104 continue; 104 continue;
105 105
106 FormData form; 106 FormData form;
107 if (!WebFormElementToFormData(form_element, WebFormControlElement(), 107 if (!WebFormElementToFormData(form_element, WebFormControlElement(),
108 REQUIRE_NONE, extract_mask, &form, nullptr)) { 108 extract_mask, &form, nullptr)) {
109 continue; 109 continue;
110 } 110 }
111 111
112 num_fields_seen += form.fields.size(); 112 num_fields_seen += form.fields.size();
113 if (num_fields_seen > kMaxParseableFields) 113 if (num_fields_seen > kMaxParseableFields)
114 return forms; 114 return forms;
115 115
116 if (form.fields.size() >= kRequiredAutofillFields && 116 if (form.fields.size() >= kRequiredAutofillFields &&
117 !ContainsKey(parsed_forms_, form)) { 117 !ContainsKey(parsed_forms_, form)) {
118 forms.push_back(form); 118 forms.push_back(form);
119 parsed_forms_.insert(form); 119 parsed_forms_.insert(form);
120 } 120 }
121 } 121 }
122 122
123 // Look for more parseable fields outside of forms. 123 // Look for more parseable fields outside of forms.
124 std::vector<WebElement> fieldsets; 124 std::vector<WebElement> fieldsets;
125 std::vector<WebFormControlElement> control_elements = 125 std::vector<WebFormControlElement> control_elements =
126 GetUnownedAutofillableFormFieldElements(document.all(), &fieldsets); 126 GetUnownedAutofillableFormFieldElements(document.all(), &fieldsets);
127 127
128 size_t num_editable_elements = 128 size_t num_editable_elements =
129 ScanFormControlElements(control_elements, log_deprecation_messages); 129 ScanFormControlElements(control_elements, log_deprecation_messages);
130 130
131 if (ShouldIgnoreForm(num_editable_elements, control_elements.size())) 131 if (ShouldIgnoreForm(num_editable_elements, control_elements.size()))
132 return forms; 132 return forms;
133 133
134 FormData synthetic_form; 134 FormData synthetic_form;
135 if (!UnownedFormElementsAndFieldSetsToFormData(fieldsets, control_elements, 135 if (!UnownedFormElementsAndFieldSetsToFormData(
136 nullptr, document.url(), 136 fieldsets, control_elements, nullptr, document.url(), extract_mask,
137 REQUIRE_NONE, extract_mask, 137 &synthetic_form, nullptr)) {
138 &synthetic_form, nullptr)) {
139 return forms; 138 return forms;
140 } 139 }
141 140
142 num_fields_seen += synthetic_form.fields.size(); 141 num_fields_seen += synthetic_form.fields.size();
143 if (num_fields_seen > kMaxParseableFields) 142 if (num_fields_seen > kMaxParseableFields)
144 return forms; 143 return forms;
145 144
146 if (synthetic_form.fields.size() >= kRequiredAutofillFields && 145 if (synthetic_form.fields.size() >= kRequiredAutofillFields &&
147 !parsed_forms_.count(synthetic_form)) { 146 !parsed_forms_.count(synthetic_form)) {
148 forms.push_back(synthetic_form); 147 forms.push_back(synthetic_form);
(...skipping 10 matching lines...) Expand all
159 initial_checked_state_.clear(); 158 initial_checked_state_.clear();
160 } 159 }
161 160
162 bool FormCache::ClearFormWithElement(const WebFormControlElement& element) { 161 bool FormCache::ClearFormWithElement(const WebFormControlElement& element) {
163 WebFormElement form_element = element.form(); 162 WebFormElement form_element = element.form();
164 std::vector<WebFormControlElement> control_elements; 163 std::vector<WebFormControlElement> control_elements;
165 if (form_element.isNull()) { 164 if (form_element.isNull()) {
166 control_elements = GetUnownedAutofillableFormFieldElements( 165 control_elements = GetUnownedAutofillableFormFieldElements(
167 element.document().all(), nullptr); 166 element.document().all(), nullptr);
168 } else { 167 } else {
169 control_elements = ExtractAutofillableElementsInForm( 168 control_elements = ExtractAutofillableElementsInForm(form_element);
170 form_element, REQUIRE_NONE);
171 } 169 }
172 for (size_t i = 0; i < control_elements.size(); ++i) { 170 for (size_t i = 0; i < control_elements.size(); ++i) {
173 WebFormControlElement control_element = control_elements[i]; 171 WebFormControlElement control_element = control_elements[i];
174 // Don't modify the value of disabled fields. 172 // Don't modify the value of disabled fields.
175 if (!control_element.isEnabled()) 173 if (!control_element.isEnabled())
176 continue; 174 continue;
177 175
178 // Don't clear field that was not autofilled 176 // Don't clear field that was not autofilled
179 if (!control_element.isAutofilled()) 177 if (!control_element.isAutofilled())
180 continue; 178 continue;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 // we would have a way to uniquely identify the form cross-process. For 243 // we would have a way to uniquely identify the form cross-process. For
246 // now, we'll check form name and form action for identity. 244 // now, we'll check form name and form action for identity.
247 // Also note that WebString() == WebString(string16()) does not evaluate 245 // Also note that WebString() == WebString(string16()) does not evaluate
248 // to |true| -- WebKit distinguishes between a "null" string (lhs) and 246 // to |true| -- WebKit distinguishes between a "null" string (lhs) and
249 // an "empty" string (rhs). We don't want that distinction, so forcing 247 // an "empty" string (rhs). We don't want that distinction, so forcing
250 // to string16. 248 // to string16.
251 base::string16 element_name = GetFormIdentifier(form_element); 249 base::string16 element_name = GetFormIdentifier(form_element);
252 GURL action(form_element.document().completeURL(form_element.action())); 250 GURL action(form_element.document().completeURL(form_element.action()));
253 if (element_name == form.data.name && action == form.data.action) { 251 if (element_name == form.data.name && action == form.data.action) {
254 found_form = true; 252 found_form = true;
255 control_elements = 253 control_elements = ExtractAutofillableElementsInForm(form_element);
256 ExtractAutofillableElementsInForm(form_element, REQUIRE_NONE);
257 break; 254 break;
258 } 255 }
259 } 256 }
260 257
261 if (!found_form) 258 if (!found_form)
262 return false; 259 return false;
263 } 260 }
264 261
265 if (control_elements.size() != form.fields.size()) { 262 if (control_elements.size() != form.fields.size()) {
266 // Keep things simple. Don't show predictions for forms that were modified 263 // Keep things simple. Don't show predictions for forms that were modified
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 std::make_pair(input_element, input_element.isChecked())); 315 std::make_pair(input_element, input_element.isChecked()));
319 } else { 316 } else {
320 ++num_editable_elements; 317 ++num_editable_elements;
321 } 318 }
322 } 319 }
323 } 320 }
324 return num_editable_elements; 321 return num_editable_elements;
325 } 322 }
326 323
327 } // namespace autofill 324 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698