OLD | NEW |
---|---|
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 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1114 bool IsFormVisible(blink::WebFrame* frame, | 1114 bool IsFormVisible(blink::WebFrame* frame, |
1115 const GURL& canonical_action, | 1115 const GURL& canonical_action, |
1116 const GURL& canonical_origin, | 1116 const GURL& canonical_origin, |
1117 const FormData& form_data, | 1117 const FormData& form_data, |
1118 const FormsPredictionsMap& form_predictions) { | 1118 const FormsPredictionsMap& form_predictions) { |
1119 const GURL frame_url = GURL(frame->document().url().string().utf8()); | 1119 const GURL frame_url = GURL(frame->document().url().string().utf8()); |
1120 blink::WebVector<blink::WebFormElement> forms; | 1120 blink::WebVector<blink::WebFormElement> forms; |
1121 frame->document().forms(forms); | 1121 frame->document().forms(forms); |
1122 | 1122 |
1123 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) | 1123 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) |
1124 const bool action_is_empty = canonical_action == canonical_origin; | 1124 const bool action_is_empty = canonical_action == canonical_origin |
vabr (Chromium)
2015/11/06 11:24:14
nit: Could you please comment that omitting the ac
ramya.v
2015/11/06 13:45:14
Done.
| |
1125 || canonical_action.is_empty(); | |
vabr (Chromium)
2015/11/06 11:24:14
Could you swap the order of the checks, so that is
ramya.v
2015/11/06 13:45:14
Done.
| |
1125 #endif | 1126 #endif |
1126 | 1127 |
1127 // Since empty or unspecified action fields are automatically set to page URL, | 1128 // Since empty or unspecified action fields are automatically set to page URL, |
1128 // action field for forms cannot be used for comparing (all forms with | 1129 // action field for forms cannot be used for comparing (all forms with |
1129 // empty/unspecified actions have the same value). If an action field is set | 1130 // empty/unspecified actions have the same value). If an action field is set |
1130 // to the page URL, this method checks ALL fields of the form instead (using | 1131 // to the page URL, this method checks ALL fields of the form instead (using |
1131 // FormData.SameFormAs). This is also true if the action was set to the page | 1132 // FormData.SameFormAs). This is also true if the action was set to the page |
1132 // URL on purpose. | 1133 // URL on purpose. |
1133 for (size_t i = 0; i < forms.size(); ++i) { | 1134 for (size_t i = 0; i < forms.size(); ++i) { |
1134 const blink::WebFormElement& form = forms[i]; | 1135 const blink::WebFormElement& form = forms[i]; |
1135 if (!IsWebNodeVisible(form)) | 1136 if (!IsWebNodeVisible(form)) |
1136 continue; | 1137 continue; |
1137 | 1138 |
1138 GURL iter_canonical_action = GetCanonicalActionForForm(form); | 1139 GURL iter_canonical_action = GetCanonicalActionForForm(form); |
1139 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) | 1140 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) |
1140 bool form_action_is_empty = iter_canonical_action == frame_url; | 1141 bool form_action_is_empty = iter_canonical_action == frame_url |
1142 || iter_canonical_action.is_empty(); | |
1141 | 1143 |
1142 if (action_is_empty != form_action_is_empty) | 1144 if (action_is_empty != form_action_is_empty) |
1143 continue; | 1145 continue; |
1144 | 1146 |
1145 if (action_is_empty) { // Both actions are empty, compare all fields. | 1147 if (action_is_empty) { // Both actions are empty, compare all fields. |
1146 FormData extracted_form_data; | 1148 FormData extracted_form_data; |
1147 WebFormElementToFormData(form, blink::WebFormControlElement(), | 1149 WebFormElementToFormData(form, blink::WebFormControlElement(), |
1148 EXTRACT_NONE, &extracted_form_data, nullptr); | 1150 EXTRACT_NONE, &extracted_form_data, nullptr); |
1149 if (form_data.SameFormAs(extracted_form_data)) { | 1151 if (form_data.SameFormAs(extracted_form_data)) { |
1150 return true; // Form still exists. | 1152 return true; // Form still exists. |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1643 // Zero selection start is for password manager, which can show usernames | 1645 // Zero selection start is for password manager, which can show usernames |
1644 // that do not begin with the user input value. | 1646 // that do not begin with the user input value. |
1645 selection_start = (offset == base::string16::npos) ? 0 : offset; | 1647 selection_start = (offset == base::string16::npos) ? 0 : offset; |
1646 } | 1648 } |
1647 | 1649 |
1648 input_element->setSelectionRange(selection_start, suggestion.length()); | 1650 input_element->setSelectionRange(selection_start, suggestion.length()); |
1649 } | 1651 } |
1650 | 1652 |
1651 } // namespace form_util | 1653 } // namespace form_util |
1652 } // namespace autofill | 1654 } // namespace autofill |
OLD | NEW |