Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(713)

Side by Side Diff: components/autofill/content/renderer/password_form_conversion_utils_browsertest.cc

Issue 2611453002: Remove ScopedVector from autofill::FormStructure (Closed)
Patch Set: Fix ios build Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 LoadWebFormFromHTML(html, &form); 206 LoadWebFormFromHTML(html, &form);
207 207
208 FormData form_data; 208 FormData form_data;
209 ASSERT_TRUE(form_util::WebFormElementToFormData( 209 ASSERT_TRUE(form_util::WebFormElementToFormData(
210 form, WebFormControlElement(), nullptr, form_util::EXTRACT_NONE, 210 form, WebFormControlElement(), nullptr, form_util::EXTRACT_NONE,
211 &form_data, nullptr)); 211 &form_data, nullptr));
212 212
213 FormStructure form_structure(form_data); 213 FormStructure form_structure(form_data);
214 214
215 int field_index = 0; 215 int field_index = 0;
216 for (std::vector<AutofillField *>::const_iterator 216 for (const auto& field : form_structure) {
217 field = form_structure.begin();
218 field != form_structure.end(); ++field, ++field_index) {
219 if (predictions_positions.find(field_index) != 217 if (predictions_positions.find(field_index) !=
220 predictions_positions.end()) { 218 predictions_positions.end()) {
221 (*predictions)[form_data][*(*field)] = 219 (*predictions)[form_data][*field] =
222 predictions_positions.find(field_index)->second; 220 predictions_positions.find(field_index)->second;
223 } 221 }
222 ++field_index;
224 } 223 }
225 } 224 }
226 225
227 // Loads the given |html| and retrieves the sole WebFormElement from it. 226 // Loads the given |html| and retrieves the sole WebFormElement from it.
228 void LoadWebFormFromHTML(const std::string& html, WebFormElement* form) { 227 void LoadWebFormFromHTML(const std::string& html, WebFormElement* form) {
229 LoadHTML(html.c_str()); 228 LoadHTML(html.c_str());
230 229
231 WebFrame* frame = GetMainFrame(); 230 WebFrame* frame = GetMainFrame();
232 ASSERT_NE(nullptr, frame); 231 ASSERT_NE(nullptr, frame);
233 232
(...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1454 builder.AddPasswordField("password", "secret", nullptr); 1453 builder.AddPasswordField("password", "secret", nullptr);
1455 std::string html = builder.ProduceHTML(); 1454 std::string html = builder.ProduceHTML();
1456 1455
1457 std::unique_ptr<PasswordForm> password_form = 1456 std::unique_ptr<PasswordForm> password_form =
1458 LoadHTMLAndConvertForm(html, nullptr, true); 1457 LoadHTMLAndConvertForm(html, nullptr, true);
1459 ASSERT_TRUE(password_form); 1458 ASSERT_TRUE(password_form);
1460 EXPECT_FALSE(password_form->does_look_like_signup_form); 1459 EXPECT_FALSE(password_form->does_look_like_signup_form);
1461 } 1460 }
1462 1461
1463 } // namespace autofill 1462 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698