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

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

Issue 11889029: Minor style cleanup in the PhoneField class: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 #ifndef CHROME_BROWSER_AUTOFILL_PHONE_FIELD_H_ 5 #ifndef CHROME_BROWSER_AUTOFILL_PHONE_FIELD_H_
6 #define CHROME_BROWSER_AUTOFILL_PHONE_FIELD_H_ 6 #define CHROME_BROWSER_AUTOFILL_PHONE_FIELD_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 19 matching lines...) Expand all
30 virtual bool ClassifyField(FieldTypeMap* map) const OVERRIDE; 30 virtual bool ClassifyField(FieldTypeMap* map) const OVERRIDE;
31 31
32 private: 32 private:
33 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ParseOneLinePhone); 33 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ParseOneLinePhone);
34 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ParseTwoLinePhone); 34 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ParseTwoLinePhone);
35 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ThreePartPhoneNumber); 35 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ThreePartPhoneNumber);
36 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ThreePartPhoneNumberPrefixSuffix); 36 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ThreePartPhoneNumberPrefixSuffix);
37 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ThreePartPhoneNumberPrefixSuffix2); 37 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ThreePartPhoneNumberPrefixSuffix2);
38 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, CountryAndCityAndPhoneNumber); 38 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, CountryAndCityAndPhoneNumber);
39 39
40 PhoneField();
41
42 // This is for easy description of the possible parsing paths of the phone 40 // This is for easy description of the possible parsing paths of the phone
43 // fields. 41 // fields.
44 enum RegexType { 42 enum RegexType {
45 REGEX_COUNTRY, 43 REGEX_COUNTRY,
46 REGEX_AREA, 44 REGEX_AREA,
47 REGEX_AREA_NOTEXT, 45 REGEX_AREA_NOTEXT,
48 REGEX_PHONE, 46 REGEX_PHONE,
49 REGEX_PREFIX_SEPARATOR, 47 REGEX_PREFIX_SEPARATOR,
50 REGEX_PREFIX, 48 REGEX_PREFIX,
51 REGEX_SUFFIX_SEPARATOR, 49 REGEX_SUFFIX_SEPARATOR,
52 REGEX_SUFFIX, 50 REGEX_SUFFIX,
53 REGEX_EXTENSION, 51 REGEX_EXTENSION,
54 52
55 // Separates regexps in grammar. 53 // Separates regexps in grammar.
56 REGEX_SEPARATOR, 54 REGEX_SEPARATOR,
57 }; 55 };
58 56
59 string16 GetRegExp(RegexType regex_id) const;
60
61 // |field| - field to fill up on successful parsing.
62 // |iter| - in/out. Form field iterator, points to the first field that is
63 // attempted to be parsed. If parsing successful, points to the first field
64 // after parsed fields.
65 // TODO(isherman): This method doc is out of date.
66 static bool ParseInternal(PhoneField* field, AutofillScanner* scanner);
67
68 // Parsed fields. 57 // Parsed fields.
69 enum PhonePart { 58 enum PhonePart {
70 FIELD_NONE = -1, 59 FIELD_NONE = -1,
71 FIELD_COUNTRY_CODE, 60 FIELD_COUNTRY_CODE,
72 FIELD_AREA_CODE, 61 FIELD_AREA_CODE,
73 FIELD_PHONE, 62 FIELD_PHONE,
74 FIELD_SUFFIX, 63 FIELD_SUFFIX,
75 FIELD_EXTENSION, 64 FIELD_EXTENSION,
76 65
77 FIELD_MAX, 66 FIELD_MAX,
78 }; 67 };
79 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
80 // FIELD_PHONE is always present; holds suffix if prefix is present. 82 // FIELD_PHONE is always present; holds suffix if prefix is present.
81 // The rest could be NULL. 83 // The rest could be NULL.
82 const AutofillField* parsed_phone_fields_[FIELD_MAX]; 84 const AutofillField* parsed_phone_fields_[FIELD_MAX];
83 85
84 static struct Parser {
85 RegexType regex; // Field matching reg-ex.
86 PhonePart phone_part; // Index of the field.
87 size_t max_size; // Max size of the field to match. 0 means any.
88 } phone_field_grammars_[];
89
90 DISALLOW_COPY_AND_ASSIGN(PhoneField); 86 DISALLOW_COPY_AND_ASSIGN(PhoneField);
91 }; 87 };
92 88
93 #endif // CHROME_BROWSER_AUTOFILL_PHONE_FIELD_H_ 89 #endif // CHROME_BROWSER_AUTOFILL_PHONE_FIELD_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/autofill/phone_field.cc » ('j') | chrome/browser/autofill/phone_field.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698