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

Side by Side Diff: components/autofill/core/browser/autofill_manager.cc

Issue 853523004: Autofill: Set requirements for number of recognized fields in an autofillable form (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 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 "components/autofill/core/browser/autofill_manager.h" 5 #include "components/autofill/core/browser/autofill_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <map> 10 #include <map>
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 base::Owned(submitted_form.release()), 379 base::Owned(submitted_form.release()),
380 forms_loaded_timestamps_[form], 380 forms_loaded_timestamps_[form],
381 initial_interaction_timestamp_, 381 initial_interaction_timestamp_,
382 timestamp)); 382 timestamp));
383 } 383 }
384 384
385 return true; 385 return true;
386 } 386 }
387 387
388 void AutofillManager::OnFormsSeen(const std::vector<FormData>& forms, 388 void AutofillManager::OnFormsSeen(const std::vector<FormData>& forms,
389 size_t unowned_form_index,
389 const TimeTicks& timestamp) { 390 const TimeTicks& timestamp) {
391 if (unowned_form_index > forms.size())
Evan Stade 2015/01/22 23:43:45 when does this happen?
Lei Zhang 2015/01/22 23:58:13 It shouldn't, but we can't trust the IPC from the
Evan Stade 2015/01/23 02:21:46 at least notreached() then? Can you get an IPC own
Lei Zhang 2015/01/23 06:59:47 ValidFormDataVector() below doesn't have a NOTREAC
392 return;
393
390 if (!IsValidFormDataVector(forms)) 394 if (!IsValidFormDataVector(forms))
391 return; 395 return;
392 396
393 if (!driver_->RendererIsAvailable()) 397 if (!driver_->RendererIsAvailable())
394 return; 398 return;
395 399
396 bool enabled = IsAutofillEnabled(); 400 bool enabled = IsAutofillEnabled();
397 if (!has_logged_autofill_enabled_) { 401 if (!has_logged_autofill_enabled_) {
398 AutofillMetrics::LogIsAutofillEnabledAtPageLoad(enabled); 402 AutofillMetrics::LogIsAutofillEnabledAtPageLoad(enabled);
399 has_logged_autofill_enabled_ = true; 403 has_logged_autofill_enabled_ = true;
400 } 404 }
401 405
402 if (!enabled) 406 if (!enabled)
403 return; 407 return;
404 408
405 for (size_t i = 0; i < forms.size(); ++i) { 409 for (size_t i = 0; i < forms.size(); ++i) {
406 forms_loaded_timestamps_[forms[i]] = timestamp; 410 forms_loaded_timestamps_[forms[i]] = timestamp;
407 } 411 }
408 412
409 ParseForms(forms); 413 ParseForms(forms, unowned_form_index);
410 } 414 }
411 415
412 void AutofillManager::OnTextFieldDidChange(const FormData& form, 416 void AutofillManager::OnTextFieldDidChange(const FormData& form,
413 const FormFieldData& field, 417 const FormFieldData& field,
414 const TimeTicks& timestamp) { 418 const TimeTicks& timestamp) {
415 if (!IsValidFormData(form) || !IsValidFormFieldData(field)) 419 if (!IsValidFormData(form) || !IsValidFormFieldData(field))
416 return; 420 return;
417 421
418 FormStructure* form_structure = NULL; 422 FormStructure* form_structure = NULL;
419 AutofillField* autofill_field = NULL; 423 AutofillField* autofill_field = NULL;
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 const AutofillType& type) const { 1208 const AutofillType& type) const {
1205 std::vector<Suggestion> suggestions = 1209 std::vector<Suggestion> suggestions =
1206 personal_data_->GetCreditCardSuggestions(type, field.value); 1210 personal_data_->GetCreditCardSuggestions(type, field.value);
1207 for (size_t i = 0; i < suggestions.size(); i++) { 1211 for (size_t i = 0; i < suggestions.size(); i++) {
1208 suggestions[i].frontend_id = 1212 suggestions[i].frontend_id =
1209 MakeFrontendID(suggestions[i].backend_id, SuggestionBackendID()); 1213 MakeFrontendID(suggestions[i].backend_id, SuggestionBackendID());
1210 } 1214 }
1211 return suggestions; 1215 return suggestions;
1212 } 1216 }
1213 1217
1214 void AutofillManager::ParseForms(const std::vector<FormData>& forms) { 1218 void AutofillManager::ParseForms(const std::vector<FormData>& forms,
1219 size_t unowned_form_index) {
1215 std::vector<FormStructure*> non_queryable_forms; 1220 std::vector<FormStructure*> non_queryable_forms;
1216 for (std::vector<FormData>::const_iterator iter = forms.begin(); 1221 for (size_t i = 0; i < forms.size(); ++i) {
1217 iter != forms.end(); ++iter) { 1222 scoped_ptr<FormStructure> form_structure(new FormStructure(forms[i]));
1218 scoped_ptr<FormStructure> form_structure(new FormStructure(*iter));
1219 if (!form_structure->ShouldBeParsed()) 1223 if (!form_structure->ShouldBeParsed())
1220 continue; 1224 continue;
1221 1225
1226 if (i == unowned_form_index)
1227 form_structure->set_is_unowned();
1228
1222 form_structure->DetermineHeuristicTypes(); 1229 form_structure->DetermineHeuristicTypes();
1223 1230
1224 if (form_structure->ShouldBeCrowdsourced()) 1231 if (form_structure->ShouldBeCrowdsourced())
1225 form_structures_.push_back(form_structure.release()); 1232 form_structures_.push_back(form_structure.release());
1226 else 1233 else
1227 non_queryable_forms.push_back(form_structure.release()); 1234 non_queryable_forms.push_back(form_structure.release());
1228 } 1235 }
1229 1236
1230 if (!form_structures_.empty() && download_manager_) { 1237 if (!form_structures_.empty() && download_manager_) {
1231 // Query the server if at least one of the forms was parsed. 1238 // Query the server if at least one of the forms was parsed.
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 return false; 1332 return false;
1326 1333
1327 // Disregard forms that we wouldn't ever autofill in the first place. 1334 // Disregard forms that we wouldn't ever autofill in the first place.
1328 if (!form.ShouldBeParsed()) 1335 if (!form.ShouldBeParsed())
1329 return false; 1336 return false;
1330 1337
1331 return true; 1338 return true;
1332 } 1339 }
1333 1340
1334 } // namespace autofill 1341 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698