| OLD | NEW |
| 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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 // Don't save data that was submitted through JavaScript. | 332 // Don't save data that was submitted through JavaScript. |
| 333 if (!form.user_submitted) | 333 if (!form.user_submitted) |
| 334 return false; | 334 return false; |
| 335 | 335 |
| 336 // Ignore forms not present in our cache. These are typically forms with | 336 // Ignore forms not present in our cache. These are typically forms with |
| 337 // wonky JavaScript that also makes them not auto-fillable. | 337 // wonky JavaScript that also makes them not auto-fillable. |
| 338 FormStructure* cached_submitted_form; | 338 FormStructure* cached_submitted_form; |
| 339 if (!FindCachedForm(form, &cached_submitted_form)) | 339 if (!FindCachedForm(form, &cached_submitted_form)) |
| 340 return false; | 340 return false; |
| 341 | 341 |
| 342 const std::vector<AutofillProfile*>& profiles = personal_data_->GetProfiles(); |
| 343 const std::vector<CreditCard*>& credit_cards = |
| 344 personal_data_->GetCreditCards(); |
| 345 |
| 342 submitted_form->UpdateFromCache(*cached_submitted_form); | 346 submitted_form->UpdateFromCache(*cached_submitted_form); |
| 343 if (submitted_form->IsAutofillable()) | 347 if (submitted_form->IsAutofillable()) { |
| 344 ImportFormData(*submitted_form); | 348 ImportFormData(*submitted_form); |
| 345 | 349 |
| 350 AutofillMetrics::LogNumberOfProfilesAtFormSubmission(profiles.size()); |
| 351 } |
| 352 |
| 346 // Only upload server statistics and UMA metrics if at least some local data | 353 // Only upload server statistics and UMA metrics if at least some local data |
| 347 // is available to use as a baseline. | 354 // is available to use as a baseline. |
| 348 const std::vector<AutofillProfile*>& profiles = personal_data_->GetProfiles(); | |
| 349 const std::vector<CreditCard*>& credit_cards = | |
| 350 personal_data_->GetCreditCards(); | |
| 351 if (!profiles.empty() || !credit_cards.empty()) { | 355 if (!profiles.empty() || !credit_cards.empty()) { |
| 352 // Copy the profile and credit card data, so that it can be accessed on a | 356 // Copy the profile and credit card data, so that it can be accessed on a |
| 353 // separate thread. | 357 // separate thread. |
| 354 std::vector<AutofillProfile> copied_profiles; | 358 std::vector<AutofillProfile> copied_profiles; |
| 355 copied_profiles.reserve(profiles.size()); | 359 copied_profiles.reserve(profiles.size()); |
| 356 for (std::vector<AutofillProfile*>::const_iterator it = profiles.begin(); | 360 for (std::vector<AutofillProfile*>::const_iterator it = profiles.begin(); |
| 357 it != profiles.end(); ++it) { | 361 it != profiles.end(); ++it) { |
| 358 copied_profiles.push_back(**it); | 362 copied_profiles.push_back(**it); |
| 359 } | 363 } |
| 360 | 364 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 } | 504 } |
| 501 | 505 |
| 502 // When filling credit card suggestions, the values and labels are | 506 // When filling credit card suggestions, the values and labels are |
| 503 // typically obfuscated, which makes detecting duplicates hard. Since | 507 // typically obfuscated, which makes detecting duplicates hard. Since |
| 504 // duplicates only tend to be a problem when filling address forms | 508 // duplicates only tend to be a problem when filling address forms |
| 505 // anyway, only don't de-dup credit card suggestions. | 509 // anyway, only don't de-dup credit card suggestions. |
| 506 if (!is_filling_credit_card) | 510 if (!is_filling_credit_card) |
| 507 RemoveDuplicateSuggestions(&suggestions); | 511 RemoveDuplicateSuggestions(&suggestions); |
| 508 | 512 |
| 509 // The first time we show suggestions on this page, log the number of | 513 // The first time we show suggestions on this page, log the number of |
| 510 // suggestions shown. | 514 // suggestions available. |
| 515 // TODO(mathp): Differentiate between number of suggestions available |
| 516 // (current metric) and number shown to the user. |
| 511 if (!has_logged_address_suggestions_count_ && !section_is_autofilled) { | 517 if (!has_logged_address_suggestions_count_ && !section_is_autofilled) { |
| 512 AutofillMetrics::LogAddressSuggestionsCount(suggestions.size()); | 518 AutofillMetrics::LogAddressSuggestionsCount(suggestions.size()); |
| 513 has_logged_address_suggestions_count_ = true; | 519 has_logged_address_suggestions_count_ = true; |
| 514 } | 520 } |
| 515 } | 521 } |
| 516 } | 522 } |
| 517 } | 523 } |
| 518 | 524 |
| 519 if (field.should_autocomplete) { | 525 if (field.should_autocomplete) { |
| 520 // Add the results from AutoComplete. They come back asynchronously, so we | 526 // Add the results from AutoComplete. They come back asynchronously, so we |
| (...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1350 return false; | 1356 return false; |
| 1351 | 1357 |
| 1352 // Disregard forms that we wouldn't ever autofill in the first place. | 1358 // Disregard forms that we wouldn't ever autofill in the first place. |
| 1353 if (!form.ShouldBeParsed()) | 1359 if (!form.ShouldBeParsed()) |
| 1354 return false; | 1360 return false; |
| 1355 | 1361 |
| 1356 return true; | 1362 return true; |
| 1357 } | 1363 } |
| 1358 | 1364 |
| 1359 } // namespace autofill | 1365 } // namespace autofill |
| OLD | NEW |