OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 for (size_t i = 0; i < lines.size(); ++i) { | 172 for (size_t i = 0; i < lines.size(); ++i) { |
173 std::string line = lines[i]; | 173 std::string line = lines[i]; |
174 | 174 |
175 if (line != kProfileSeparator) { | 175 if (line != kProfileSeparator) { |
176 // Add a field to the current profile. | 176 // Add a field to the current profile. |
177 size_t separator_pos = line.find(kFieldSeparator); | 177 size_t separator_pos = line.find(kFieldSeparator); |
178 ASSERT_NE(std::string::npos, separator_pos); | 178 ASSERT_NE(std::string::npos, separator_pos); |
179 string16 field_type = UTF8ToUTF16(line.substr(0, separator_pos)); | 179 string16 field_type = UTF8ToUTF16(line.substr(0, separator_pos)); |
180 string16 value = UTF8ToUTF16(line.substr(separator_pos + kFieldOffset)); | 180 string16 value = UTF8ToUTF16(line.substr(separator_pos + kFieldOffset)); |
181 | 181 |
182 webkit_glue::FormField field(field_type, | 182 webkit_glue::FormField field; |
183 field_type, | 183 field.label = field_type; |
184 value, | 184 field.name = field_type; |
185 ASCIIToUTF16("text"), | 185 field.value = value; |
186 WebKit::WebInputElement::defaultMaxLength(), | 186 field.form_control_type = ASCIIToUTF16("text"); |
187 false); | |
188 form.fields.push_back(field); | 187 form.fields.push_back(field); |
189 } | 188 } |
190 | 189 |
191 // The first line is always a profile separator, and the last profile is not | 190 // The first line is always a profile separator, and the last profile is not |
192 // followed by an explicit separator. | 191 // followed by an explicit separator. |
193 if ((i > 0 && line == kProfileSeparator) || i == lines.size() - 1) { | 192 if ((i > 0 && line == kProfileSeparator) || i == lines.size() - 1) { |
194 // Reached the end of a profile. Try to import it. | 193 // Reached the end of a profile. Try to import it. |
195 FormStructure form_structure(form); | 194 FormStructure form_structure(form); |
196 for (size_t i = 0; i < form_structure.field_count(); ++i) { | 195 for (size_t i = 0; i < form_structure.field_count(); ++i) { |
197 // Set the heuristic type for each field, which is currently serialized | 196 // Set the heuristic type for each field, which is currently serialized |
(...skipping 15 matching lines...) Expand all Loading... |
213 } | 212 } |
214 } | 213 } |
215 | 214 |
216 *merged_profiles = SerializeProfiles(personal_data_->web_profiles()); | 215 *merged_profiles = SerializeProfiles(personal_data_->web_profiles()); |
217 } | 216 } |
218 | 217 |
219 TEST_F(AutofillMergeTest, DataDrivenMergeProfiles) { | 218 TEST_F(AutofillMergeTest, DataDrivenMergeProfiles) { |
220 RunDataDrivenTest(GetInputDirectory(kTestName), GetOutputDirectory(kTestName), | 219 RunDataDrivenTest(GetInputDirectory(kTestName), GetOutputDirectory(kTestName), |
221 kFileNamePattern); | 220 kFileNamePattern); |
222 } | 221 } |
OLD | NEW |