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

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

Issue 853523004: Autofill: Set requirements for number of recognized fields in an autofillable form (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More relaxed check for form tag Created 5 years, 11 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/phone_field.h" 5 #include "components/autofill/core/browser/phone_field.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 } 233 }
234 } else { 234 } else {
235 ok = AddClassification(parsed_phone_fields_[FIELD_PHONE], 235 ok = AddClassification(parsed_phone_fields_[FIELD_PHONE],
236 PHONE_HOME_WHOLE_NUMBER, 236 PHONE_HOME_WHOLE_NUMBER,
237 map); 237 map);
238 } 238 }
239 239
240 return ok; 240 return ok;
241 } 241 }
242 242
243 size_t PhoneField::FieldCount() const {
Evan Stade 2015/01/21 22:52:50 why not just return 1? Why should three separate i
Lei Zhang 2015/01/22 08:07:37 Recognizing many fields in a phone number is a str
244 size_t count = 0;
245 for (size_t i = 0; i < FIELD_MAX; ++i) {
246 if (parsed_phone_fields_[i])
247 ++count;
248 }
249
250 return count;
251 }
252
243 PhoneField::PhoneField() { 253 PhoneField::PhoneField() {
244 memset(parsed_phone_fields_, 0, sizeof(parsed_phone_fields_)); 254 memset(parsed_phone_fields_, 0, sizeof(parsed_phone_fields_));
245 } 255 }
246 256
247 // static 257 // static
248 base::string16 PhoneField::GetRegExp(RegexType regex_id) { 258 base::string16 PhoneField::GetRegExp(RegexType regex_id) {
249 switch (regex_id) { 259 switch (regex_id) {
250 case REGEX_COUNTRY: 260 case REGEX_COUNTRY:
251 return base::UTF8ToUTF16(kCountryCodeRe); 261 return base::UTF8ToUTF16(kCountryCodeRe);
252 case REGEX_AREA: 262 case REGEX_AREA:
(...skipping 13 matching lines...) Expand all
266 case REGEX_EXTENSION: 276 case REGEX_EXTENSION:
267 return base::UTF8ToUTF16(kPhoneExtensionRe); 277 return base::UTF8ToUTF16(kPhoneExtensionRe);
268 default: 278 default:
269 NOTREACHED(); 279 NOTREACHED();
270 break; 280 break;
271 } 281 }
272 return base::string16(); 282 return base::string16();
273 } 283 }
274 284
275 } // namespace autofill 285 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698