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/core/browser/form_structure.h" | 5 #include "components/autofill/core/browser/form_structure.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 } // namespace | 346 } // namespace |
347 | 347 |
348 FormStructure::FormStructure(const FormData& form) | 348 FormStructure::FormStructure(const FormData& form) |
349 : form_name_(form.name), | 349 : form_name_(form.name), |
350 source_url_(form.origin), | 350 source_url_(form.origin), |
351 target_url_(form.action), | 351 target_url_(form.action), |
352 autofill_count_(0), | 352 autofill_count_(0), |
353 active_field_count_(0), | 353 active_field_count_(0), |
354 upload_required_(USE_UPLOAD_RATES), | 354 upload_required_(USE_UPLOAD_RATES), |
355 has_author_specified_types_(false), | 355 has_author_specified_types_(false), |
356 has_password_field_(false) { | 356 has_password_field_(false), |
| 357 is_form_tag_(form.is_form_tag) { |
357 // Copy the form fields. | 358 // Copy the form fields. |
358 std::map<base::string16, size_t> unique_names; | 359 std::map<base::string16, size_t> unique_names; |
359 for (std::vector<FormFieldData>::const_iterator field = | 360 for (std::vector<FormFieldData>::const_iterator field = |
360 form.fields.begin(); | 361 form.fields.begin(); |
361 field != form.fields.end(); ++field) { | 362 field != form.fields.end(); ++field) { |
362 if (!ShouldSkipField(*field)) { | 363 if (!ShouldSkipField(*field)) { |
363 // Add all supported form fields (including with empty names) to the | 364 // Add all supported form fields (including with empty names) to the |
364 // signature. This is a requirement for Autofill servers. | 365 // signature. This is a requirement for Autofill servers. |
365 form_signature_field_names_.append("&"); | 366 form_signature_field_names_.append("&"); |
366 form_signature_field_names_.append(StripDigitsIfRequired(field->name)); | 367 form_signature_field_names_.append(StripDigitsIfRequired(field->name)); |
(...skipping 23 matching lines...) Expand all Loading... |
390 // First, try to detect field types based on each field's |autocomplete| | 391 // First, try to detect field types based on each field's |autocomplete| |
391 // attribute value. If there is at least one form field that specifies an | 392 // attribute value. If there is at least one form field that specifies an |
392 // autocomplete type hint, don't try to apply other heuristics to match fields | 393 // autocomplete type hint, don't try to apply other heuristics to match fields |
393 // in this form. | 394 // in this form. |
394 bool has_author_specified_sections; | 395 bool has_author_specified_sections; |
395 ParseFieldTypesFromAutocompleteAttributes(&has_author_specified_types_, | 396 ParseFieldTypesFromAutocompleteAttributes(&has_author_specified_types_, |
396 &has_author_specified_sections); | 397 &has_author_specified_sections); |
397 | 398 |
398 if (!has_author_specified_types_) { | 399 if (!has_author_specified_types_) { |
399 ServerFieldTypeMap field_type_map; | 400 ServerFieldTypeMap field_type_map; |
400 FormField::ParseFormFields(fields_.get(), &field_type_map); | 401 FormField::ParseFormFields(fields_.get(), is_form_tag_, &field_type_map); |
401 for (size_t i = 0; i < field_count(); ++i) { | 402 for (size_t i = 0; i < field_count(); ++i) { |
402 AutofillField* field = fields_[i]; | 403 AutofillField* field = fields_[i]; |
403 ServerFieldTypeMap::iterator iter = | 404 ServerFieldTypeMap::iterator iter = |
404 field_type_map.find(field->unique_name()); | 405 field_type_map.find(field->unique_name()); |
405 if (iter != field_type_map.end()) | 406 if (iter != field_type_map.end()) |
406 field->set_heuristic_type(iter->second); | 407 field->set_heuristic_type(iter->second); |
407 } | 408 } |
408 } | 409 } |
409 | 410 |
410 UpdateAutofillCount(); | 411 UpdateAutofillCount(); |
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1245 for (AutofillField* field : fields_) { | 1246 for (AutofillField* field : fields_) { |
1246 FieldTypeGroup field_type_group = field->Type().group(); | 1247 FieldTypeGroup field_type_group = field->Type().group(); |
1247 if (field_type_group == CREDIT_CARD) | 1248 if (field_type_group == CREDIT_CARD) |
1248 field->set_section(field->section() + "-cc"); | 1249 field->set_section(field->section() + "-cc"); |
1249 else | 1250 else |
1250 field->set_section(field->section() + "-default"); | 1251 field->set_section(field->section() + "-default"); |
1251 } | 1252 } |
1252 } | 1253 } |
1253 | 1254 |
1254 } // namespace autofill | 1255 } // namespace autofill |
OLD | NEW |