address_field.h revision f2477e01787aa58f445919b809d89e252beef54f
1// Copyright 2013 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 COMPONENTS_AUTOFILL_CORE_BROWSER_ADDRESS_FIELD_H_ 6#define COMPONENTS_AUTOFILL_CORE_BROWSER_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/strings/string16.h" 14#include "components/autofill/core/browser/autofill_type.h" 15#include "components/autofill/core/browser/form_field.h" 16 17namespace autofill { 18 19class AutofillField; 20class AutofillScanner; 21 22class AddressField : public FormField { 23 public: 24 static FormField* Parse(AutofillScanner* scanner); 25 26 protected: 27 // FormField: 28 virtual bool ClassifyField(ServerFieldTypeMap* map) const OVERRIDE; 29 30 private: 31 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseOneLineAddress); 32 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseTwoLineAddress); 33 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseThreeLineAddress); 34 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseStreetAddressFromTextArea); 35 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseCity); 36 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseState); 37 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseZip); 38 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseStateAndZipOneLabel); 39 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseCountry); 40 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseTwoLineAddressMissingLabel); 41 FRIEND_TEST_ALL_PREFIXES(AddressFieldTest, ParseCompany); 42 43 AddressField(); 44 45 bool ParseCompany(AutofillScanner* scanner); 46 bool ParseAddressLines(AutofillScanner* scanner); 47 bool ParseCountry(AutofillScanner* scanner); 48 bool ParseZipCode(AutofillScanner* scanner); 49 bool ParseCity(AutofillScanner* scanner); 50 bool ParseState(AutofillScanner* scanner); 51 52 const AutofillField* company_; 53 const AutofillField* address1_; 54 const AutofillField* address2_; 55 const AutofillField* street_address_; 56 const AutofillField* city_; 57 const AutofillField* state_; 58 const AutofillField* zip_; 59 const AutofillField* zip4_; // optional ZIP+4; we don't fill this yet. 60 const AutofillField* country_; 61 62 DISALLOW_COPY_AND_ASSIGN(AddressField); 63}; 64 65} // namespace autofill 66 67#endif // COMPONENTS_AUTOFILL_CORE_BROWSER_ADDRESS_FIELD_H_ 68