| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CHROME_BROWSER_PERMISSIONS_PERMISSION_UMA_UTIL_H_ | 5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_UMA_UTIL_H_ |
| 6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_UMA_UTIL_H_ | 6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_UMA_UTIL_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "chrome/browser/permissions/permission_request.h" | 13 #include "chrome/browser/permissions/permission_request.h" |
| 14 #include "chrome/browser/permissions/permission_util.h" | 14 #include "chrome/browser/permissions/permission_util.h" |
| 15 | 15 |
| 16 enum class PermissionRequestGestureType; | 16 enum class PermissionRequestGestureType; |
| 17 class GURL; | 17 class GURL; |
| 18 class PermissionRequest; | 18 class PermissionRequest; |
| 19 class Profile; | 19 class Profile; |
| 20 | 20 |
| 21 namespace content { | |
| 22 enum class PermissionType; | |
| 23 } // namespace content | |
| 24 | |
| 25 // This should stay in sync with the SourceUI enum in the permission report | 21 // This should stay in sync with the SourceUI enum in the permission report |
| 26 // protobuf (src/chrome/common/safe_browsing/permission_report.proto). | 22 // protobuf (src/chrome/common/safe_browsing/permission_report.proto). |
| 27 enum class PermissionSourceUI { | 23 enum class PermissionSourceUI { |
| 28 PROMPT = 0, | 24 PROMPT = 0, |
| 29 OIB = 1, | 25 OIB = 1, |
| 30 SITE_SETTINGS = 2, | 26 SITE_SETTINGS = 2, |
| 31 PAGE_ACTION = 3, | 27 PAGE_ACTION = 3, |
| 32 | 28 |
| 33 // Always keep this at the end. | 29 // Always keep this at the end. |
| 34 SOURCE_UI_NUM, | 30 SOURCE_UI_NUM, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 49 BLACKLISTED = 2, | 45 BLACKLISTED = 2, |
| 50 | 46 |
| 51 // Always keep this at the end. | 47 // Always keep this at the end. |
| 52 RESPONSE_NUM, | 48 RESPONSE_NUM, |
| 53 }; | 49 }; |
| 54 | 50 |
| 55 // A bundle for the information sent in a PermissionReport. | 51 // A bundle for the information sent in a PermissionReport. |
| 56 struct PermissionReportInfo { | 52 struct PermissionReportInfo { |
| 57 PermissionReportInfo( | 53 PermissionReportInfo( |
| 58 const GURL& origin, | 54 const GURL& origin, |
| 59 content::PermissionType permission, | 55 ContentSettingsType permission, |
| 60 PermissionAction action, | 56 PermissionAction action, |
| 61 PermissionSourceUI source_ui, | 57 PermissionSourceUI source_ui, |
| 62 PermissionRequestGestureType gesture_type, | 58 PermissionRequestGestureType gesture_type, |
| 63 PermissionPersistDecision persist_decision, | 59 PermissionPersistDecision persist_decision, |
| 64 int num_prior_dismissals, | 60 int num_prior_dismissals, |
| 65 int num_prior_ignores); | 61 int num_prior_ignores); |
| 66 | 62 |
| 67 PermissionReportInfo(const PermissionReportInfo& other); | 63 PermissionReportInfo(const PermissionReportInfo& other); |
| 68 | 64 |
| 69 GURL origin; | 65 GURL origin; |
| 70 content::PermissionType permission; | 66 ContentSettingsType permission; |
| 71 PermissionAction action; | 67 PermissionAction action; |
| 72 PermissionSourceUI source_ui; | 68 PermissionSourceUI source_ui; |
| 73 PermissionRequestGestureType gesture_type; | 69 PermissionRequestGestureType gesture_type; |
| 74 PermissionPersistDecision persist_decision; | 70 PermissionPersistDecision persist_decision; |
| 75 int num_prior_dismissals; | 71 int num_prior_dismissals; |
| 76 int num_prior_ignores; | 72 int num_prior_ignores; |
| 77 }; | 73 }; |
| 78 | 74 |
| 79 // Provides a convenient way of logging UMA for permission related operations. | 75 // Provides a convenient way of logging UMA for permission related operations. |
| 80 class PermissionUmaUtil { | 76 class PermissionUmaUtil { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 94 static const char kPermissionsPromptMergedBubbleDenied[]; | 90 static const char kPermissionsPromptMergedBubbleDenied[]; |
| 95 static const char kPermissionsPromptAcceptedPriorDismissCountPrefix[]; | 91 static const char kPermissionsPromptAcceptedPriorDismissCountPrefix[]; |
| 96 static const char kPermissionsPromptAcceptedPriorIgnoreCountPrefix[]; | 92 static const char kPermissionsPromptAcceptedPriorIgnoreCountPrefix[]; |
| 97 static const char kPermissionsPromptDeniedPriorDismissCountPrefix[]; | 93 static const char kPermissionsPromptDeniedPriorDismissCountPrefix[]; |
| 98 static const char kPermissionsPromptDeniedPriorIgnoreCountPrefix[]; | 94 static const char kPermissionsPromptDeniedPriorIgnoreCountPrefix[]; |
| 99 static const char kPermissionsPromptDismissedPriorDismissCountPrefix[]; | 95 static const char kPermissionsPromptDismissedPriorDismissCountPrefix[]; |
| 100 static const char kPermissionsPromptDismissedPriorIgnoreCountPrefix[]; | 96 static const char kPermissionsPromptDismissedPriorIgnoreCountPrefix[]; |
| 101 static const char kPermissionsPromptIgnoredPriorDismissCountPrefix[]; | 97 static const char kPermissionsPromptIgnoredPriorDismissCountPrefix[]; |
| 102 static const char kPermissionsPromptIgnoredPriorIgnoreCountPrefix[]; | 98 static const char kPermissionsPromptIgnoredPriorIgnoreCountPrefix[]; |
| 103 | 99 |
| 100 // TODO(timloh): Remove this content::PermissionType overload when we add MIDI |
| 101 // to ContentSettingsType. |
| 104 static void PermissionRequested(content::PermissionType permission, | 102 static void PermissionRequested(content::PermissionType permission, |
| 105 const GURL& requesting_origin, | 103 const GURL& requesting_origin, |
| 106 const GURL& embedding_origin, | 104 const GURL& embedding_origin, |
| 107 Profile* profile); | 105 Profile* profile); |
| 108 static void PermissionGranted(content::PermissionType permission, | 106 static void PermissionRequested(ContentSettingsType permission, |
| 107 const GURL& requesting_origin, |
| 108 const GURL& embedding_origin, |
| 109 Profile* profile); |
| 110 static void PermissionGranted(ContentSettingsType permission, |
| 109 PermissionRequestGestureType gesture_type, | 111 PermissionRequestGestureType gesture_type, |
| 110 const GURL& requesting_origin, | 112 const GURL& requesting_origin, |
| 111 Profile* profile); | 113 Profile* profile); |
| 112 static void PermissionDenied(content::PermissionType permission, | 114 static void PermissionDenied(ContentSettingsType permission, |
| 113 PermissionRequestGestureType gesture_type, | 115 PermissionRequestGestureType gesture_type, |
| 114 const GURL& requesting_origin, | 116 const GURL& requesting_origin, |
| 115 Profile* profile); | 117 Profile* profile); |
| 116 static void PermissionDismissed(content::PermissionType permission, | 118 static void PermissionDismissed(ContentSettingsType permission, |
| 117 PermissionRequestGestureType gesture_type, | 119 PermissionRequestGestureType gesture_type, |
| 118 const GURL& requesting_origin, | 120 const GURL& requesting_origin, |
| 119 Profile* profile); | 121 Profile* profile); |
| 120 static void PermissionIgnored(content::PermissionType permission, | 122 static void PermissionIgnored(ContentSettingsType permission, |
| 121 PermissionRequestGestureType gesture_type, | 123 PermissionRequestGestureType gesture_type, |
| 122 const GURL& requesting_origin, | 124 const GURL& requesting_origin, |
| 123 Profile* profile); | 125 Profile* profile); |
| 124 static void PermissionRevoked(content::PermissionType permission, | 126 static void PermissionRevoked(ContentSettingsType permission, |
| 125 PermissionSourceUI source_ui, | 127 PermissionSourceUI source_ui, |
| 126 const GURL& revoked_origin, | 128 const GURL& revoked_origin, |
| 127 Profile* profile); | 129 Profile* profile); |
| 128 static void RecordSafeBrowsingResponse(base::TimeDelta response_time, | 130 static void RecordSafeBrowsingResponse(base::TimeDelta response_time, |
| 129 SafeBrowsingResponse response); | 131 SafeBrowsingResponse response); |
| 130 // UMA specifically for when permission prompts are shown. This should be | 132 // UMA specifically for when permission prompts are shown. This should be |
| 131 // roughly equivalent to the metrics above, however it is | 133 // roughly equivalent to the metrics above, however it is |
| 132 // useful to have separate UMA to a few reasons: | 134 // useful to have separate UMA to a few reasons: |
| 133 // - to account for, and get data on coalesced permission bubbles | 135 // - to account for, and get data on coalesced permission bubbles |
| 134 // - there are other types of permissions prompts (e.g. download limiting) | 136 // - there are other types of permissions prompts (e.g. download limiting) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 163 PermissionRequestGestureType gesture_type); | 165 PermissionRequestGestureType gesture_type); |
| 164 | 166 |
| 165 static void RecordPermissionPromptDenied( | 167 static void RecordPermissionPromptDenied( |
| 166 PermissionRequestType request_type, | 168 PermissionRequestType request_type, |
| 167 PermissionRequestGestureType gesture_type); | 169 PermissionRequestGestureType gesture_type); |
| 168 | 170 |
| 169 // A permission prompt was accepted or denied, and the prompt displayed a | 171 // A permission prompt was accepted or denied, and the prompt displayed a |
| 170 // persistence toggle. Records whether the toggle was enabled (persist) or | 172 // persistence toggle. Records whether the toggle was enabled (persist) or |
| 171 // disabled (don't persist). | 173 // disabled (don't persist). |
| 172 static void PermissionPromptAcceptedWithPersistenceToggle( | 174 static void PermissionPromptAcceptedWithPersistenceToggle( |
| 173 content::PermissionType permission, | 175 ContentSettingsType permission, |
| 174 bool toggle_enabled); | 176 bool toggle_enabled); |
| 175 | 177 |
| 176 static void PermissionPromptDeniedWithPersistenceToggle( | 178 static void PermissionPromptDeniedWithPersistenceToggle( |
| 177 content::PermissionType permission, | 179 ContentSettingsType permission, |
| 178 bool toggle_enabled); | 180 bool toggle_enabled); |
| 179 | 181 |
| 180 private: | 182 private: |
| 181 friend class PermissionUmaUtilTest; | 183 friend class PermissionUmaUtilTest; |
| 182 | 184 |
| 183 static bool IsOptedIntoPermissionActionReporting(Profile* profile); | 185 static bool IsOptedIntoPermissionActionReporting(Profile* profile); |
| 184 | 186 |
| 185 static void RecordPermissionAction(content::PermissionType permission, | 187 static void RecordPermissionAction(ContentSettingsType permission, |
| 186 PermissionAction action, | 188 PermissionAction action, |
| 187 PermissionSourceUI source_ui, | 189 PermissionSourceUI source_ui, |
| 188 PermissionRequestGestureType gesture_type, | 190 PermissionRequestGestureType gesture_type, |
| 189 const GURL& requesting_origin, | 191 const GURL& requesting_origin, |
| 190 Profile* profile); | 192 Profile* profile); |
| 191 | 193 |
| 192 // Records |count| total prior actions for a prompt of type |permission| | 194 // Records |count| total prior actions for a prompt of type |permission| |
| 193 // for a single origin using |prefix| for the metric. | 195 // for a single origin using |prefix| for the metric. |
| 194 static void RecordPermissionPromptPriorCount( | 196 static void RecordPermissionPromptPriorCount( |
| 195 content::PermissionType permission, | 197 ContentSettingsType permission, |
| 196 const std::string& prefix, | 198 const std::string& prefix, |
| 197 int count); | 199 int count); |
| 198 | 200 |
| 199 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionUmaUtil); | 201 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionUmaUtil); |
| 200 }; | 202 }; |
| 201 | 203 |
| 202 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_UMA_UTIL_H_ | 204 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_UMA_UTIL_H_ |
| OLD | NEW |