| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> |
| 10 #include <string> | 11 #include <string> |
| 11 | 12 |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 15 #include "components/autofill/core/browser/phone_number_i18n.h" | 15 #include "components/autofill/core/browser/phone_number_i18n.h" |
| 16 | 16 |
| 17 namespace base { | 17 namespace base { |
| 18 class DictionaryValue; | 18 class DictionaryValue; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace autofill { | 21 namespace autofill { |
| 22 | 22 |
| 23 class AutofillProfile; | 23 class AutofillProfile; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 const base::string16& sorting_code, | 55 const base::string16& sorting_code, |
| 56 const base::string16& phone_number, | 56 const base::string16& phone_number, |
| 57 const std::string& object_id, | 57 const std::string& object_id, |
| 58 const std::string& language_code); | 58 const std::string& language_code); |
| 59 | 59 |
| 60 ~Address(); | 60 ~Address(); |
| 61 | 61 |
| 62 // Returns an empty scoped_ptr if input is invalid or a valid address that is | 62 // Returns an empty scoped_ptr if input is invalid or a valid address that is |
| 63 // selectable for Google Wallet use. Does not require "id" in |dictionary|. | 63 // selectable for Google Wallet use. Does not require "id" in |dictionary|. |
| 64 // IDs are not required for billing addresses. | 64 // IDs are not required for billing addresses. |
| 65 static scoped_ptr<Address> CreateAddress( | 65 static std::unique_ptr<Address> CreateAddress( |
| 66 const base::DictionaryValue& dictionary); | 66 const base::DictionaryValue& dictionary); |
| 67 | 67 |
| 68 // TODO(ahutter): Make obvious in the function name that this public method | 68 // TODO(ahutter): Make obvious in the function name that this public method |
| 69 // only works for shipping address and assumes existance of "postal_address". | 69 // only works for shipping address and assumes existance of "postal_address". |
| 70 // Builds an Address from |dictionary|, which must have an "id" field. This | 70 // Builds an Address from |dictionary|, which must have an "id" field. This |
| 71 // function is designed for use with shipping addresses. The function may fail | 71 // function is designed for use with shipping addresses. The function may fail |
| 72 // and return an empty pointer if its input is invalid. | 72 // and return an empty pointer if its input is invalid. |
| 73 static scoped_ptr<Address> CreateAddressWithID( | 73 static std::unique_ptr<Address> CreateAddressWithID( |
| 74 const base::DictionaryValue& dictionary); | 74 const base::DictionaryValue& dictionary); |
| 75 | 75 |
| 76 // Returns an empty scoped_ptr if input in invalid or a valid address that | 76 // Returns an empty scoped_ptr if input in invalid or a valid address that |
| 77 // can only be used for displaying to the user. | 77 // can only be used for displaying to the user. |
| 78 static scoped_ptr<Address> CreateDisplayAddress( | 78 static std::unique_ptr<Address> CreateDisplayAddress( |
| 79 const base::DictionaryValue& dictionary); | 79 const base::DictionaryValue& dictionary); |
| 80 | 80 |
| 81 // If an address is being upgraded, it will be sent to the server in a | 81 // If an address is being upgraded, it will be sent to the server in a |
| 82 // different format and with a few additional fields set, most importantly | 82 // different format and with a few additional fields set, most importantly |
| 83 // |object_id_|. | 83 // |object_id_|. |
| 84 scoped_ptr<base::DictionaryValue> ToDictionaryWithID() const; | 84 std::unique_ptr<base::DictionaryValue> ToDictionaryWithID() const; |
| 85 | 85 |
| 86 // Newly created addresses will not have an associated |object_id_| and are | 86 // Newly created addresses will not have an associated |object_id_| and are |
| 87 // sent to the server in a slightly different format. | 87 // sent to the server in a slightly different format. |
| 88 scoped_ptr<base::DictionaryValue> ToDictionaryWithoutID() const; | 88 std::unique_ptr<base::DictionaryValue> ToDictionaryWithoutID() const; |
| 89 | 89 |
| 90 // Returns a string that summarizes this address, suitable for display to | 90 // Returns a string that summarizes this address, suitable for display to |
| 91 // the user. | 91 // the user. |
| 92 base::string16 DisplayName() const; | 92 base::string16 DisplayName() const; |
| 93 | 93 |
| 94 // Returns a string that could be used as a sub-label, suitable for display | 94 // Returns a string that could be used as a sub-label, suitable for display |
| 95 // to the user together with DisplayName(). | 95 // to the user together with DisplayName(). |
| 96 base::string16 DisplayNameDetail() const; | 96 base::string16 DisplayNameDetail() const; |
| 97 | 97 |
| 98 // Returns the phone number as a string that is suitable for display to the | 98 // Returns the phone number as a string that is suitable for display to the |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 std::string language_code_; | 224 std::string language_code_; |
| 225 | 225 |
| 226 // This class is intentionally copyable. | 226 // This class is intentionally copyable. |
| 227 DISALLOW_ASSIGN(Address); | 227 DISALLOW_ASSIGN(Address); |
| 228 }; | 228 }; |
| 229 | 229 |
| 230 } // namespace wallet | 230 } // namespace wallet |
| 231 } // namespace autofill | 231 } // namespace autofill |
| 232 | 232 |
| 233 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_WALLET_ADDRESS_H_ | 233 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_WALLET_ADDRESS_H_ |
| OLD | NEW |