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

Side by Side Diff: components/autofill/core/browser/address_i18n.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/core/browser/address_i18n.h" 5 #include "components/autofill/core/browser/address_i18n.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 11 matching lines...) Expand all
22 const std::string& app_locale, 22 const std::string& app_locale,
23 const AutofillType& type) { 23 const AutofillType& type) {
24 return profile.GetInfo(type, app_locale); 24 return profile.GetInfo(type, app_locale);
25 } 25 }
26 26
27 } // namespace 27 } // namespace
28 28
29 using ::i18n::addressinput::AddressData; 29 using ::i18n::addressinput::AddressData;
30 using ::i18n::addressinput::AddressField; 30 using ::i18n::addressinput::AddressField;
31 31
32 scoped_ptr<AddressData> CreateAddressData( 32 std::unique_ptr<AddressData> CreateAddressData(
33 const base::Callback<base::string16(const AutofillType&)>& get_info) { 33 const base::Callback<base::string16(const AutofillType&)>& get_info) {
34 scoped_ptr<AddressData> address_data(new AddressData()); 34 std::unique_ptr<AddressData> address_data(new AddressData());
35 address_data->recipient = base::UTF16ToUTF8( 35 address_data->recipient = base::UTF16ToUTF8(
36 get_info.Run(AutofillType(NAME_FULL))); 36 get_info.Run(AutofillType(NAME_FULL)));
37 address_data->organization = base::UTF16ToUTF8( 37 address_data->organization = base::UTF16ToUTF8(
38 get_info.Run(AutofillType(COMPANY_NAME))); 38 get_info.Run(AutofillType(COMPANY_NAME)));
39 address_data->region_code = base::UTF16ToUTF8( 39 address_data->region_code = base::UTF16ToUTF8(
40 get_info.Run(AutofillType(HTML_TYPE_COUNTRY_CODE, HTML_MODE_NONE))); 40 get_info.Run(AutofillType(HTML_TYPE_COUNTRY_CODE, HTML_MODE_NONE)));
41 address_data->administrative_area = base::UTF16ToUTF8( 41 address_data->administrative_area = base::UTF16ToUTF8(
42 get_info.Run(AutofillType(ADDRESS_HOME_STATE))); 42 get_info.Run(AutofillType(ADDRESS_HOME_STATE)));
43 address_data->locality = base::UTF16ToUTF8( 43 address_data->locality = base::UTF16ToUTF8(
44 get_info.Run(AutofillType(ADDRESS_HOME_CITY))); 44 get_info.Run(AutofillType(ADDRESS_HOME_CITY)));
45 address_data->dependent_locality = base::UTF16ToUTF8( 45 address_data->dependent_locality = base::UTF16ToUTF8(
46 get_info.Run(AutofillType(ADDRESS_HOME_DEPENDENT_LOCALITY))); 46 get_info.Run(AutofillType(ADDRESS_HOME_DEPENDENT_LOCALITY)));
47 address_data->sorting_code = base::UTF16ToUTF8( 47 address_data->sorting_code = base::UTF16ToUTF8(
48 get_info.Run(AutofillType(ADDRESS_HOME_SORTING_CODE))); 48 get_info.Run(AutofillType(ADDRESS_HOME_SORTING_CODE)));
49 address_data->postal_code = base::UTF16ToUTF8( 49 address_data->postal_code = base::UTF16ToUTF8(
50 get_info.Run(AutofillType(ADDRESS_HOME_ZIP))); 50 get_info.Run(AutofillType(ADDRESS_HOME_ZIP)));
51 address_data->address_line = base::SplitString( 51 address_data->address_line = base::SplitString(
52 base::UTF16ToUTF8( 52 base::UTF16ToUTF8(
53 get_info.Run(AutofillType(ADDRESS_HOME_STREET_ADDRESS))), 53 get_info.Run(AutofillType(ADDRESS_HOME_STREET_ADDRESS))),
54 "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); 54 "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
55 return address_data; 55 return address_data;
56 } 56 }
57 57
58 scoped_ptr< ::i18n::addressinput::AddressData> 58 std::unique_ptr<::i18n::addressinput::AddressData>
59 CreateAddressDataFromAutofillProfile(const AutofillProfile& profile, 59 CreateAddressDataFromAutofillProfile(const AutofillProfile& profile,
60 const std::string& app_locale) { 60 const std::string& app_locale) {
61 scoped_ptr< ::i18n::addressinput::AddressData> address_data = 61 std::unique_ptr<::i18n::addressinput::AddressData> address_data =
62 i18n::CreateAddressData(base::Bind(&GetInfoHelper, profile, app_locale)); 62 i18n::CreateAddressData(base::Bind(&GetInfoHelper, profile, app_locale));
63 address_data->language_code = profile.language_code(); 63 address_data->language_code = profile.language_code();
64 return address_data; 64 return address_data;
65 } 65 }
66 66
67 ServerFieldType TypeForField(AddressField address_field, bool billing) { 67 ServerFieldType TypeForField(AddressField address_field, bool billing) {
68 switch (address_field) { 68 switch (address_field) {
69 case ::i18n::addressinput::COUNTRY: 69 case ::i18n::addressinput::COUNTRY:
70 return billing ? ADDRESS_BILLING_COUNTRY : ADDRESS_HOME_COUNTRY; 70 return billing ? ADDRESS_BILLING_COUNTRY : ADDRESS_HOME_COUNTRY;
71 case ::i18n::addressinput::ADMIN_AREA: 71 case ::i18n::addressinput::ADMIN_AREA:
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 if (field) 141 if (field)
142 *field = ::i18n::addressinput::RECIPIENT; 142 *field = ::i18n::addressinput::RECIPIENT;
143 return true; 143 return true;
144 default: 144 default:
145 return false; 145 return false;
146 } 146 }
147 } 147 }
148 148
149 } // namespace i18n 149 } // namespace i18n
150 } // namespace autofill 150 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/address_i18n.h ('k') | components/autofill/core/browser/address_i18n_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698