Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(397)

Side by Side Diff: chrome/browser/autofill/wallet/wallet_address.cc

Issue 12208070: allow wallet items to appear in requestAutocomplete UI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clang fix Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "chrome/browser/autofill/wallet/wallet_address.h" 5 #include "chrome/browser/autofill/wallet/wallet_address.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/utf_string_conversions.h"
8 #include "base/values.h" 9 #include "base/values.h"
9 10
10 namespace wallet { 11 namespace wallet {
11 12
12 Address::Address() {} 13 Address::Address() {}
13 14
14 Address::Address(const std::string& country_name_code, 15 Address::Address(const std::string& country_name_code,
15 const std::string& recipient_name, 16 const std::string& recipient_name,
16 const std::string& address_line_1, 17 const std::string& address_line_1,
17 const std::string& address_line_2, 18 const std::string& address_line_2,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 dict->SetString("country_name_code", country_name_code_); 56 dict->SetString("country_name_code", country_name_code_);
56 dict->SetString("recipient_name", recipient_name_); 57 dict->SetString("recipient_name", recipient_name_);
57 dict->SetString("locality_name", locality_name_); 58 dict->SetString("locality_name", locality_name_);
58 dict->SetString("administrative_area_name", 59 dict->SetString("administrative_area_name",
59 administrative_area_name_); 60 administrative_area_name_);
60 dict->SetString("postal_code_number", postal_code_number_); 61 dict->SetString("postal_code_number", postal_code_number_);
61 62
62 return dict.Pass(); 63 return dict.Pass();
63 } 64 }
64 65
66 string16 Address::DisplayName() const {
67 // TODO(estade): improve this stub implementation.
68 return UTF8ToUTF16(recipient_name() + ", " + address_line_1());
69 }
70
71 string16 Address::GetInfo(AutofillFieldType type) const {
72 switch (type) {
73 case NAME_FULL:
74 return UTF8ToUTF16(recipient_name());
75
76 case ADDRESS_HOME_LINE1:
77 return UTF8ToUTF16(address_line_1());
78
79 case ADDRESS_HOME_LINE2:
80 return UTF8ToUTF16(address_line_2());
81
82 case ADDRESS_HOME_CITY:
83 return UTF8ToUTF16(locality_name());
84
85 case ADDRESS_HOME_STATE:
86 return UTF8ToUTF16(admin_area_name());
87
88 case ADDRESS_HOME_ZIP:
89 return UTF8ToUTF16(postal_code_number());
90
91 // TODO(estade): implement more.
92 default:
93 NOTREACHED();
94 return string16();
95 }
96 }
65 97
66 scoped_ptr<Address> 98 scoped_ptr<Address>
67 Address::CreateAddressWithID(const base::DictionaryValue& dictionary) { 99 Address::CreateAddressWithID(const base::DictionaryValue& dictionary) {
68 std::string object_id; 100 std::string object_id;
69 if (!dictionary.GetString("id", &object_id)) { 101 if (!dictionary.GetString("id", &object_id)) {
70 DLOG(ERROR) << "Response from Google Wallet missing object id"; 102 DLOG(ERROR) << "Response from Google Wallet missing object id";
71 return scoped_ptr<Address>(); 103 return scoped_ptr<Address>();
72 } 104 }
73 105
74 std::string country_name_code; 106 std::string country_name_code;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 phone_number_ == other.phone_number_ && 226 phone_number_ == other.phone_number_ &&
195 object_id_ == other.object_id_; 227 object_id_ == other.object_id_;
196 } 228 }
197 229
198 bool Address::operator!=(const Address& other) const { 230 bool Address::operator!=(const Address& other) const {
199 return !(*this == other); 231 return !(*this == other);
200 } 232 }
201 233
202 } // namespace wallet 234 } // namespace wallet
203 235
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698