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

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

Issue 1020683003: Make content::PermissionType an enum class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix android compile Created 5 years, 9 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
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 #include "content/public/browser/permission_type.h" 7 #include "content/public/browser/permission_type.h"
8 #include "url/gurl.h" 8 #include "url/gurl.h"
9 9
10 // UMA keys need to be statically initialized so plain function would not 10 // UMA keys need to be statically initialized so plain function would not
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 default: 91 default:
92 NOTREACHED() << "PERMISSION " << permission << " not accounted for"; 92 NOTREACHED() << "PERMISSION " << permission << " not accounted for";
93 } 93 }
94 } 94 }
95 95
96 void RecordPermissionRequest( 96 void RecordPermissionRequest(
97 ContentSettingsType permission, bool secure_origin) { 97 ContentSettingsType permission, bool secure_origin) {
98 content::PermissionType type; 98 content::PermissionType type;
99 switch (permission) { 99 switch (permission) {
100 case CONTENT_SETTINGS_TYPE_GEOLOCATION: 100 case CONTENT_SETTINGS_TYPE_GEOLOCATION:
101 type = content::PERMISSION_GEOLOCATION; 101 type = content::PermissionType::GEOLOCATION;
102 break; 102 break;
103 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: 103 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
104 type = content::PERMISSION_NOTIFICATIONS; 104 type = content::PermissionType::NOTIFICATIONS;
105 break; 105 break;
106 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: 106 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX:
107 type = content::PERMISSION_MIDI_SYSEX; 107 type = content::PermissionType::MIDI_SYSEX;
108 break; 108 break;
109 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: 109 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING:
110 type = content::PERMISSION_PUSH_MESSAGING; 110 type = content::PermissionType::PUSH_MESSAGING;
111 break; 111 break;
112 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) 112 #if defined(OS_ANDROID) || defined(OS_CHROMEOS)
113 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER: 113 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER:
114 type = content::PERMISSION_PROTECTED_MEDIA_IDENTIFIER; 114 type = content::PermissionType::PROTECTED_MEDIA_IDENTIFIER;
115 break; 115 break;
116 #endif 116 #endif
117 default: 117 default:
118 NOTREACHED() << "PERMISSION " << permission << " not accounted for"; 118 NOTREACHED() << "PERMISSION " << permission << " not accounted for";
119 return; 119 return;
120 } 120 }
121 UMA_HISTOGRAM_ENUMERATION( 121 UMA_HISTOGRAM_ENUMERATION(
122 "ContentSettings.PermissionRequested", type, content::PERMISSION_NUM); 122 "ContentSettings.PermissionRequested",
123 static_cast<base::HistogramBase::Sample>(type),
124 static_cast<base::HistogramBase::Sample>(content::PermissionType::NUM));
123 if (secure_origin) { 125 if (secure_origin) {
124 UMA_HISTOGRAM_ENUMERATION( 126 UMA_HISTOGRAM_ENUMERATION(
125 "ContentSettings.PermissionRequested_SecureOrigin", 127 "ContentSettings.PermissionRequested_SecureOrigin",
126 type, 128 static_cast<base::HistogramBase::Sample>(type),
127 content::PERMISSION_NUM); 129 static_cast<base::HistogramBase::Sample>(content::PermissionType::NUM));
128 } else { 130 } else {
129 UMA_HISTOGRAM_ENUMERATION( 131 UMA_HISTOGRAM_ENUMERATION(
130 "ContentSettings.PermissionRequested_InsecureOrigin", 132 "ContentSettings.PermissionRequested_InsecureOrigin",
131 type, 133 static_cast<base::HistogramBase::Sample>(type),
132 content::PERMISSION_NUM); 134 static_cast<base::HistogramBase::Sample>(content::PermissionType::NUM));
133 } 135 }
134 } 136 }
135 137
136 } // namespace 138 } // namespace
137 139
138 // Make sure you update histograms.xml permission histogram_suffix if you 140 // Make sure you update histograms.xml permission histogram_suffix if you
139 // add new permission 141 // add new permission
140 void PermissionContextUmaUtil::PermissionRequested( 142 void PermissionContextUmaUtil::PermissionRequested(
141 ContentSettingsType permission, const GURL& requesting_origin) { 143 ContentSettingsType permission, const GURL& requesting_origin) {
142 RecordPermissionRequest(permission, requesting_origin.SchemeIsSecure()); 144 RecordPermissionRequest(permission, requesting_origin.SchemeIsSecure());
(...skipping 15 matching lines...) Expand all
158 ContentSettingsType permission, const GURL& requesting_origin) { 160 ContentSettingsType permission, const GURL& requesting_origin) {
159 RecordPermissionAction(permission, DISMISSED, 161 RecordPermissionAction(permission, DISMISSED,
160 requesting_origin.SchemeIsSecure()); 162 requesting_origin.SchemeIsSecure());
161 } 163 }
162 164
163 void PermissionContextUmaUtil::PermissionIgnored( 165 void PermissionContextUmaUtil::PermissionIgnored(
164 ContentSettingsType permission, const GURL& requesting_origin) { 166 ContentSettingsType permission, const GURL& requesting_origin) {
165 RecordPermissionAction(permission, IGNORED, 167 RecordPermissionAction(permission, IGNORED,
166 requesting_origin.SchemeIsSecure()); 168 requesting_origin.SchemeIsSecure());
167 } 169 }
OLDNEW
« no previous file with comments | « chrome/browser/chrome_content_browser_client_unittest.cc ('k') | content/browser/frame_host/render_frame_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698