| 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); | |
| 81 } | 79 } |
| 82 | 80 |
| 83 std::unique_ptr<base::DictionaryValue> component(new base::DictionaryValue); | 81 std::unique_ptr<base::DictionaryValue> component(new base::DictionaryValue); |
| 84 component->SetString(kFieldNameKey, components[i].name); | 82 component->SetString(kFieldNameKey, components[i].name); |
| 85 | 83 |
| 86 switch (components[i].field) { | 84 switch (components[i].field) { |
| 87 case i18n::addressinput::COUNTRY: | 85 case i18n::addressinput::COUNTRY: |
| 88 component->SetString(kFieldTypeKey, kCountryField); | 86 component->SetString(kFieldTypeKey, kCountryField); |
| 89 break; | 87 break; |
| 90 case i18n::addressinput::ADMIN_AREA: | 88 case i18n::addressinput::ADMIN_AREA: |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 GetAddressComponents(countries.front()->country_code(), ui_language_code, | 154 GetAddressComponents(countries.front()->country_code(), ui_language_code, |
| 157 default_country_components.get(), | 155 default_country_components.get(), |
| 158 &default_country_language_code); | 156 &default_country_language_code); |
| 159 localized_strings->Set("autofillDefaultCountryComponents", | 157 localized_strings->Set("autofillDefaultCountryComponents", |
| 160 default_country_components.release()); | 158 default_country_components.release()); |
| 161 localized_strings->SetString("autofillDefaultCountryLanguageCode", | 159 localized_strings->SetString("autofillDefaultCountryLanguageCode", |
| 162 default_country_language_code); | 160 default_country_language_code); |
| 163 } | 161 } |
| 164 | 162 |
| 165 } // namespace autofill | 163 } // namespace autofill |
| OLD | NEW |