| Index: chrome/browser/autofill/phone_field.cc
 | 
| diff --git a/chrome/browser/autofill/phone_field.cc b/chrome/browser/autofill/phone_field.cc
 | 
| index 14214a1b132a33607b39a14bbdad22c7ae14b26e..eec4ccdf6e5390a2bbd19d6688a80d240dea4c7b 100644
 | 
| --- a/chrome/browser/autofill/phone_field.cc
 | 
| +++ b/chrome/browser/autofill/phone_field.cc
 | 
| @@ -12,10 +12,20 @@
 | 
|  #include "chrome/browser/autofill/autofill_field.h"
 | 
|  #include "chrome/browser/autofill/autofill_regex_constants.h"
 | 
|  #include "chrome/browser/autofill/autofill_scanner.h"
 | 
| -#include "chrome/browser/autofill/fax_number.h"
 | 
| -#include "chrome/browser/autofill/home_phone_number.h"
 | 
|  #include "ui/base/l10n/l10n_util.h"
 | 
|  
 | 
| +namespace {
 | 
| +
 | 
| +// This string includes all area code separators, including NoText.
 | 
| +string16 GetAreaRegex() {
 | 
| +  string16 area_code = UTF8ToUTF16(autofill::kAreaCodeRe);
 | 
| +  area_code.append(ASCIIToUTF16("|"));  // Regexp separator.
 | 
| +  area_code.append(UTF8ToUTF16(autofill::kAreaCodeNotextRe));
 | 
| +  return area_code;
 | 
| +}
 | 
| +
 | 
| +}  // namespace
 | 
| +
 | 
|  // Phone field grammars - first matched grammar will be parsed. Grammars are
 | 
|  // separated by { REGEX_SEPARATOR, FIELD_NONE, 0 }. Suffix and extension are
 | 
|  // parsed separately unless they are necessary parts of the match.
 | 
| @@ -112,22 +122,14 @@ FormField* PhoneField::Parse(AutofillScanner* scanner) {
 | 
|      return NULL;
 | 
|  
 | 
|    scoped_ptr<PhoneField> phone_field(new PhoneField);
 | 
| -
 | 
| -  // Go through the phones in order HOME, FAX, attempting to match. HOME should
 | 
| -  // be the last as it is a catch all case ("fax" and "faxarea" parsed as FAX,
 | 
| -  // but "area" and "someotherarea" parsed as HOME, for example).
 | 
| -  for (int i = PHONE_TYPE_MAX - 1; i >= PHONE_TYPE_FIRST; --i) {
 | 
| -    phone_field->SetPhoneType(static_cast<PhoneField::PhoneType>(i));
 | 
| -    if (ParseInternal(phone_field.get(), scanner, i == HOME_PHONE))
 | 
| -      return phone_field.release();
 | 
| -  }
 | 
| +  if (ParseInternal(phone_field.get(), scanner))
 | 
| +    return phone_field.release();
 | 
|  
 | 
|    return NULL;
 | 
|  }
 | 
|  
 | 
|  PhoneField::PhoneField() {
 | 
|    memset(parsed_phone_fields_, 0, sizeof(parsed_phone_fields_));
 | 
| -  SetPhoneType(HOME_PHONE);
 | 
|  }
 | 
|  
 | 
