OLD | NEW |
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" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 } | 69 } |
70 DCHECK(!components.empty()); | 70 DCHECK(!components.empty()); |
71 | 71 |
72 base::ListValue* line = nullptr; | 72 base::ListValue* line = nullptr; |
73 for (size_t i = 0; i < components.size(); ++i) { | 73 for (size_t i = 0; i < components.size(); ++i) { |
74 if (i == 0 || | 74 if (i == 0 || |
75 components[i - 1].length_hint == AddressUiComponent::HINT_LONG || | 75 components[i - 1].length_hint == AddressUiComponent::HINT_LONG || |
76 components[i].length_hint == AddressUiComponent::HINT_LONG) { | 76 components[i].length_hint == AddressUiComponent::HINT_LONG) { |
77 line = new base::ListValue; | 77 line = new base::ListValue; |
78 address_components->Append(base::WrapUnique(line)); | 78 address_components->Append(base::WrapUnique(line)); |
| 79 // |line| is invalidated at this point, so it needs to be reset. |
| 80 address_components->GetList(address_components->GetSize() - 1, &line); |
79 } | 81 } |
80 | 82 |
81 std::unique_ptr<base::DictionaryValue> component(new base::DictionaryValue); | 83 std::unique_ptr<base::DictionaryValue> component(new base::DictionaryValue); |
82 component->SetString(kFieldNameKey, components[i].name); | 84 component->SetString(kFieldNameKey, components[i].name); |
83 | 85 |
84 switch (components[i].field) { | 86 switch (components[i].field) { |
85 case i18n::addressinput::COUNTRY: | 87 case i18n::addressinput::COUNTRY: |
86 component->SetString(kFieldTypeKey, kCountryField); | 88 component->SetString(kFieldTypeKey, kCountryField); |
87 break; | 89 break; |
88 case i18n::addressinput::ADMIN_AREA: | 90 case i18n::addressinput::ADMIN_AREA: |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 GetAddressComponents(countries.front()->country_code(), ui_language_code, | 156 GetAddressComponents(countries.front()->country_code(), ui_language_code, |
155 default_country_components.get(), | 157 default_country_components.get(), |
156 &default_country_language_code); | 158 &default_country_language_code); |
157 localized_strings->Set("autofillDefaultCountryComponents", | 159 localized_strings->Set("autofillDefaultCountryComponents", |
158 default_country_components.release()); | 160 default_country_components.release()); |
159 localized_strings->SetString("autofillDefaultCountryLanguageCode", | 161 localized_strings->SetString("autofillDefaultCountryLanguageCode", |
160 default_country_language_code); | 162 default_country_language_code); |
161 } | 163 } |
162 | 164 |
163 } // namespace autofill | 165 } // namespace autofill |
OLD | NEW |