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

Side by Side Diff: chrome/browser/permissions/permission_uma_util.cc

Issue 1921533004: Add a low-frequency RAPPOR configuration, and use it for Safe Browsing and Permissions metrics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Actually make permissions RAPPOR use the new config Created 4 years, 8 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 "chrome/browser/permissions/permission_uma_util.h" 5 #include "chrome/browser/permissions/permission_uma_util.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 18 matching lines...) Expand all
29 PERMISSION_ACTION_NUM); \ 29 PERMISSION_ACTION_NUM); \
30 } else { \ 30 } else { \
31 UMA_HISTOGRAM_ENUMERATION(permission_insecure, action, \ 31 UMA_HISTOGRAM_ENUMERATION(permission_insecure, action, \
32 PERMISSION_ACTION_NUM); \ 32 PERMISSION_ACTION_NUM); \
33 } 33 }
34 34
35 using content::PermissionType; 35 using content::PermissionType;
36 36
37 namespace { 37 namespace {
38 38
39 // Deprecated. This method is used for the single-dimensional RAPPOR metrics
40 // that are being replaced by the multi-dimensional ones.
41 const std::string GetRapporMetric(PermissionType permission, 39 const std::string GetRapporMetric(PermissionType permission,
42 PermissionAction action) { 40 PermissionAction action) {
43 std::string action_str; 41 std::string action_str;
44 switch (action) { 42 switch (action) {
45 case GRANTED: 43 case GRANTED:
46 action_str = "Granted"; 44 action_str = "Granted";
47 break; 45 break;
48 case DENIED: 46 case DENIED:
49 action_str = "Denied"; 47 action_str = "Denied";
50 break; 48 break;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // The user is not prompted for these permissions, thus there is no 135 // The user is not prompted for these permissions, thus there is no
138 // permission action recorded for them. 136 // permission action recorded for them.
139 case PermissionType::MIDI: 137 case PermissionType::MIDI:
140 case PermissionType::BACKGROUND_SYNC: 138 case PermissionType::BACKGROUND_SYNC:
141 case PermissionType::NUM: 139 case PermissionType::NUM:
142 NOTREACHED() << "PERMISSION " 140 NOTREACHED() << "PERMISSION "
143 << PermissionUtil::GetPermissionString(permission) 141 << PermissionUtil::GetPermissionString(permission)
144 << " not accounted for"; 142 << " not accounted for";
145 } 143 }
146 144
147 // There are two sets of semi-redundant RAPPOR metrics being reported:
148 // The soon-to-be-deprecated single dimensional ones, and the new
149 // multi-dimensional ones.
150 rappor::RapporService* rappor_service = g_browser_process->rappor_service(); 145 rappor::RapporService* rappor_service = g_browser_process->rappor_service();
151 const std::string rappor_metric = GetRapporMetric(permission, action); 146 const std::string deprecated_metric = GetRapporMetric(permission, action);
152 if (!rappor_metric.empty()) 147 if (!deprecated_metric.empty() && rappor_service) {
153 rappor::SampleDomainAndRegistryFromGURL( 148 // TODO(dominickn): remove this deprecated metric - crbug.com/605836.
154 rappor_service, rappor_metric, requesting_origin); 149 rappor::SampleDomainAndRegistryFromGURL(rappor_service, deprecated_metric,
150 requesting_origin);
155 151
156 // Add multi-dimensional RAPPOR reporting for safe-browsing users. 152 // The new metric name is the deprecated metric name with "2" on the end,
157 std::string permission_str = 153 // e.g. ContentSettings.PermissionActions_Geolocation.Granted.Url2.
158 PermissionUtil::GetPermissionString(permission); 154 std::string rappor_metric = deprecated_metric + "2";
felt 2016/04/28 23:40:44 I'm a little confused here. Why is recording the n
dominickn 2016/04/29 07:14:45 Only because it's easier to append, rather that ch
159 if (!rappor_service || permission_str.empty()) 155 rappor_service->RecordSample(
160 return; 156 rappor_metric, rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE,
161 157 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin));
162 std::unique_ptr<rappor::Sample> sample = 158 }
163 rappor_service->CreateSample(rappor::SAFEBROWSING_RAPPOR_TYPE);
164 sample->SetStringField("Scheme", requesting_origin.scheme());
165 sample->SetStringField("Host", requesting_origin.host());
166 sample->SetStringField("Port", requesting_origin.port());
167 sample->SetStringField("Domain",
168 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin));
169 sample->SetFlagsField("Actions", static_cast<uint64_t>(1) << action,
170 PermissionAction::PERMISSION_ACTION_NUM);
171 rappor_service->RecordSampleObj("Permissions.Action." + permission_str,
172 std::move(sample));
173 } 159 }
174 160
175 void RecordPermissionRequest(PermissionType permission, 161 void RecordPermissionRequest(PermissionType permission,
176 const GURL& requesting_origin, 162 const GURL& requesting_origin,
177 const GURL& embedding_origin, 163 const GURL& embedding_origin,
178 Profile* profile) { 164 Profile* profile) {
179 bool secure_origin = content::IsOriginSecure(requesting_origin); 165 rappor::RapporService* rappor_service = g_browser_process->rappor_service();
180 if (permission == PermissionType::GEOLOCATION) { 166 if (rappor_service) {
167 if (permission == PermissionType::GEOLOCATION) {
168 // TODO(dominickn): remove this deprecated metric - crbug.com/605836.
181 rappor::SampleDomainAndRegistryFromGURL( 169 rappor::SampleDomainAndRegistryFromGURL(
182 g_browser_process->rappor_service(), 170 rappor_service,
183 "ContentSettings.PermissionRequested.Geolocation.Url", 171 "ContentSettings.PermissionRequested.Geolocation.Url",
184 requesting_origin); 172 requesting_origin);
185 } else if (permission == PermissionType::NOTIFICATIONS) { 173 rappor_service->RecordSample(
174 "ContentSettings.PermissionRequested.Geolocation.Url2",
175 rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE,
176 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin));
177 } else if (permission == PermissionType::NOTIFICATIONS) {
178 // TODO(dominickn): remove this deprecated metric - crbug.com/605836.
186 rappor::SampleDomainAndRegistryFromGURL( 179 rappor::SampleDomainAndRegistryFromGURL(
187 g_browser_process->rappor_service(), 180 rappor_service,
188 "ContentSettings.PermissionRequested.Notifications.Url", 181 "ContentSettings.PermissionRequested.Notifications.Url",
189 requesting_origin); 182 requesting_origin);
183 rappor_service->RecordSample(
184 "ContentSettings.PermissionRequested.Notifications.Url2",
185 rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE,
186 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin));
187 }
190 } 188 }
189
190 bool secure_origin = content::IsOriginSecure(requesting_origin);
191 UMA_HISTOGRAM_ENUMERATION( 191 UMA_HISTOGRAM_ENUMERATION(
192 "ContentSettings.PermissionRequested", 192 "ContentSettings.PermissionRequested",
193 static_cast<base::HistogramBase::Sample>(permission), 193 static_cast<base::HistogramBase::Sample>(permission),
194 static_cast<base::HistogramBase::Sample>(PermissionType::NUM)); 194 static_cast<base::HistogramBase::Sample>(PermissionType::NUM));
195 if (secure_origin) { 195 if (secure_origin) {
196 UMA_HISTOGRAM_ENUMERATION( 196 UMA_HISTOGRAM_ENUMERATION(
197 "ContentSettings.PermissionRequested_SecureOrigin", 197 "ContentSettings.PermissionRequested_SecureOrigin",
198 static_cast<base::HistogramBase::Sample>(permission), 198 static_cast<base::HistogramBase::Sample>(permission),
199 static_cast<base::HistogramBase::Sample>(PermissionType::NUM)); 199 static_cast<base::HistogramBase::Sample>(PermissionType::NUM));
200 } else { 200 } else {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 const std::vector<PermissionBubbleRequest*>& requests) { 280 const std::vector<PermissionBubbleRequest*>& requests) {
281 DCHECK(!requests.empty()); 281 DCHECK(!requests.empty());
282 PermissionBubbleType permission_prompt_type = PermissionBubbleType::MULTIPLE; 282 PermissionBubbleType permission_prompt_type = PermissionBubbleType::MULTIPLE;
283 if (requests.size() == 1) 283 if (requests.size() == 1)
284 permission_prompt_type = requests[0]->GetPermissionBubbleType(); 284 permission_prompt_type = requests[0]->GetPermissionBubbleType();
285 UMA_HISTOGRAM_ENUMERATION( 285 UMA_HISTOGRAM_ENUMERATION(
286 "Permissions.Prompt.Shown", 286 "Permissions.Prompt.Shown",
287 static_cast<base::HistogramBase::Sample>(permission_prompt_type), 287 static_cast<base::HistogramBase::Sample>(permission_prompt_type),
288 static_cast<base::HistogramBase::Sample>(PermissionBubbleType::NUM)); 288 static_cast<base::HistogramBase::Sample>(PermissionBubbleType::NUM));
289 } 289 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/safe_browsing_blocking_page.h » ('j') | components/rappor/rappor_parameters.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698