| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_H_ | 5 #ifndef CHROME_BROWSER_AUTOFILL_ADDRESS_H_ |
| 6 #define CHROME_BROWSER_AUTOFILL_ADDRESS_H_ | 6 #define CHROME_BROWSER_AUTOFILL_ADDRESS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> |
| 9 #include <vector> | 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/string16.h" | 12 #include "base/string16.h" |
| 12 #include "chrome/browser/autofill/form_group.h" | 13 #include "chrome/browser/autofill/form_group.h" |
| 13 | 14 |
| 14 // A form group that stores address information. | 15 // A form group that stores address information. |
| 15 class Address : public FormGroup { | 16 class Address : public FormGroup { |
| 16 public: | 17 public: |
| 17 Address(); | 18 Address(); |
| 18 virtual ~Address(); | 19 virtual ~Address(); |
| 19 | 20 |
| 20 // FormGroup implementation: | 21 // FormGroup implementation: |
| 21 virtual FormGroup* Clone() const = 0; | 22 virtual FormGroup* Clone() const = 0; |
| 22 virtual void GetPossibleFieldTypes(const string16& text, | 23 virtual void GetPossibleFieldTypes(const string16& text, |
| 23 FieldTypeSet* possible_types) const; | 24 FieldTypeSet* possible_types) const; |
| 24 virtual void GetAvailableFieldTypes(FieldTypeSet* available_types) const; | 25 virtual void GetAvailableFieldTypes(FieldTypeSet* available_types) const; |
| 25 virtual void FindInfoMatches(const AutoFillType& type, | 26 virtual void FindInfoMatches(const AutoFillType& type, |
| 26 const string16& info, | 27 const string16& info, |
| 27 std::vector<string16>* matched_text) const; | 28 std::vector<string16>* matched_text) const; |
| 28 virtual string16 GetFieldText(const AutoFillType& type) const; | 29 virtual string16 GetFieldText(const AutoFillType& type) const; |
| 29 virtual void SetInfo(const AutoFillType& type, const string16& value); | 30 virtual void SetInfo(const AutoFillType& type, const string16& value); |
| 30 | 31 |
| 32 const std::string& country_code() const { return country_code_; } |
| 33 void set_country_code(const std::string& country_code) { |
| 34 country_code_ = country_code; |
| 35 } |
| 36 |
| 31 // Sets all of the fields to the empty string. | 37 // Sets all of the fields to the empty string. |
| 32 void Clear(); | 38 void Clear(); |
| 33 | 39 |
| 34 // Sets the values of this object to the values in |address|. | 40 // Sets the values of this object to the values in |address|. |
| 35 void Clone(const Address& address); | 41 void Clone(const Address& address); |
| 36 | 42 |
| 37 protected: | 43 protected: |
| 38 explicit Address(const Address& address); | 44 explicit Address(const Address& address); |
| 39 | 45 |
| 40 private: | 46 private: |
| 41 // Vector of tokens in an address line. | 47 // Vector of tokens in an address line. |
| 42 typedef std::vector<string16> LineTokens; | 48 typedef std::vector<string16> LineTokens; |
| 43 | 49 |
| 44 const string16& line1() const { return line1_; } | 50 const string16& line1() const { return line1_; } |
| 45 const string16& line2() const { return line2_; } | 51 const string16& line2() const { return line2_; } |
| 46 const string16& apt_num() const { return apt_num_; } | 52 const string16& apt_num() const { return apt_num_; } |
| 47 const string16& city() const { return city_; } | 53 const string16& city() const { return city_; } |
| 48 const string16& state() const { return state_; } | 54 const string16& state() const { return state_; } |
| 49 const string16& country() const { return country_; } | |
| 50 const string16& zip_code() const { return zip_code_; } | 55 const string16& zip_code() const { return zip_code_; } |
| 51 | 56 |
| 57 // Returns the localized country name corresponding to |country_code_|. |
| 58 string16 Country() const; |
| 59 |
| 52 void set_line1(const string16& line1); | 60 void set_line1(const string16& line1); |
| 53 void set_line2(const string16& line2); | 61 void set_line2(const string16& line2); |
| 54 void set_apt_num(const string16& apt_num) { apt_num_ = apt_num; } | 62 void set_apt_num(const string16& apt_num) { apt_num_ = apt_num; } |
| 55 void set_city(const string16& city) { city_ = city; } | 63 void set_city(const string16& city) { city_ = city; } |
| 56 void set_state(const string16& state) { state_ = state; } | 64 void set_state(const string16& state) { state_ = state; } |
| 57 void set_country(const string16& country) { country_ = country; } | |
| 58 void set_zip_code(const string16& zip_code) { zip_code_ = zip_code; } | 65 void set_zip_code(const string16& zip_code) { zip_code_ = zip_code; } |
| 59 | 66 |
| 67 // Sets the |country_code_| based on |country|, which should be a localized |
| 68 // country name. |
| 69 void SetCountry(const string16& country); |
| 70 |
| 60 void operator=(const Address& address); | 71 void operator=(const Address& address); |
| 61 | 72 |
| 62 // The following functions match |text| against the various values of the | 73 // The following functions match |text| against the various values of the |
| 63 // address, returning true on match. | 74 // address, returning true on match. |
| 64 virtual bool IsLine1(const string16& text) const; | 75 virtual bool IsLine1(const string16& text) const; |
| 65 virtual bool IsLine2(const string16& text) const; | 76 virtual bool IsLine2(const string16& text) const; |
| 66 virtual bool IsAptNum(const string16& text) const; | 77 virtual bool IsAptNum(const string16& text) const; |
| 67 virtual bool IsCity(const string16& text) const; | 78 virtual bool IsCity(const string16& text) const; |
| 68 virtual bool IsState(const string16& text) const; | 79 virtual bool IsState(const string16& text) const; |
| 69 virtual bool IsCountry(const string16& text) const; | 80 virtual bool IsCountry(const string16& text) const; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 95 // List of tokens in each part of |line1_| and |line2_|. | 106 // List of tokens in each part of |line1_| and |line2_|. |
| 96 LineTokens line1_tokens_; | 107 LineTokens line1_tokens_; |
| 97 LineTokens line2_tokens_; | 108 LineTokens line2_tokens_; |
| 98 | 109 |
| 99 // The address. | 110 // The address. |
| 100 string16 line1_; | 111 string16 line1_; |
| 101 string16 line2_; | 112 string16 line2_; |
| 102 string16 apt_num_; | 113 string16 apt_num_; |
| 103 string16 city_; | 114 string16 city_; |
| 104 string16 state_; | 115 string16 state_; |
| 105 string16 country_; | 116 std::string country_code_; |
| 106 string16 zip_code_; | 117 string16 zip_code_; |
| 107 }; | 118 }; |
| 108 | 119 |
| 109 #endif // CHROME_BROWSER_AUTOFILL_ADDRESS_H_ | 120 #endif // CHROME_BROWSER_AUTOFILL_ADDRESS_H_ |
| OLD | NEW |