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

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

Issue 2651163002: Add UMA for autoblocking and embargoing. (Closed)
Patch Set: Created 3 years, 11 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"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "base/time/time.h"
12 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/permissions/permission_decision_auto_blocker.h" 14 #include "chrome/browser/permissions/permission_decision_auto_blocker.h"
14 #include "chrome/browser/permissions/permission_manager.h" 15 #include "chrome/browser/permissions/permission_manager.h"
15 #include "chrome/browser/permissions/permission_request.h" 16 #include "chrome/browser/permissions/permission_request.h"
16 #include "chrome/browser/permissions/permission_util.h" 17 #include "chrome/browser/permissions/permission_util.h"
17 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 19 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
19 #include "chrome/browser/safe_browsing/ui_manager.h" 20 #include "chrome/browser/safe_browsing/ui_manager.h"
20 #include "chrome/browser/sync/profile_sync_service_factory.h" 21 #include "chrome/browser/sync/profile_sync_service_factory.h"
21 #include "chrome/common/chrome_switches.h" 22 #include "chrome/common/chrome_switches.h"
(...skipping 29 matching lines...) Expand all
51 no_gesture_metric_name, \ 52 no_gesture_metric_name, \
52 gesture_type, \ 53 gesture_type, \
53 permission_bubble_type) \ 54 permission_bubble_type) \
54 if (gesture_type == PermissionRequestGestureType::GESTURE) { \ 55 if (gesture_type == PermissionRequestGestureType::GESTURE) { \
55 PERMISSION_BUBBLE_TYPE_UMA(gesture_metric_name, permission_bubble_type); \ 56 PERMISSION_BUBBLE_TYPE_UMA(gesture_metric_name, permission_bubble_type); \
56 } else if (gesture_type == PermissionRequestGestureType::NO_GESTURE) { \ 57 } else if (gesture_type == PermissionRequestGestureType::NO_GESTURE) { \
57 PERMISSION_BUBBLE_TYPE_UMA(no_gesture_metric_name, \ 58 PERMISSION_BUBBLE_TYPE_UMA(no_gesture_metric_name, \
58 permission_bubble_type); \ 59 permission_bubble_type); \
59 } 60 }
60 61
62 #define PERMISSION_UMA
dominickn 2017/01/27 06:05:47 Remove this :)
meredithl 2017/01/29 23:48:30 Done.
63
61 using content::PermissionType; 64 using content::PermissionType;
62 65
63 namespace { 66 namespace {
64 67
65 const std::string GetRapporMetric(PermissionType permission, 68 const std::string GetRapporMetric(PermissionType permission,
66 PermissionAction action) { 69 PermissionAction action) {
67 std::string action_str; 70 std::string action_str;
68 switch (action) { 71 switch (action) {
69 case GRANTED: 72 case GRANTED:
70 action_str = "Granted"; 73 action_str = "Granted";
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 permission == PermissionType::AUDIO_CAPTURE || 353 permission == PermissionType::AUDIO_CAPTURE ||
351 permission == PermissionType::VIDEO_CAPTURE) { 354 permission == PermissionType::VIDEO_CAPTURE) {
352 // An unknown gesture type is passed in since gesture type is only 355 // An unknown gesture type is passed in since gesture type is only
353 // applicable in prompt UIs where revocations are not possible. 356 // applicable in prompt UIs where revocations are not possible.
354 RecordPermissionAction(permission, REVOKED, source_ui, 357 RecordPermissionAction(permission, REVOKED, source_ui,
355 PermissionRequestGestureType::UNKNOWN, 358 PermissionRequestGestureType::UNKNOWN,
356 revoked_origin, profile); 359 revoked_origin, profile);
357 } 360 }
358 } 361 }
359 362
363 void PermissionUmaUtil::RecordPermissionEmbargoReason(
364 PermissionEmbargoReason embargo_reason) {
365 UMA_HISTOGRAM_ENUMERATION("Permissions.AutoBlocker.EmbargoReason",
366 embargo_reason,
367 PermissionEmbargoReason::EMBARGO_NUM);
368 }
369
370 void PermissionUmaUtil::RecordRepeatedEmbargo(
371 PermissionEmbargoReason embargo_reason) {
372 // NOT_EMBARGOED should not ever result in an (origin, permission) pair being
373 // placed under embargo, let alone repeatedly.
374 DCHECK_NE(PermissionEmbargoReason::NOT_EMBARGOED, embargo_reason);
375 UMA_HISTOGRAM_ENUMERATION("Permissions.AutoBlocker.RepeatedEmbargo",
376 embargo_reason,
377 PermissionEmbargoReason::EMBARGO_NUM);
378 }
379
380 void PermissionUmaUtil::RecordSafeBrowsingResponse(
381 base::TimeDelta response_time,
382 SafeBrowsingResponse response) {
383 UMA_HISTOGRAM_TIMES("Permissions.AutoBlocker.SafeBrowsingResponseTime",
384 response_time);
385 UMA_HISTOGRAM_ENUMERATION("Permissions.AutoBlocker.SafeBrowsingResponse",
386 response, SafeBrowsingResponse::RESPONSE_NUM);
387 }
388
360 void PermissionUmaUtil::PermissionPromptShown( 389 void PermissionUmaUtil::PermissionPromptShown(
361 const std::vector<PermissionRequest*>& requests) { 390 const std::vector<PermissionRequest*>& requests) {
362 DCHECK(!requests.empty()); 391 DCHECK(!requests.empty());
363 392
364 PermissionRequestType permission_prompt_type = 393 PermissionRequestType permission_prompt_type =
365 PermissionRequestType::MULTIPLE; 394 PermissionRequestType::MULTIPLE;
366 PermissionRequestGestureType permission_gesture_type = 395 PermissionRequestGestureType permission_gesture_type =
367 PermissionRequestGestureType::UNKNOWN; 396 PermissionRequestGestureType::UNKNOWN;
368 if (requests.size() == 1) { 397 if (requests.size() == 1) {
369 permission_prompt_type = requests[0]->GetPermissionRequestType(); 398 permission_prompt_type = requests[0]->GetPermissionRequestType();
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 if (!deprecated_metric.empty() && rappor_service) { 745 if (!deprecated_metric.empty() && rappor_service) {
717 rappor::SampleDomainAndRegistryFromGURL(rappor_service, deprecated_metric, 746 rappor::SampleDomainAndRegistryFromGURL(rappor_service, deprecated_metric,
718 requesting_origin); 747 requesting_origin);
719 748
720 std::string rappor_metric = deprecated_metric + "2"; 749 std::string rappor_metric = deprecated_metric + "2";
721 rappor_service->RecordSampleString( 750 rappor_service->RecordSampleString(
722 rappor_metric, rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE, 751 rappor_metric, rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE,
723 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin)); 752 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin));
724 } 753 }
725 } 754 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698