Chromium Code Reviews| 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> |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 enum AutofillFormSubmittedState { | 88 enum AutofillFormSubmittedState { |
| 89 NON_FILLABLE_FORM_OR_NEW_DATA, | 89 NON_FILLABLE_FORM_OR_NEW_DATA, |
| 90 FILLABLE_FORM_AUTOFILLED_ALL, | 90 FILLABLE_FORM_AUTOFILLED_ALL, |
| 91 FILLABLE_FORM_AUTOFILLED_SOME, | 91 FILLABLE_FORM_AUTOFILLED_SOME, |
| 92 FILLABLE_FORM_AUTOFILLED_NONE_DID_SHOW_SUGGESTIONS, | 92 FILLABLE_FORM_AUTOFILLED_NONE_DID_SHOW_SUGGESTIONS, |
| 93 FILLABLE_FORM_AUTOFILLED_NONE_DID_NOT_SHOW_SUGGESTIONS, | 93 FILLABLE_FORM_AUTOFILLED_NONE_DID_NOT_SHOW_SUGGESTIONS, |
| 94 AUTOFILL_FORM_SUBMITTED_STATE_ENUM_SIZE, | 94 AUTOFILL_FORM_SUBMITTED_STATE_ENUM_SIZE, |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 enum CardUploadDecisionMetric { | 97 enum CardUploadDecisionMetric { |
| 98 // All the required conditions were satisfied and the card upload prompt was | 98 // Card upload prompt was triggered either because all the conditions were |
| 99 // triggered. | 99 // automatically satisfied or because we can potentially fix fields to |
| 100 UPLOAD_OFFERED, | 100 // satisfy some conditions. For example, requesting user to input CVC when |
| 101 // CVC was missing. See |UPLOAD_OFFERED_NO_CVC|. | |
| 102 UPLOAD_OFFERED = 1 << 0, | |
| 101 // No CVC was detected. We don't know whether any addresses were available | 103 // No CVC was detected. We don't know whether any addresses were available |
| 102 // nor whether we would have been able to get upload details. | 104 // nor whether we would have been able to get upload details. |
| 103 UPLOAD_NOT_OFFERED_NO_CVC, | 105 UPLOAD_NOT_OFFERED_NO_CVC = 1 << 1, |
| 104 // A CVC was detected but no recently created or used address was available. | 106 // A CVC was detected but no recently created or used address was available. |
| 105 // We don't know whether we would have been able to get upload details. | 107 // We don't know whether we would have been able to get upload details. |
| 106 UPLOAD_NOT_OFFERED_NO_ADDRESS, | 108 UPLOAD_NOT_OFFERED_NO_ADDRESS = 1 << 2, |
| 107 // A CVC and one or more addresses were available but no name was found on | 109 // A CVC and one or more addresses were available but no name was found on |
| 108 // either the card or the adress(es). We don't know whether the address(es) | 110 // either the card or the adress(es). We don't know whether the address(es) |
| 109 // were otherwise valid nor whether we would have been able to get upload | 111 // were otherwise valid nor whether we would have been able to get upload |
| 110 // details. | 112 // details. |
| 111 UPLOAD_NOT_OFFERED_NO_NAME, | 113 UPLOAD_NOT_OFFERED_NO_NAME = 1 << 3, |
| 112 // A CVC, multiple addresses, and a name were available but the adresses had | 114 // A CVC, multiple addresses, and a name were available but the adresses had |
| 113 // conflicting zip codes. We don't know whether we would have been able to | 115 // conflicting zip codes. We don't know whether we would have been able to |
| 114 // get upload details. | 116 // get upload details. |
| 115 UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS, | 117 UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS = 1 << 4, |
| 116 // A CVC, one or more addresses, and a name were available but no zip code | 118 // A CVC, one or more addresses, and a name were available but no zip code |
| 117 // was found on any of the adress(es). We don't know whether we would have | 119 // was found on any of the adress(es). We don't know whether we would have |
| 118 // been able to get upload details. | 120 // been able to get upload details. |
| 119 UPLOAD_NOT_OFFERED_NO_ZIP_CODE, | 121 UPLOAD_NOT_OFFERED_NO_ZIP_CODE = 1 << 5, |
| 120 // A CVC, one or more valid addresses, and a name were available but the | 122 // A CVC, one or more valid addresses, and a name were available but the |
| 121 // request to Payments for upload details failed. | 123 // request to Payments for upload details failed. |
| 122 UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED, | 124 UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED = 1 << 6, |
| 123 // A CVC and one or more addresses were available but the names on the card | 125 // A CVC and one or more addresses were available but the names on the card |
| 124 // and/or the addresses didn't match. We don't know whether the address(es) | 126 // and/or the addresses didn't match. We don't know whether the address(es) |
| 125 // were otherwise valid nor whether we would have been able to get upload | 127 // were otherwise valid nor whether we would have been able to get upload |
| 126 // details. | 128 // details. |
| 127 UPLOAD_NOT_OFFERED_CONFLICTING_NAMES, | 129 UPLOAD_NOT_OFFERED_CONFLICTING_NAMES = 1 << 7, |
| 128 // No CVC was detected, but valid addresses and names were. Upload is still | 130 // No CVC was detected, but valid addresses and names were. Upload is still |
| 129 // possible if the user manually enters CVC, so upload was offered. | 131 // possible if the user manually enters CVC, so upload was offered. |
| 130 UPLOAD_OFFERED_NO_CVC, | 132 UPLOAD_OFFERED_NO_CVC = 1 << 8, |
| 131 NUM_CARD_UPLOAD_DECISION_METRICS, | 133 // One or more of the required conditions were not satisfied and the card |
| 134 // upload prompt was not triggered. | |
| 135 UPLOAD_NOT_OFFERED = 1 << 9, | |
|
Steven Holte
2017/05/02 19:33:20
Does it make sense to simplify some of these bits?
csashi
2017/05/02 20:23:31
Done. There are no redundant bits now.
Our intent
| |
| 136 // Update |kNumCardUploadDecisionMetrics| when adding new enum here. | |
| 132 }; | 137 }; |
| 133 | 138 |
| 134 enum DeveloperEngagementMetric { | 139 enum DeveloperEngagementMetric { |
| 135 // Parsed a form that is potentially autofillable and does not contain any | 140 // Parsed a form that is potentially autofillable and does not contain any |
| 136 // web developer-specified field type hint. | 141 // web developer-specified field type hint. |
| 137 FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS = 0, | 142 FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS = 0, |
| 138 // Parsed a form that is potentially autofillable and contains at least one | 143 // Parsed a form that is potentially autofillable and contains at least one |
| 139 // web developer-specified field type hint, a la | 144 // web developer-specified field type hint, a la |
| 140 // http://is.gd/whatwg_autocomplete | 145 // http://is.gd/whatwg_autocomplete |
| 141 FILLABLE_FORM_PARSED_WITH_TYPE_HINTS, | 146 FILLABLE_FORM_PARSED_WITH_TYPE_HINTS, |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 638 bool CanLog() const; | 643 bool CanLog() const; |
| 639 int64_t MillisecondsSinceFormLoaded() const; | 644 int64_t MillisecondsSinceFormLoaded() const; |
| 640 void GetNewSourceID(); | 645 void GetNewSourceID(); |
| 641 | 646 |
| 642 ukm::UkmService* ukm_service_; // Weak reference. | 647 ukm::UkmService* ukm_service_; // Weak reference. |
| 643 int32_t source_id_ = -1; | 648 int32_t source_id_ = -1; |
| 644 GURL url_; | 649 GURL url_; |
| 645 base::TimeTicks form_loaded_timestamp_; | 650 base::TimeTicks form_loaded_timestamp_; |
| 646 }; | 651 }; |
| 647 | 652 |
| 648 static void LogCardUploadDecisionMetric(CardUploadDecisionMetric metric); | 653 // |upload_decision_metrics| is a bitmask of |CardUploadDecisionMetric|. |
| 654 static void LogCardUploadDecisionMetrics(int upload_decision_metrics); | |
| 649 static void LogCreditCardInfoBarMetric( | 655 static void LogCreditCardInfoBarMetric( |
| 650 InfoBarMetric metric, | 656 InfoBarMetric metric, |
| 651 bool is_uploading, | 657 bool is_uploading, |
| 652 int previous_save_credit_card_prompt_user_decision); | 658 int previous_save_credit_card_prompt_user_decision); |
| 653 static void LogCreditCardFillingInfoBarMetric(InfoBarMetric metric); | 659 static void LogCreditCardFillingInfoBarMetric(InfoBarMetric metric); |
| 654 static void LogSaveCardPromptMetric( | 660 static void LogSaveCardPromptMetric( |
| 655 SaveCardPromptMetric metric, | 661 SaveCardPromptMetric metric, |
| 656 bool is_uploading, | 662 bool is_uploading, |
| 657 bool is_reshow, | 663 bool is_reshow, |
| 658 int previous_save_credit_card_prompt_user_decision); | 664 int previous_save_credit_card_prompt_user_decision); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 797 static void LogIsQueriedCreditCardFormSecure(bool is_secure); | 803 static void LogIsQueriedCreditCardFormSecure(bool is_secure); |
| 798 | 804 |
| 799 // Log how the converted wallet address was added to the local autofill | 805 // Log how the converted wallet address was added to the local autofill |
| 800 // profiles. | 806 // profiles. |
| 801 static void LogWalletAddressConversionType(WalletAddressConversionType type); | 807 static void LogWalletAddressConversionType(WalletAddressConversionType type); |
| 802 | 808 |
| 803 // This should be called when the user selects the Form-Not-Secure warning | 809 // This should be called when the user selects the Form-Not-Secure warning |
| 804 // suggestion to show an explanation of the warning. | 810 // suggestion to show an explanation of the warning. |
| 805 static void LogShowedHttpNotSecureExplanation(); | 811 static void LogShowedHttpNotSecureExplanation(); |
| 806 | 812 |
| 807 // Logs the card upload decision ukm based on the specified |url| and | 813 // Logs the card upload decisions ukm for the specified |url|. |
| 808 // |upload_decision|. | 814 // |upload_decision_metrics| is a bitmask of |CardUploadDecisionMetric|. |
| 809 static void LogCardUploadDecisionUkm( | 815 static void LogCardUploadDecisionsUkm(ukm::UkmService* ukm_service, |
| 810 ukm::UkmService* ukm_service, | 816 const GURL& url, |
| 811 const GURL& url, | 817 int upload_decision_metrics); |
| 812 AutofillMetrics::CardUploadDecisionMetric upload_decision); | |
| 813 | 818 |
| 814 // Logs the developer engagement ukm for the specified |url| and autofill | 819 // Logs the developer engagement ukm for the specified |url| and autofill |
| 815 // fields in the form structure. | 820 // fields in the form structure. |developer_engagement_metrics| is a bitmask |
| 816 static void LogDeveloperEngagementUkm( | 821 // of |AutofillMetrics::DeveloperEngagementMetric|. |
| 817 ukm::UkmService* ukm_service, | 822 static void LogDeveloperEngagementUkm(ukm::UkmService* ukm_service, |
| 818 const GURL& url, | 823 const GURL& url, |
| 819 std::vector<AutofillMetrics::DeveloperEngagementMetric> metrics); | 824 int developer_engagement_metrics); |
| 820 | 825 |
| 821 // Logs the the |ukm_entry_name| with the specified |url| and the specified | 826 // Logs the the |ukm_entry_name| with the specified |url| and the specified |
| 822 // |metrics|. Returns whether the ukm was sucessfully logged. | 827 // |metrics|. Returns whether the ukm was sucessfully logged. |
| 823 static bool LogUkm(ukm::UkmService* ukm_service, | 828 static bool LogUkm(ukm::UkmService* ukm_service, |
| 824 const GURL& url, | 829 const GURL& url, |
| 825 const std::string& ukm_entry_name, | 830 const std::string& ukm_entry_name, |
| 826 const std::vector<std::pair<const char*, int>>& metrics); | 831 const std::vector<std::pair<const char*, int>>& metrics); |
| 827 | 832 |
| 828 // Utility to log autofill form events in the relevant histograms depending on | 833 // Utility to log autofill form events in the relevant histograms depending on |
| 829 // the presence of server and/or local data. | 834 // the presence of server and/or local data. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 879 bool logged_suggestion_filled_was_masked_server_card_; | 884 bool logged_suggestion_filled_was_masked_server_card_; |
| 880 | 885 |
| 881 // The last field that was polled for suggestions. | 886 // The last field that was polled for suggestions. |
| 882 FormFieldData last_polled_field_; | 887 FormFieldData last_polled_field_; |
| 883 | 888 |
| 884 FormInteractionsUkmLogger* | 889 FormInteractionsUkmLogger* |
| 885 form_interactions_ukm_logger_; // Weak reference. | 890 form_interactions_ukm_logger_; // Weak reference. |
| 886 }; | 891 }; |
| 887 | 892 |
| 888 private: | 893 private: |
| 894 static const int kNumCardUploadDecisionMetrics = 10; | |
| 895 | |
| 889 DISALLOW_IMPLICIT_CONSTRUCTORS(AutofillMetrics); | 896 DISALLOW_IMPLICIT_CONSTRUCTORS(AutofillMetrics); |
| 890 }; | 897 }; |
| 891 | 898 |
| 892 } // namespace autofill | 899 } // namespace autofill |
| 893 | 900 |
| 894 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_METRICS_H_ | 901 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_METRICS_H_ |
| OLD | NEW |