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

Side by Side Diff: components/autofill/content/browser/wallet/wallet_address.cc

Issue 1859453002: components/autofill: scoped_ptr -> unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments addressed Created 4 years, 8 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
OLDNEW
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 #include "components/autofill/content/browser/wallet/wallet_address.h" 5 #include "components/autofill/content/browser/wallet/wallet_address.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/string_split.h" 8 #include "base/strings/string_split.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 sorting_code_(sorting_code), 162 sorting_code_(sorting_code),
163 phone_number_(phone_number), 163 phone_number_(phone_number),
164 phone_object_(phone_number, country_name_code), 164 phone_object_(phone_number, country_name_code),
165 object_id_(object_id), 165 object_id_(object_id),
166 is_complete_address_(true), 166 is_complete_address_(true),
167 language_code_(language_code) {} 167 language_code_(language_code) {}
168 168
169 Address::~Address() {} 169 Address::~Address() {}
170 170
171 // static 171 // static
172 scoped_ptr<Address> Address::CreateAddressWithID( 172 std::unique_ptr<Address> Address::CreateAddressWithID(
173 const base::DictionaryValue& dictionary) { 173 const base::DictionaryValue& dictionary) {
174 std::string object_id; 174 std::string object_id;
175 if (!dictionary.GetString("id", &object_id)) { 175 if (!dictionary.GetString("id", &object_id)) {
176 DLOG(ERROR) << "Response from Google Payments missing object id"; 176 DLOG(ERROR) << "Response from Google Payments missing object id";
177 return scoped_ptr<Address>(); 177 return std::unique_ptr<Address>();
178 } 178 }
179 return scoped_ptr<Address>(CreateAddressInternal(dictionary, object_id)); 179 return std::unique_ptr<Address>(CreateAddressInternal(dictionary, object_id));
180 } 180 }
181 181
182 // static 182 // static
183 scoped_ptr<Address> Address::CreateAddress( 183 std::unique_ptr<Address> Address::CreateAddress(
184 const base::DictionaryValue& dictionary) { 184 const base::DictionaryValue& dictionary) {
185 std::string object_id; 185 std::string object_id;
186 dictionary.GetString("id", &object_id); 186 dictionary.GetString("id", &object_id);
187 return scoped_ptr<Address>(CreateAddressInternal(dictionary, object_id)); 187 return std::unique_ptr<Address>(CreateAddressInternal(dictionary, object_id));
188 } 188 }
189 189
190 // static 190 // static
191 scoped_ptr<Address> Address::CreateDisplayAddress( 191 std::unique_ptr<Address> Address::CreateDisplayAddress(
192 const base::DictionaryValue& dictionary) { 192 const base::DictionaryValue& dictionary) {
193 std::string country_code; 193 std::string country_code;
194 if (!dictionary.GetString("country_code", &country_code)) { 194 if (!dictionary.GetString("country_code", &country_code)) {
195 DLOG(ERROR) << "Reponse from Google Payments missing country code"; 195 DLOG(ERROR) << "Reponse from Google Payments missing country code";
196 return scoped_ptr<Address>(); 196 return std::unique_ptr<Address>();
197 } 197 }
198 198
199 base::string16 name; 199 base::string16 name;
200 if (!dictionary.GetString("name", &name)) { 200 if (!dictionary.GetString("name", &name)) {
201 DLOG(ERROR) << "Reponse from Google Payments missing name"; 201 DLOG(ERROR) << "Reponse from Google Payments missing name";
202 return scoped_ptr<Address>(); 202 return std::unique_ptr<Address>();
203 } 203 }
204 204
205 base::string16 postal_code; 205 base::string16 postal_code;
206 if (!dictionary.GetString("postal_code", &postal_code)) { 206 if (!dictionary.GetString("postal_code", &postal_code)) {
207 DLOG(ERROR) << "Reponse from Google Payments missing postal code"; 207 DLOG(ERROR) << "Reponse from Google Payments missing postal code";
208 return scoped_ptr<Address>(); 208 return std::unique_ptr<Address>();
209 } 209 }
210 210
211 base::string16 sorting_code; 211 base::string16 sorting_code;
212 if (!dictionary.GetString("sorting_code", &sorting_code)) { 212 if (!dictionary.GetString("sorting_code", &sorting_code)) {
213 DVLOG(1) << "Reponse from Google Payments missing sorting code"; 213 DVLOG(1) << "Reponse from Google Payments missing sorting code";
214 } 214 }
215 215
216 std::vector<base::string16> street_address; 216 std::vector<base::string16> street_address;
217 base::string16 address1; 217 base::string16 address1;
218 if (dictionary.GetString("address1", &address1)) 218 if (dictionary.GetString("address1", &address1))
(...skipping 28 matching lines...) Expand all
247 DVLOG(1) << "Reponse from Google Payments missing phone number"; 247 DVLOG(1) << "Reponse from Google Payments missing phone number";
248 248
249 std::string address_state; 249 std::string address_state;
250 if (!dictionary.GetString("type", &address_state)) 250 if (!dictionary.GetString("type", &address_state))
251 DVLOG(1) << "Response from Google Payments missing type/state of address"; 251 DVLOG(1) << "Response from Google Payments missing type/state of address";
252 252
253 std::string language_code; 253 std::string language_code;
254 if (!dictionary.GetString("language_code", &language_code)) 254 if (!dictionary.GetString("language_code", &language_code))
255 DVLOG(1) << "Response from Google Payments missing language code"; 255 DVLOG(1) << "Response from Google Payments missing language code";
256 256
257 scoped_ptr<Address> address( 257 std::unique_ptr<Address> address(new Address(
258 new Address(country_code, 258 country_code, name, street_address, city, dependent_locality_name, state,
259 name, 259 postal_code, sorting_code, phone_number, std::string(), language_code));
260 street_address,
261 city,
262 dependent_locality_name,
263 state,
264 postal_code,
265 sorting_code,
266 phone_number,
267 std::string(),
268 language_code));
269 address->set_is_complete_address(address_state == kFullAddress); 260 address->set_is_complete_address(address_state == kFullAddress);
270 261
271 return address; 262 return address;
272 } 263 }
273 264
274 scoped_ptr<base::DictionaryValue> Address::ToDictionaryWithID() const { 265 std::unique_ptr<base::DictionaryValue> Address::ToDictionaryWithID() const {
275 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 266 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
276 267
277 if (!object_id_.empty()) 268 if (!object_id_.empty())
278 dict->SetString("id", object_id_); 269 dict->SetString("id", object_id_);
279 dict->SetString("phone_number", phone_number_); 270 dict->SetString("phone_number", phone_number_);
280 dict->Set("postal_address", ToDictionaryWithoutID().release()); 271 dict->Set("postal_address", ToDictionaryWithoutID().release());
281 272
282 return dict; 273 return dict;
283 } 274 }
284 275
285 scoped_ptr<base::DictionaryValue> Address::ToDictionaryWithoutID() const { 276 std::unique_ptr<base::DictionaryValue> Address::ToDictionaryWithoutID() const {
286 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 277 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
287 278
288 scoped_ptr<base::ListValue> address_lines(new base::ListValue()); 279 std::unique_ptr<base::ListValue> address_lines(new base::ListValue());
289 address_lines->AppendStrings(street_address_); 280 address_lines->AppendStrings(street_address_);
290 dict->Set("address_line", address_lines.release()); 281 dict->Set("address_line", address_lines.release());
291 282
292 dict->SetString("country_name_code", country_name_code_); 283 dict->SetString("country_name_code", country_name_code_);
293 dict->SetString("recipient_name", recipient_name_); 284 dict->SetString("recipient_name", recipient_name_);
294 dict->SetString("locality_name", locality_name_); 285 dict->SetString("locality_name", locality_name_);
295 dict->SetString("dependent_locality_name", dependent_locality_name_); 286 dict->SetString("dependent_locality_name", dependent_locality_name_);
296 dict->SetString("administrative_area_name", 287 dict->SetString("administrative_area_name",
297 administrative_area_name_); 288 administrative_area_name_);
298 dict->SetString("postal_code_number", postal_code_number_); 289 dict->SetString("postal_code_number", postal_code_number_);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 language_code_ == other.language_code_ && 404 language_code_ == other.language_code_ &&
414 EqualsIgnoreID(other); 405 EqualsIgnoreID(other);
415 } 406 }
416 407
417 bool Address::operator!=(const Address& other) const { 408 bool Address::operator!=(const Address& other) const {
418 return !(*this == other); 409 return !(*this == other);
419 } 410 }
420 411
421 } // namespace wallet 412 } // namespace wallet
422 } // namespace autofill 413 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698