Update mojo surfaces bindings and mojo/cc/ glue
[chromium-blink-merge.git] / chrome / browser / content_settings / permission_context_uma_util.cc
blob2b7ff8f18f6d8c071bba34f6ffa245493b4fe91e
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"
8 namespace {
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 {
14 GRANTED = 0,
15 DENIED = 1,
16 DISMISSED = 2,
17 IGNORED = 3,
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
26 enum PermissionType {
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.
33 PERMISSION_NUM,
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_NOTIFICATIONS:
44 UMA_HISTOGRAM_ENUMERATION(
45 "ContentSettings.PermisionActions_Notifications",
46 action,
47 PERMISSION_ACTION_NUM);
48 break;
49 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX:
50 UMA_HISTOGRAM_ENUMERATION("ContentSettings.PermisionActions_MidiSysEx",
51 action,
52 PERMISSION_ACTION_NUM);
53 break;
54 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING:
55 UMA_HISTOGRAM_ENUMERATION(
56 "ContentSettings.PermisionActions_PushMessaging",
57 action,
58 PERMISSION_ACTION_NUM);
59 break;
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.
64 break;
65 #endif
66 default:
67 NOTREACHED() << "PERMISSION " << permission << " not accounted for";
71 void RecordPermissionRequest(
72 ContentSettingsType permission) {
73 PermissionType type;
74 switch (permission) {
75 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
76 type = PERMISSION_NOTIFICATIONS;
77 break;
78 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX:
79 type = PERMISSION_MIDI_SYSEX;
80 break;
81 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING:
82 type = PERMISSION_PUSH_MESSAGING;
83 break;
84 default:
85 NOTREACHED() << "PERMISSION " << permission << " not accounted for";
86 type = PERMISSION_UNKNOWN;
88 UMA_HISTOGRAM_ENUMERATION("ContentSettings.PermissionRequested", type,
89 PERMISSION_NUM);
92 } // namespace
94 // Make sure you update histograms.xml permission histogram_suffix if you
95 // add new permission
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);