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

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: 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/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "components/autofill/core/browser/autofill_country.h" 12 #include "components/autofill/core/browser/autofill_country.h"
13 #include "components/autofill/core/browser/country_combobox_model.h" 13 #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" 14 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui .h"
16 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui _component.h" 15 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui _component.h"
17 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/localizati on.h" 16 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/localizati on.h"
18 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
19 18
20 using autofill::AutofillCountry; 19 using autofill::AutofillCountry;
21 using autofill::ServerFieldType; 20 using autofill::ServerFieldType;
22 using i18n::addressinput::AddressUiComponent; 21 using i18n::addressinput::AddressUiComponent;
23 22
24 namespace autofill { 23 namespace autofill {
(...skipping 11 matching lines...) Expand all
36 const char kCityField[] = "city"; 35 const char kCityField[] = "city";
37 const char kStateField[] = "state"; 36 const char kStateField[] = "state";
38 const char kPostalCodeField[] = "postalCode"; 37 const char kPostalCodeField[] = "postalCode";
39 const char kSortingCodeField[] = "sortingCode"; 38 const char kSortingCodeField[] = "sortingCode";
40 const char kCountryField[] = "country"; 39 const char kCountryField[] = "country";
41 40
42 // Address field length values. 41 // Address field length values.
43 const char kShortField[] = "short"; 42 const char kShortField[] = "short";
44 const char kLongField[] = "long"; 43 const char kLongField[] = "long";
45 44
45 ServerFieldType GetFieldTypeFromString(const std::string& type) {
46 if (type == kFullNameField)
47 return NAME_FULL;
48 if (type == kCompanyNameField)
49 return COMPANY_NAME;
50 if (type == kAddressLineField)
51 return ADDRESS_HOME_STREET_ADDRESS;
52 if (type == kDependentLocalityField)
53 return ADDRESS_HOME_DEPENDENT_LOCALITY;
54 if (type == kCityField)
55 return ADDRESS_HOME_CITY;
56 if (type == kStateField)
57 return ADDRESS_HOME_STATE;
58 if (type == kPostalCodeField)
59 return ADDRESS_HOME_ZIP;
60 if (type == kSortingCodeField)
61 return ADDRESS_HOME_SORTING_CODE;
62 if (type == kCountryField)
63 return ADDRESS_HOME_COUNTRY;
64 NOTREACHED();
please use gerrit instead 2017/05/19 18:46:53 #include "base/logging.h"
Moe 2017/05/19 19:09:12 Done.
65 return UNKNOWN_TYPE;
66 }
67
46 // Fills |components| with the address UI components that should be used to 68 // 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 69 // 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 70 // |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 71 // to the BCP 47 language code that should be used to format the address for
50 // display. 72 // display.
51 void GetAddressComponents(const std::string& country_code, 73 void GetAddressComponents(const std::string& country_code,
52 const std::string& ui_language_code, 74 const std::string& ui_language_code,
53 base::ListValue* address_components, 75 base::ListValue* address_components,
54 std::string* components_language_code) { 76 std::string* components_language_code) {
55 DCHECK(address_components); 77 DCHECK(address_components);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 GetAddressComponents(countries.front()->country_code(), ui_language_code, 178 GetAddressComponents(countries.front()->country_code(), ui_language_code,
157 default_country_components.get(), 179 default_country_components.get(),
158 &default_country_language_code); 180 &default_country_language_code);
159 localized_strings->Set("autofillDefaultCountryComponents", 181 localized_strings->Set("autofillDefaultCountryComponents",
160 default_country_components.release()); 182 default_country_components.release());
161 localized_strings->SetString("autofillDefaultCountryLanguageCode", 183 localized_strings->SetString("autofillDefaultCountryLanguageCode",
162 default_country_language_code); 184 default_country_language_code);
163 } 185 }
164 186
165 } // namespace autofill 187 } // 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