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 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_METRICS_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_METRICS_H_ |
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_METRICS_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_METRICS_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "components/autofill/core/browser/autofill_client.h" | 15 #include "components/autofill/core/browser/autofill_client.h" |
16 #include "components/autofill/core/browser/autofill_profile.h" | 16 #include "components/autofill/core/browser/autofill_profile.h" |
17 #include "components/autofill/core/browser/credit_card.h" | 17 #include "components/autofill/core/browser/credit_card.h" |
18 #include "components/autofill/core/browser/field_types.h" | 18 #include "components/autofill/core/browser/field_types.h" |
19 #include "components/autofill/core/common/autofill_pref_names.h" | 19 #include "components/autofill/core/common/autofill_pref_names.h" |
20 #include "components/autofill/core/common/form_field_data.h" | 20 #include "components/autofill/core/common/form_field_data.h" |
21 | 21 #include "components/ukm/public/ukm_recorder.h" |
22 namespace ukm { | |
23 class UkmService; | |
24 } // namespace ukm | |
25 | 22 |
26 namespace internal { | 23 namespace internal { |
27 // Name constants are exposed here so they can be referenced from tests. | 24 // Name constants are exposed here so they can be referenced from tests. |
28 extern const char kUKMCardUploadDecisionEntryName[]; | 25 extern const char kUKMCardUploadDecisionEntryName[]; |
29 extern const char kUKMCardUploadDecisionMetricName[]; | 26 extern const char kUKMCardUploadDecisionMetricName[]; |
30 extern const char kUKMDeveloperEngagementEntryName[]; | 27 extern const char kUKMDeveloperEngagementEntryName[]; |
31 extern const char kUKMDeveloperEngagementMetricName[]; | 28 extern const char kUKMDeveloperEngagementMetricName[]; |
32 | 29 |
33 // Each form interaction event has a separate |UkmEntry|. | 30 // Each form interaction event has a separate |UkmEntry|. |
34 | 31 |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 // The converted wallet address was merged into an existing local profile. | 614 // The converted wallet address was merged into an existing local profile. |
618 CONVERTED_ADDRESS_MERGED, | 615 CONVERTED_ADDRESS_MERGED, |
619 // The converted wallet address was added as a new local profile. | 616 // The converted wallet address was added as a new local profile. |
620 CONVERTED_ADDRESS_ADDED, | 617 CONVERTED_ADDRESS_ADDED, |
621 NUM_CONVERTED_ADDRESS_CONVERSION_TYPES | 618 NUM_CONVERTED_ADDRESS_CONVERSION_TYPES |
622 }; | 619 }; |
623 | 620 |
624 // Utility to log URL keyed form interaction events. | 621 // Utility to log URL keyed form interaction events. |
625 class FormInteractionsUkmLogger { | 622 class FormInteractionsUkmLogger { |
626 public: | 623 public: |
627 explicit FormInteractionsUkmLogger(ukm::UkmService* ukm_service); | 624 explicit FormInteractionsUkmLogger(ukm::UkmRecorder* ukm_recorder); |
628 | 625 |
629 const GURL& url() const { return url_; } | 626 const GURL& url() const { return url_; } |
630 | 627 |
631 void OnFormsParsed(const GURL& url); | 628 void OnFormsParsed(const GURL& url); |
632 void LogInteractedWithForm(bool is_for_credit_card, | 629 void LogInteractedWithForm(bool is_for_credit_card, |
633 size_t local_record_type_count, | 630 size_t local_record_type_count, |
634 size_t server_record_type_count); | 631 size_t server_record_type_count); |
635 void LogSuggestionsShown(); | 632 void LogSuggestionsShown(); |
636 void LogSelectedMaskedServerCard(); | 633 void LogSelectedMaskedServerCard(); |
637 void LogDidFillSuggestion(int record_type); | 634 void LogDidFillSuggestion(int record_type); |
638 void LogTextFieldDidChange(const AutofillField& field); | 635 void LogTextFieldDidChange(const AutofillField& field); |
639 void LogFormSubmitted(AutofillFormSubmittedState state); | 636 void LogFormSubmitted(AutofillFormSubmittedState state); |
640 | 637 |
641 // We initialize |url_| with the form's URL when we log the first form | 638 // We initialize |url_| with the form's URL when we log the first form |
642 // interaction. Later, we may update |url_| with the |source_url()| for the | 639 // interaction. Later, we may update |url_| with the |source_url()| for the |
643 // submitted form. | 640 // submitted form. |
644 void UpdateSourceURL(const GURL& url); | 641 void UpdateSourceURL(const GURL& url); |
645 | 642 |
646 private: | 643 private: |
647 bool CanLog() const; | 644 bool CanLog() const; |
648 int64_t MillisecondsSinceFormParsed() const; | 645 int64_t MillisecondsSinceFormParsed() const; |
649 void GetNewSourceID(); | 646 void GetNewSourceID(); |
650 | 647 |
651 ukm::UkmService* ukm_service_; // Weak reference. | 648 ukm::UkmRecorder* ukm_recorder_; // Weak reference. |
652 int32_t source_id_ = -1; | 649 ukm::SourceId source_id_ = -1; |
653 GURL url_; | 650 GURL url_; |
654 base::TimeTicks form_parsed_timestamp_; | 651 base::TimeTicks form_parsed_timestamp_; |
655 }; | 652 }; |
656 | 653 |
657 // |upload_decision_metrics| is a bitmask of |CardUploadDecisionMetric|. | 654 // |upload_decision_metrics| is a bitmask of |CardUploadDecisionMetric|. |
658 static void LogCardUploadDecisionMetrics(int upload_decision_metrics); | 655 static void LogCardUploadDecisionMetrics(int upload_decision_metrics); |
659 static void LogCreditCardInfoBarMetric( | 656 static void LogCreditCardInfoBarMetric( |
660 InfoBarMetric metric, | 657 InfoBarMetric metric, |
661 bool is_uploading, | 658 bool is_uploading, |
662 int previous_save_credit_card_prompt_user_decision); | 659 int previous_save_credit_card_prompt_user_decision); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
814 // Log how the converted wallet address was added to the local autofill | 811 // Log how the converted wallet address was added to the local autofill |
815 // profiles. | 812 // profiles. |
816 static void LogWalletAddressConversionType(WalletAddressConversionType type); | 813 static void LogWalletAddressConversionType(WalletAddressConversionType type); |
817 | 814 |
818 // This should be called when the user selects the Form-Not-Secure warning | 815 // This should be called when the user selects the Form-Not-Secure warning |
819 // suggestion to show an explanation of the warning. | 816 // suggestion to show an explanation of the warning. |
820 static void LogShowedHttpNotSecureExplanation(); | 817 static void LogShowedHttpNotSecureExplanation(); |
821 | 818 |
822 // Logs the card upload decisions ukm for the specified |url|. | 819 // Logs the card upload decisions ukm for the specified |url|. |
823 // |upload_decision_metrics| is a bitmask of |CardUploadDecisionMetric|. | 820 // |upload_decision_metrics| is a bitmask of |CardUploadDecisionMetric|. |
824 static void LogCardUploadDecisionsUkm(ukm::UkmService* ukm_service, | 821 static void LogCardUploadDecisionsUkm(ukm::UkmRecorder* ukm_recorder, |
825 const GURL& url, | 822 const GURL& url, |
826 int upload_decision_metrics); | 823 int upload_decision_metrics); |
827 | 824 |
828 // Logs the developer engagement ukm for the specified |url| and autofill | 825 // Logs the developer engagement ukm for the specified |url| and autofill |
829 // fields in the form structure. |developer_engagement_metrics| is a bitmask | 826 // fields in the form structure. |developer_engagement_metrics| is a bitmask |
830 // of |AutofillMetrics::DeveloperEngagementMetric|. | 827 // of |AutofillMetrics::DeveloperEngagementMetric|. |
831 static void LogDeveloperEngagementUkm(ukm::UkmService* ukm_service, | 828 static void LogDeveloperEngagementUkm(ukm::UkmRecorder* ukm_recorder, |
832 const GURL& url, | 829 const GURL& url, |
833 int developer_engagement_metrics); | 830 int developer_engagement_metrics); |
834 | 831 |
835 // Logs the the |ukm_entry_name| with the specified |url| and the specified | 832 // Logs the the |ukm_entry_name| with the specified |url| and the specified |
836 // |metrics|. Returns whether the ukm was sucessfully logged. | 833 // |metrics|. Returns whether the ukm was sucessfully logged. |
837 static bool LogUkm(ukm::UkmService* ukm_service, | 834 static bool LogUkm(ukm::UkmRecorder* ukm_recorder, |
838 const GURL& url, | 835 const GURL& url, |
839 const std::string& ukm_entry_name, | 836 const std::string& ukm_entry_name, |
840 const std::vector<std::pair<const char*, int>>& metrics); | 837 const std::vector<std::pair<const char*, int>>& metrics); |
841 | 838 |
842 // Utility to log autofill form events in the relevant histograms depending on | 839 // Utility to log autofill form events in the relevant histograms depending on |
843 // the presence of server and/or local data. | 840 // the presence of server and/or local data. |
844 class FormEventLogger { | 841 class FormEventLogger { |
845 public: | 842 public: |
846 FormEventLogger(bool is_for_credit_card, | 843 FormEventLogger(bool is_for_credit_card, |
847 FormInteractionsUkmLogger* form_interactions_ukm_logger); | 844 FormInteractionsUkmLogger* form_interactions_ukm_logger); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
901 | 898 |
902 private: | 899 private: |
903 static const int kNumCardUploadDecisionMetrics = 12; | 900 static const int kNumCardUploadDecisionMetrics = 12; |
904 | 901 |
905 DISALLOW_IMPLICIT_CONSTRUCTORS(AutofillMetrics); | 902 DISALLOW_IMPLICIT_CONSTRUCTORS(AutofillMetrics); |
906 }; | 903 }; |
907 | 904 |
908 } // namespace autofill | 905 } // namespace autofill |
909 | 906 |
910 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_METRICS_H_ | 907 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_METRICS_H_ |
OLD | NEW |