Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1196)

Side by Side Diff: chrome/browser/content_settings/permission_context_uma_util.cc

Issue 376253005: Migrate the notification permission to the new common permission classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
11 // permission actions. Never delete or reorder an entry; only add new entries 11 // permission actions. Never delete or reorder an entry; only add new entries
12 // immediately before PERMISSION_NUM 12 // immediately before PERMISSION_NUM
13 enum PermissionAction { 13 enum PermissionAction {
14 GRANTED = 0, 14 GRANTED = 0,
15 DENIED = 1, 15 DENIED = 1,
16 DISMISSED = 2, 16 DISMISSED = 2,
17 IGNORED = 3, 17 IGNORED = 3,
18 18
19 // Always keep this at the end. 19 // Always keep this at the end.
20 PERMISSION_ACTION_NUM, 20 PERMISSION_ACTION_NUM,
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, 27 PERMISSION_UNKNOWN = 0,
28 PERMISSION_MIDI_SYSEX, 28 PERMISSION_MIDI_SYSEX = 1,
29 PERMISSION_PUSH_MESSAGING, 29 PERMISSION_PUSH_MESSAGING = 2,
30 PERMISSION_NOTIFICATIONS = 3,
30 31
31 // Always keep this at the end. 32 // Always keep this at the end.
32 PERMISSION_NUM, 33 PERMISSION_NUM,
33 }; 34 };
34 35
35 static const char* kMidiUmaKey = "ContentSettings.PermisionActions_MidiSysEx";
36 static const char* kPushMessageUmaKey =
37 "ContentSettings.PermisionActions_PushMessaging";
38
39 void RecordPermissionAction( 36 void RecordPermissionAction(
40 ContentSettingsType permission, PermissionAction action) { 37 ContentSettingsType permission, PermissionAction action) {
41 switch (permission) { 38 switch (permission) {
42 case CONTENT_SETTINGS_TYPE_GEOLOCATION: 39 case CONTENT_SETTINGS_TYPE_GEOLOCATION:
43 // TODO(miguelg): support geolocation through 40 // TODO(miguelg): support geolocation through
44 // the generic permission class. 41 // the generic permission class.
45 break; 42 break;
43 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
44 UMA_HISTOGRAM_ENUMERATION(
45 "ContentSettings.PermisionActions_Notifications",
46 action,
47 PERMISSION_ACTION_NUM);
48 break;
46 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: 49 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX:
47 UMA_HISTOGRAM_ENUMERATION(kMidiUmaKey, 50 UMA_HISTOGRAM_ENUMERATION("ContentSettings.PermisionActions_MidiSysEx",
48 action, 51 action,
49 PERMISSION_ACTION_NUM); 52 PERMISSION_ACTION_NUM);
50 break; 53 break;
51 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: 54 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING:
52 UMA_HISTOGRAM_ENUMERATION(kPushMessageUmaKey, 55 UMA_HISTOGRAM_ENUMERATION(
53 action, 56 "ContentSettings.PermisionActions_PushMessaging",
54 PERMISSION_ACTION_NUM); 57 action,
58 PERMISSION_ACTION_NUM);
55 break; 59 break;
56 #if defined(OS_ANDROID) 60 #if defined(OS_ANDROID)
57 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER: 61 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER:
58 // TODO(miguelg): support protected media through 62 // TODO(miguelg): support protected media through
59 // the generic permission class. 63 // the generic permission class.
60 break; 64 break;
61 #endif 65 #endif
62 default: 66 default:
63 NOTREACHED() << "PERMISSION " << permission << " not accounted for"; 67 NOTREACHED() << "PERMISSION " << permission << " not accounted for";
64 } 68 }
65 } 69 }
66 70
67 void RecordPermissionRequest( 71 void RecordPermissionRequest(
68 ContentSettingsType permission) { 72 ContentSettingsType permission) {
69 PermissionType type; 73 PermissionType type;
70 switch (permission) { 74 switch (permission) {
75 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
76 type = PERMISSION_NOTIFICATIONS;
77 break;
71 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: 78 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX:
72 type = PERMISSION_MIDI_SYSEX; 79 type = PERMISSION_MIDI_SYSEX;
73 break; 80 break;
74 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: 81 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING:
75 type = PERMISSION_PUSH_MESSAGING; 82 type = PERMISSION_PUSH_MESSAGING;
76 break; 83 break;
77 default: 84 default:
78 NOTREACHED() << "PERMISSION " << permission << " not accounted for"; 85 NOTREACHED() << "PERMISSION " << permission << " not accounted for";
79 type = PERMISSION_UNKNOWN; 86 type = PERMISSION_UNKNOWN;
80 } 87 }
(...skipping 22 matching lines...) Expand all
103 110
104 void PermissionContextUmaUtil::PermissionDismissed( 111 void PermissionContextUmaUtil::PermissionDismissed(
105 ContentSettingsType permission) { 112 ContentSettingsType permission) {
106 RecordPermissionAction(permission, DISMISSED); 113 RecordPermissionAction(permission, DISMISSED);
107 } 114 }
108 115
109 void PermissionContextUmaUtil::PermissionIgnored( 116 void PermissionContextUmaUtil::PermissionIgnored(
110 ContentSettingsType permission) { 117 ContentSettingsType permission) {
111 RecordPermissionAction(permission, IGNORED); 118 RecordPermissionAction(permission, IGNORED);
112 } 119 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698