| 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 "base/metrics/histogram.h" | 5 #include "base/metrics/histogram.h" |
| 6 #include "chrome/browser/content_settings/permission_context_uma_util.h" | 6 #include "chrome/browser/content_settings/permission_context_uma_util.h" |
| 7 #include "content/public/browser/permission_type.h" | 7 #include "content/public/browser/permission_type.h" |
| 8 #include "url/gurl.h" | 8 #include "url/gurl.h" |
| 9 | 9 |
| 10 // UMA keys need to be statically initialized so plain function would not | 10 // UMA keys need to be statically initialized so plain function would not |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 action); | 71 action); |
| 72 break; | 72 break; |
| 73 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: | 73 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: |
| 74 PERMISSION_ACTION_UMA( | 74 PERMISSION_ACTION_UMA( |
| 75 secure_origin, | 75 secure_origin, |
| 76 "ContentSettings.PermissionActions_PushMessaging", | 76 "ContentSettings.PermissionActions_PushMessaging", |
| 77 "ContentSettings.PermissionActionsSecureOrigin_PushMessaging", | 77 "ContentSettings.PermissionActionsSecureOrigin_PushMessaging", |
| 78 "ContentSettings.PermissionActionsInsecureOrigin_PushMessaging", | 78 "ContentSettings.PermissionActionsInsecureOrigin_PushMessaging", |
| 79 action); | 79 action); |
| 80 break; | 80 break; |
| 81 #if defined(OS_ANDROID) | 81 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) |
| 82 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER: | 82 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER: |
| 83 // TODO(miguelg): support protected media through | 83 PERMISSION_ACTION_UMA( |
| 84 // the generic permission class. | 84 secure_origin, |
| 85 "ContentSettings.PermissionActions_ProtectedMedia", |
| 86 "ContentSettings.PermissionActionsSecureOrigin_ProtectedMedia", |
| 87 "ContentSettings.PermissionActionsInsecureOrigin_ProtectedMedia", |
| 88 action); |
| 85 break; | 89 break; |
| 86 #endif | 90 #endif |
| 87 default: | 91 default: |
| 88 NOTREACHED() << "PERMISSION " << permission << " not accounted for"; | 92 NOTREACHED() << "PERMISSION " << permission << " not accounted for"; |
| 89 } | 93 } |
| 90 } | 94 } |
| 91 | 95 |
| 92 void RecordPermissionRequest( | 96 void RecordPermissionRequest( |
| 93 ContentSettingsType permission, bool secure_origin) { | 97 ContentSettingsType permission, bool secure_origin) { |
| 94 content::PermissionType type; | 98 content::PermissionType type; |
| 95 switch (permission) { | 99 switch (permission) { |
| 96 case CONTENT_SETTINGS_TYPE_GEOLOCATION: | 100 case CONTENT_SETTINGS_TYPE_GEOLOCATION: |
| 97 type = content::PERMISSION_GEOLOCATION; | 101 type = content::PERMISSION_GEOLOCATION; |
| 98 break; | 102 break; |
| 99 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: | 103 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
| 100 type = content::PERMISSION_NOTIFICATIONS; | 104 type = content::PERMISSION_NOTIFICATIONS; |
| 101 break; | 105 break; |
| 102 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: | 106 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: |
| 103 type = content::PERMISSION_MIDI_SYSEX; | 107 type = content::PERMISSION_MIDI_SYSEX; |
| 104 break; | 108 break; |
| 105 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: | 109 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: |
| 106 type = content::PERMISSION_PUSH_MESSAGING; | 110 type = content::PERMISSION_PUSH_MESSAGING; |
| 107 break; | 111 break; |
| 112 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) |
| 113 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER: |
| 114 type = content::PERMISSION_PROTECTED_MEDIA; |
| 115 break; |
| 116 #endif |
| 108 default: | 117 default: |
| 109 NOTREACHED() << "PERMISSION " << permission << " not accounted for"; | 118 NOTREACHED() << "PERMISSION " << permission << " not accounted for"; |
| 110 return; | 119 return; |
| 111 } | 120 } |
| 112 UMA_HISTOGRAM_ENUMERATION( | 121 UMA_HISTOGRAM_ENUMERATION( |
| 113 "ContentSettings.PermissionRequested", type, content::PERMISSION_NUM); | 122 "ContentSettings.PermissionRequested", type, content::PERMISSION_NUM); |
| 114 if (secure_origin) { | 123 if (secure_origin) { |
| 115 UMA_HISTOGRAM_ENUMERATION( | 124 UMA_HISTOGRAM_ENUMERATION( |
| 116 "ContentSettings.PermissionRequested_SecureOrigin", | 125 "ContentSettings.PermissionRequested_SecureOrigin", |
| 117 type, | 126 type, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 ContentSettingsType permission, const GURL& requesting_origin) { | 158 ContentSettingsType permission, const GURL& requesting_origin) { |
| 150 RecordPermissionAction(permission, DISMISSED, | 159 RecordPermissionAction(permission, DISMISSED, |
| 151 requesting_origin.SchemeIsSecure()); | 160 requesting_origin.SchemeIsSecure()); |
| 152 } | 161 } |
| 153 | 162 |
| 154 void PermissionContextUmaUtil::PermissionIgnored( | 163 void PermissionContextUmaUtil::PermissionIgnored( |
| 155 ContentSettingsType permission, const GURL& requesting_origin) { | 164 ContentSettingsType permission, const GURL& requesting_origin) { |
| 156 RecordPermissionAction(permission, IGNORED, | 165 RecordPermissionAction(permission, IGNORED, |
| 157 requesting_origin.SchemeIsSecure()); | 166 requesting_origin.SchemeIsSecure()); |
| 158 } | 167 } |
| OLD | NEW |