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

Side by Side Diff: chrome/browser/permissions/permission_uma_util.h

Issue 2675483002: Replace PermissionType in chrome/ with ContentSettingsType (Closed)
Patch Set: rebase Created 3 years, 10 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 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 "chrome/browser/permissions/permission_request.h" 12 #include "chrome/browser/permissions/permission_request.h"
13 #include "chrome/browser/permissions/permission_util.h" 13 #include "chrome/browser/permissions/permission_util.h"
14 14
15 enum class PermissionRequestGestureType; 15 enum class PermissionRequestGestureType;
16 class GURL; 16 class GURL;
17 class PermissionRequest; 17 class PermissionRequest;
18 class Profile; 18 class Profile;
19 19
20 namespace content {
21 enum class PermissionType;
22 } // namespace content
23
24 // This should stay in sync with the SourceUI enum in the permission report 20 // This should stay in sync with the SourceUI enum in the permission report
25 // protobuf (src/chrome/common/safe_browsing/permission_report.proto). 21 // protobuf (src/chrome/common/safe_browsing/permission_report.proto).
26 enum class PermissionSourceUI { 22 enum class PermissionSourceUI {
27 PROMPT = 0, 23 PROMPT = 0,
28 OIB = 1, 24 OIB = 1,
29 SITE_SETTINGS = 2, 25 SITE_SETTINGS = 2,
30 PAGE_ACTION = 3, 26 PAGE_ACTION = 3,
31 27
32 // Always keep this at the end. 28 // Always keep this at the end.
33 SOURCE_UI_NUM, 29 SOURCE_UI_NUM,
34 }; 30 };
35 31
36 // This should stay in sync with the PersistDecision enum in the permission 32 // This should stay in sync with the PersistDecision enum in the permission
37 // report message (src/chrome/common/safe_browsing/permission_report.proto). 33 // report message (src/chrome/common/safe_browsing/permission_report.proto).
38 enum class PermissionPersistDecision { 34 enum class PermissionPersistDecision {
39 UNSPECIFIED = 0, 35 UNSPECIFIED = 0,
40 PERSISTED = 1, 36 PERSISTED = 1,
41 NOT_PERSISTED = 2, 37 NOT_PERSISTED = 2,
42 }; 38 };
43 39
44 // A bundle for the information sent in a PermissionReport. 40 // A bundle for the information sent in a PermissionReport.
45 struct PermissionReportInfo { 41 struct PermissionReportInfo {
46 PermissionReportInfo( 42 PermissionReportInfo(
47 const GURL& origin, 43 const GURL& origin,
48 content::PermissionType permission, 44 ContentSettingsType permission,
49 PermissionAction action, 45 PermissionAction action,
50 PermissionSourceUI source_ui, 46 PermissionSourceUI source_ui,
51 PermissionRequestGestureType gesture_type, 47 PermissionRequestGestureType gesture_type,
52 PermissionPersistDecision persist_decision, 48 PermissionPersistDecision persist_decision,
53 int num_prior_dismissals, 49 int num_prior_dismissals,
54 int num_prior_ignores); 50 int num_prior_ignores);
55 51
56 PermissionReportInfo(const PermissionReportInfo& other); 52 PermissionReportInfo(const PermissionReportInfo& other);
57 53
58 GURL origin; 54 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 63
68 // Provides a convenient way of logging UMA for permission related operations. 64 // Provides a convenient way of logging UMA for permission related operations.
69 class PermissionUmaUtil { 65 class PermissionUmaUtil {
(...skipping 13 matching lines...) Expand all
83 static const char kPermissionsPromptMergedBubbleDenied[]; 79 static const char kPermissionsPromptMergedBubbleDenied[];
84 static const char kPermissionsPromptAcceptedPriorDismissCountPrefix[]; 80 static const char kPermissionsPromptAcceptedPriorDismissCountPrefix[];
85 static const char kPermissionsPromptAcceptedPriorIgnoreCountPrefix[]; 81 static const char kPermissionsPromptAcceptedPriorIgnoreCountPrefix[];
86 static const char kPermissionsPromptDeniedPriorDismissCountPrefix[]; 82 static const char kPermissionsPromptDeniedPriorDismissCountPrefix[];
87 static const char kPermissionsPromptDeniedPriorIgnoreCountPrefix[]; 83 static const char kPermissionsPromptDeniedPriorIgnoreCountPrefix[];
88 static const char kPermissionsPromptDismissedPriorDismissCountPrefix[]; 84 static const char kPermissionsPromptDismissedPriorDismissCountPrefix[];
89 static const char kPermissionsPromptDismissedPriorIgnoreCountPrefix[]; 85 static const char kPermissionsPromptDismissedPriorIgnoreCountPrefix[];
90 static const char kPermissionsPromptIgnoredPriorDismissCountPrefix[]; 86 static const char kPermissionsPromptIgnoredPriorDismissCountPrefix[];
91 static const char kPermissionsPromptIgnoredPriorIgnoreCountPrefix[]; 87 static const char kPermissionsPromptIgnoredPriorIgnoreCountPrefix[];
92 88
89 // TODO(timloh): Remove this content::PermissionType overload when possible.
raymes 2017/02/09 00:39:57 nit: "when possible" is a bit vague. Could you cla
Timothy Loh 2017/02/10 07:25:38 Done.
93 static void PermissionRequested(content::PermissionType permission, 90 static void PermissionRequested(content::PermissionType permission,
94 const GURL& requesting_origin, 91 const GURL& requesting_origin,
95 const GURL& embedding_origin, 92 const GURL& embedding_origin,
96 Profile* profile); 93 Profile* profile);
97 static void PermissionGranted(content::PermissionType permission, 94 static void PermissionRequested(ContentSettingsType permission,
95 const GURL& requesting_origin,
96 const GURL& embedding_origin,
97 Profile* profile);
98 static void PermissionGranted(ContentSettingsType permission,
98 PermissionRequestGestureType gesture_type, 99 PermissionRequestGestureType gesture_type,
99 const GURL& requesting_origin, 100 const GURL& requesting_origin,
100 Profile* profile); 101 Profile* profile);
101 static void PermissionDenied(content::PermissionType permission, 102 static void PermissionDenied(ContentSettingsType permission,
102 PermissionRequestGestureType gesture_type, 103 PermissionRequestGestureType gesture_type,
103 const GURL& requesting_origin, 104 const GURL& requesting_origin,
104 Profile* profile); 105 Profile* profile);
105 static void PermissionDismissed(content::PermissionType permission, 106 static void PermissionDismissed(ContentSettingsType permission,
106 PermissionRequestGestureType gesture_type, 107 PermissionRequestGestureType gesture_type,
107 const GURL& requesting_origin, 108 const GURL& requesting_origin,
108 Profile* profile); 109 Profile* profile);
109 static void PermissionIgnored(content::PermissionType permission, 110 static void PermissionIgnored(ContentSettingsType permission,
110 PermissionRequestGestureType gesture_type, 111 PermissionRequestGestureType gesture_type,
111 const GURL& requesting_origin, 112 const GURL& requesting_origin,
112 Profile* profile); 113 Profile* profile);
113 static void PermissionRevoked(content::PermissionType permission, 114 static void PermissionRevoked(ContentSettingsType permission,
114 PermissionSourceUI source_ui, 115 PermissionSourceUI source_ui,
115 const GURL& revoked_origin, 116 const GURL& revoked_origin,
116 Profile* profile); 117 Profile* profile);
117 118
118 // UMA specifically for when permission prompts are shown. This should be 119 // UMA specifically for when permission prompts are shown. This should be
119 // roughly equivalent to the metrics above, however it is 120 // roughly equivalent to the metrics above, however it is
120 // useful to have separate UMA to a few reasons: 121 // useful to have separate UMA to a few reasons:
121 // - to account for, and get data on coalesced permission bubbles 122 // - to account for, and get data on coalesced permission bubbles
122 // - there are other types of permissions prompts (e.g. download limiting) 123 // - there are other types of permissions prompts (e.g. download limiting)
123 // which don't go through PermissionContext 124 // which don't go through PermissionContext
(...skipping 27 matching lines...) Expand all
151 PermissionRequestGestureType gesture_type); 152 PermissionRequestGestureType gesture_type);
152 153
153 static void RecordPermissionPromptDenied( 154 static void RecordPermissionPromptDenied(
154 PermissionRequestType request_type, 155 PermissionRequestType request_type,
155 PermissionRequestGestureType gesture_type); 156 PermissionRequestGestureType gesture_type);
156 157
157 // A permission prompt was accepted or denied, and the prompt displayed a 158 // A permission prompt was accepted or denied, and the prompt displayed a
158 // persistence toggle. Records whether the toggle was enabled (persist) or 159 // persistence toggle. Records whether the toggle was enabled (persist) or
159 // disabled (don't persist). 160 // disabled (don't persist).
160 static void PermissionPromptAcceptedWithPersistenceToggle( 161 static void PermissionPromptAcceptedWithPersistenceToggle(
161 content::PermissionType permission, 162 ContentSettingsType permission,
162 bool toggle_enabled); 163 bool toggle_enabled);
163 164
164 static void PermissionPromptDeniedWithPersistenceToggle( 165 static void PermissionPromptDeniedWithPersistenceToggle(
165 content::PermissionType permission, 166 ContentSettingsType permission,
166 bool toggle_enabled); 167 bool toggle_enabled);
167 168
168 private: 169 private:
169 friend class PermissionUmaUtilTest; 170 friend class PermissionUmaUtilTest;
170 171
171 static bool IsOptedIntoPermissionActionReporting(Profile* profile); 172 static bool IsOptedIntoPermissionActionReporting(Profile* profile);
172 173
173 static void RecordPermissionAction(content::PermissionType permission, 174 static void RecordPermissionAction(ContentSettingsType permission,
174 PermissionAction action, 175 PermissionAction action,
175 PermissionSourceUI source_ui, 176 PermissionSourceUI source_ui,
176 PermissionRequestGestureType gesture_type, 177 PermissionRequestGestureType gesture_type,
177 const GURL& requesting_origin, 178 const GURL& requesting_origin,
178 Profile* profile); 179 Profile* profile);
179 180
180 // Records |count| total prior actions for a prompt of type |permission| 181 // Records |count| total prior actions for a prompt of type |permission|
181 // for a single origin using |prefix| for the metric. 182 // for a single origin using |prefix| for the metric.
182 static void RecordPermissionPromptPriorCount( 183 static void RecordPermissionPromptPriorCount(
183 content::PermissionType permission, 184 ContentSettingsType permission,
184 const std::string& prefix, 185 const std::string& prefix,
185 int count); 186 int count);
186 187
187 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionUmaUtil); 188 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionUmaUtil);
188 }; 189 };
189 190
190 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_UMA_UTIL_H_ 191 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_UMA_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698