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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 const char kIgnorePatternInFieldName[] = "\\d{5,}+"; | 65 const char kIgnorePatternInFieldName[] = "\\d{5,}+"; |
66 | 66 |
67 // A form is considered to have a high prediction mismatch rate if the number of | 67 // A form is considered to have a high prediction mismatch rate if the number of |
68 // mismatches exceeds this threshold. | 68 // mismatches exceeds this threshold. |
69 const int kNumberOfMismatchesThreshold = 3; | 69 const int kNumberOfMismatchesThreshold = 3; |
70 | 70 |
71 // Returns whether sending autofill field metadata to the server is enabled. | 71 // Returns whether sending autofill field metadata to the server is enabled. |
72 bool IsAutofillFieldMetadataEnabled() { | 72 bool IsAutofillFieldMetadataEnabled() { |
73 const std::string group_name = | 73 const std::string group_name = |
74 base::FieldTrialList::FindFullName("AutofillFieldMetadata"); | 74 base::FieldTrialList::FindFullName("AutofillFieldMetadata"); |
75 return base::StartsWithASCII(group_name, "Enabled", true); | 75 return base::StartsWith(group_name, "Enabled", base::CompareCase::SENSITIVE); |
76 } | 76 } |
77 | 77 |
78 // Helper for |EncodeUploadRequest()| that creates a bit field corresponding to | 78 // Helper for |EncodeUploadRequest()| that creates a bit field corresponding to |
79 // |available_field_types| and returns the hex representation as a string. | 79 // |available_field_types| and returns the hex representation as a string. |
80 std::string EncodeFieldTypes(const ServerFieldTypeSet& available_field_types) { | 80 std::string EncodeFieldTypes(const ServerFieldTypeSet& available_field_types) { |
81 // There are |MAX_VALID_FIELD_TYPE| different field types and 8 bits per byte, | 81 // There are |MAX_VALID_FIELD_TYPE| different field types and 8 bits per byte, |
82 // so we need ceil(MAX_VALID_FIELD_TYPE / 8) bytes to encode the bit field. | 82 // so we need ceil(MAX_VALID_FIELD_TYPE / 8) bytes to encode the bit field. |
83 const size_t kNumBytes = (MAX_VALID_FIELD_TYPE + 0x7) / 8; | 83 const size_t kNumBytes = (MAX_VALID_FIELD_TYPE + 0x7) / 8; |
84 | 84 |
85 // Pack the types in |available_field_types| into |bit_field|. | 85 // Pack the types in |available_field_types| into |bit_field|. |
(...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1144 } | 1144 } |
1145 | 1145 |
1146 if (mode != HTML_MODE_NONE) { | 1146 if (mode != HTML_MODE_NONE) { |
1147 section = "-" + tokens.back(); | 1147 section = "-" + tokens.back(); |
1148 tokens.pop_back(); | 1148 tokens.pop_back(); |
1149 } | 1149 } |
1150 | 1150 |
1151 // The preceding token, if any, may be a named section. | 1151 // The preceding token, if any, may be a named section. |
1152 const std::string kSectionPrefix = "section-"; | 1152 const std::string kSectionPrefix = "section-"; |
1153 if (!tokens.empty() && | 1153 if (!tokens.empty() && |
1154 base::StartsWithASCII(tokens.back(), kSectionPrefix, true)) { | 1154 base::StartsWith(tokens.back(), kSectionPrefix, |
| 1155 base::CompareCase::SENSITIVE)) { |
1155 // Prepend this section name to the suffix set in the preceding block. | 1156 // Prepend this section name to the suffix set in the preceding block. |
1156 section = tokens.back().substr(kSectionPrefix.size()) + section; | 1157 section = tokens.back().substr(kSectionPrefix.size()) + section; |
1157 tokens.pop_back(); | 1158 tokens.pop_back(); |
1158 } | 1159 } |
1159 | 1160 |
1160 // No other tokens are allowed. If there are any remaining, abort. | 1161 // No other tokens are allowed. If there are any remaining, abort. |
1161 if (!tokens.empty()) | 1162 if (!tokens.empty()) |
1162 continue; | 1163 continue; |
1163 | 1164 |
1164 if (section != kDefaultSection) { | 1165 if (section != kDefaultSection) { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1311 for (AutofillField* field : fields_) { | 1312 for (AutofillField* field : fields_) { |
1312 FieldTypeGroup field_type_group = field->Type().group(); | 1313 FieldTypeGroup field_type_group = field->Type().group(); |
1313 if (field_type_group == CREDIT_CARD) | 1314 if (field_type_group == CREDIT_CARD) |
1314 field->set_section(field->section() + "-cc"); | 1315 field->set_section(field->section() + "-cc"); |
1315 else | 1316 else |
1316 field->set_section(field->section() + "-default"); | 1317 field->set_section(field->section() + "-default"); |
1317 } | 1318 } |
1318 } | 1319 } |
1319 | 1320 |
1320 } // namespace autofill | 1321 } // namespace autofill |
OLD | NEW |