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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 list->reset(new ListValue); | 104 list->reset(new ListValue); |
105 | 105 |
106 std::vector<string16> values; | 106 std::vector<string16> values; |
107 profile.GetRawMultiInfo(type, &values); | 107 profile.GetRawMultiInfo(type, &values); |
108 | 108 |
109 // |GetRawMultiInfo()| always returns at least one, potentially empty, item. | 109 // |GetRawMultiInfo()| always returns at least one, potentially empty, item. |
110 if (values.size() == 1 && values.front().empty()) | 110 if (values.size() == 1 && values.front().empty()) |
111 return; | 111 return; |
112 | 112 |
113 for (size_t i = 0; i < values.size(); ++i) { | 113 for (size_t i = 0; i < values.size(); ++i) { |
114 (*list)->Set(i, Value::CreateStringValue(values[i])); | 114 (*list)->Set(i, new base::StringValue(values[i])); |
115 } | 115 } |
116 } | 116 } |
117 | 117 |
118 // Set the multi-valued element for |type| from input |list| values. | 118 // Set the multi-valued element for |type| from input |list| values. |
119 void SetValueList(const ListValue* list, | 119 void SetValueList(const ListValue* list, |
120 AutofillFieldType type, | 120 AutofillFieldType type, |
121 AutofillProfile* profile) { | 121 AutofillProfile* profile) { |
122 std::vector<string16> values(list->GetSize()); | 122 std::vector<string16> values(list->GetSize()); |
123 for (size_t i = 0; i < list->GetSize(); ++i) { | 123 for (size_t i = 0; i < list->GetSize(); ++i) { |
124 string16 value; | 124 string16 value; |
(...skipping 18 matching lines...) Expand all Loading... |
143 DCHECK_EQ(first_names.size(), last_names.size()); | 143 DCHECK_EQ(first_names.size(), last_names.size()); |
144 | 144 |
145 // |GetRawMultiInfo()| always returns at least one, potentially empty, item. | 145 // |GetRawMultiInfo()| always returns at least one, potentially empty, item. |
146 if (first_names.size() == 1 && first_names.front().empty() && | 146 if (first_names.size() == 1 && first_names.front().empty() && |
147 middle_names.front().empty() && last_names.front().empty()) { | 147 middle_names.front().empty() && last_names.front().empty()) { |
148 return; | 148 return; |
149 } | 149 } |
150 | 150 |
151 for (size_t i = 0; i < first_names.size(); ++i) { | 151 for (size_t i = 0; i < first_names.size(); ++i) { |
152 ListValue* name = new ListValue; // owned by |list| | 152 ListValue* name = new ListValue; // owned by |list| |
153 name->Set(0, Value::CreateStringValue(first_names[i])); | 153 name->Set(0, new base::StringValue(first_names[i])); |
154 name->Set(1, Value::CreateStringValue(middle_names[i])); | 154 name->Set(1, new base::StringValue(middle_names[i])); |
155 name->Set(2, Value::CreateStringValue(last_names[i])); | 155 name->Set(2, new base::StringValue(last_names[i])); |
156 (*names)->Set(i, name); | 156 (*names)->Set(i, name); |
157 } | 157 } |
158 } | 158 } |
159 | 159 |
160 // Set the multi-valued element for |type| from input |list| values. | 160 // Set the multi-valued element for |type| from input |list| values. |
161 void SetNameList(const ListValue* names, AutofillProfile* profile) { | 161 void SetNameList(const ListValue* names, AutofillProfile* profile) { |
162 const size_t size = names->GetSize(); | 162 const size_t size = names->GetSize(); |
163 std::vector<string16> first_names(size); | 163 std::vector<string16> first_names(size); |
164 std::vector<string16> middle_names(size); | 164 std::vector<string16> middle_names(size); |
165 std::vector<string16> last_names(size); | 165 std::vector<string16> last_names(size); |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 | 616 |
617 web_ui()->CallJavascriptFunction( | 617 web_ui()->CallJavascriptFunction( |
618 "AutofillEditAddressOverlay.setValidatedPhoneNumbers", *list_value); | 618 "AutofillEditAddressOverlay.setValidatedPhoneNumbers", *list_value); |
619 } | 619 } |
620 | 620 |
621 bool AutofillOptionsHandler::IsPersonalDataLoaded() const { | 621 bool AutofillOptionsHandler::IsPersonalDataLoaded() const { |
622 return personal_data_ && personal_data_->IsDataLoaded(); | 622 return personal_data_ && personal_data_->IsDataLoaded(); |
623 } | 623 } |
624 | 624 |
625 } // namespace options | 625 } // namespace options |
OLD | NEW |