| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BROWSER_WALLET_WALLET_ADDRESS_H_ | 5 #ifndef COMPONENTS_AUTOFILL_BROWSER_WALLET_WALLET_ADDRESS_H_ |
| 6 #define COMPONENTS_AUTOFILL_BROWSER_WALLET_WALLET_ADDRESS_H_ | 6 #define COMPONENTS_AUTOFILL_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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 const std::string& object_id); | 53 const std::string& object_id); |
| 54 | 54 |
| 55 ~Address(); | 55 ~Address(); |
| 56 | 56 |
| 57 // Returns an empty scoped_ptr if input is invalid or a valid address that is | 57 // Returns an empty scoped_ptr if input is invalid or a valid address that is |
| 58 // selectable for Google Wallet use. Does not require "id" in |dictionary|. | 58 // selectable for Google Wallet use. Does not require "id" in |dictionary|. |
| 59 // IDs are not required for billing addresses. | 59 // IDs are not required for billing addresses. |
| 60 static scoped_ptr<Address> CreateAddress( | 60 static scoped_ptr<Address> CreateAddress( |
| 61 const base::DictionaryValue& dictionary); | 61 const base::DictionaryValue& dictionary); |
| 62 | 62 |
| 63 // TODO(ahutter): Make obvious in the function name that this public method |
| 64 // only works for shipping address and assumes existance of "postal_address". |
| 63 // Builds an Address from |dictionary|, which must have an "id" field. This | 65 // Builds an Address from |dictionary|, which must have an "id" field. This |
| 64 // function is designed for use with shipping addresses. The function may fail | 66 // function is designed for use with shipping addresses. The function may fail |
| 65 // and return an empty pointer if its input is invalid. | 67 // and return an empty pointer if its input is invalid. |
| 66 static scoped_ptr<Address> CreateAddressWithID( | 68 static scoped_ptr<Address> CreateAddressWithID( |
| 67 const base::DictionaryValue& dictionary); | 69 const base::DictionaryValue& dictionary); |
| 68 | 70 |
| 69 // Returns an empty scoped_ptr if input in invalid or a valid address that | 71 // Returns an empty scoped_ptr if input in invalid or a valid address that |
| 70 // can only be used for displaying to the user. | 72 // can only be used for displaying to the user. |
| 71 static scoped_ptr<Address> CreateDisplayAddress( | 73 static scoped_ptr<Address> CreateDisplayAddress( |
| 72 const base::DictionaryValue& dictionary); | 74 const base::DictionaryValue& dictionary); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 98 const base::string16& address_line_2() const { return address_line_2_; } | 100 const base::string16& address_line_2() const { return address_line_2_; } |
| 99 const base::string16& locality_name() const { return locality_name_; } | 101 const base::string16& locality_name() const { return locality_name_; } |
| 100 const base::string16& administrative_area_name() const { | 102 const base::string16& administrative_area_name() const { |
| 101 return administrative_area_name_; | 103 return administrative_area_name_; |
| 102 } | 104 } |
| 103 const base::string16& postal_code_number() const { | 105 const base::string16& postal_code_number() const { |
| 104 return postal_code_number_; | 106 return postal_code_number_; |
| 105 } | 107 } |
| 106 const base::string16& phone_number() const { return phone_number_; } | 108 const base::string16& phone_number() const { return phone_number_; } |
| 107 const std::string& object_id() const { return object_id_; } | 109 const std::string& object_id() const { return object_id_; } |
| 110 bool is_complete_address() const { |
| 111 return is_complete_address_; |
| 112 } |
| 108 | 113 |
| 109 void set_country_name_code(const std::string& country_name_code) { | 114 void set_country_name_code(const std::string& country_name_code) { |
| 110 country_name_code_ = country_name_code; | 115 country_name_code_ = country_name_code; |
| 111 } | 116 } |
| 112 void set_recipient_name(const base::string16& recipient_name) { | 117 void set_recipient_name(const base::string16& recipient_name) { |
| 113 recipient_name_ = recipient_name; | 118 recipient_name_ = recipient_name; |
| 114 } | 119 } |
| 115 void set_address_line_1(const base::string16& address_line_1) { | 120 void set_address_line_1(const base::string16& address_line_1) { |
| 116 address_line_1_ = address_line_1; | 121 address_line_1_ = address_line_1; |
| 117 } | 122 } |
| 118 void set_address_line_2(const base::string16& address_line_2) { | 123 void set_address_line_2(const base::string16& address_line_2) { |
| 119 address_line_2_ = address_line_2; | 124 address_line_2_ = address_line_2; |
| 120 } | 125 } |
| 121 void set_locality_name(const base::string16& locality_name) { | 126 void set_locality_name(const base::string16& locality_name) { |
| 122 locality_name_ = locality_name; | 127 locality_name_ = locality_name; |
| 123 } | 128 } |
| 124 void set_administrative_area_name( | 129 void set_administrative_area_name( |
| 125 const base::string16& administrative_area_name) { | 130 const base::string16& administrative_area_name) { |
| 126 administrative_area_name_ = administrative_area_name; | 131 administrative_area_name_ = administrative_area_name; |
| 127 } | 132 } |
| 128 void set_postal_code_number(const base::string16& postal_code_number) { | 133 void set_postal_code_number(const base::string16& postal_code_number) { |
| 129 postal_code_number_ = postal_code_number; | 134 postal_code_number_ = postal_code_number; |
| 130 } | 135 } |
| 131 void set_phone_number(const base::string16& phone_number) { | 136 void set_phone_number(const base::string16& phone_number) { |
| 132 phone_number_ = phone_number; | 137 phone_number_ = phone_number; |
| 133 } | 138 } |
| 134 void set_object_id(const std::string& object_id) { | 139 void set_object_id(const std::string& object_id) { |
| 135 object_id_ = object_id; | 140 object_id_ = object_id; |
| 136 } | 141 } |
| 142 void set_is_complete_address(bool is_complete_address) { |
| 143 is_complete_address_ = is_complete_address; |
| 144 } |
| 137 | 145 |
| 138 bool operator==(const Address& other) const; | 146 bool operator==(const Address& other) const; |
| 139 bool operator!=(const Address& other) const; | 147 bool operator!=(const Address& other) const; |
| 140 | 148 |
| 141 private: | 149 private: |
| 142 // |country_name_code_| should be an ISO 3166-1-alpha-2 (two letter codes, as | 150 // |country_name_code_| should be an ISO 3166-1-alpha-2 (two letter codes, as |
| 143 // used in DNS). For example, "GB". | 151 // used in DNS). For example, "GB". |
| 144 std::string country_name_code_; | 152 std::string country_name_code_; |
| 145 | 153 |
| 146 // The recipient's name. For example "John Doe". | 154 // The recipient's name. For example "John Doe". |
| (...skipping 21 matching lines...) Expand all Loading... |
| 168 base::string16 postal_code_number_; | 176 base::string16 postal_code_number_; |
| 169 | 177 |
| 170 // A valid international phone number. If |phone_number_| is a user provided | 178 // A valid international phone number. If |phone_number_| is a user provided |
| 171 // value, it should have been validated using libphonenumber by clients of | 179 // value, it should have been validated using libphonenumber by clients of |
| 172 // this class before being set; see http://code.google.com/p/libphonenumber/. | 180 // this class before being set; see http://code.google.com/p/libphonenumber/. |
| 173 base::string16 phone_number_; | 181 base::string16 phone_number_; |
| 174 | 182 |
| 175 // Externalized Online Wallet id for this address. | 183 // Externalized Online Wallet id for this address. |
| 176 std::string object_id_; | 184 std::string object_id_; |
| 177 | 185 |
| 186 // Server's understanding of this address as complete address or not. |
| 187 bool is_complete_address_; |
| 188 |
| 178 // This class is intentionally copyable. | 189 // This class is intentionally copyable. |
| 179 DISALLOW_ASSIGN(Address); | 190 DISALLOW_ASSIGN(Address); |
| 180 }; | 191 }; |
| 181 | 192 |
| 182 } // namespace wallet | 193 } // namespace wallet |
| 183 } // namespace autofill | 194 } // namespace autofill |
| 184 | 195 |
| 185 #endif // COMPONENTS_AUTOFILL_BROWSER_WALLET_WALLET_ADDRESS_H_ | 196 #endif // COMPONENTS_AUTOFILL_BROWSER_WALLET_WALLET_ADDRESS_H_ |
| OLD | NEW |