OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_WALLET_ADDRESS_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_WALLET_ADDRESS_H_ |
6 #define COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_WALLET_ADDRESS_H_ | 6 #define COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_WALLET_ADDRESS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 // is_valid, is_default) when SaveToWallet is implemented. | 38 // is_valid, is_default) when SaveToWallet is implemented. |
39 // See http://crbug.com/164284. | 39 // See http://crbug.com/164284. |
40 | 40 |
41 Address(); | 41 Address(); |
42 | 42 |
43 // Using the raw info in |profile|, create a wallet::Address. | 43 // Using the raw info in |profile|, create a wallet::Address. |
44 explicit Address(const AutofillProfile& profile); | 44 explicit Address(const AutofillProfile& profile); |
45 | 45 |
46 Address(const std::string& country_name_code, | 46 Address(const std::string& country_name_code, |
47 const base::string16& recipient_name, | 47 const base::string16& recipient_name, |
48 const base::string16& address_line_1, | 48 const std::vector<base::string16>& street_address, |
49 const base::string16& address_line_2, | |
50 const base::string16& locality_name, | 49 const base::string16& locality_name, |
| 50 const base::string16& dependent_locality_name, |
51 const base::string16& administrative_area_name, | 51 const base::string16& administrative_area_name, |
52 const base::string16& postal_code_number, | 52 const base::string16& postal_code_number, |
| 53 const base::string16& sorting_code, |
53 const base::string16& phone_number, | 54 const base::string16& phone_number, |
54 const std::string& object_id); | 55 const std::string& object_id); |
55 | 56 |
56 ~Address(); | 57 ~Address(); |
57 | 58 |
58 // Returns an empty scoped_ptr if input is invalid or a valid address that is | 59 // Returns an empty scoped_ptr if input is invalid or a valid address that is |
59 // selectable for Google Wallet use. Does not require "id" in |dictionary|. | 60 // selectable for Google Wallet use. Does not require "id" in |dictionary|. |
60 // IDs are not required for billing addresses. | 61 // IDs are not required for billing addresses. |
61 static scoped_ptr<Address> CreateAddress( | 62 static scoped_ptr<Address> CreateAddress( |
62 const base::DictionaryValue& dictionary); | 63 const base::DictionaryValue& dictionary); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 // Returns the phone number as a string that is suitable for display to the | 95 // Returns the phone number as a string that is suitable for display to the |
95 // user. | 96 // user. |
96 base::string16 DisplayPhoneNumber() const; | 97 base::string16 DisplayPhoneNumber() const; |
97 | 98 |
98 // Returns data appropriate for |type|. | 99 // Returns data appropriate for |type|. |
99 base::string16 GetInfo(const AutofillType& type, | 100 base::string16 GetInfo(const AutofillType& type, |
100 const std::string& app_locale) const; | 101 const std::string& app_locale) const; |
101 | 102 |
102 const std::string& country_name_code() const { return country_name_code_; } | 103 const std::string& country_name_code() const { return country_name_code_; } |
103 const base::string16& recipient_name() const { return recipient_name_; } | 104 const base::string16& recipient_name() const { return recipient_name_; } |
104 const base::string16& address_line_1() const { return address_line_1_; } | 105 const std::vector<base::string16>& street_address() const { |
105 const base::string16& address_line_2() const { return address_line_2_; } | 106 return street_address_; |
| 107 } |
106 const base::string16& locality_name() const { return locality_name_; } | 108 const base::string16& locality_name() const { return locality_name_; } |
107 const base::string16& administrative_area_name() const { | 109 const base::string16& administrative_area_name() const { |
108 return administrative_area_name_; | 110 return administrative_area_name_; |
109 } | 111 } |
110 const base::string16& postal_code_number() const { | 112 const base::string16& postal_code_number() const { |
111 return postal_code_number_; | 113 return postal_code_number_; |
112 } | 114 } |
113 const base::string16& phone_number() const { return phone_number_; } | 115 const base::string16& phone_number() const { return phone_number_; } |
114 const std::string& object_id() const { return object_id_; } | 116 const std::string& object_id() const { return object_id_; } |
115 bool is_complete_address() const { | 117 bool is_complete_address() const { |
116 return is_complete_address_; | 118 return is_complete_address_; |
117 } | 119 } |
118 | 120 |
119 void set_country_name_code(const std::string& country_name_code) { | 121 void set_country_name_code(const std::string& country_name_code) { |
120 country_name_code_ = country_name_code; | 122 country_name_code_ = country_name_code; |
121 } | 123 } |
122 void set_recipient_name(const base::string16& recipient_name) { | 124 void set_recipient_name(const base::string16& recipient_name) { |
123 recipient_name_ = recipient_name; | 125 recipient_name_ = recipient_name; |
124 } | 126 } |
125 void set_address_line_1(const base::string16& address_line_1) { | 127 void set_street_address(const std::vector<base::string16>& street_address) { |
126 address_line_1_ = address_line_1; | 128 street_address_ = street_address; |
127 } | |
128 void set_address_line_2(const base::string16& address_line_2) { | |
129 address_line_2_ = address_line_2; | |
130 } | 129 } |
131 void set_locality_name(const base::string16& locality_name) { | 130 void set_locality_name(const base::string16& locality_name) { |
132 locality_name_ = locality_name; | 131 locality_name_ = locality_name; |
133 } | 132 } |
| 133 void set_dependent_locality_name( |
| 134 const base::string16& dependent_locality_name) { |
| 135 dependent_locality_name_ = dependent_locality_name; |
| 136 } |
134 void set_administrative_area_name( | 137 void set_administrative_area_name( |
135 const base::string16& administrative_area_name) { | 138 const base::string16& administrative_area_name) { |
136 administrative_area_name_ = administrative_area_name; | 139 administrative_area_name_ = administrative_area_name; |
137 } | 140 } |
138 void set_postal_code_number(const base::string16& postal_code_number) { | 141 void set_postal_code_number(const base::string16& postal_code_number) { |
139 postal_code_number_ = postal_code_number; | 142 postal_code_number_ = postal_code_number; |
140 } | 143 } |
| 144 void set_sorting_code(const base::string16& sorting_code) { |
| 145 sorting_code_ = sorting_code; |
| 146 } |
141 void SetPhoneNumber(const base::string16& phone_number); | 147 void SetPhoneNumber(const base::string16& phone_number); |
142 void set_object_id(const std::string& object_id) { | 148 void set_object_id(const std::string& object_id) { |
143 object_id_ = object_id; | 149 object_id_ = object_id; |
144 } | 150 } |
145 void set_is_complete_address(bool is_complete_address) { | 151 void set_is_complete_address(bool is_complete_address) { |
146 is_complete_address_ = is_complete_address; | 152 is_complete_address_ = is_complete_address; |
147 } | 153 } |
148 | 154 |
149 // Tests if this address exact matches |other|. |object_id| is ignored. | 155 // Tests if this address exact matches |other|. |object_id| is ignored. |
150 bool EqualsIgnoreID(const Address& other) const; | 156 bool EqualsIgnoreID(const Address& other) const; |
151 | 157 |
152 // Tests if this address exact matches |other| including |object_id|. | 158 // Tests if this address exact matches |other| including |object_id|. |
153 bool operator==(const Address& other) const; | 159 bool operator==(const Address& other) const; |
154 bool operator!=(const Address& other) const; | 160 bool operator!=(const Address& other) const; |
155 | 161 |
156 private: | 162 private: |
| 163 // Gets the street address on the given line (0-indexed). |
| 164 base::string16 GetStreetAddressLine(size_t line) const; |
| 165 |
157 // |country_name_code_| should be an ISO 3166-1-alpha-2 (two letter codes, as | 166 // |country_name_code_| should be an ISO 3166-1-alpha-2 (two letter codes, as |
158 // used in DNS). For example, "GB". | 167 // used in DNS). For example, "GB". |
159 std::string country_name_code_; | 168 std::string country_name_code_; |
160 | 169 |
161 // The recipient's name. For example "John Doe". | 170 // The recipient's name. For example "John Doe". |
162 base::string16 recipient_name_; | 171 base::string16 recipient_name_; |
163 | 172 |
164 // |address_line_1| and |address_line_2| correspond to the "AddressLine" | 173 // Address lines (arbitrarily many). |
165 // elements in xAL, which are used to hold unstructured text. | 174 std::vector<base::string16> street_address_; |
166 base::string16 address_line_1_; | |
167 base::string16 address_line_2_; | |
168 | 175 |
169 // Locality. This is something of a fuzzy term, but it generally refers to | 176 // Locality. This is something of a fuzzy term, but it generally refers to |
170 // the city/town portion of an address. In regions of the world where | 177 // the city/town portion of an address. |
171 // localities are not well defined or do not fit into this structure well | |
172 // (for example, Japan and China), leave locality_name empty and use | |
173 // |address_line_2|. | |
174 // Examples: US city, IT comune, UK post town. | 178 // Examples: US city, IT comune, UK post town. |
175 base::string16 locality_name_; | 179 base::string16 locality_name_; |
176 | 180 |
| 181 // Dependent locality is used in Korea and China. |
| 182 // Example: a Chinese county under the authority of a prefecture-level city. |
| 183 base::string16 dependent_locality_name_; |
| 184 |
177 // Top-level administrative subdivision of this country. | 185 // Top-level administrative subdivision of this country. |
178 // Examples: US state, IT region, UK constituent nation, JP prefecture. | 186 // Examples: US state, IT region, UK constituent nation, JP prefecture. |
179 // Note: this must be in short form, e.g. TX rather than Texas. | 187 // Note: this must be in short form, e.g. TX rather than Texas. |
180 base::string16 administrative_area_name_; | 188 base::string16 administrative_area_name_; |
181 | 189 |
182 // Despite the name, |postal_code_number_| values are frequently alphanumeric. | 190 // Despite the name, |postal_code_number_| values are frequently alphanumeric. |
183 // Examples: "94043", "SW1W", "SW1W 9TQ". | 191 // Examples: "94043", "SW1W", "SW1W 9TQ". |
184 base::string16 postal_code_number_; | 192 base::string16 postal_code_number_; |
185 | 193 |
| 194 // Sorting code, e.g. CEDEX in France. |
| 195 base::string16 sorting_code_; |
| 196 |
186 // A valid international phone number. If |phone_number_| is a user provided | 197 // A valid international phone number. If |phone_number_| is a user provided |
187 // value, it should have been validated using libphonenumber by clients of | 198 // value, it should have been validated using libphonenumber by clients of |
188 // this class before being set; see http://code.google.com/p/libphonenumber/. | 199 // this class before being set; see http://code.google.com/p/libphonenumber/. |
189 base::string16 phone_number_; | 200 base::string16 phone_number_; |
190 | 201 |
191 // The parsed phone number. | 202 // The parsed phone number. |
192 i18n::PhoneObject phone_object_; | 203 i18n::PhoneObject phone_object_; |
193 | 204 |
194 // Externalized Online Wallet id for this address. | 205 // Externalized Online Wallet id for this address. |
195 std::string object_id_; | 206 std::string object_id_; |
196 | 207 |
197 // Server's understanding of this address as complete address or not. | 208 // Server's understanding of this address as complete address or not. |
198 bool is_complete_address_; | 209 bool is_complete_address_; |
199 | 210 |
200 // This class is intentionally copyable. | 211 // This class is intentionally copyable. |
201 DISALLOW_ASSIGN(Address); | 212 DISALLOW_ASSIGN(Address); |
202 }; | 213 }; |
203 | 214 |
204 } // namespace wallet | 215 } // namespace wallet |
205 } // namespace autofill | 216 } // namespace autofill |
206 | 217 |
207 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_WALLET_ADDRESS_H_ | 218 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_WALLET_ADDRESS_H_ |
OLD | NEW |