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

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

Issue 2839063004: [Autofill] UKM for suggestions polled field. (Closed)
Patch Set: Address comments. Created 3 years, 8 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 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 if (is_autofill_possible && 598 if (is_autofill_possible &&
599 driver_->RendererIsAvailable() && 599 driver_->RendererIsAvailable() &&
600 got_autofillable_form) { 600 got_autofillable_form) {
601 // On desktop, don't return non credit card related suggestions for forms or 601 // On desktop, don't return non credit card related suggestions for forms or
602 // fields that have the "autocomplete" attribute set to off. 602 // fields that have the "autocomplete" attribute set to off.
603 if (IsDesktopPlatform() && !is_filling_credit_card && 603 if (IsDesktopPlatform() && !is_filling_credit_card &&
604 !field.should_autocomplete) { 604 !field.should_autocomplete) {
605 return; 605 return;
606 } 606 }
607 if (is_filling_credit_card) { 607 if (is_filling_credit_card) {
608 suggestions = GetCreditCardSuggestions(field, autofill_field->Type()); 608 suggestions = GetCreditCardSuggestions(field, *autofill_field);
609 } else { 609 } else {
610 suggestions = 610 suggestions =
611 GetProfileSuggestions(*form_structure, field, *autofill_field); 611 GetProfileSuggestions(*form_structure, field, *autofill_field);
612 } 612 }
613 613
614 if (!suggestions.empty()) { 614 if (!suggestions.empty()) {
615 if (is_filling_credit_card) 615 if (is_filling_credit_card)
616 AutofillMetrics::LogIsQueriedCreditCardFormSecure(is_context_secure); 616 AutofillMetrics::LogIsQueriedCreditCardFormSecure(is_context_secure);
617 617
618 // Don't provide credit card suggestions for non-secure pages, but do 618 // Don't provide credit card suggestions for non-secure pages, but do
(...skipping 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1856 // Annotate the updated form with its predicted types. 1856 // Annotate the updated form with its predicted types.
1857 driver_->SendAutofillTypePredictionsToRenderer({*updated_form}); 1857 driver_->SendAutofillTypePredictionsToRenderer({*updated_form});
1858 1858
1859 return true; 1859 return true;
1860 } 1860 }
1861 1861
1862 std::vector<Suggestion> AutofillManager::GetProfileSuggestions( 1862 std::vector<Suggestion> AutofillManager::GetProfileSuggestions(
1863 const FormStructure& form, 1863 const FormStructure& form,
1864 const FormFieldData& field, 1864 const FormFieldData& field,
1865 const AutofillField& autofill_field) const { 1865 const AutofillField& autofill_field) const {
1866 address_form_event_logger_->OnDidPollSuggestions(field); 1866 address_form_event_logger_->OnDidPollSuggestions(field, autofill_field);
1867 1867
1868 std::vector<ServerFieldType> field_types(form.field_count()); 1868 std::vector<ServerFieldType> field_types(form.field_count());
1869 for (size_t i = 0; i < form.field_count(); ++i) { 1869 for (size_t i = 0; i < form.field_count(); ++i) {
1870 field_types.push_back(form.field(i)->Type().GetStorableType()); 1870 field_types.push_back(form.field(i)->Type().GetStorableType());
1871 } 1871 }
1872 1872
1873 std::vector<Suggestion> suggestions = personal_data_->GetProfileSuggestions( 1873 std::vector<Suggestion> suggestions = personal_data_->GetProfileSuggestions(
1874 autofill_field.Type(), field.value, field.is_autofilled, field_types); 1874 autofill_field.Type(), field.value, field.is_autofilled, field_types);
1875 1875
1876 // Adjust phone number to display in prefix/suffix case. 1876 // Adjust phone number to display in prefix/suffix case.
1877 if (autofill_field.Type().GetStorableType() == PHONE_HOME_NUMBER) { 1877 if (autofill_field.Type().GetStorableType() == PHONE_HOME_NUMBER) {
1878 for (size_t i = 0; i < suggestions.size(); ++i) { 1878 for (size_t i = 0; i < suggestions.size(); ++i) {
1879 suggestions[i].value = AutofillField::GetPhoneNumberValue( 1879 suggestions[i].value = AutofillField::GetPhoneNumberValue(
1880 autofill_field, suggestions[i].value, field); 1880 autofill_field, suggestions[i].value, field);
1881 } 1881 }
1882 } 1882 }
1883 1883
1884 for (size_t i = 0; i < suggestions.size(); ++i) { 1884 for (size_t i = 0; i < suggestions.size(); ++i) {
1885 suggestions[i].frontend_id = 1885 suggestions[i].frontend_id =
1886 MakeFrontendID(std::string(), suggestions[i].backend_id); 1886 MakeFrontendID(std::string(), suggestions[i].backend_id);
1887 } 1887 }
1888 return suggestions; 1888 return suggestions;
1889 } 1889 }
1890 1890
1891 std::vector<Suggestion> AutofillManager::GetCreditCardSuggestions( 1891 std::vector<Suggestion> AutofillManager::GetCreditCardSuggestions(
1892 const FormFieldData& field, 1892 const FormFieldData& field,
1893 const AutofillType& type) const { 1893 const AutofillField& autofill_field) const {
1894 credit_card_form_event_logger_->OnDidPollSuggestions(field); 1894 credit_card_form_event_logger_->OnDidPollSuggestions(field, autofill_field);
1895 1895
1896 // The field value is sanitized before attempting to match it to the user's 1896 // The field value is sanitized before attempting to match it to the user's
1897 // data. 1897 // data.
1898 std::vector<Suggestion> suggestions = 1898 std::vector<Suggestion> suggestions =
1899 personal_data_->GetCreditCardSuggestions( 1899 personal_data_->GetCreditCardSuggestions(
1900 type, SanitizeCreditCardFieldValue(field.value)); 1900 autofill_field.Type(), SanitizeCreditCardFieldValue(field.value));
1901 for (size_t i = 0; i < suggestions.size(); i++) { 1901 for (size_t i = 0; i < suggestions.size(); i++) {
1902 suggestions[i].frontend_id = 1902 suggestions[i].frontend_id =
1903 MakeFrontendID(suggestions[i].backend_id, std::string()); 1903 MakeFrontendID(suggestions[i].backend_id, std::string());
1904 suggestions[i].is_value_bold = IsCreditCardPopupValueBold(); 1904 suggestions[i].is_value_bold = IsCreditCardPopupValueBold();
1905 } 1905 }
1906 return suggestions; 1906 return suggestions;
1907 } 1907 }
1908 1908
1909 void AutofillManager::ParseForms(const std::vector<FormData>& forms) { 1909 void AutofillManager::ParseForms(const std::vector<FormData>& forms) {
1910 if (forms.empty()) 1910 if (forms.empty())
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
2259 } 2259 }
2260 #endif // ENABLE_FORM_DEBUG_DUMP 2260 #endif // ENABLE_FORM_DEBUG_DUMP
2261 2261
2262 void AutofillManager::LogCardUploadDecisionUkm( 2262 void AutofillManager::LogCardUploadDecisionUkm(
2263 AutofillMetrics::CardUploadDecisionMetric upload_decision) { 2263 AutofillMetrics::CardUploadDecisionMetric upload_decision) {
2264 AutofillMetrics::LogCardUploadDecisionUkm( 2264 AutofillMetrics::LogCardUploadDecisionUkm(
2265 client_->GetUkmService(), pending_upload_request_url_, upload_decision); 2265 client_->GetUkmService(), pending_upload_request_url_, upload_decision);
2266 } 2266 }
2267 2267
2268 } // namespace autofill 2268 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698