| 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 | 7 |
| 8 namespace { | 8 namespace { |
| 9 | 9 |
| 10 // Enum for UMA purposes, make sure you update histograms.xml if you add new | 10 // Enum for UMA purposes, make sure you update histograms.xml if you add new |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 }; | 21 }; |
| 22 | 22 |
| 23 // Enum for UMA purposes, make sure you update histograms.xml if you add new | 23 // Enum for UMA purposes, make sure you update histograms.xml if you add new |
| 24 // permission actions. Never delete or reorder an entry; only add new entries | 24 // permission actions. Never delete or reorder an entry; only add new entries |
| 25 // immediately before PERMISSION_NUM | 25 // immediately before PERMISSION_NUM |
| 26 enum PermissionType { | 26 enum PermissionType { |
| 27 PERMISSION_UNKNOWN = 0, | 27 PERMISSION_UNKNOWN = 0, |
| 28 PERMISSION_MIDI_SYSEX = 1, | 28 PERMISSION_MIDI_SYSEX = 1, |
| 29 PERMISSION_PUSH_MESSAGING = 2, | 29 PERMISSION_PUSH_MESSAGING = 2, |
| 30 PERMISSION_NOTIFICATIONS = 3, | 30 PERMISSION_NOTIFICATIONS = 3, |
| 31 PERMISSION_GEOLOCATION = 4, |
| 31 | 32 |
| 32 // Always keep this at the end. | 33 // Always keep this at the end. |
| 33 PERMISSION_NUM, | 34 PERMISSION_NUM, |
| 34 }; | 35 }; |
| 35 | 36 |
| 36 void RecordPermissionAction( | 37 void RecordPermissionAction( |
| 37 ContentSettingsType permission, PermissionAction action) { | 38 ContentSettingsType permission, PermissionAction action) { |
| 38 switch (permission) { | 39 switch (permission) { |
| 39 case CONTENT_SETTINGS_TYPE_GEOLOCATION: | 40 case CONTENT_SETTINGS_TYPE_GEOLOCATION: |
| 40 // TODO(miguelg): support geolocation through | 41 UMA_HISTOGRAM_ENUMERATION( |
| 41 // the generic permission class. | 42 "ContentSettings.PermissionActions_Geolocation", |
| 43 action, |
| 44 PERMISSION_ACTION_NUM); |
| 42 break; | 45 break; |
| 43 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: | 46 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
| 44 UMA_HISTOGRAM_ENUMERATION( | 47 UMA_HISTOGRAM_ENUMERATION( |
| 45 "ContentSettings.PermissionActions_Notifications", | 48 "ContentSettings.PermissionActions_Notifications", |
| 46 action, | 49 action, |
| 47 PERMISSION_ACTION_NUM); | 50 PERMISSION_ACTION_NUM); |
| 48 break; | 51 break; |
| 49 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: | 52 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: |
| 50 UMA_HISTOGRAM_ENUMERATION("ContentSettings.PermissionActions_MidiSysEx", | 53 UMA_HISTOGRAM_ENUMERATION("ContentSettings.PermissionActions_MidiSysEx", |
| 51 action, | 54 action, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 65 #endif | 68 #endif |
| 66 default: | 69 default: |
| 67 NOTREACHED() << "PERMISSION " << permission << " not accounted for"; | 70 NOTREACHED() << "PERMISSION " << permission << " not accounted for"; |
| 68 } | 71 } |
| 69 } | 72 } |
| 70 | 73 |
| 71 void RecordPermissionRequest( | 74 void RecordPermissionRequest( |
| 72 ContentSettingsType permission) { | 75 ContentSettingsType permission) { |
| 73 PermissionType type; | 76 PermissionType type; |
| 74 switch (permission) { | 77 switch (permission) { |
| 78 case CONTENT_SETTINGS_TYPE_GEOLOCATION: |
| 79 type = PERMISSION_GEOLOCATION; |
| 80 break; |
| 75 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: | 81 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
| 76 type = PERMISSION_NOTIFICATIONS; | 82 type = PERMISSION_NOTIFICATIONS; |
| 77 break; | 83 break; |
| 78 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: | 84 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: |
| 79 type = PERMISSION_MIDI_SYSEX; | 85 type = PERMISSION_MIDI_SYSEX; |
| 80 break; | 86 break; |
| 81 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: | 87 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: |
| 82 type = PERMISSION_PUSH_MESSAGING; | 88 type = PERMISSION_PUSH_MESSAGING; |
| 83 break; | 89 break; |
| 84 default: | 90 default: |
| (...skipping 25 matching lines...) Expand all Loading... |
| 110 | 116 |
| 111 void PermissionContextUmaUtil::PermissionDismissed( | 117 void PermissionContextUmaUtil::PermissionDismissed( |
| 112 ContentSettingsType permission) { | 118 ContentSettingsType permission) { |
| 113 RecordPermissionAction(permission, DISMISSED); | 119 RecordPermissionAction(permission, DISMISSED); |
| 114 } | 120 } |
| 115 | 121 |
| 116 void PermissionContextUmaUtil::PermissionIgnored( | 122 void PermissionContextUmaUtil::PermissionIgnored( |
| 117 ContentSettingsType permission) { | 123 ContentSettingsType permission) { |
| 118 RecordPermissionAction(permission, IGNORED); | 124 RecordPermissionAction(permission, IGNORED); |
| 119 } | 125 } |
| OLD | NEW |