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

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

Issue 2409123002: Remove kEnablePasswordChangeSupport and clean-up form_autofill_util.cc (Closed)
Patch Set: Remove kEnablePasswordChangeSupport and clean-up form_autofill_util.cc Created 4 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_autofill_util.h" 5 #include "components/autofill/content/renderer/form_autofill_util.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 } 1206 }
1207 1207
1208 bool IsFormVisible(blink::WebFrame* frame, 1208 bool IsFormVisible(blink::WebFrame* frame,
1209 const GURL& canonical_action, 1209 const GURL& canonical_action,
1210 const GURL& canonical_origin, 1210 const GURL& canonical_origin,
1211 const FormData& form_data) { 1211 const FormData& form_data) {
1212 const GURL frame_origin = GetCanonicalOriginForDocument(frame->document()); 1212 const GURL frame_origin = GetCanonicalOriginForDocument(frame->document());
1213 blink::WebVector<WebFormElement> forms; 1213 blink::WebVector<WebFormElement> forms;
1214 frame->document().forms(forms); 1214 frame->document().forms(forms);
1215 1215
1216 #if !defined(OS_ANDROID)
1217 // Omitting the action attribute would result in |canonical_origin| for 1216 // Omitting the action attribute would result in |canonical_origin| for
1218 // hierarchical schemes like http:, and in an empty URL for non-hierarchical 1217 // hierarchical schemes like http:, and in an empty URL for non-hierarchical
1219 // schemes like about: or data: etc. 1218 // schemes like about: or data: etc.
1220 const bool action_is_empty = canonical_action.is_empty() 1219 const bool action_is_empty = canonical_action.is_empty()
1221 || canonical_action == canonical_origin; 1220 || canonical_action == canonical_origin;
1222 #endif
1223 1221
1224 // Since empty or unspecified action fields are automatically set to page URL, 1222 // Since empty or unspecified action fields are automatically set to page URL,
1225 // action field for forms cannot be used for comparing (all forms with 1223 // action field for forms cannot be used for comparing (all forms with
1226 // empty/unspecified actions have the same value). If an action field is set 1224 // empty/unspecified actions have the same value). If an action field is set
1227 // to the page URL, this method checks ALL fields of the form instead (using 1225 // to the page URL, this method checks ALL fields of the form instead (using
1228 // FormData.SameFormAs). This is also true if the action was set to the page 1226 // FormData.SameFormAs). This is also true if the action was set to the page
1229 // URL on purpose. 1227 // URL on purpose.
1230 for (const WebFormElement& form : forms) { 1228 for (const WebFormElement& form : forms) {
1231 if (!AreFormContentsVisible(form)) 1229 if (!AreFormContentsVisible(form))
1232 continue; 1230 continue;
1233 1231
1234 GURL iter_canonical_action = GetCanonicalActionForForm(form); 1232 GURL iter_canonical_action = GetCanonicalActionForForm(form);
1235 #if !defined(OS_ANDROID)
1236 bool form_action_is_empty = iter_canonical_action.is_empty() || 1233 bool form_action_is_empty = iter_canonical_action.is_empty() ||
1237 iter_canonical_action == frame_origin; 1234 iter_canonical_action == frame_origin;
1238 if (action_is_empty != form_action_is_empty) 1235 if (action_is_empty != form_action_is_empty)
1239 continue; 1236 continue;
1240 1237
1241 if (action_is_empty) { // Both actions are empty, compare all fields. 1238 if (action_is_empty) { // Both actions are empty, compare all fields.
1242 FormData extracted_form_data; 1239 FormData extracted_form_data;
1243 WebFormElementToFormData(form, WebFormControlElement(), nullptr, 1240 WebFormElementToFormData(form, WebFormControlElement(), nullptr,
1244 EXTRACT_NONE, &extracted_form_data, nullptr); 1241 EXTRACT_NONE, &extracted_form_data, nullptr);
1245 if (form_data.SameFormAs(extracted_form_data)) { 1242 if (form_data.SameFormAs(extracted_form_data)) {
1246 return true; // Form still exists. 1243 return true; // Form still exists.
1247 } 1244 }
1248 } else { // Both actions are non-empty, compare actions only. 1245 } else { // Both actions are non-empty, compare actions only.
1249 if (canonical_action == iter_canonical_action) { 1246 if (canonical_action == iter_canonical_action) {
1250 return true; // Form still exists. 1247 return true; // Form still exists.
1251 } 1248 }
1252 } 1249 }
1253 #else // OS_ANDROID
1254 if (canonical_action == iter_canonical_action) {
1255 return true; // Form still exists.
1256 }
1257 #endif
1258 } 1250 }
1259 1251
1260 return false; 1252 return false;
1261 } 1253 }
1262 1254
1263 bool IsSomeControlElementVisible( 1255 bool IsSomeControlElementVisible(
1264 const WebVector<WebFormControlElement>& control_elements) { 1256 const WebVector<WebFormControlElement>& control_elements) {
1265 for (const WebFormControlElement& control_element : control_elements) { 1257 for (const WebFormControlElement& control_element : control_elements) {
1266 if (IsWebNodeVisible(control_element)) 1258 if (IsWebNodeVisible(control_element))
1267 return true; 1259 return true;
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
1809 // Zero selection start is for password manager, which can show usernames 1801 // Zero selection start is for password manager, which can show usernames
1810 // that do not begin with the user input value. 1802 // that do not begin with the user input value.
1811 selection_start = (offset == base::string16::npos) ? 0 : offset; 1803 selection_start = (offset == base::string16::npos) ? 0 : offset;
1812 } 1804 }
1813 1805
1814 input_element->setSelectionRange(selection_start, suggestion.length()); 1806 input_element->setSelectionRange(selection_start, suggestion.length());
1815 } 1807 }
1816 1808
1817 } // namespace form_util 1809 } // namespace form_util
1818 } // namespace autofill 1810 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | components/password_manager/core/common/password_manager_features.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698