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 { |
| 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, |
| 67 SourceUI source_ui, |
55 Profile* profile); | 68 Profile* profile); |
56 static void PermissionDenied(content::PermissionType permission, | 69 static void PermissionDenied(content::PermissionType permission, |
57 const GURL& requesting_origin, | 70 const GURL& requesting_origin, |
| 71 SourceUI source_ui, |
58 Profile* profile); | 72 Profile* profile); |
59 static void PermissionDismissed(content::PermissionType permission, | 73 static void PermissionDismissed(content::PermissionType permission, |
60 const GURL& requesting_origin, | 74 const GURL& requesting_origin, |
| 75 SourceUI source_ui, |
61 Profile* profile); | 76 Profile* profile); |
62 static void PermissionIgnored(content::PermissionType permission, | 77 static void PermissionIgnored(content::PermissionType permission, |
63 const GURL& requesting_origin, | 78 const GURL& requesting_origin, |
| 79 SourceUI source_ui, |
64 Profile* profile); | 80 Profile* profile); |
65 static void PermissionRevoked(content::PermissionType permission, | 81 static void PermissionRevoked(content::PermissionType permission, |
66 const GURL& revoked_origin, | 82 const GURL& revoked_origin, |
| 83 SourceUI source_ui, |
67 Profile* profile); | 84 Profile* profile); |
68 | 85 |
69 // UMA specifically for when permission prompts are shown. This should be | 86 // UMA specifically for when permission prompts are shown. This should be |
70 // roughly equivalent to the metrics above, however it is | 87 // roughly equivalent to the metrics above, however it is |
71 // useful to have separate UMA to a few reasons: | 88 // useful to have separate UMA to a few reasons: |
72 // - to account for, and get data on coalesced permission bubbles | 89 // - to account for, and get data on coalesced permission bubbles |
73 // - there are other types of permissions prompts (e.g. download limiting) | 90 // - there are other types of permissions prompts (e.g. download limiting) |
74 // which don't go through PermissionContext | 91 // which don't go through PermissionContext |
75 // - the above metrics don't always add up (e.g. sum of | 92 // - 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 | 93 // granted+denied+dismissed+ignored is not equal to requested), so it is |
(...skipping 16 matching lines...) Expand all Loading... |
93 private: | 110 private: |
94 friend class PermissionUmaUtilTest; | 111 friend class PermissionUmaUtilTest; |
95 | 112 |
96 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionUmaUtil); | 113 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionUmaUtil); |
97 | 114 |
98 static bool IsOptedIntoPermissionActionReporting(Profile* profile); | 115 static bool IsOptedIntoPermissionActionReporting(Profile* profile); |
99 | 116 |
100 static void RecordPermissionAction(content::PermissionType permission, | 117 static void RecordPermissionAction(content::PermissionType permission, |
101 PermissionAction action, | 118 PermissionAction action, |
102 const GURL& requesting_origin, | 119 const GURL& requesting_origin, |
| 120 SourceUI source_ui, |
103 Profile* profile); | 121 Profile* profile); |
104 }; | 122 }; |
105 | 123 |
106 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_UMA_UTIL_H_ | 124 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_UMA_UTIL_H_ |
OLD | NEW |