OLD | NEW |
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 "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h" | 5 #include "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h" |
6 | 6 |
7 #include "base/strings/string_split.h" | 7 #include "base/strings/string_split.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "components/autofill/core/browser/autofill_profile.h" | 10 #include "components/autofill/core/browser/autofill_profile.h" |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 case NAME_BILLING_FULL: | 196 case NAME_BILLING_FULL: |
197 case NAME_FULL: | 197 case NAME_FULL: |
198 if (field) | 198 if (field) |
199 *field = ::i18n::addressinput::RECIPIENT; | 199 *field = ::i18n::addressinput::RECIPIENT; |
200 return true; | 200 return true; |
201 default: | 201 default: |
202 return false; | 202 return false; |
203 } | 203 } |
204 } | 204 } |
205 | 205 |
206 void CreateAddressData( | |
207 const base::Callback<base::string16(const AutofillType&)>& get_info, | |
208 AddressData* address_data) { | |
209 address_data->recipient = UTF16ToUTF8(get_info.Run(AutofillType(NAME_FULL))); | |
210 address_data->country_code = UTF16ToUTF8( | |
211 get_info.Run(AutofillType(HTML_TYPE_COUNTRY_CODE, HTML_MODE_SHIPPING))); | |
212 DCHECK_EQ(2U, address_data->country_code.size()); | |
213 address_data->administrative_area = UTF16ToUTF8( | |
214 get_info.Run(AutofillType(ADDRESS_HOME_STATE))); | |
215 address_data->locality = UTF16ToUTF8( | |
216 get_info.Run(AutofillType(ADDRESS_HOME_CITY))); | |
217 address_data->dependent_locality = UTF16ToUTF8( | |
218 get_info.Run(AutofillType(ADDRESS_HOME_DEPENDENT_LOCALITY))); | |
219 address_data->sorting_code = UTF16ToUTF8( | |
220 get_info.Run(AutofillType(ADDRESS_HOME_SORTING_CODE))); | |
221 address_data->postal_code = UTF16ToUTF8( | |
222 get_info.Run(AutofillType(ADDRESS_HOME_ZIP))); | |
223 base::SplitString( | |
224 UTF16ToUTF8(get_info.Run(AutofillType(ADDRESS_HOME_STREET_ADDRESS))), | |
225 '\n', | |
226 &address_data->address_lines); | |
227 } | |
228 | |
229 bool CountryIsFullySupported(const std::string& country_code) { | 206 bool CountryIsFullySupported(const std::string& country_code) { |
230 DCHECK_EQ(2U, country_code.size()); | 207 DCHECK_EQ(2U, country_code.size()); |
231 std::vector< ::i18n::addressinput::AddressUiComponent> components = | 208 std::vector< ::i18n::addressinput::AddressUiComponent> components = |
232 ::i18n::addressinput::BuildComponents( | 209 ::i18n::addressinput::BuildComponents( |
233 country_code, g_browser_process->GetApplicationLocale(), NULL); | 210 country_code, g_browser_process->GetApplicationLocale(), NULL); |
234 for (size_t i = 0; i < components.size(); ++i) { | 211 for (size_t i = 0; i < components.size(); ++i) { |
235 if (components[i].field == ::i18n::addressinput::DEPENDENT_LOCALITY) | 212 if (components[i].field == ::i18n::addressinput::DEPENDENT_LOCALITY) |
236 return false; | 213 return false; |
237 } | 214 } |
238 return true; | 215 return true; |
239 } | 216 } |
240 | 217 |
241 } // namespace i18ninput | 218 } // namespace i18ninput |
242 } // namespace autofill | 219 } // namespace autofill |
OLD | NEW |