Chromium Code Reviews| 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 23 matching lines...) Expand all Loading... | |
| 34 enum PermissionAction { | 34 enum PermissionAction { |
| 35 GRANTED = 0, | 35 GRANTED = 0, |
| 36 DENIED = 1, | 36 DENIED = 1, |
| 37 DISMISSED = 2, | 37 DISMISSED = 2, |
| 38 IGNORED = 3, | 38 IGNORED = 3, |
| 39 | 39 |
| 40 // Always keep this at the end. | 40 // Always keep this at the end. |
| 41 PERMISSION_ACTION_NUM, | 41 PERMISSION_ACTION_NUM, |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 void RecordPermissionAction( | 44 void RecordPermissionAction( |
|
Miguel Garcia
2014/12/03 18:57:36
Don't you need to add media here as well?
timvolodine
2014/12/04 17:22:26
Done.
| |
| 45 ContentSettingsType permission, | 45 ContentSettingsType permission, |
| 46 PermissionAction action, | 46 PermissionAction action, |
| 47 bool secure_origin) { | 47 bool secure_origin) { |
| 48 switch (permission) { | 48 switch (permission) { |
| 49 case CONTENT_SETTINGS_TYPE_GEOLOCATION: | 49 case CONTENT_SETTINGS_TYPE_GEOLOCATION: |
| 50 PERMISSION_ACTION_UMA( | 50 PERMISSION_ACTION_UMA( |
| 51 secure_origin, | 51 secure_origin, |
| 52 "ContentSettings.PermissionActions_Geolocation", | 52 "ContentSettings.PermissionActions_Geolocation", |
| 53 "ContentSettings.PermissionActionsSecureOrigin_Geolocation", | 53 "ContentSettings.PermissionActionsSecureOrigin_Geolocation", |
| 54 "ContentSettings.PermissionActionsInsecureOrigin_Geolocation", | 54 "ContentSettings.PermissionActionsInsecureOrigin_Geolocation", |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 break; | 98 break; |
| 99 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: | 99 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
| 100 type = content::PERMISSION_NOTIFICATIONS; | 100 type = content::PERMISSION_NOTIFICATIONS; |
| 101 break; | 101 break; |
| 102 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: | 102 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: |
| 103 type = content::PERMISSION_MIDI_SYSEX; | 103 type = content::PERMISSION_MIDI_SYSEX; |
| 104 break; | 104 break; |
| 105 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: | 105 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: |
| 106 type = content::PERMISSION_PUSH_MESSAGING; | 106 type = content::PERMISSION_PUSH_MESSAGING; |
| 107 break; | 107 break; |
| 108 #if defined(OS_ANDROID) | |
|
Miguel Garcia
2014/12/03 18:57:36
You need a change in histograms.xml to add the new
timvolodine
2014/12/04 17:22:26
Yes, thanks for catching this. Done.
| |
| 109 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER: | |
| 110 type = content::PERMISSION_PROTECTED_MEDIA; | |
| 111 break; | |
| 112 #endif | |
| 108 default: | 113 default: |
| 109 NOTREACHED() << "PERMISSION " << permission << " not accounted for"; | 114 NOTREACHED() << "PERMISSION " << permission << " not accounted for"; |
| 110 return; | 115 return; |
| 111 } | 116 } |
| 112 UMA_HISTOGRAM_ENUMERATION( | 117 UMA_HISTOGRAM_ENUMERATION( |
| 113 "ContentSettings.PermissionRequested", type, content::PERMISSION_NUM); | 118 "ContentSettings.PermissionRequested", type, content::PERMISSION_NUM); |
| 114 if (secure_origin) { | 119 if (secure_origin) { |
| 115 UMA_HISTOGRAM_ENUMERATION( | 120 UMA_HISTOGRAM_ENUMERATION( |
| 116 "ContentSettings.PermissionRequested_SecureOrigin", | 121 "ContentSettings.PermissionRequested_SecureOrigin", |
| 117 type, | 122 type, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 ContentSettingsType permission, const GURL& requesting_origin) { | 154 ContentSettingsType permission, const GURL& requesting_origin) { |
| 150 RecordPermissionAction(permission, DISMISSED, | 155 RecordPermissionAction(permission, DISMISSED, |
| 151 requesting_origin.SchemeIsSecure()); | 156 requesting_origin.SchemeIsSecure()); |
| 152 } | 157 } |
| 153 | 158 |
| 154 void PermissionContextUmaUtil::PermissionIgnored( | 159 void PermissionContextUmaUtil::PermissionIgnored( |
| 155 ContentSettingsType permission, const GURL& requesting_origin) { | 160 ContentSettingsType permission, const GURL& requesting_origin) { |
| 156 RecordPermissionAction(permission, IGNORED, | 161 RecordPermissionAction(permission, IGNORED, |
| 157 requesting_origin.SchemeIsSecure()); | 162 requesting_origin.SchemeIsSecure()); |
| 158 } | 163 } |
| OLD | NEW |