#ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_PHONE_FIELD_H_
#define COMPONENTS_AUTOFILL_CORE_BROWSER_PHONE_FIELD_H_
#include <vector>
#include "base/compiler_specific.h"
#include "components/autofill/core/browser/autofill_type.h"
#include "components/autofill/core/browser/form_field.h"
#include "components/autofill/core/browser/phone_number.h"
namespace autofill {
class AutofillField;
class AutofillScanner;
class PhoneField : public FormField {
public:
virtual ~PhoneField();
static FormField* Parse(AutofillScanner* scanner);
protected:
virtual bool ClassifyField(ServerFieldTypeMap* map) const OVERRIDE;
private:
FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ParseOneLinePhone);
FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ParseTwoLinePhone);
FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ThreePartPhoneNumber);
FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ThreePartPhoneNumberPrefixSuffix);
FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ThreePartPhoneNumberPrefixSuffix2);
FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, CountryAndCityAndPhoneNumber);
enum RegexType {
REGEX_COUNTRY,
REGEX_AREA,
REGEX_AREA_NOTEXT,
REGEX_PHONE,
REGEX_PREFIX_SEPARATOR,
REGEX_PREFIX,
REGEX_SUFFIX_SEPARATOR,
REGEX_SUFFIX,
REGEX_EXTENSION,
REGEX_SEPARATOR,
};
enum PhonePart {
FIELD_NONE = -1,
FIELD_COUNTRY_CODE,
FIELD_AREA_CODE,
FIELD_PHONE,
FIELD_SUFFIX,
FIELD_EXTENSION,
FIELD_MAX,
};
struct Parser {
RegexType regex;
PhonePart phone_part;
size_t max_size;
};
static const Parser kPhoneFieldGrammars[];
PhoneField();
static base::string16 GetRegExp(RegexType regex_id);
const AutofillField* parsed_phone_fields_[FIELD_MAX];
DISALLOW_COPY_AND_ASSIGN(PhoneField);
};
}
#endif