OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/webui/options/autofill_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/autofill_options_handler.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
| 9 #include <memory> |
9 #include <utility> | 10 #include <utility> |
10 #include <vector> | 11 #include <vector> |
11 | 12 |
12 #include "base/bind.h" | 13 #include "base/bind.h" |
13 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
14 #include "base/command_line.h" | 15 #include "base/command_line.h" |
15 #include "base/guid.h" | 16 #include "base/guid.h" |
16 #include "base/logging.h" | 17 #include "base/logging.h" |
17 #include "base/macros.h" | 18 #include "base/macros.h" |
| 19 #include "base/memory/ptr_util.h" |
18 #include "base/strings/string16.h" | 20 #include "base/strings/string16.h" |
19 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
20 #include "base/strings/string_split.h" | 22 #include "base/strings/string_split.h" |
21 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
22 #include "base/values.h" | 24 #include "base/values.h" |
23 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 25 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
24 #include "chrome/browser/browser_process.h" | 26 #include "chrome/browser/browser_process.h" |
25 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
26 #include "chrome/browser/ui/autofill/country_combobox_model.h" | 28 #include "chrome/browser/ui/autofill/country_combobox_model.h" |
27 #include "chrome/common/url_constants.h" | 29 #include "chrome/common/url_constants.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 DCHECK(!components.empty()); | 110 DCHECK(!components.empty()); |
109 | 111 |
110 base::ListValue* line = nullptr; | 112 base::ListValue* line = nullptr; |
111 static const char kField[] = "field"; | 113 static const char kField[] = "field"; |
112 static const char kLength[] = "length"; | 114 static const char kLength[] = "length"; |
113 for (size_t i = 0; i < components.size(); ++i) { | 115 for (size_t i = 0; i < components.size(); ++i) { |
114 if (i == 0 || | 116 if (i == 0 || |
115 components[i - 1].length_hint == AddressUiComponent::HINT_LONG || | 117 components[i - 1].length_hint == AddressUiComponent::HINT_LONG || |
116 components[i].length_hint == AddressUiComponent::HINT_LONG) { | 118 components[i].length_hint == AddressUiComponent::HINT_LONG) { |
117 line = new base::ListValue; | 119 line = new base::ListValue; |
118 address_components->Append(line); | 120 address_components->Append(base::WrapUnique(line)); |
119 } | 121 } |
120 | 122 |
121 std::unique_ptr<base::DictionaryValue> component(new base::DictionaryValue); | 123 std::unique_ptr<base::DictionaryValue> component(new base::DictionaryValue); |
122 component->SetString("name", components[i].name); | 124 component->SetString("name", components[i].name); |
123 | 125 |
124 switch (components[i].field) { | 126 switch (components[i].field) { |
125 case i18n::addressinput::COUNTRY: | 127 case i18n::addressinput::COUNTRY: |
126 component->SetString(kField, kCountryField); | 128 component->SetString(kField, kCountryField); |
127 break; | 129 break; |
128 case i18n::addressinput::ADMIN_AREA: | 130 case i18n::addressinput::ADMIN_AREA: |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 address->SetString(kLanguageCode, profile.language_code()); | 630 address->SetString(kLanguageCode, profile.language_code()); |
629 | 631 |
630 std::unique_ptr<base::ListValue> components(new base::ListValue); | 632 std::unique_ptr<base::ListValue> components(new base::ListValue); |
631 GetAddressComponents( | 633 GetAddressComponents( |
632 base::UTF16ToUTF8(profile.GetRawInfo(autofill::ADDRESS_HOME_COUNTRY)), | 634 base::UTF16ToUTF8(profile.GetRawInfo(autofill::ADDRESS_HOME_COUNTRY)), |
633 profile.language_code(), components.get(), nullptr); | 635 profile.language_code(), components.get(), nullptr); |
634 address->Set(kComponents, components.release()); | 636 address->Set(kComponents, components.release()); |
635 } | 637 } |
636 | 638 |
637 } // namespace options | 639 } // namespace options |
OLD | NEW |