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

Side by Side Diff: components/autofill/core/browser/form_structure.cc

Issue 1172183002: Move StartsWith[ASCII] to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@string_util3
Patch Set: merger Created 5 years, 6 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/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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 const char kIgnorePatternInFieldName[] = "\\d{5,}+"; 63 const char kIgnorePatternInFieldName[] = "\\d{5,}+";
64 64
65 // A form is considered to have a high prediction mismatch rate if the number of 65 // A form is considered to have a high prediction mismatch rate if the number of
66 // mismatches exceeds this threshold. 66 // mismatches exceeds this threshold.
67 const int kNumberOfMismatchesThreshold = 3; 67 const int kNumberOfMismatchesThreshold = 3;
68 68
69 // Returns whether sending autofill field metadata to the server is enabled. 69 // Returns whether sending autofill field metadata to the server is enabled.
70 bool IsAutofillFieldMetadataEnabled() { 70 bool IsAutofillFieldMetadataEnabled() {
71 const std::string group_name = 71 const std::string group_name =
72 base::FieldTrialList::FindFullName("AutofillFieldMetadata"); 72 base::FieldTrialList::FindFullName("AutofillFieldMetadata");
73 return StartsWithASCII(group_name, "Enabled", true); 73 return base::StartsWithASCII(group_name, "Enabled", true);
74 } 74 }
75 75
76 // Helper for |EncodeUploadRequest()| that creates a bit field corresponding to 76 // Helper for |EncodeUploadRequest()| that creates a bit field corresponding to
77 // |available_field_types| and returns the hex representation as a string. 77 // |available_field_types| and returns the hex representation as a string.
78 std::string EncodeFieldTypes(const ServerFieldTypeSet& available_field_types) { 78 std::string EncodeFieldTypes(const ServerFieldTypeSet& available_field_types) {
79 // There are |MAX_VALID_FIELD_TYPE| different field types and 8 bits per byte, 79 // There are |MAX_VALID_FIELD_TYPE| different field types and 8 bits per byte,
80 // so we need ceil(MAX_VALID_FIELD_TYPE / 8) bytes to encode the bit field. 80 // so we need ceil(MAX_VALID_FIELD_TYPE / 8) bytes to encode the bit field.
81 const size_t kNumBytes = (MAX_VALID_FIELD_TYPE + 0x7) / 8; 81 const size_t kNumBytes = (MAX_VALID_FIELD_TYPE + 0x7) / 8;
82 82
83 // Pack the types in |available_field_types| into |bit_field|. 83 // Pack the types in |available_field_types| into |bit_field|.
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 } 1138 }
1139 1139
1140 if (mode != HTML_MODE_NONE) { 1140 if (mode != HTML_MODE_NONE) {
1141 section = "-" + tokens.back(); 1141 section = "-" + tokens.back();
1142 tokens.pop_back(); 1142 tokens.pop_back();
1143 } 1143 }
1144 1144
1145 // The preceding token, if any, may be a named section. 1145 // The preceding token, if any, may be a named section.
1146 const std::string kSectionPrefix = "section-"; 1146 const std::string kSectionPrefix = "section-";
1147 if (!tokens.empty() && 1147 if (!tokens.empty() &&
1148 StartsWithASCII(tokens.back(), kSectionPrefix, true)) { 1148 base::StartsWithASCII(tokens.back(), kSectionPrefix, true)) {
1149 // Prepend this section name to the suffix set in the preceding block. 1149 // Prepend this section name to the suffix set in the preceding block.
1150 section = tokens.back().substr(kSectionPrefix.size()) + section; 1150 section = tokens.back().substr(kSectionPrefix.size()) + section;
1151 tokens.pop_back(); 1151 tokens.pop_back();
1152 } 1152 }
1153 1153
1154 // No other tokens are allowed. If there are any remaining, abort. 1154 // No other tokens are allowed. If there are any remaining, abort.
1155 if (!tokens.empty()) 1155 if (!tokens.empty())
1156 continue; 1156 continue;
1157 1157
1158 if (section != kDefaultSection) { 1158 if (section != kDefaultSection) {
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 for (AutofillField* field : fields_) { 1305 for (AutofillField* field : fields_) {
1306 FieldTypeGroup field_type_group = field->Type().group(); 1306 FieldTypeGroup field_type_group = field->Type().group();
1307 if (field_type_group == CREDIT_CARD) 1307 if (field_type_group == CREDIT_CARD)
1308 field->set_section(field->section() + "-cc"); 1308 field->set_section(field->section() + "-cc");
1309 else 1309 else
1310 field->set_section(field->section() + "-default"); 1310 field->set_section(field->section() + "-default");
1311 } 1311 }
1312 } 1312 }
1313 1313
1314 } // namespace autofill 1314 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698