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.
5 #include "base/metrics/histogram.h"
6 #include "chrome/browser/content_settings/permission_context_uma_util.h"
10 // Enum for UMA purposes, make sure you update histograms.xml if you add new
11 // permission actions. Never delete or reorder an entry; only add new entries
12 // immediately before PERMISSION_NUM
13 enum PermissionAction
{
19 // Always keep this at the end.
20 PERMISSION_ACTION_NUM
,
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
25 // immediately before PERMISSION_NUM
27 PERMISSION_UNKNOWN
= 0,
28 PERMISSION_MIDI_SYSEX
= 1,
29 PERMISSION_PUSH_MESSAGING
= 2,
30 PERMISSION_NOTIFICATIONS
= 3,
32 // Always keep this at the end.
36 void RecordPermissionAction(
37 ContentSettingsType permission
, PermissionAction action
) {
39 case CONTENT_SETTINGS_TYPE_GEOLOCATION
:
40 // TODO(miguelg): support geolocation through
41 // the generic permission class.
43 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS
:
44 UMA_HISTOGRAM_ENUMERATION(
45 "ContentSettings.PermisionActions_Notifications",
47 PERMISSION_ACTION_NUM
);
49 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX
:
50 UMA_HISTOGRAM_ENUMERATION("ContentSettings.PermisionActions_MidiSysEx",
52 PERMISSION_ACTION_NUM
);
54 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING
:
55 UMA_HISTOGRAM_ENUMERATION(
56 "ContentSettings.PermisionActions_PushMessaging",
58 PERMISSION_ACTION_NUM
);
60 #if defined(OS_ANDROID)
61 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER
:
62 // TODO(miguelg): support protected media through
63 // the generic permission class.
67 NOTREACHED() << "PERMISSION " << permission
<< " not accounted for";
71 void RecordPermissionRequest(
72 ContentSettingsType permission
) {
75 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS
:
76 type
= PERMISSION_NOTIFICATIONS
;
78 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX
:
79 type
= PERMISSION_MIDI_SYSEX
;
81 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING
:
82 type
= PERMISSION_PUSH_MESSAGING
;
85 NOTREACHED() << "PERMISSION " << permission
<< " not accounted for";
86 type
= PERMISSION_UNKNOWN
;
88 UMA_HISTOGRAM_ENUMERATION("ContentSettings.PermissionRequested", type
,
94 // Make sure you update histograms.xml permission histogram_suffix if you
96 void PermissionContextUmaUtil::PermissionRequested(
97 ContentSettingsType permission
) {
98 RecordPermissionRequest(permission
);
101 void PermissionContextUmaUtil::PermissionGranted(
102 ContentSettingsType permission
) {
103 RecordPermissionAction(permission
, GRANTED
);
106 void PermissionContextUmaUtil::PermissionDenied(
107 ContentSettingsType permission
) {
108 RecordPermissionAction(permission
, DENIED
);
111 void PermissionContextUmaUtil::PermissionDismissed(
112 ContentSettingsType permission
) {
113 RecordPermissionAction(permission
, DISMISSED
);
116 void PermissionContextUmaUtil::PermissionIgnored(
117 ContentSettingsType permission
) {
118 RecordPermissionAction(permission
, IGNORED
);