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

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

Issue 2776223002: Adds UKM for autofill attributes in form_structure. (Closed)
Patch Set: Adds UKM for autofill attributes in form_structure. 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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 fields_.push_back(base::MakeUnique<AutofillField>(field, unique_name)); 326 fields_.push_back(base::MakeUnique<AutofillField>(field, unique_name));
326 } 327 }
327 328
328 form_signature_ = autofill::CalculateFormSignature(form); 329 form_signature_ = autofill::CalculateFormSignature(form);
329 // Do further processing on the fields, as needed. 330 // Do further processing on the fields, as needed.
330 ProcessExtractedFields(); 331 ProcessExtractedFields();
331 } 332 }
332 333
333 FormStructure::~FormStructure() {} 334 FormStructure::~FormStructure() {}
334 335
335 void FormStructure::DetermineHeuristicTypes() { 336 void FormStructure::DetermineHeuristicTypes(ukm::UkmService* ukm_service,
337 const GURL& url) {
336 const auto determine_heuristic_types_start_time = base::TimeTicks::Now(); 338 const auto determine_heuristic_types_start_time = base::TimeTicks::Now();
337 339
338 // First, try to detect field types based on each field's |autocomplete| 340 // First, try to detect field types based on each field's |autocomplete|
339 // attribute value. 341 // attribute value.
340 if (!was_parsed_for_autocomplete_attributes_) 342 if (!was_parsed_for_autocomplete_attributes_)
341 ParseFieldTypesFromAutocompleteAttributes(); 343 ParseFieldTypesFromAutocompleteAttributes();
342 344
343 // Then if there are enough active fields, and if we are dealing with either a 345 // Then if there are enough active fields, and if we are dealing with either a
344 // proper <form> or a <form>-less checkout, run the heuristics and server 346 // proper <form> or a <form>-less checkout, run the heuristics and server
345 // prediction routines. 347 // prediction routines.
346 if (active_field_count() >= kRequiredFieldsForPredictionRoutines && 348 if (active_field_count() >= kRequiredFieldsForPredictionRoutines &&
347 (is_form_tag_ || is_formless_checkout_)) { 349 (is_form_tag_ || is_formless_checkout_)) {
348 const FieldCandidatesMap field_type_map = 350 const FieldCandidatesMap field_type_map =
349 FormField::ParseFormFields(fields_, is_form_tag_); 351 FormField::ParseFormFields(fields_, is_form_tag_);
350 for (const auto& field : fields_) { 352 for (const auto& field : fields_) {
351 const auto iter = field_type_map.find(field->unique_name()); 353 const auto iter = field_type_map.find(field->unique_name());
352 if (iter != field_type_map.end()) 354 if (iter != field_type_map.end())
353 field->set_heuristic_type(iter->second.BestHeuristicType()); 355 field->set_heuristic_type(iter->second.BestHeuristicType());
354 } 356 }
355 } 357 }
356 358
357 UpdateAutofillCount(); 359 UpdateAutofillCount();
358 IdentifySections(has_author_specified_sections_); 360 IdentifySections(has_author_specified_sections_);
359 361
360 if (IsAutofillable()) { 362 if (IsAutofillable()) {
361 AutofillMetrics::LogDeveloperEngagementMetric( 363 AutofillMetrics::LogDeveloperEngagementMetric(
362 AutofillMetrics::FILLABLE_FORM_PARSED); 364 AutofillMetrics::FILLABLE_FORM_PARSED);
365 AutofillMetrics::LogDeveloperEngagementUkm(
366 ukm_service, url, AutofillMetrics::FILLABLE_FORM_PARSED);
363 if (has_author_specified_types_) { 367 if (has_author_specified_types_) {
364 AutofillMetrics::LogDeveloperEngagementMetric( 368 AutofillMetrics::LogDeveloperEngagementMetric(
365 AutofillMetrics::FILLABLE_FORM_CONTAINS_TYPE_HINTS); 369 AutofillMetrics::FILLABLE_FORM_CONTAINS_TYPE_HINTS);
370 AutofillMetrics::LogDeveloperEngagementUkm(
371 ukm_service, url, AutofillMetrics::FILLABLE_FORM_CONTAINS_TYPE_HINTS);
366 } 372 }
367 } 373 }
368 374
369 AutofillMetrics::LogDetermineHeuristicTypesTiming( 375 AutofillMetrics::LogDetermineHeuristicTypesTiming(
370 base::TimeTicks::Now() - determine_heuristic_types_start_time); 376 base::TimeTicks::Now() - determine_heuristic_types_start_time);
371 } 377 }
372 378
373 bool FormStructure::EncodeUploadRequest( 379 bool FormStructure::EncodeUploadRequest(
374 const ServerFieldTypeSet& available_field_types, 380 const ServerFieldTypeSet& available_field_types,
375 bool form_was_autofilled, 381 bool form_was_autofilled,
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after
1319 filtered_strings[0].at(prefix_len)) { 1325 filtered_strings[0].at(prefix_len)) {
1320 // Mismatch found. 1326 // Mismatch found.
1321 return filtered_strings[i].substr(0, prefix_len); 1327 return filtered_strings[i].substr(0, prefix_len);
1322 } 1328 }
1323 } 1329 }
1324 } 1330 }
1325 return filtered_strings[0]; 1331 return filtered_strings[0];
1326 } 1332 }
1327 1333
1328 } // namespace autofill 1334 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698