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

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: 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
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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 get_info.Run(AutofillType(ADDRESS_HOME_ZIP))); 175 get_info.Run(AutofillType(ADDRESS_HOME_ZIP)));
172 base::SplitString( 176 base::SplitString(
173 UTF16ToUTF8(get_info.Run(AutofillType(ADDRESS_HOME_STREET_ADDRESS))), 177 UTF16ToUTF8(get_info.Run(AutofillType(ADDRESS_HOME_STREET_ADDRESS))),
174 '\n', 178 '\n',
175 &address_data->address_lines); 179 &address_data->address_lines);
176 } 180 }
177 181
178 bool CountryIsFullySupported(const std::string& country_code) { 182 bool CountryIsFullySupported(const std::string& country_code) {
179 DCHECK_EQ(2U, country_code.size()); 183 DCHECK_EQ(2U, country_code.size());
180 std::vector< ::i18n::addressinput::AddressUiComponent> components = 184 std::vector< ::i18n::addressinput::AddressUiComponent> components =
181 ::i18n::addressinput::BuildComponents(country_code); 185 ::i18n::addressinput::BuildComponents(
186 country_code, g_browser_process->GetApplicationLocale(), NULL);
182 for (size_t i = 0; i < components.size(); ++i) { 187 for (size_t i = 0; i < components.size(); ++i) {
183 if (components[i].field == ::i18n::addressinput::DEPENDENT_LOCALITY) 188 if (components[i].field == ::i18n::addressinput::DEPENDENT_LOCALITY)
184 return false; 189 return false;
185 } 190 }
186 return true; 191 return true;
187 } 192 }
188 193
189 } // namespace i18ninput 194 } // namespace i18ninput
190 } // namespace autofill 195 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698