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