|  bool PhoneField::ClassifyField(FieldTypeMap* map) const {
 | 
| @@ -140,19 +142,19 @@ bool PhoneField::ClassifyField(FieldTypeMap* map) const {
 | 
|        (parsed_phone_fields_[FIELD_SUFFIX] != NULL)) {
 | 
|      if (parsed_phone_fields_[FIELD_COUNTRY_CODE] != NULL) {
 | 
|        ok = ok && AddClassification(parsed_phone_fields_[FIELD_COUNTRY_CODE],
 | 
| -                                   number_->GetCountryCodeType(),
 | 
| +                                   PHONE_HOME_COUNTRY_CODE,
 | 
|                                     map);
 | 
|      }
 | 
|  
 | 
| -    AutofillFieldType field_number_type = number_->GetNumberType();
 | 
| +    AutofillFieldType field_number_type = PHONE_HOME_NUMBER;
 | 
|      if (parsed_phone_fields_[FIELD_AREA_CODE] != NULL) {
 | 
|        ok = ok && AddClassification(parsed_phone_fields_[FIELD_AREA_CODE],
 | 
| -                                   number_->GetCityCodeType(),
 | 
| +                                   PHONE_HOME_CITY_CODE,
 | 
|                                     map);
 | 
|      } else if (parsed_phone_fields_[FIELD_COUNTRY_CODE] != NULL) {
 | 
|        // Only if we can find country code without city code, it means the phone
 | 
|        // number include city code.
 | 
| -      field_number_type = number_->GetCityAndNumberType();
 | 
| +      field_number_type = PHONE_HOME_CITY_AND_NUMBER;
 | 
|      }
 | 
|      // We tag the prefix as PHONE_HOME_NUMBER, then when filling the form
 | 
|      // we fill only the prefix depending on the size of the input field.
 | 
| @@ -163,82 +165,38 @@ bool PhoneField::ClassifyField(FieldTypeMap* map) const {
 | 
|      // we fill only the suffix depending on the size of the input field.
 | 
|      if (parsed_phone_fields_[FIELD_SUFFIX] != NULL) {
 | 
|        ok = ok && AddClassification(parsed_phone_fields_[FIELD_SUFFIX],
 | 
| -                                   number_->GetNumberType(),
 | 
| +                                   PHONE_HOME_NUMBER,
 | 
|                                     map);
 | 
|      }
 | 
|    } else {
 | 
|      ok = AddClassification(parsed_phone_fields_[FIELD_PHONE],
 | 
| -                           number_->GetWholeNumberType(),
 | 
| +                           PHONE_HOME_WHOLE_NUMBER,
 | 
|                             map);
 | 
|    }
 | 
|  
 | 
|    return ok;
 | 
|  }
 | 
|  
 | 
| -string16  PhoneField::GetCountryRegex() const {
 | 
| -  // This one is the same for Home and Fax numbers.
 | 
| -  return UTF8ToUTF16(autofill::kCountryCodeRe);
 | 
| -}
 | 
| -
 | 
| -string16 PhoneField::GetAreaRegex() const {
 | 
| -  // This one is the same for Home and Fax numbers.
 | 
| -  string16 area_code = UTF8ToUTF16(autofill::kAreaCodeRe);
 | 
| -  area_code.append(ASCIIToUTF16("|"));  // Regexp separator.
 | 
| -  area_code.append(GetAreaNoTextRegex());
 | 
| -  return area_code;
 | 
| -}
 | 
| -
 | 
| -string16 PhoneField::GetAreaNoTextRegex() const {
 | 
| -  // This one is the same for Home and Fax numbers.
 | 
| -  return UTF8ToUTF16(autofill::kAreaCodeNotextRe);
 | 
| -}
 | 
| -
 | 
| -string16 PhoneField::GetPhoneRegex() const {
 | 
| -  if (phone_type_ == HOME_PHONE)
 | 
| -    return UTF8ToUTF16(autofill::kPhoneRe);
 | 
| -  else if (phone_type_ == FAX_PHONE)
 | 
| -    return UTF8ToUTF16(autofill::kFaxRe);
 | 
| -  else
 | 
| -    NOTREACHED();
 | 
| -  return string16();
 | 
| -}
 | 
| -
 | 
| -string16 PhoneField::GetPrefixSeparatorRegex() const {
 | 
| -  // This one is the same for Home and Fax numbers.
 | 
| -  return UTF8ToUTF16(autofill::kPhonePrefixSeparatorRe);
 | 
| -}
 | 
| -
 | 
| -string16 PhoneField::GetPrefixRegex() const {
 | 
| -  // This one is the same for Home and Fax numbers.
 | 
| -  return UTF8ToUTF16(autofill::kPhonePrefixRe);
 | 
| -}
 | 
| -
 | 
| -string16 PhoneField::GetSuffixSeparatorRegex() const {
 | 
| -  // This one is the same for Home and Fax numbers.
 | 
| -  return UTF8ToUTF16(autofill::kPhoneSuffixSeparatorRe);
 | 
| -}
 | 
| -
 | 
| -string16 PhoneField::GetSuffixRegex() const {
 | 
| -  // This one is the same for Home and Fax numbers.
 | 
| -  return UTF8ToUTF16(autofill::kPhoneSuffixRe);
 | 
| -}
 | 
| -
 | 
| -string16 PhoneField::GetExtensionRegex() const {
 | 
| -  // This one is the same for Home and Fax numbers.
 | 
| -  return UTF8ToUTF16(autofill::kPhoneExtensionRe);
 | 
| -}
 | 
| -
 | 
|  string16 PhoneField::GetRegExp(RegexType regex_id) const {
 | 
|    switch (regex_id) {
 | 
| -    case REGEX_COUNTRY: return GetCountryRegex();
 | 
| -    case REGEX_AREA: return GetAreaRegex();
 | 
| -    case REGEX_AREA_NOTEXT: return GetAreaNoTextRegex();
 | 
| -    case REGEX_PHONE: return GetPhoneRegex();
 | 
| -    case REGEX_PREFIX_SEPARATOR: return GetPrefixSeparatorRegex();
 | 
| -    case REGEX_PREFIX: return GetPrefixRegex();
 | 
| -    case REGEX_SUFFIX_SEPARATOR: return GetSuffixSeparatorRegex();
 | 
| -    case REGEX_SUFFIX: return GetSuffixRegex();
 | 
| -    case REGEX_EXTENSION: return GetExtensionRegex();
 | 
| +    case REGEX_COUNTRY:
 | 
| +      return UTF8ToUTF16(autofill::kCountryCodeRe);
 | 
| +    case REGEX_AREA:
 | 
| +      return GetAreaRegex();
 | 
| +    case REGEX_AREA_NOTEXT:
 | 
| +      return UTF8ToUTF16(autofill::kAreaCodeNotextRe);
 | 
| +    case REGEX_PHONE:
 | 
| +      return UTF8ToUTF16(autofill::kPhoneRe);
 | 
| +    case REGEX_PREFIX_SEPARATOR:
 | 
| +      return UTF8ToUTF16(autofill::kPhonePrefixSeparatorRe);
 | 
| +    case REGEX_PREFIX:
 | 
| +      return UTF8ToUTF16(autofill::kPhonePrefixRe);
 | 
| +    case REGEX_SUFFIX_SEPARATOR:
 | 
| +      return UTF8ToUTF16(autofill::kPhoneSuffixSeparatorRe);
 | 
| +    case REGEX_SUFFIX:
 | 
| +      return UTF8ToUTF16(autofill::kPhoneSuffixRe);
 | 
| +    case REGEX_EXTENSION:
 | 
| +      return UTF8ToUTF16(autofill::kPhoneExtensionRe);
 | 
|      default:
 | 
|        NOTREACHED();
 | 
|        break;
 | 
| @@ -248,8 +206,7 @@ string16 PhoneField::GetRegExp(RegexType regex_id) const {
 | 
|  
 | 
|  // static
 | 
|  bool PhoneField::ParseInternal(PhoneField *phone_field,
 | 
| -                               AutofillScanner* scanner,
 | 
| -                               bool regular_phone) {
 | 
| +                               AutofillScanner* scanner) {
 | 
|    DCHECK(phone_field);
 | 
|    scanner->SaveCursor();
 | 
|  
 | 
| @@ -310,27 +267,16 @@ bool PhoneField::ParseInternal(PhoneField *phone_field,
 | 
|  
 | 
|    // Look for a third text box.
 | 
|    if (!phone_field->parsed_phone_fields_[FIELD_SUFFIX]) {
 | 
| -    if (!ParseField(scanner, phone_field->GetSuffixRegex(),
 | 
| +    if (!ParseField(scanner, UTF8ToUTF16(autofill::kPhoneSuffixRe),
 | 
|                      &phone_field->parsed_phone_fields_[FIELD_SUFFIX])) {
 | 
| -      ParseField(scanner, phone_field->GetSuffixSeparatorRegex(),
 | 
| +      ParseField(scanner, UTF8ToUTF16(autofill::kPhoneSuffixSeparatorRe),
 | 
|                   &phone_field->parsed_phone_fields_[FIELD_SUFFIX]);
 | 
|      }
 | 
|    }
 | 
|  
 | 
|    // Now look for an extension.
 | 
| -  ParseField(scanner, phone_field->GetExtensionRegex(),
 | 
| +  ParseField(scanner, UTF8ToUTF16(autofill::kPhoneExtensionRe),
 | 
|               &phone_field->parsed_phone_fields_[FIELD_EXTENSION]);
 | 
|  
 | 
|    return true;
 | 
|  }
 | 
| -
 | 
| -void PhoneField::SetPhoneType(PhoneType phone_type) {
 | 
| -  // Field types are different as well, so we create a temporary phone number,
 | 
| -  // to get relevant field types.
 | 
| -  if (phone_type == HOME_PHONE)
 | 
| -    number_.reset(new PhoneNumber(AutofillType::PHONE_HOME, NULL));
 | 
| -  else
 | 
| -    number_.reset(new PhoneNumber(AutofillType::PHONE_FAX, NULL));
 | 
| -  phone_type_ = phone_type;
 | 
| -}
 | 
| -
 | 
| 
 |