| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_ADDRESS_FIELD_H_ | 5 #ifndef CHROME_BROWSER_AUTOFILL_ADDRESS_FIELD_H_ |
| 6 #define CHROME_BROWSER_AUTOFILL_ADDRESS_FIELD_H_ | 6 #define CHROME_BROWSER_AUTOFILL_ADDRESS_FIELD_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 14 #include "base/string16.h" | 14 #include "base/string16.h" |
| 15 #include "chrome/browser/autofill/autofill_type.h" | 15 #include "chrome/browser/autofill/autofill_type.h" |
| 16 #include "chrome/browser/autofill/field_types.h" | 16 #include "chrome/browser/autofill/field_types.h" |
| 17 #include "chrome/browser/autofill/form_field.h" | 17 #include "chrome/browser/autofill/form_field.h" |
| 18 | 18 |
| 19 class AutofillField; | 19 class AutofillField; |
| 20 class AutofillScanner; | 20 class AutofillScanner; |
| 21 | 21 |
| 22 class AddressField : public FormField { | 22 class AddressField : public FormField { |
| 23 public: | 23 public: |
| 24 static FormField* Parse(AutofillScanner* scanner, bool is_ecml); | 24 static FormField* Parse(AutofillScanner* scanner); |
| 25 | 25 |
| 26 // Tries to determine the billing/shipping type of this address. | 26 // Tries to determine the billing/shipping type of this address. |
| 27 AddressType FindType() const; | 27 AddressType FindType() const; |
| 28 | 28 |
| 29 protected: | 29 protected: |
| 30 // FormField: | 30 // FormField: |
| 31 virtual bool ClassifyField(FieldTypeMap* map) const OVERRIDE; | 31 virtual bool ClassifyField(FieldTypeMap* map) const OVERRIDE; |
| 32 | 32 |
| 33 private: | 33 private: |
| 34 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseOneLineAddress); | 34 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseOneLineAddress); |
| 35 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseOneLineAddressBilling); | 35 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseOneLineAddressBilling); |
| 36 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseOneLineAddressShipping); | 36 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseOneLineAddressShipping); |
| 37 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseOneLineAddressEcml); | |
| 38 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseTwoLineAddress); | 37 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseTwoLineAddress); |
| 39 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseThreeLineAddress); | 38 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseThreeLineAddress); |
| 40 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseTwoLineAddressEcml); | |
| 41 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseCity); | 39 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseCity); |
| 42 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseCityEcml); | |
| 43 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseState); | 40 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseState); |
| 44 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseStateEcml); | |
| 45 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseZip); | 41 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseZip); |
| 46 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseZipEcml); | |
| 47 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseStateAndZipOneLabel); | 42 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseStateAndZipOneLabel); |
| 48 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseCountry); | 43 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseCountry); |
| 49 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseCountryEcml); | |
| 50 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseTwoLineAddressMissingLabel); | 44 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseTwoLineAddressMissingLabel); |
| 51 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseCompany); | 45 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseCompany); |
| 52 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseCompanyEcml); | |
| 53 | 46 |
| 54 AddressField(); | 47 AddressField(); |
| 55 | 48 |
| 56 static bool ParseCompany(AutofillScanner* scanner, | 49 static bool ParseCompany(AutofillScanner* scanner, |
| 57 bool is_ecml, | |
| 58 AddressField* address_field); | 50 AddressField* address_field); |
| 59 static bool ParseAddressLines(AutofillScanner* scanner, | 51 static bool ParseAddressLines(AutofillScanner* scanner, |
| 60 bool is_ecml, | |
| 61 AddressField* address_field); | 52 AddressField* address_field); |
| 62 static bool ParseCountry(AutofillScanner* scanner, | 53 static bool ParseCountry(AutofillScanner* scanner, |
| 63 bool is_ecml, | |
| 64 AddressField* address_field); | 54 AddressField* address_field); |
| 65 static bool ParseZipCode(AutofillScanner* scanner, | 55 static bool ParseZipCode(AutofillScanner* scanner, |
| 66 bool is_ecml, | |
| 67 AddressField* address_field); | 56 AddressField* address_field); |
| 68 static bool ParseCity(AutofillScanner* scanner, | 57 static bool ParseCity(AutofillScanner* scanner, |
| 69 bool is_ecml, | |
| 70 AddressField* address_field); | 58 AddressField* address_field); |
| 71 static bool ParseState(AutofillScanner* scanner, | 59 static bool ParseState(AutofillScanner* scanner, |
| 72 bool is_ecml, | |
| 73 AddressField* address_field); | 60 AddressField* address_field); |
| 74 | 61 |
| 75 // Looks for an address type in the given text, which the caller must | 62 // Looks for an address type in the given text, which the caller must |
| 76 // convert to lowercase. | 63 // convert to lowercase. |
| 77 static AddressType AddressTypeFromText(const string16& text); | 64 static AddressType AddressTypeFromText(const string16& text); |
| 78 | 65 |
| 79 const AutofillField* company_; // optional | 66 const AutofillField* company_; // optional |
| 80 const AutofillField* address1_; | 67 const AutofillField* address1_; |
| 81 const AutofillField* address2_; // optional | 68 const AutofillField* address2_; // optional |
| 82 const AutofillField* city_; | 69 const AutofillField* city_; |
| 83 const AutofillField* state_; // optional | 70 const AutofillField* state_; // optional |
| 84 const AutofillField* zip_; | 71 const AutofillField* zip_; |
| 85 const AutofillField* zip4_; // optional ZIP+4; we don't fill this yet | 72 const AutofillField* zip4_; // optional ZIP+4; we don't fill this yet |
| 86 const AutofillField* country_; // optional | 73 const AutofillField* country_; // optional |
| 87 | 74 |
| 88 AddressType type_; | 75 AddressType type_; |
| 89 | 76 |
| 90 DISALLOW_COPY_AND_ASSIGN(AddressField); | 77 DISALLOW_COPY_AND_ASSIGN(AddressField); |
| 91 }; | 78 }; |
| 92 | 79 |
| 93 #endif // CHROME_BROWSER_AUTOFILL_ADDRESS_FIELD_H_ | 80 #endif // CHROME_BROWSER_AUTOFILL_ADDRESS_FIELD_H_ |
| OLD | NEW |