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 #include "chrome/browser/permissions/permission_uma_util.h" | 5 #include "chrome/browser/permissions/permission_uma_util.h" |
6 | 6 |
7 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/permissions/permission_manager.h" | 10 #include "chrome/browser/permissions/permission_manager.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 action_str = "Dismissed"; | 65 action_str = "Dismissed"; |
66 break; | 66 break; |
67 case IGNORED: | 67 case IGNORED: |
68 action_str = "Ignored"; | 68 action_str = "Ignored"; |
69 break; | 69 break; |
70 default: | 70 default: |
71 NOTREACHED(); | 71 NOTREACHED(); |
72 break; | 72 break; |
73 } | 73 } |
74 | 74 |
| 75 // Do not record the deprecated RAPPOR metrics for media permissions. |
| 76 if (permission == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA || |
| 77 permission == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) { |
| 78 return ""; |
| 79 } |
| 80 |
75 std::string permission_str = | 81 std::string permission_str = |
76 PermissionUtil::GetPermissionString(permission); | 82 PermissionUtil::GetPermissionString(permission); |
77 if (permission_str.empty()) | 83 if (permission_str.empty()) |
78 return ""; | 84 return ""; |
79 return base::StringPrintf("ContentSettings.PermissionActions_%s.%s.Url", | 85 return base::StringPrintf("ContentSettings.PermissionActions_%s.%s.Url", |
80 permission_str.c_str(), action_str.c_str()); | 86 permission_str.c_str(), action_str.c_str()); |
81 } | 87 } |
82 | 88 |
83 void RecordPermissionAction(ContentSettingsType permission, | 89 void RecordPermissionAction(ContentSettingsType permission, |
84 PermissionAction action, | 90 PermissionAction action, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 action); | 134 action); |
129 break; | 135 break; |
130 #endif | 136 #endif |
131 case CONTENT_SETTINGS_TYPE_DURABLE_STORAGE: | 137 case CONTENT_SETTINGS_TYPE_DURABLE_STORAGE: |
132 PERMISSION_ACTION_UMA( | 138 PERMISSION_ACTION_UMA( |
133 secure_origin, "ContentSettings.PermissionActions_DurableStorage", | 139 secure_origin, "ContentSettings.PermissionActions_DurableStorage", |
134 "ContentSettings.PermissionActionsSecureOrigin_DurableStorage", | 140 "ContentSettings.PermissionActionsSecureOrigin_DurableStorage", |
135 "ContentSettings.PermissionActionsInsecureOrigin_DurableStorage", | 141 "ContentSettings.PermissionActionsInsecureOrigin_DurableStorage", |
136 action); | 142 action); |
137 break; | 143 break; |
| 144 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC: |
| 145 // Media permissions are disabled on insecure origins, so there's no |
| 146 // need to record metrics for secure/insecue. |
| 147 UMA_HISTOGRAM_ENUMERATION("Permissions.Action.AudioCapture", action, |
| 148 PERMISSION_ACTION_NUM); |
| 149 break; |
| 150 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA: |
| 151 UMA_HISTOGRAM_ENUMERATION("Permissions.Action.VideoCapture", action, |
| 152 PERMISSION_ACTION_NUM); |
| 153 break; |
138 default: | 154 default: |
139 NOTREACHED() << "PERMISSION " << permission << " not accounted for"; | 155 NOTREACHED() << "PERMISSION " << permission << " not accounted for"; |
140 } | 156 } |
141 | 157 |
142 // There are two sets of semi-redundant RAPPOR metrics being reported: | 158 // There are two sets of semi-redundant RAPPOR metrics being reported: |
143 // The soon-to-be-deprecated single dimensional ones, and the new | 159 // The soon-to-be-deprecated single dimensional ones, and the new |
144 // multi-dimensional ones. | 160 // multi-dimensional ones. |
145 rappor::RapporService* rappor_service = g_browser_process->rappor_service(); | 161 rappor::RapporService* rappor_service = g_browser_process->rappor_service(); |
146 const std::string rappor_metric = GetRapporMetric(permission, action); | 162 const std::string rappor_metric = GetRapporMetric(permission, action); |
147 if (!rappor_metric.empty()) | 163 if (!rappor_metric.empty()) |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 | 316 |
301 void PermissionUmaUtil::PermissionDismissed( | 317 void PermissionUmaUtil::PermissionDismissed( |
302 ContentSettingsType permission, const GURL& requesting_origin) { | 318 ContentSettingsType permission, const GURL& requesting_origin) { |
303 RecordPermissionAction(permission, DISMISSED, requesting_origin); | 319 RecordPermissionAction(permission, DISMISSED, requesting_origin); |
304 } | 320 } |
305 | 321 |
306 void PermissionUmaUtil::PermissionIgnored( | 322 void PermissionUmaUtil::PermissionIgnored( |
307 ContentSettingsType permission, const GURL& requesting_origin) { | 323 ContentSettingsType permission, const GURL& requesting_origin) { |
308 RecordPermissionAction(permission, IGNORED, requesting_origin); | 324 RecordPermissionAction(permission, IGNORED, requesting_origin); |
309 } | 325 } |
OLD | NEW |