| 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 | 12 |
| 13 class GURL; | 13 class GURL; |
| 14 class Profile; | 14 class Profile; |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 enum class PermissionType; | 17 enum class PermissionType; |
| 18 } // namespace content | 18 } // namespace content |
| 19 | 19 |
| 20 class PermissionBubbleRequest; | 20 class PermissionRequest; |
| 21 | 21 |
| 22 // Enum for UMA purposes, make sure you update histograms.xml if you add new | 22 // Enum for UMA purposes, make sure you update histograms.xml if you add new |
| 23 // permission actions. Never delete or reorder an entry; only add new entries | 23 // permission actions. Never delete or reorder an entry; only add new entries |
| 24 // immediately before PERMISSION_NUM | 24 // immediately before PERMISSION_NUM |
| 25 enum PermissionAction { | 25 enum PermissionAction { |
| 26 GRANTED = 0, | 26 GRANTED = 0, |
| 27 DENIED = 1, | 27 DENIED = 1, |
| 28 DISMISSED = 2, | 28 DISMISSED = 2, |
| 29 IGNORED = 3, | 29 IGNORED = 3, |
| 30 REVOKED = 4, | 30 REVOKED = 4, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 // UMA specifically for when permission prompts are shown. This should be | 69 // UMA specifically for when permission prompts are shown. This should be |
| 70 // roughly equivalent to the metrics above, however it is | 70 // roughly equivalent to the metrics above, however it is |
| 71 // useful to have separate UMA to a few reasons: | 71 // useful to have separate UMA to a few reasons: |
| 72 // - to account for, and get data on coalesced permission bubbles | 72 // - to account for, and get data on coalesced permission bubbles |
| 73 // - there are other types of permissions prompts (e.g. download limiting) | 73 // - there are other types of permissions prompts (e.g. download limiting) |
| 74 // which don't go through PermissionContext | 74 // which don't go through PermissionContext |
| 75 // - the above metrics don't always add up (e.g. sum of | 75 // - 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 | 76 // granted+denied+dismissed+ignored is not equal to requested), so it is |
| 77 // unclear from those metrics alone how many prompts are seen by users. | 77 // unclear from those metrics alone how many prompts are seen by users. |
| 78 static void PermissionPromptShown( | 78 static void PermissionPromptShown( |
| 79 const std::vector<PermissionBubbleRequest*>& requests); | 79 const std::vector<PermissionRequest*>& requests); |
| 80 | 80 |
| 81 // The following two functions can be combined with the PermissionPromptShown | 81 // The following two functions can be combined with the PermissionPromptShown |
| 82 // metrics to calculate accept, deny and ignore rates. | 82 // metrics to calculate accept, deny and ignore rates. |
| 83 // Note that for coalesced permission bubbles, PermissionPromptAccepted will | 83 // Note that for coalesced permission bubbles, PermissionPromptAccepted will |
| 84 // always be called, with |accept_states| containing whether each request was | 84 // always be called, with |accept_states| containing whether each request was |
| 85 // accepted or denied. | 85 // accepted or denied. |
| 86 static void PermissionPromptAccepted( | 86 static void PermissionPromptAccepted( |
| 87 const std::vector<PermissionBubbleRequest*>& requests, | 87 const std::vector<PermissionRequest*>& requests, |
| 88 const std::vector<bool>& accept_states); | 88 const std::vector<bool>& accept_states); |
| 89 | 89 |
| 90 static void PermissionPromptDenied( | 90 static void PermissionPromptDenied( |
| 91 const std::vector<PermissionBubbleRequest*>& requests); | 91 const std::vector<PermissionRequest*>& requests); |
| 92 | 92 |
| 93 private: | 93 private: |
| 94 friend class PermissionUmaUtilTest; | 94 friend class PermissionUmaUtilTest; |
| 95 | 95 |
| 96 static bool IsOptedIntoPermissionActionReporting(Profile* profile); | 96 static bool IsOptedIntoPermissionActionReporting(Profile* profile); |
| 97 | 97 |
| 98 static void RecordPermissionAction(content::PermissionType permission, | 98 static void RecordPermissionAction(content::PermissionType permission, |
| 99 PermissionAction action, | 99 PermissionAction action, |
| 100 const GURL& requesting_origin, | 100 const GURL& requesting_origin, |
| 101 Profile* profile); | 101 Profile* profile); |
| 102 | 102 |
| 103 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionUmaUtil); | 103 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionUmaUtil); |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_UMA_UTIL_H_ | 106 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_UMA_UTIL_H_ |
| OLD | NEW |