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 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1166 FormData* form, | 1166 FormData* form, |
1167 FormFieldData* field) { | 1167 FormFieldData* field) { |
1168 form->origin = GetCanonicalOriginForDocument(document); | 1168 form->origin = GetCanonicalOriginForDocument(document); |
1169 form->is_form_tag = false; | 1169 form->is_form_tag = false; |
1170 | 1170 |
1171 return FormOrFieldsetsToFormData( | 1171 return FormOrFieldsetsToFormData( |
1172 nullptr, element, fieldsets, control_elements, | 1172 nullptr, element, fieldsets, control_elements, |
1173 field_value_and_properties_map, extract_mask, form, field); | 1173 field_value_and_properties_map, extract_mask, form, field); |
1174 } | 1174 } |
1175 | 1175 |
1176 GURL StripAuthAndParams(const GURL& gurl) { | |
1177 // We want to keep the path but strip any authentication data, as well as | |
1178 // query and ref portions of URL, for the form action and form origin. | |
1179 GURL::Replacements rep; | |
1180 rep.ClearUsername(); | |
1181 rep.ClearPassword(); | |
1182 rep.ClearQuery(); | |
1183 rep.ClearRef(); | |
1184 return gurl.ReplaceComponents(rep); | |
1185 } | |
1186 | |
1187 } // namespace | 1176 } // namespace |
1188 | 1177 |
1189 ScopedLayoutPreventer::ScopedLayoutPreventer() { | 1178 ScopedLayoutPreventer::ScopedLayoutPreventer() { |
1190 DCHECK(!g_prevent_layout) << "Is any other instance of ScopedLayoutPreventer " | 1179 DCHECK(!g_prevent_layout) << "Is any other instance of ScopedLayoutPreventer " |
1191 "alive in the same process?"; | 1180 "alive in the same process?"; |
1192 g_prevent_layout = true; | 1181 g_prevent_layout = true; |
1193 } | 1182 } |
1194 | 1183 |
1195 ScopedLayoutPreventer::~ScopedLayoutPreventer() { | 1184 ScopedLayoutPreventer::~ScopedLayoutPreventer() { |
1196 DCHECK(g_prevent_layout) << "Is any other instance of ScopedLayoutPreventer " | 1185 DCHECK(g_prevent_layout) << "Is any other instance of ScopedLayoutPreventer " |
1197 "alive in the same process?"; | 1186 "alive in the same process?"; |
1198 g_prevent_layout = false; | 1187 g_prevent_layout = false; |
1199 } | 1188 } |
1200 | 1189 |
| 1190 GURL StripAuthAndParams(const GURL& gurl) { |
| 1191 GURL::Replacements rep; |
| 1192 rep.ClearUsername(); |
| 1193 rep.ClearPassword(); |
| 1194 rep.ClearQuery(); |
| 1195 rep.ClearRef(); |
| 1196 return gurl.ReplaceComponents(rep); |
| 1197 } |
| 1198 |
1201 bool ExtractFormData(const WebFormElement& form_element, FormData* data) { | 1199 bool ExtractFormData(const WebFormElement& form_element, FormData* data) { |
1202 return WebFormElementToFormData( | 1200 return WebFormElementToFormData( |
1203 form_element, WebFormControlElement(), nullptr, | 1201 form_element, WebFormControlElement(), nullptr, |
1204 static_cast<form_util::ExtractMask>(form_util::EXTRACT_VALUE | | 1202 static_cast<form_util::ExtractMask>(form_util::EXTRACT_VALUE | |
1205 form_util::EXTRACT_OPTION_TEXT | | 1203 form_util::EXTRACT_OPTION_TEXT | |
1206 form_util::EXTRACT_OPTIONS), | 1204 form_util::EXTRACT_OPTIONS), |
1207 data, NULL); | 1205 data, NULL); |
1208 } | 1206 } |
1209 | 1207 |
1210 bool IsFormVisible(blink::WebFrame* frame, | 1208 bool IsFormVisible(blink::WebFrame* frame, |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1811 // Zero selection start is for password manager, which can show usernames | 1809 // Zero selection start is for password manager, which can show usernames |
1812 // that do not begin with the user input value. | 1810 // that do not begin with the user input value. |
1813 selection_start = (offset == base::string16::npos) ? 0 : offset; | 1811 selection_start = (offset == base::string16::npos) ? 0 : offset; |
1814 } | 1812 } |
1815 | 1813 |
1816 input_element->setSelectionRange(selection_start, suggestion.length()); | 1814 input_element->setSelectionRange(selection_start, suggestion.length()); |
1817 } | 1815 } |
1818 | 1816 |
1819 } // namespace form_util | 1817 } // namespace form_util |
1820 } // namespace autofill | 1818 } // namespace autofill |
OLD | NEW |