| OLD | NEW |
| 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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 permission == PermissionType::AUDIO_CAPTURE || | 351 permission == PermissionType::AUDIO_CAPTURE || |
| 351 permission == PermissionType::VIDEO_CAPTURE) { | 352 permission == PermissionType::VIDEO_CAPTURE) { |
| 352 // An unknown gesture type is passed in since gesture type is only | 353 // An unknown gesture type is passed in since gesture type is only |
| 353 // applicable in prompt UIs where revocations are not possible. | 354 // applicable in prompt UIs where revocations are not possible. |
| 354 RecordPermissionAction(permission, REVOKED, source_ui, | 355 RecordPermissionAction(permission, REVOKED, source_ui, |
| 355 PermissionRequestGestureType::UNKNOWN, | 356 PermissionRequestGestureType::UNKNOWN, |
| 356 revoked_origin, profile); | 357 revoked_origin, profile); |
| 357 } | 358 } |
| 358 } | 359 } |
| 359 | 360 |
| 361 void PermissionUmaUtil::RecordPermissionEmbargoReason( |
| 362 PermissionEmbargoReason embargo_reason) { |
| 363 UMA_HISTOGRAM_ENUMERATION("Permissions.AutoBlocker.EmbargoReason", |
| 364 embargo_reason, |
| 365 PermissionEmbargoReason::REASON_NUM); |
| 366 } |
| 367 |
| 368 void PermissionUmaUtil::RecordRepeatedEmbargo( |
| 369 PermissionEmbargoReason embargo_reason) { |
| 370 // NOT_EMBARGOED should not ever result in an (origin, permission) pair being |
| 371 // placed under embargo, let alone repeatedly. |
| 372 DCHECK_NE(PermissionEmbargoReason::NOT_EMBARGOED, embargo_reason); |
| 373 UMA_HISTOGRAM_ENUMERATION("Permissions.AutoBlocker.RepeatedEmbargo", |
| 374 embargo_reason, |
| 375 PermissionEmbargoReason::REASON_NUM); |
| 376 } |
| 377 |
| 378 void PermissionUmaUtil::RecordSafeBrowsingResponse( |
| 379 base::TimeDelta response_time, |
| 380 SafeBrowsingResponse response) { |
| 381 UMA_HISTOGRAM_TIMES("Permissions.AutoBlocker.SafeBrowsingResponseTime", |
| 382 response_time); |
| 383 UMA_HISTOGRAM_ENUMERATION("Permissions.AutoBlocker.SafeBrowsingResponse", |
| 384 response, SafeBrowsingResponse::RESPONSE_NUM); |
| 385 } |
| 386 |
| 360 void PermissionUmaUtil::PermissionPromptShown( | 387 void PermissionUmaUtil::PermissionPromptShown( |
| 361 const std::vector<PermissionRequest*>& requests) { | 388 const std::vector<PermissionRequest*>& requests) { |
| 362 DCHECK(!requests.empty()); | 389 DCHECK(!requests.empty()); |
| 363 | 390 |
| 364 PermissionRequestType permission_prompt_type = | 391 PermissionRequestType permission_prompt_type = |
| 365 PermissionRequestType::MULTIPLE; | 392 PermissionRequestType::MULTIPLE; |
| 366 PermissionRequestGestureType permission_gesture_type = | 393 PermissionRequestGestureType permission_gesture_type = |
| 367 PermissionRequestGestureType::UNKNOWN; | 394 PermissionRequestGestureType::UNKNOWN; |
| 368 if (requests.size() == 1) { | 395 if (requests.size() == 1) { |
| 369 permission_prompt_type = requests[0]->GetPermissionRequestType(); | 396 permission_prompt_type = requests[0]->GetPermissionRequestType(); |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 if (!deprecated_metric.empty() && rappor_service) { | 743 if (!deprecated_metric.empty() && rappor_service) { |
| 717 rappor::SampleDomainAndRegistryFromGURL(rappor_service, deprecated_metric, | 744 rappor::SampleDomainAndRegistryFromGURL(rappor_service, deprecated_metric, |
| 718 requesting_origin); | 745 requesting_origin); |
| 719 | 746 |
| 720 std::string rappor_metric = deprecated_metric + "2"; | 747 std::string rappor_metric = deprecated_metric + "2"; |
| 721 rappor_service->RecordSampleString( | 748 rappor_service->RecordSampleString( |
| 722 rappor_metric, rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE, | 749 rappor_metric, rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE, |
| 723 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin)); | 750 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin)); |
| 724 } | 751 } |
| 725 } | 752 } |
| OLD | NEW |