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

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

Issue 2776223002: Adds UKM for autofill attributes in form_structure. (Closed)
Patch Set: Resolves merge conflicts with FORM_CONTAINS_UPI_VPA_HINT. 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/form_structure.h" 5 #include "components/autofill/core/browser/form_structure.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 18 matching lines...) Expand all
29 #include "components/autofill/core/browser/form_field.h" 29 #include "components/autofill/core/browser/form_field.h"
30 #include "components/autofill/core/common/autofill_constants.h" 30 #include "components/autofill/core/common/autofill_constants.h"
31 #include "components/autofill/core/common/autofill_util.h" 31 #include "components/autofill/core/common/autofill_util.h"
32 #include "components/autofill/core/common/form_data.h" 32 #include "components/autofill/core/common/form_data.h"
33 #include "components/autofill/core/common/form_data_predictions.h" 33 #include "components/autofill/core/common/form_data_predictions.h"
34 #include "components/autofill/core/common/form_field_data.h" 34 #include "components/autofill/core/common/form_field_data.h"
35 #include "components/autofill/core/common/form_field_data_predictions.h" 35 #include "components/autofill/core/common/form_field_data_predictions.h"
36 #include "components/autofill/core/common/signatures_util.h" 36 #include "components/autofill/core/common/signatures_util.h"
37 #include "components/rappor/public/rappor_utils.h" 37 #include "components/rappor/public/rappor_utils.h"
38 #include "components/rappor/rappor_service_impl.h" 38 #include "components/rappor/rappor_service_impl.h"
39 #include "components/ukm/ukm_service.h"
39 40
40 namespace autofill { 41 namespace autofill {
41 namespace { 42 namespace {
42 43
43 const char kClientVersion[] = "6.1.1715.1442/en (GGLL)"; 44 const char kClientVersion[] = "6.1.1715.1442/en (GGLL)";
44 const char kBillingMode[] = "billing"; 45 const char kBillingMode[] = "billing";
45 const char kShippingMode[] = "shipping"; 46 const char kShippingMode[] = "shipping";
46 47
47 // A form is considered to have a high prediction mismatch rate if the number of 48 // A form is considered to have a high prediction mismatch rate if the number of
48 // mismatches exceeds this threshold. 49 // mismatches exceeds this threshold.
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 fields_.push_back(base::MakeUnique<AutofillField>(field, unique_name)); 330 fields_.push_back(base::MakeUnique<AutofillField>(field, unique_name));
330 } 331 }
331 332
332 form_signature_ = autofill::CalculateFormSignature(form); 333 form_signature_ = autofill::CalculateFormSignature(form);
333 // Do further processing on the fields, as needed. 334 // Do further processing on the fields, as needed.
334 ProcessExtractedFields(); 335 ProcessExtractedFields();
335 } 336 }
336 337
337 FormStructure::~FormStructure() {} 338 FormStructure::~FormStructure() {}
338 339
339 void FormStructure::DetermineHeuristicTypes() { 340 void FormStructure::DetermineHeuristicTypes(ukm::UkmService* ukm_service) {
340 const auto determine_heuristic_types_start_time = base::TimeTicks::Now(); 341 const auto determine_heuristic_types_start_time = base::TimeTicks::Now();
341 342
342 // First, try to detect field types based on each field's |autocomplete| 343 // First, try to detect field types based on each field's |autocomplete|
343 // attribute value. 344 // attribute value.
344 if (!was_parsed_for_autocomplete_attributes_) 345 if (!was_parsed_for_autocomplete_attributes_)
345 ParseFieldTypesFromAutocompleteAttributes(); 346 ParseFieldTypesFromAutocompleteAttributes();
346 347
347 // Then if there are enough active fields, and if we are dealing with either a 348 // Then if there are enough active fields, and if we are dealing with either a
348 // proper <form> or a <form>-less checkout, run the heuristics and server 349 // proper <form> or a <form>-less checkout, run the heuristics and server
349 // prediction routines. 350 // prediction routines.
350 if (active_field_count() >= kRequiredFieldsForPredictionRoutines && 351 if (active_field_count() >= kRequiredFieldsForPredictionRoutines &&
351 (is_form_tag_ || is_formless_checkout_)) { 352 (is_form_tag_ || is_formless_checkout_)) {
352 const FieldCandidatesMap field_type_map = 353 const FieldCandidatesMap field_type_map =
353 FormField::ParseFormFields(fields_, is_form_tag_); 354 FormField::ParseFormFields(fields_, is_form_tag_);
354 for (const auto& field : fields_) { 355 for (const auto& field : fields_) {
355 const auto iter = field_type_map.find(field->unique_name()); 356 const auto iter = field_type_map.find(field->unique_name());
356 if (iter != field_type_map.end()) 357 if (iter != field_type_map.end())
357 field->set_heuristic_type(iter->second.BestHeuristicType()); 358 field->set_heuristic_type(iter->second.BestHeuristicType());
358 } 359 }
359 } 360 }
360 361
361 UpdateAutofillCount(); 362 UpdateAutofillCount();
362 IdentifySections(has_author_specified_sections_); 363 IdentifySections(has_author_specified_sections_);
363 364
364 if (IsAutofillable()) { 365 if (IsAutofillable()) {
365 AutofillMetrics::LogDeveloperEngagementMetric( 366 const auto metric =
366 AutofillMetrics::FILLABLE_FORM_PARSED); 367 has_author_specified_types_
367 if (has_author_specified_types_) { 368 ? AutofillMetrics::FILLABLE_FORM_PARSED_WITH_TYPE_HINTS
368 AutofillMetrics::LogDeveloperEngagementMetric( 369 : AutofillMetrics::FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS;
369 AutofillMetrics::FILLABLE_FORM_CONTAINS_TYPE_HINTS); 370 AutofillMetrics::LogDeveloperEngagementMetric(metric);
370 } 371 AutofillMetrics::LogDeveloperEngagementUkm(ukm_service, source_url(),
372 metric);
371 } 373 }
372 374
373 if (has_author_specified_upi_vpa_hint_) { 375 if (has_author_specified_upi_vpa_hint_) {
374 AutofillMetrics::LogDeveloperEngagementMetric( 376 AutofillMetrics::LogDeveloperEngagementMetric(
375 AutofillMetrics::FORM_CONTAINS_UPI_VPA_HINT); 377 AutofillMetrics::FORM_CONTAINS_UPI_VPA_HINT);
376 } 378 }
377 379
378 AutofillMetrics::LogDetermineHeuristicTypesTiming( 380 AutofillMetrics::LogDetermineHeuristicTypesTiming(
379 base::TimeTicks::Now() - determine_heuristic_types_start_time); 381 base::TimeTicks::Now() - determine_heuristic_types_start_time);
380 } 382 }
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 filtered_strings[0].at(prefix_len)) { 1336 filtered_strings[0].at(prefix_len)) {
1335 // Mismatch found. 1337 // Mismatch found.
1336 return filtered_strings[i].substr(0, prefix_len); 1338 return filtered_strings[i].substr(0, prefix_len);
1337 } 1339 }
1338 } 1340 }
1339 } 1341 }
1340 return filtered_strings[0]; 1342 return filtered_strings[0];
1341 } 1343 }
1342 1344
1343 } // namespace autofill 1345 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/form_structure.h ('k') | components/autofill/core/browser/form_structure_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698