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

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

Issue 2184823007: Add a feature which, when enabled, blocks permissions after X prompt dismissals. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing nits Created 4 years, 4 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/command_line.h" 9 #include "base/command_line.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 action_str = "Ignored"; 78 action_str = "Ignored";
79 break; 79 break;
80 case REVOKED: 80 case REVOKED:
81 action_str = "Revoked"; 81 action_str = "Revoked";
82 break; 82 break;
83 default: 83 default:
84 NOTREACHED(); 84 NOTREACHED();
85 break; 85 break;
86 } 86 }
87 87
88 std::string permission_str = 88 std::string permission_str = PermissionUtil::GetPermissionString(permission);
89 PermissionUtil::GetPermissionString(permission);
90 if (permission_str.empty()) 89 if (permission_str.empty())
91 return ""; 90 return "";
92 return base::StringPrintf("ContentSettings.PermissionActions_%s.%s.Url", 91 return base::StringPrintf("ContentSettings.PermissionActions_%s.%s.Url",
93 permission_str.c_str(), action_str.c_str()); 92 permission_str.c_str(), action_str.c_str());
94 } 93 }
95 94
96 void RecordPermissionRequest(PermissionType permission, 95 void RecordPermissionRequest(PermissionType permission,
97 const GURL& requesting_origin, 96 const GURL& requesting_origin,
98 const GURL& embedding_origin, 97 const GURL& embedding_origin,
99 Profile* profile) { 98 Profile* profile) {
100 rappor::RapporService* rappor_service = g_browser_process->rappor_service(); 99 rappor::RapporService* rappor_service = g_browser_process->rappor_service();
101 if (rappor_service) { 100 if (rappor_service) {
102 if (permission == PermissionType::GEOLOCATION) { 101 if (permission == PermissionType::GEOLOCATION) {
103 // TODO(dominickn): remove this deprecated metric - crbug.com/605836. 102 // TODO(dominickn): remove this deprecated metric - crbug.com/605836.
104 rappor::SampleDomainAndRegistryFromGURL( 103 rappor::SampleDomainAndRegistryFromGURL(
105 rappor_service, 104 rappor_service, "ContentSettings.PermissionRequested.Geolocation.Url",
106 "ContentSettings.PermissionRequested.Geolocation.Url",
107 requesting_origin); 105 requesting_origin);
108 rappor_service->RecordSample( 106 rappor_service->RecordSample(
109 "ContentSettings.PermissionRequested.Geolocation.Url2", 107 "ContentSettings.PermissionRequested.Geolocation.Url2",
110 rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE, 108 rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE,
111 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin)); 109 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin));
112 } else if (permission == PermissionType::NOTIFICATIONS) { 110 } else if (permission == PermissionType::NOTIFICATIONS) {
113 // TODO(dominickn): remove this deprecated metric - crbug.com/605836. 111 // TODO(dominickn): remove this deprecated metric - crbug.com/605836.
114 rappor::SampleDomainAndRegistryFromGURL( 112 rappor::SampleDomainAndRegistryFromGURL(
115 rappor_service, 113 rappor_service,
116 "ContentSettings.PermissionRequested.Notifications.Url", 114 "ContentSettings.PermissionRequested.Notifications.Url",
117 requesting_origin); 115 requesting_origin);
118 rappor_service->RecordSample( 116 rappor_service->RecordSample(
119 "ContentSettings.PermissionRequested.Notifications.Url2", 117 "ContentSettings.PermissionRequested.Notifications.Url2",
120 rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE, 118 rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE,
121 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin)); 119 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin));
122 } else if (permission == PermissionType::MIDI || 120 } else if (permission == PermissionType::MIDI ||
123 permission == PermissionType::MIDI_SYSEX) { 121 permission == PermissionType::MIDI_SYSEX) {
124 // TODO(dominickn): remove this deprecated metric - crbug.com/605836. 122 // TODO(dominickn): remove this deprecated metric - crbug.com/605836.
125 rappor::SampleDomainAndRegistryFromGURL( 123 rappor::SampleDomainAndRegistryFromGURL(
126 rappor_service, 124 rappor_service, "ContentSettings.PermissionRequested.Midi.Url",
127 "ContentSettings.PermissionRequested.Midi.Url",
128 requesting_origin); 125 requesting_origin);
129 rappor_service->RecordSample( 126 rappor_service->RecordSample(
130 "ContentSettings.PermissionRequested.Midi.Url2", 127 "ContentSettings.PermissionRequested.Midi.Url2",
131 rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE, 128 rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE,
132 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin)); 129 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin));
133 } 130 }
134 } 131 }
135 132
136 bool secure_origin = content::IsOriginSecure(requesting_origin); 133 bool secure_origin = content::IsOriginSecure(requesting_origin);
137 UMA_HISTOGRAM_ENUMERATION( 134 UMA_HISTOGRAM_ENUMERATION(
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 DCHECK(!requests.empty()); 346 DCHECK(!requests.empty());
350 DCHECK(requests.size() == 1); 347 DCHECK(requests.size() == 1);
351 348
352 PERMISSION_BUBBLE_TYPE_UMA(kPermissionsPromptDenied, 349 PERMISSION_BUBBLE_TYPE_UMA(kPermissionsPromptDenied,
353 requests[0]->GetPermissionRequestType()); 350 requests[0]->GetPermissionRequestType());
354 PERMISSION_BUBBLE_GESTURE_TYPE_UMA( 351 PERMISSION_BUBBLE_GESTURE_TYPE_UMA(
355 kPermissionsPromptDeniedGesture, kPermissionsPromptDeniedNoGesture, 352 kPermissionsPromptDeniedGesture, kPermissionsPromptDeniedNoGesture,
356 requests[0]->GetGestureType(), requests[0]->GetPermissionRequestType()); 353 requests[0]->GetGestureType(), requests[0]->GetPermissionRequestType());
357 } 354 }
358 355
356 void PermissionUmaUtil::PermissionPromptDismissed(
357 content::PermissionType permission,
358 int count) {
359 switch (permission) {
360 case PermissionType::GEOLOCATION:
361 UMA_HISTOGRAM_COUNTS_100("Permissions.Prompt.DismissCount.Geolocation",
362 count);
363 break;
364 case PermissionType::NOTIFICATIONS:
365 UMA_HISTOGRAM_COUNTS_100("Permissions.Prompt.DismissCount.Notifications",
366 count);
367 break;
368 case PermissionType::MIDI_SYSEX:
369 UMA_HISTOGRAM_COUNTS_100("Permissions.Prompt.DismissCount.MidiSysEx",
370 count);
371 break;
372 case PermissionType::PUSH_MESSAGING:
373 UMA_HISTOGRAM_COUNTS_100("Permissions.Prompt.DismissCount.PushMessaging",
374 count);
375 break;
376 case PermissionType::PROTECTED_MEDIA_IDENTIFIER:
377 UMA_HISTOGRAM_COUNTS_100("Permissions.Prompt.DismissCount.ProtectedMedia",
378 count);
379 break;
380 case PermissionType::DURABLE_STORAGE:
381 UMA_HISTOGRAM_COUNTS_100("Permissions.Prompt.DismissCount.DurableStorage",
382 count);
383 break;
384 case PermissionType::AUDIO_CAPTURE:
385 UMA_HISTOGRAM_COUNTS_100("Permissions.Prompt.DismissCount.AudioCapture",
386 count);
387 break;
388 case PermissionType::VIDEO_CAPTURE:
389 UMA_HISTOGRAM_COUNTS_100("Permissions.Prompt.DismissCount.VideoCapture",
390 count);
391 break;
392 // The user is not prompted for these permissions, thus there is no dismiss
393 // recorded for them.
394 case PermissionType::MIDI:
395 case PermissionType::BACKGROUND_SYNC:
396 case PermissionType::NUM:
397 NOTREACHED() << "PERMISSION "
398 << PermissionUtil::GetPermissionString(permission)
399 << " not accounted for";
400 }
401 }
402
403 void PermissionUmaUtil::PermissionPromptIgnored(
404 content::PermissionType permission,
405 int count) {
406 switch (permission) {
407 case PermissionType::GEOLOCATION:
408 UMA_HISTOGRAM_COUNTS_100("Permissions.Prompt.IgnoreCount.Geolocation",
409 count);
410 break;
411 case PermissionType::NOTIFICATIONS:
412 UMA_HISTOGRAM_COUNTS_100("Permissions.Prompt.IgnoreCount.Notifications",
413 count);
414 break;
415 case PermissionType::MIDI_SYSEX:
416 UMA_HISTOGRAM_COUNTS_100("Permissions.Prompt.IgnoreCount.MidiSysEx",
417 count);
418 break;
419 case PermissionType::PUSH_MESSAGING:
420 UMA_HISTOGRAM_COUNTS_100("Permissions.Prompt.IgnoreCount.PushMessaging",
421 count);
422 break;
423 case PermissionType::PROTECTED_MEDIA_IDENTIFIER:
424 UMA_HISTOGRAM_COUNTS_100("Permissions.Prompt.IgnoreCount.ProtectedMedia",
425 count);
426 break;
427 case PermissionType::DURABLE_STORAGE:
428 UMA_HISTOGRAM_COUNTS_100("Permissions.Prompt.IgnoreCount.DurableStorage",
429 count);
430 break;
431 case PermissionType::AUDIO_CAPTURE:
432 UMA_HISTOGRAM_COUNTS_100("Permissions.Prompt.IgnoreCount.AudioCapture",
433 count);
434 break;
435 case PermissionType::VIDEO_CAPTURE:
436 UMA_HISTOGRAM_COUNTS_100("Permissions.Prompt.IgnoreCount.VideoCapture",
437 count);
438 break;
439 // The user is not prompted for these permissions, thus there is no
440 // ignore recorded for them.
441 case PermissionType::MIDI:
442 case PermissionType::BACKGROUND_SYNC:
443 case PermissionType::NUM:
444 NOTREACHED() << "PERMISSION "
445 << PermissionUtil::GetPermissionString(permission)
446 << " not accounted for";
447 }
448 }
449
359 bool PermissionUmaUtil::IsOptedIntoPermissionActionReporting(Profile* profile) { 450 bool PermissionUmaUtil::IsOptedIntoPermissionActionReporting(Profile* profile) {
360 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 451 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
361 switches::kEnablePermissionActionReporting)) 452 switches::kEnablePermissionActionReporting))
362 return false; 453 return false;
363 454
364 DCHECK(profile); 455 DCHECK(profile);
365 if (profile->GetProfileType() == Profile::INCOGNITO_PROFILE) 456 if (profile->GetProfileType() == Profile::INCOGNITO_PROFILE)
366 return false; 457 return false;
367 if (!profile->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled)) 458 if (!profile->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled))
368 return false; 459 return false;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 if (!deprecated_metric.empty() && rappor_service) { 563 if (!deprecated_metric.empty() && rappor_service) {
473 rappor::SampleDomainAndRegistryFromGURL(rappor_service, deprecated_metric, 564 rappor::SampleDomainAndRegistryFromGURL(rappor_service, deprecated_metric,
474 requesting_origin); 565 requesting_origin);
475 566
476 std::string rappor_metric = deprecated_metric + "2"; 567 std::string rappor_metric = deprecated_metric + "2";
477 rappor_service->RecordSample( 568 rappor_service->RecordSample(
478 rappor_metric, rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE, 569 rappor_metric, rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE,
479 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin)); 570 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin));
480 } 571 }
481 } 572 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698