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 | |
12 // an entry; only add new entries immediately before PERMISSION_NUM | |
13 enum PermissionAction { | |
14 REQUESTED = 0, | |
15 GRANTED = 1, | |
16 DENIED = 2, | |
17 DISMISSED = 3, | |
18 IGNORED = 4, | |
19 | |
20 // Always keep this at the end. | |
21 PERMISSION_ACTION_NUM, | |
22 }; | |
23 | |
24 static const char* kMidiUmaKey = "ContentSettings.PermisionActions_MidiSysEx"; | |
25 static const char* kPushMessageUmaKey = | |
26 "ContentSettings.PermisionActions_PushMessaging"; | |
27 | |
28 void PermissionUmaInternal( | |
29 ContentSettingsType permission, PermissionAction action) { | |
30 switch (permission) { | |
31 case CONTENT_SETTINGS_TYPE_GEOLOCATION: | |
32 // TODO(miguelg): support geolocation through | |
33 // the generic permission class. | |
34 break; | |
35 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: | |
36 UMA_HISTOGRAM_ENUMERATION(kMidiUmaKey, | |
37 action, | |
38 PERMISSION_ACTION_NUM); | |
39 break; | |
40 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: | |
41 UMA_HISTOGRAM_ENUMERATION(kPushMessageUmaKey, | |
42 action, | |
43 PERMISSION_ACTION_NUM); | |
44 break; | |
45 #if defined(OS_ANDROID) | |
46 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER: | |
47 // TODO(miguelg): support protected media through | |
48 // the generic permission class. | |
49 break; | |
50 #endif | |
51 default: | |
52 NOTREACHED() << "PERMISSION " << permission << " not accounted for"; | |
53 } | |
54 } | |
55 | |
56 } // namespace | |
57 | |
58 | |
59 // Make sure you update histograms.xml permission histogram_suffix if you | |
60 // add new permission | |
61 // static | |
Bernhard Bauer
2014/07/14 15:22:15
Nit: static could come immediately before the meth
Miguel Garcia
2014/07/14 16:57:50
I removed it, it is clear from the class that they
| |
62 | |
63 void PermissionContextUmaUtil::PermissionRequested( | |
64 ContentSettingsType permission) { | |
65 PermissionUmaInternal(permission, REQUESTED); | |
66 } | |
67 | |
68 | |
69 void PermissionContextUmaUtil::PermissionGranted( | |
70 ContentSettingsType permission) { | |
71 PermissionUmaInternal(permission, GRANTED); | |
72 } | |
73 | |
74 void PermissionContextUmaUtil::PermissionDenied( | |
75 ContentSettingsType permission) { | |
76 PermissionUmaInternal(permission, DENIED); | |
77 } | |
78 | |
79 void PermissionContextUmaUtil::PermissionDismissed( | |
80 ContentSettingsType permission) { | |
81 PermissionUmaInternal(permission, DISMISSED); | |
82 } | |
83 | |
84 void PermissionContextUmaUtil::PermissionIgnored( | |
85 ContentSettingsType permission) { | |
86 PermissionUmaInternal(permission, IGNORED); | |
87 } | |
OLD | NEW |