| 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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 if (!FindCachedForm(form, &cached_submitted_form)) | 348 if (!FindCachedForm(form, &cached_submitted_form)) |
| 349 return false; | 349 return false; |
| 350 | 350 |
| 351 submitted_form->UpdateFromCache(*cached_submitted_form); | 351 submitted_form->UpdateFromCache(*cached_submitted_form); |
| 352 if (submitted_form->IsAutofillable()) | 352 if (submitted_form->IsAutofillable()) |
| 353 ImportFormData(*submitted_form); | 353 ImportFormData(*submitted_form); |
| 354 | 354 |
| 355 // Only upload server statistics and UMA metrics if at least some local data | 355 // Only upload server statistics and UMA metrics if at least some local data |
| 356 // is available to use as a baseline. | 356 // is available to use as a baseline. |
| 357 const std::vector<AutofillProfile*>& profiles = personal_data_->GetProfiles(); | 357 const std::vector<AutofillProfile*>& profiles = personal_data_->GetProfiles(); |
| 358 if (submitted_form->IsAutofillable()) { |
| 359 AutofillMetrics::LogNumberOfProfilesAtAutofillableFormSubmission( |
| 360 personal_data_->GetProfiles().size()); |
| 361 } |
| 358 const std::vector<CreditCard*>& credit_cards = | 362 const std::vector<CreditCard*>& credit_cards = |
| 359 personal_data_->GetCreditCards(); | 363 personal_data_->GetCreditCards(); |
| 360 if (!profiles.empty() || !credit_cards.empty()) { | 364 if (!profiles.empty() || !credit_cards.empty()) { |
| 361 // Copy the profile and credit card data, so that it can be accessed on a | 365 // Copy the profile and credit card data, so that it can be accessed on a |
| 362 // separate thread. | 366 // separate thread. |
| 363 std::vector<AutofillProfile> copied_profiles; | 367 std::vector<AutofillProfile> copied_profiles; |
| 364 copied_profiles.reserve(profiles.size()); | 368 copied_profiles.reserve(profiles.size()); |
| 365 for (std::vector<AutofillProfile*>::const_iterator it = profiles.begin(); | 369 for (std::vector<AutofillProfile*>::const_iterator it = profiles.begin(); |
| 366 it != profiles.end(); ++it) { | 370 it != profiles.end(); ++it) { |
| 367 copied_profiles.push_back(**it); | 371 copied_profiles.push_back(**it); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 } | 527 } |
| 524 | 528 |
| 525 // When filling credit card suggestions, the values and labels are | 529 // When filling credit card suggestions, the values and labels are |
| 526 // typically obfuscated, which makes detecting duplicates hard. Since | 530 // typically obfuscated, which makes detecting duplicates hard. Since |
| 527 // duplicates only tend to be a problem when filling address forms | 531 // duplicates only tend to be a problem when filling address forms |
| 528 // anyway, only don't de-dup credit card suggestions. | 532 // anyway, only don't de-dup credit card suggestions. |
| 529 if (!is_filling_credit_card) | 533 if (!is_filling_credit_card) |
| 530 RemoveDuplicateSuggestions(&suggestions); | 534 RemoveDuplicateSuggestions(&suggestions); |
| 531 | 535 |
| 532 // The first time we show suggestions on this page, log the number of | 536 // The first time we show suggestions on this page, log the number of |
| 533 // suggestions shown. | 537 // suggestions available. |
| 538 // TODO(mathp): Differentiate between number of suggestions available |
| 539 // (current metric) and number shown to the user. |
| 534 if (!has_logged_address_suggestions_count_ && !section_is_autofilled) { | 540 if (!has_logged_address_suggestions_count_ && !section_is_autofilled) { |
| 535 AutofillMetrics::LogAddressSuggestionsCount(suggestions.size()); | 541 AutofillMetrics::LogAddressSuggestionsCount(suggestions.size()); |
| 536 has_logged_address_suggestions_count_ = true; | 542 has_logged_address_suggestions_count_ = true; |
| 537 } | 543 } |
| 538 } | 544 } |
| 539 } | 545 } |
| 540 } | 546 } |
| 541 | 547 |
| 542 if (field.should_autocomplete) { | 548 if (field.should_autocomplete) { |
| 543 // Add the results from AutoComplete. They come back asynchronously, so we | 549 // Add the results from AutoComplete. They come back asynchronously, so we |
| (...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1389 return false; | 1395 return false; |
| 1390 | 1396 |
| 1391 // Disregard forms that we wouldn't ever autofill in the first place. | 1397 // Disregard forms that we wouldn't ever autofill in the first place. |
| 1392 if (!form.ShouldBeParsed()) | 1398 if (!form.ShouldBeParsed()) |
| 1393 return false; | 1399 return false; |
| 1394 | 1400 |
| 1395 return true; | 1401 return true; |
| 1396 } | 1402 } |
| 1397 | 1403 |
| 1398 } // namespace autofill | 1404 } // namespace autofill |
| OLD | NEW |