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

Side by Side Diff: chrome/browser/autofill/phone_field.h

Issue 12434004: Move remaining Autofill code to //components/autofill. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix long lines Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_AUTOFILL_PHONE_FIELD_H_
6 #define CHROME_BROWSER_AUTOFILL_PHONE_FIELD_H_
7
8 #include <vector>
9
10 #include "base/compiler_specific.h"
11 #include "chrome/browser/autofill/autofill_type.h"
12 #include "chrome/browser/autofill/form_field.h"
13 #include "chrome/browser/autofill/phone_number.h"
14
15 class AutofillField;
16 class AutofillScanner;
17
18 // A phone number in one of the following formats:
19 // - area code, prefix, suffix
20 // - area code, number
21 // - number
22 class PhoneField : public FormField {
23 public:
24 virtual ~PhoneField();
25
26 static FormField* Parse(AutofillScanner* scanner);
27
28 protected:
29 // FormField:
30 virtual bool ClassifyField(FieldTypeMap* map) const OVERRIDE;
31
32 private:
33 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ParseOneLinePhone);
34 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ParseTwoLinePhone);
35 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ThreePartPhoneNumber);
36 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ThreePartPhoneNumberPrefixSuffix);
37 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ThreePartPhoneNumberPrefixSuffix2);
38 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, CountryAndCityAndPhoneNumber);
39
40 // This is for easy description of the possible parsing paths of the phone
41 // fields.
42 enum RegexType {
43 REGEX_COUNTRY,
44 REGEX_AREA,
45 REGEX_AREA_NOTEXT,
46 REGEX_PHONE,
47 REGEX_PREFIX_SEPARATOR,
48 REGEX_PREFIX,
49 REGEX_SUFFIX_SEPARATOR,
50 REGEX_SUFFIX,
51 REGEX_EXTENSION,
52
53 // Separates regexps in grammar.
54 REGEX_SEPARATOR,
55 };
56
57 // Parsed fields.
58 enum PhonePart {
59 FIELD_NONE = -1,
60 FIELD_COUNTRY_CODE,
61 FIELD_AREA_CODE,
62 FIELD_PHONE,
63 FIELD_SUFFIX,
64 FIELD_EXTENSION,
65
66 FIELD_MAX,
67 };
68
69 struct Parser {
70 RegexType regex; // Field matching reg-ex.
71 PhonePart phone_part; // Index of the field.
72 size_t max_size; // Max size of the field to match. 0 means any.
73 };
74
75 static const Parser kPhoneFieldGrammars[];
76
77 PhoneField();
78
79 // Returns the regular expression string correspoding to |regex_id|
80 static string16 GetRegExp(RegexType regex_id);
81
82 // FIELD_PHONE is always present; holds suffix if prefix is present.
83 // The rest could be NULL.
84 const AutofillField* parsed_phone_fields_[FIELD_MAX];
85
86 DISALLOW_COPY_AND_ASSIGN(PhoneField);
87 };
88
89 #endif // CHROME_BROWSER_AUTOFILL_PHONE_FIELD_H_
OLDNEW
« no previous file with comments | « chrome/browser/autofill/personal_data_manager_unittest.cc ('k') | chrome/browser/autofill/phone_field.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698