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" |
(...skipping 17 matching lines...) Expand all Loading... | |
28 DISMISSED = 2, | 28 DISMISSED = 2, |
29 IGNORED = 3, | 29 IGNORED = 3, |
30 REVOKED = 4, | 30 REVOKED = 4, |
31 REENABLED = 5, | 31 REENABLED = 5, |
32 REQUESTED = 6, | 32 REQUESTED = 6, |
33 | 33 |
34 // Always keep this at the end. | 34 // Always keep this at the end. |
35 PERMISSION_ACTION_NUM, | 35 PERMISSION_ACTION_NUM, |
36 }; | 36 }; |
37 | 37 |
38 // This should stay in sync with the SourceUI enum in the permission report | |
39 // protobuf (src/chrome/common/safe_browsing/permission_report.proto). | |
40 enum SourceUI { | |
raymes
2016/07/12 07:18:14
nit: I think we should call this PermissionSourceU
stefanocs
2016/07/13 01:23:52
Done.
| |
41 PROMPT = 0, | |
42 OIB = 1, | |
43 SITE_SETTINGS = 2, | |
44 PAGE_ACTION = 3, | |
45 | |
46 // Always keep this at the end. | |
47 SOURCE_UI_NUM, | |
48 }; | |
49 | |
38 // Provides a convenient way of logging UMA for permission related operations. | 50 // Provides a convenient way of logging UMA for permission related operations. |
39 class PermissionUmaUtil { | 51 class PermissionUmaUtil { |
40 public: | 52 public: |
41 static const char kPermissionsPromptShown[]; | 53 static const char kPermissionsPromptShown[]; |
42 static const char kPermissionsPromptAccepted[]; | 54 static const char kPermissionsPromptAccepted[]; |
43 static const char kPermissionsPromptDenied[]; | 55 static const char kPermissionsPromptDenied[]; |
44 static const char kPermissionsPromptRequestsPerPrompt[]; | 56 static const char kPermissionsPromptRequestsPerPrompt[]; |
45 static const char kPermissionsPromptMergedBubbleTypes[]; | 57 static const char kPermissionsPromptMergedBubbleTypes[]; |
46 static const char kPermissionsPromptMergedBubbleAccepted[]; | 58 static const char kPermissionsPromptMergedBubbleAccepted[]; |
47 static const char kPermissionsPromptMergedBubbleDenied[]; | 59 static const char kPermissionsPromptMergedBubbleDenied[]; |
48 | 60 |
49 static void PermissionRequested(content::PermissionType permission, | 61 static void PermissionRequested(content::PermissionType permission, |
50 const GURL& requesting_origin, | 62 const GURL& requesting_origin, |
51 const GURL& embedding_origin, | 63 const GURL& embedding_origin, |
52 Profile* profile); | 64 Profile* profile); |
53 static void PermissionGranted(content::PermissionType permission, | 65 static void PermissionGranted(content::PermissionType permission, |
54 const GURL& requesting_origin, | 66 const GURL& requesting_origin, |
55 Profile* profile); | 67 Profile* profile); |
56 static void PermissionDenied(content::PermissionType permission, | 68 static void PermissionDenied(content::PermissionType permission, |
57 const GURL& requesting_origin, | 69 const GURL& requesting_origin, |
58 Profile* profile); | 70 Profile* profile); |
59 static void PermissionDismissed(content::PermissionType permission, | 71 static void PermissionDismissed(content::PermissionType permission, |
60 const GURL& requesting_origin, | 72 const GURL& requesting_origin, |
61 Profile* profile); | 73 Profile* profile); |
62 static void PermissionIgnored(content::PermissionType permission, | 74 static void PermissionIgnored(content::PermissionType permission, |
63 const GURL& requesting_origin, | 75 const GURL& requesting_origin, |
64 Profile* profile); | 76 Profile* profile); |
65 static void PermissionRevoked(content::PermissionType permission, | 77 static void PermissionRevoked(content::PermissionType permission, |
66 const GURL& revoked_origin, | 78 const GURL& revoked_origin, |
79 SourceUI source_ui, | |
67 Profile* profile); | 80 Profile* profile); |
68 | 81 |
69 // UMA specifically for when permission prompts are shown. This should be | 82 // UMA specifically for when permission prompts are shown. This should be |
70 // roughly equivalent to the metrics above, however it is | 83 // roughly equivalent to the metrics above, however it is |
71 // useful to have separate UMA to a few reasons: | 84 // useful to have separate UMA to a few reasons: |
72 // - to account for, and get data on coalesced permission bubbles | 85 // - to account for, and get data on coalesced permission bubbles |
73 // - there are other types of permissions prompts (e.g. download limiting) | 86 // - there are other types of permissions prompts (e.g. download limiting) |
74 // which don't go through PermissionContext | 87 // which don't go through PermissionContext |
75 // - the above metrics don't always add up (e.g. sum of | 88 // - the above metrics don't always add up (e.g. sum of |
76 // granted+denied+dismissed+ignored is not equal to requested), so it is | 89 // granted+denied+dismissed+ignored is not equal to requested), so it is |
(...skipping 16 matching lines...) Expand all Loading... | |
93 private: | 106 private: |
94 friend class PermissionUmaUtilTest; | 107 friend class PermissionUmaUtilTest; |
95 | 108 |
96 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionUmaUtil); | 109 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionUmaUtil); |
97 | 110 |
98 static bool IsOptedIntoPermissionActionReporting(Profile* profile); | 111 static bool IsOptedIntoPermissionActionReporting(Profile* profile); |
99 | 112 |
100 static void RecordPermissionAction(content::PermissionType permission, | 113 static void RecordPermissionAction(content::PermissionType permission, |
101 PermissionAction action, | 114 PermissionAction action, |
102 const GURL& requesting_origin, | 115 const GURL& requesting_origin, |
116 SourceUI source_ui, | |
raymes
2016/07/12 07:18:14
nit: I think this should go before the origin (gro
stefanocs
2016/07/13 01:23:52
Done.
| |
103 Profile* profile); | 117 Profile* profile); |
104 }; | 118 }; |
105 | 119 |
106 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_UMA_UTIL_H_ | 120 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_UMA_UTIL_H_ |
OLD | NEW |