| 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 enum PermissionEmbargoStatus { | 75 enum PermissionEmbargoStatus { |
| 80 NOT_EMBARGOED = 0, | 76 NOT_EMBARGOED = 0, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 103 static const char kPermissionsPromptMergedBubbleDenied[]; | 99 static const char kPermissionsPromptMergedBubbleDenied[]; |
| 104 static const char kPermissionsPromptAcceptedPriorDismissCountPrefix[]; | 100 static const char kPermissionsPromptAcceptedPriorDismissCountPrefix[]; |
| 105 static const char kPermissionsPromptAcceptedPriorIgnoreCountPrefix[]; | 101 static const char kPermissionsPromptAcceptedPriorIgnoreCountPrefix[]; |
| 106 static const char kPermissionsPromptDeniedPriorDismissCountPrefix[]; | 102 static const char kPermissionsPromptDeniedPriorDismissCountPrefix[]; |
| 107 static const char kPermissionsPromptDeniedPriorIgnoreCountPrefix[]; | 103 static const char kPermissionsPromptDeniedPriorIgnoreCountPrefix[]; |
| 108 static const char kPermissionsPromptDismissedPriorDismissCountPrefix[]; | 104 static const char kPermissionsPromptDismissedPriorDismissCountPrefix[]; |
| 109 static const char kPermissionsPromptDismissedPriorIgnoreCountPrefix[]; | 105 static const char kPermissionsPromptDismissedPriorIgnoreCountPrefix[]; |
| 110 static const char kPermissionsPromptIgnoredPriorDismissCountPrefix[]; | 106 static const char kPermissionsPromptIgnoredPriorDismissCountPrefix[]; |
| 111 static const char kPermissionsPromptIgnoredPriorIgnoreCountPrefix[]; | 107 static const char kPermissionsPromptIgnoredPriorIgnoreCountPrefix[]; |
| 112 | 108 |
| 109 // TODO(timloh): Remove this content::PermissionType overload when we add MIDI |
| 110 // to ContentSettingsType. |
| 113 static void PermissionRequested(content::PermissionType permission, | 111 static void PermissionRequested(content::PermissionType permission, |
| 114 const GURL& requesting_origin, | 112 const GURL& requesting_origin, |
| 115 const GURL& embedding_origin, | 113 const GURL& embedding_origin, |
| 116 Profile* profile); | 114 Profile* profile); |
| 117 static void PermissionGranted(content::PermissionType permission, | 115 static void PermissionRequested(ContentSettingsType permission, |
| 116 const GURL& requesting_origin, |
| 117 const GURL& embedding_origin, |
| 118 Profile* profile); |
| 119 static void PermissionGranted(ContentSettingsType permission, |
| 118 PermissionRequestGestureType gesture_type, | 120 PermissionRequestGestureType gesture_type, |
| 119 const GURL& requesting_origin, | 121 const GURL& requesting_origin, |
| 120 Profile* profile); | 122 Profile* profile); |
| 121 static void PermissionDenied(content::PermissionType permission, | 123 static void PermissionDenied(ContentSettingsType permission, |
| 122 PermissionRequestGestureType gesture_type, | 124 PermissionRequestGestureType gesture_type, |
| 123 const GURL& requesting_origin, | 125 const GURL& requesting_origin, |
| 124 Profile* profile); | 126 Profile* profile); |
| 125 static void PermissionDismissed(content::PermissionType permission, | 127 static void PermissionDismissed(ContentSettingsType permission, |
| 126 PermissionRequestGestureType gesture_type, | 128 PermissionRequestGestureType gesture_type, |
| 127 const GURL& requesting_origin, | 129 const GURL& requesting_origin, |
| 128 Profile* profile); | 130 Profile* profile); |
| 129 static void PermissionIgnored(content::PermissionType permission, | 131 static void PermissionIgnored(ContentSettingsType permission, |
| 130 PermissionRequestGestureType gesture_type, | 132 PermissionRequestGestureType gesture_type, |
| 131 const GURL& requesting_origin, | 133 const GURL& requesting_origin, |
| 132 Profile* profile); | 134 Profile* profile); |
| 133 static void PermissionRevoked(content::PermissionType permission, | 135 static void PermissionRevoked(ContentSettingsType permission, |
| 134 PermissionSourceUI source_ui, | 136 PermissionSourceUI source_ui, |
| 135 const GURL& revoked_origin, | 137 const GURL& revoked_origin, |
| 136 Profile* profile); | 138 Profile* profile); |
| 137 | 139 |
| 138 static void RecordPermissionEmbargoStatus( | 140 static void RecordPermissionEmbargoStatus( |
| 139 PermissionEmbargoStatus embargo_status); | 141 PermissionEmbargoStatus embargo_status); |
| 140 | 142 |
| 141 static void RecordSafeBrowsingResponse(base::TimeDelta response_time, | 143 static void RecordSafeBrowsingResponse(base::TimeDelta response_time, |
| 142 SafeBrowsingResponse response); | 144 SafeBrowsingResponse response); |
| 143 | 145 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 PermissionRequestGestureType gesture_type); | 179 PermissionRequestGestureType gesture_type); |
| 178 | 180 |
| 179 static void RecordPermissionPromptDenied( | 181 static void RecordPermissionPromptDenied( |
| 180 PermissionRequestType request_type, | 182 PermissionRequestType request_type, |
| 181 PermissionRequestGestureType gesture_type); | 183 PermissionRequestGestureType gesture_type); |
| 182 | 184 |
| 183 // A permission prompt was accepted or denied, and the prompt displayed a | 185 // A permission prompt was accepted or denied, and the prompt displayed a |
| 184 // persistence toggle. Records whether the toggle was enabled (persist) or | 186 // persistence toggle. Records whether the toggle was enabled (persist) or |
| 185 // disabled (don't persist). | 187 // disabled (don't persist). |
| 186 static void PermissionPromptAcceptedWithPersistenceToggle( | 188 static void PermissionPromptAcceptedWithPersistenceToggle( |
| 187 content::PermissionType permission, | 189 ContentSettingsType permission, |
| 188 bool toggle_enabled); | 190 bool toggle_enabled); |
| 189 | 191 |
| 190 static void PermissionPromptDeniedWithPersistenceToggle( | 192 static void PermissionPromptDeniedWithPersistenceToggle( |
| 191 content::PermissionType permission, | 193 ContentSettingsType permission, |
| 192 bool toggle_enabled); | 194 bool toggle_enabled); |
| 193 | 195 |
| 194 private: | 196 private: |
| 195 friend class PermissionUmaUtilTest; | 197 friend class PermissionUmaUtilTest; |
| 196 | 198 |
| 197 static bool IsOptedIntoPermissionActionReporting(Profile* profile); | 199 static bool IsOptedIntoPermissionActionReporting(Profile* profile); |
| 198 | 200 |
| 199 static void RecordPermissionAction(content::PermissionType permission, | 201 static void RecordPermissionAction(ContentSettingsType permission, |
| 200 PermissionAction action, | 202 PermissionAction action, |
| 201 PermissionSourceUI source_ui, | 203 PermissionSourceUI source_ui, |
| 202 PermissionRequestGestureType gesture_type, | 204 PermissionRequestGestureType gesture_type, |
| 203 const GURL& requesting_origin, | 205 const GURL& requesting_origin, |
| 204 Profile* profile); | 206 Profile* profile); |
| 205 | 207 |
| 206 // Records |count| total prior actions for a prompt of type |permission| | 208 // Records |count| total prior actions for a prompt of type |permission| |
| 207 // for a single origin using |prefix| for the metric. | 209 // for a single origin using |prefix| for the metric. |
| 208 static void RecordPermissionPromptPriorCount( | 210 static void RecordPermissionPromptPriorCount( |
| 209 content::PermissionType permission, | 211 ContentSettingsType permission, |
| 210 const std::string& prefix, | 212 const std::string& prefix, |
| 211 int count); | 213 int count); |
| 212 | 214 |
| 213 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionUmaUtil); | 215 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionUmaUtil); |
| 214 }; | 216 }; |
| 215 | 217 |
| 216 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_UMA_UTIL_H_ | 218 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_UMA_UTIL_H_ |
| OLD | NEW |