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

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

Issue 2888413006: [Payment Request] Moves autofill utility function to autofill_address_util.h (Closed)
Patch Set: Addressed comment Created 3 years, 7 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
« no previous file with comments | « components/autofill/core/browser/autofill_address_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/autofill_address_util.h" 5 #include "components/autofill/core/browser/autofill_address_util.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
11 #include "base/values.h" 12 #include "base/values.h"
12 #include "components/autofill/core/browser/autofill_country.h" 13 #include "components/autofill/core/browser/autofill_country.h"
13 #include "components/autofill/core/browser/country_combobox_model.h" 14 #include "components/autofill/core/browser/country_combobox_model.h"
14 #include "components/autofill/core/browser/field_types.h"
15 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui .h" 15 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui .h"
16 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui _component.h" 16 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui _component.h"
17 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/localizati on.h" 17 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/localizati on.h"
18 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
19 19
20 using autofill::AutofillCountry; 20 using autofill::AutofillCountry;
21 using autofill::ServerFieldType; 21 using autofill::ServerFieldType;
22 using i18n::addressinput::AddressUiComponent; 22 using i18n::addressinput::AddressUiComponent;
23 23
24 namespace autofill { 24 namespace autofill {
(...skipping 11 matching lines...) Expand all
36 const char kCityField[] = "city"; 36 const char kCityField[] = "city";
37 const char kStateField[] = "state"; 37 const char kStateField[] = "state";
38 const char kPostalCodeField[] = "postalCode"; 38 const char kPostalCodeField[] = "postalCode";
39 const char kSortingCodeField[] = "sortingCode"; 39 const char kSortingCodeField[] = "sortingCode";
40 const char kCountryField[] = "country"; 40 const char kCountryField[] = "country";
41 41
42 // Address field length values. 42 // Address field length values.
43 const char kShortField[] = "short"; 43 const char kShortField[] = "short";
44 const char kLongField[] = "long"; 44 const char kLongField[] = "long";
45 45
46 ServerFieldType GetFieldTypeFromString(const std::string& type) {
47 if (type == kFullNameField)
48 return NAME_FULL;
49 if (type == kCompanyNameField)
50 return COMPANY_NAME;
51 if (type == kAddressLineField)
52 return ADDRESS_HOME_STREET_ADDRESS;
53 if (type == kDependentLocalityField)
54 return ADDRESS_HOME_DEPENDENT_LOCALITY;
55 if (type == kCityField)
56 return ADDRESS_HOME_CITY;
57 if (type == kStateField)
58 return ADDRESS_HOME_STATE;
59 if (type == kPostalCodeField)
60 return ADDRESS_HOME_ZIP;
61 if (type == kSortingCodeField)
62 return ADDRESS_HOME_SORTING_CODE;
63 if (type == kCountryField)
64 return ADDRESS_HOME_COUNTRY;
65 NOTREACHED();
66 return UNKNOWN_TYPE;
67 }
68
46 // Fills |components| with the address UI components that should be used to 69 // Fills |components| with the address UI components that should be used to
47 // input an address for |country_code| when UI BCP 47 language code is 70 // input an address for |country_code| when UI BCP 47 language code is
48 // |ui_language_code|. If |components_language_code| is not NULL, then sets it 71 // |ui_language_code|. If |components_language_code| is not NULL, then sets it
49 // to the BCP 47 language code that should be used to format the address for 72 // to the BCP 47 language code that should be used to format the address for
50 // display. 73 // display.
51 void GetAddressComponents(const std::string& country_code, 74 void GetAddressComponents(const std::string& country_code,
52 const std::string& ui_language_code, 75 const std::string& ui_language_code,
53 base::ListValue* address_components, 76 base::ListValue* address_components,
54 std::string* components_language_code) { 77 std::string* components_language_code) {
55 DCHECK(address_components); 78 DCHECK(address_components);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 GetAddressComponents(countries.front()->country_code(), ui_language_code, 179 GetAddressComponents(countries.front()->country_code(), ui_language_code,
157 default_country_components.get(), 180 default_country_components.get(),
158 &default_country_language_code); 181 &default_country_language_code);
159 localized_strings->Set("autofillDefaultCountryComponents", 182 localized_strings->Set("autofillDefaultCountryComponents",
160 default_country_components.release()); 183 default_country_components.release());
161 localized_strings->SetString("autofillDefaultCountryLanguageCode", 184 localized_strings->SetString("autofillDefaultCountryLanguageCode",
162 default_country_language_code); 185 default_country_language_code);
163 } 186 }
164 187
165 } // namespace autofill 188 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_address_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698