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

Side by Side Diff: components/autofill/core/browser/address_i18n.cc

Issue 490373002: Add back organization field for autofill settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Git migration. Created 6 years, 3 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 16 matching lines...) Expand all
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 scoped_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 scoped_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(
38 get_info.Run(AutofillType(COMPANY_NAME)));
37 address_data->region_code = base::UTF16ToUTF8( 39 address_data->region_code = base::UTF16ToUTF8(
38 get_info.Run(AutofillType(HTML_TYPE_COUNTRY_CODE, HTML_MODE_NONE))); 40 get_info.Run(AutofillType(HTML_TYPE_COUNTRY_CODE, HTML_MODE_NONE)));
39 address_data->administrative_area = base::UTF16ToUTF8( 41 address_data->administrative_area = base::UTF16ToUTF8(
40 get_info.Run(AutofillType(ADDRESS_HOME_STATE))); 42 get_info.Run(AutofillType(ADDRESS_HOME_STATE)));
41 address_data->locality = base::UTF16ToUTF8( 43 address_data->locality = base::UTF16ToUTF8(
42 get_info.Run(AutofillType(ADDRESS_HOME_CITY))); 44 get_info.Run(AutofillType(ADDRESS_HOME_CITY)));
43 address_data->dependent_locality = base::UTF16ToUTF8( 45 address_data->dependent_locality = base::UTF16ToUTF8(
44 get_info.Run(AutofillType(ADDRESS_HOME_DEPENDENT_LOCALITY))); 46 get_info.Run(AutofillType(ADDRESS_HOME_DEPENDENT_LOCALITY)));
45 address_data->sorting_code = base::UTF16ToUTF8( 47 address_data->sorting_code = base::UTF16ToUTF8(
46 get_info.Run(AutofillType(ADDRESS_HOME_SORTING_CODE))); 48 get_info.Run(AutofillType(ADDRESS_HOME_SORTING_CODE)));
(...skipping 27 matching lines...) Expand all
74 case ::i18n::addressinput::DEPENDENT_LOCALITY: 76 case ::i18n::addressinput::DEPENDENT_LOCALITY:
75 return billing ? ADDRESS_BILLING_DEPENDENT_LOCALITY 77 return billing ? ADDRESS_BILLING_DEPENDENT_LOCALITY
76 : ADDRESS_HOME_DEPENDENT_LOCALITY; 78 : ADDRESS_HOME_DEPENDENT_LOCALITY;
77 case ::i18n::addressinput::POSTAL_CODE: 79 case ::i18n::addressinput::POSTAL_CODE:
78 return billing ? ADDRESS_BILLING_ZIP : ADDRESS_HOME_ZIP; 80 return billing ? ADDRESS_BILLING_ZIP : ADDRESS_HOME_ZIP;
79 case ::i18n::addressinput::SORTING_CODE: 81 case ::i18n::addressinput::SORTING_CODE:
80 return billing ? ADDRESS_BILLING_SORTING_CODE : ADDRESS_HOME_SORTING_CODE; 82 return billing ? ADDRESS_BILLING_SORTING_CODE : ADDRESS_HOME_SORTING_CODE;
81 case ::i18n::addressinput::STREET_ADDRESS: 83 case ::i18n::addressinput::STREET_ADDRESS:
82 return billing ? ADDRESS_BILLING_STREET_ADDRESS 84 return billing ? ADDRESS_BILLING_STREET_ADDRESS
83 : ADDRESS_HOME_STREET_ADDRESS; 85 : ADDRESS_HOME_STREET_ADDRESS;
86 case ::i18n::addressinput::ORGANIZATION:
87 return COMPANY_NAME;
84 case ::i18n::addressinput::RECIPIENT: 88 case ::i18n::addressinput::RECIPIENT:
85 return billing ? NAME_BILLING_FULL : NAME_FULL; 89 return billing ? NAME_BILLING_FULL : NAME_FULL;
86 } 90 }
87 NOTREACHED(); 91 NOTREACHED();
88 return UNKNOWN_TYPE; 92 return UNKNOWN_TYPE;
89 } 93 }
90 94
91 bool FieldForType(ServerFieldType server_type, AddressField* field) { 95 bool FieldForType(ServerFieldType server_type, AddressField* field) {
92 switch (server_type) { 96 switch (server_type) {
93 case ADDRESS_BILLING_COUNTRY: 97 case ADDRESS_BILLING_COUNTRY:
(...skipping 28 matching lines...) Expand all
122 return true; 126 return true;
123 case ADDRESS_BILLING_STREET_ADDRESS: 127 case ADDRESS_BILLING_STREET_ADDRESS:
124 case ADDRESS_BILLING_LINE1: 128 case ADDRESS_BILLING_LINE1:
125 case ADDRESS_BILLING_LINE2: 129 case ADDRESS_BILLING_LINE2:
126 case ADDRESS_HOME_STREET_ADDRESS: 130 case ADDRESS_HOME_STREET_ADDRESS:
127 case ADDRESS_HOME_LINE1: 131 case ADDRESS_HOME_LINE1:
128 case ADDRESS_HOME_LINE2: 132 case ADDRESS_HOME_LINE2:
129 if (field) 133 if (field)
130 *field = ::i18n::addressinput::STREET_ADDRESS; 134 *field = ::i18n::addressinput::STREET_ADDRESS;
131 return true; 135 return true;
136 case COMPANY_NAME:
137 if (field)
138 *field = ::i18n::addressinput::ORGANIZATION;
139 return true;
132 case NAME_BILLING_FULL: 140 case NAME_BILLING_FULL:
133 case NAME_FULL: 141 case NAME_FULL:
134 if (field) 142 if (field)
135 *field = ::i18n::addressinput::RECIPIENT; 143 *field = ::i18n::addressinput::RECIPIENT;
136 return true; 144 return true;
137 default: 145 default:
138 return false; 146 return false;
139 } 147 }
140 } 148 }
141 149
142 } // namespace i18n 150 } // namespace i18n
143 } // namespace autofill 151 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/autofill_options_handler.cc ('k') | components/autofill/core/browser/address_i18n_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698