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

Side by Side Diff: chrome/browser/ui/autofill/autofill_dialog_i18n_input.cc

Issue 208243005: Determine language code and type of format for address. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add ctime include. Created 6 years, 9 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
« no previous file with comments | « no previous file | chrome/browser/ui/autofill/country_combobox_model_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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 "components/autofill/core/browser/autofill_profile.h" 10 #include "components/autofill/core/browser/autofill_profile.h"
10 #include "components/autofill/core/browser/credit_card.h" 11 #include "components/autofill/core/browser/credit_card.h"
11 #include "components/autofill/core/browser/field_types.h" 12 #include "components/autofill/core/browser/field_types.h"
12 #include "grit/component_strings.h" 13 #include "grit/component_strings.h"
13 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre ss_data.h" 14 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre ss_data.h"
14 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre ss_field.h" 15 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre ss_field.h"
15 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre ss_ui.h" 16 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre ss_ui.h"
16 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre ss_ui_component.h" 17 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre ss_ui_component.h"
17 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
18 19
(...skipping 12 matching lines...) Expand all
31 return DetailInput::SHORT; 32 return DetailInput::SHORT;
32 DCHECK_EQ(hint, AddressUiComponent::HINT_LONG); 33 DCHECK_EQ(hint, AddressUiComponent::HINT_LONG);
33 return DetailInput::LONG; 34 return DetailInput::LONG;
34 } 35 }
35 36
36 } // namespace 37 } // namespace
37 38
38 void BuildAddressInputs(common::AddressType address_type, 39 void BuildAddressInputs(common::AddressType address_type,
39 const std::string& country_code, 40 const std::string& country_code,
40 DetailInputs* inputs) { 41 DetailInputs* inputs) {
42 // TODO(rouslan): Store the language code for the autofill profile.
43 // http://crbug.com/354955
41 std::vector<AddressUiComponent> components( 44 std::vector<AddressUiComponent> components(
42 ::i18n::addressinput::BuildComponents(country_code)); 45 ::i18n::addressinput::BuildComponents(
46 country_code, g_browser_process->GetApplicationLocale(), NULL));
43 47
44 const bool billing = address_type == common::ADDRESS_TYPE_BILLING; 48 const bool billing = address_type == common::ADDRESS_TYPE_BILLING;
45 49
46 for (size_t i = 0; i < components.size(); ++i) { 50 for (size_t i = 0; i < components.size(); ++i) {
47 const AddressUiComponent& component = components[i]; 51 const AddressUiComponent& component = components[i];
48 if (component.field == ::i18n::addressinput::ORGANIZATION) { 52 if (component.field == ::i18n::addressinput::ORGANIZATION) {
49 // TODO(dbeam): figure out when we actually need this. 53 // TODO(dbeam): figure out when we actually need this.
50 continue; 54 continue;
51 } 55 }
52 56
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 get_info.Run(AutofillType(ADDRESS_HOME_ZIP))); 239 get_info.Run(AutofillType(ADDRESS_HOME_ZIP)));
236 base::SplitString( 240 base::SplitString(
237 UTF16ToUTF8(get_info.Run(AutofillType(ADDRESS_HOME_STREET_ADDRESS))), 241 UTF16ToUTF8(get_info.Run(AutofillType(ADDRESS_HOME_STREET_ADDRESS))),
238 '\n', 242 '\n',
239 &address_data->address_lines); 243 &address_data->address_lines);
240 } 244 }
241 245
242 bool CountryIsFullySupported(const std::string& country_code) { 246 bool CountryIsFullySupported(const std::string& country_code) {
243 DCHECK_EQ(2U, country_code.size()); 247 DCHECK_EQ(2U, country_code.size());
244 std::vector< ::i18n::addressinput::AddressUiComponent> components = 248 std::vector< ::i18n::addressinput::AddressUiComponent> components =
245 ::i18n::addressinput::BuildComponents(country_code); 249 ::i18n::addressinput::BuildComponents(
250 country_code, g_browser_process->GetApplicationLocale(), NULL);
246 for (size_t i = 0; i < components.size(); ++i) { 251 for (size_t i = 0; i < components.size(); ++i) {
247 if (components[i].field == ::i18n::addressinput::DEPENDENT_LOCALITY) 252 if (components[i].field == ::i18n::addressinput::DEPENDENT_LOCALITY)
248 return false; 253 return false;
249 } 254 }
250 return true; 255 return true;
251 } 256 }
252 257
253 } // namespace i18ninput 258 } // namespace i18ninput
254 } // namespace autofill 259 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/autofill/country_combobox_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698