OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/metrics/histogram.h" | |
6 #include "chrome/browser/content_settings/permission_context_uma_util.h" | |
7 | |
8 namespace { | |
9 | |
10 // Enum for UMA purposes, make sure you update histograms.xml if you | |
11 // add new permission actions. Never delete or reorder | |
Mark P
2014/07/15 20:17:40
nit: weird line lengths
Miguel Garcia
2014/07/16 11:15:27
Done.
| |
12 // an entry; only add new entries immediately before PERMISSION_NUM | |
13 enum PermissionAction { | |
14 GRANTED = 0, | |
15 DENIED = 1, | |
16 DISMISSED = 2, | |
17 IGNORED = 3, | |
18 | |
19 // Always keep this at the end. | |
20 PERMISSION_ACTION_NUM, | |
21 }; | |
22 | |
23 enum PermissionType { | |
Mark P
2014/07/15 20:17:41
please add an analogous comment to that above righ
Miguel Garcia
2014/07/16 11:15:27
Done.
| |
24 PERMISSION_UNKNOWN, | |
25 PERMISSION_MIDI_SYSEX, | |
26 PERMISSION_PUSH_MESSAGING, | |
27 | |
28 // Always keep this at the end. | |
29 PERMISSION_NUM, | |
30 }; | |
31 | |
32 static const char* kMidiUmaKey = "ContentSettings.PermisionActions_MidiSysEx"; | |
33 static const char* kPushMessageUmaKey = | |
34 "ContentSettings.PermisionActions_PushMessaging"; | |
35 | |
36 void RecordPermissionAction( | |
37 ContentSettingsType permission, PermissionAction action) { | |
38 switch (permission) { | |
39 case CONTENT_SETTINGS_TYPE_GEOLOCATION: | |
40 // TODO(miguelg): support geolocation through | |
41 // the generic permission class. | |
42 break; | |
43 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: | |
44 UMA_HISTOGRAM_ENUMERATION(kMidiUmaKey, | |
45 action, | |
46 PERMISSION_ACTION_NUM); | |
47 break; | |
48 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: | |
49 UMA_HISTOGRAM_ENUMERATION(kPushMessageUmaKey, | |
50 action, | |
51 PERMISSION_ACTION_NUM); | |
52 break; | |
53 #if defined(OS_ANDROID) | |
54 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER: | |
55 // TODO(miguelg): support protected media through | |
56 // the generic permission class. | |
57 break; | |
58 #endif | |
59 default: | |
60 NOTREACHED() << "PERMISSION " << permission << " not accounted for"; | |
61 } | |
62 } | |
63 | |
64 void RecordPermissionRequest( | |
65 ContentSettingsType permission) { | |
66 PermissionType type; | |
67 switch (permission) { | |
68 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: | |
69 type = PERMISSION_MIDI_SYSEX; | |
70 break; | |
71 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: | |
72 type = PERMISSION_PUSH_MESSAGING; | |
73 break; | |
74 default: | |
75 NOTREACHED() << "PERMISSION " << permission << " not accounted for"; | |
76 type = PERMISSION_UNKNOWN; | |
77 } | |
78 UMA_HISTOGRAM_ENUMERATION("ContentSettings.PermissionRequested", type, | |
79 PERMISSION_NUM); | |
80 } | |
81 | |
82 } // namespace | |
83 | |
84 | |
Mark P
2014/07/15 20:17:40
in general, what's with the extra vertical space i
| |
85 // Make sure you update histograms.xml permission histogram_suffix if you | |
86 // add new permission | |
87 void PermissionContextUmaUtil::PermissionRequested( | |
88 ContentSettingsType permission) { | |
89 RecordPermissionRequest(permission); | |
90 } | |
91 | |
92 | |
93 void PermissionContextUmaUtil::PermissionGranted( | |
94 ContentSettingsType permission) { | |
95 RecordPermissionAction(permission, GRANTED); | |
96 } | |
97 | |
98 void PermissionContextUmaUtil::PermissionDenied( | |
99 ContentSettingsType permission) { | |
100 RecordPermissionAction(permission, DENIED); | |
101 } | |
102 | |
103 void PermissionContextUmaUtil::PermissionDismissed( | |
104 ContentSettingsType permission) { | |
105 RecordPermissionAction(permission, DISMISSED); | |
106 } | |
107 | |
108 void PermissionContextUmaUtil::PermissionIgnored( | |
109 ContentSettingsType permission) { | |
110 RecordPermissionAction(permission, IGNORED); | |
111 } | |
OLD | NEW |