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" |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 // ignore recorded for them. | 440 // ignore recorded for them. |
441 case PermissionType::MIDI: | 441 case PermissionType::MIDI: |
442 case PermissionType::BACKGROUND_SYNC: | 442 case PermissionType::BACKGROUND_SYNC: |
443 case PermissionType::NUM: | 443 case PermissionType::NUM: |
444 NOTREACHED() << "PERMISSION " | 444 NOTREACHED() << "PERMISSION " |
445 << PermissionUtil::GetPermissionString(permission) | 445 << PermissionUtil::GetPermissionString(permission) |
446 << " not accounted for"; | 446 << " not accounted for"; |
447 } | 447 } |
448 } | 448 } |
449 | 449 |
| 450 void PermissionUmaUtil::PermissionPromptAcceptedWithPersistenceToggle( |
| 451 content::PermissionType permission, |
| 452 bool toggle_enabled) { |
| 453 switch (permission) { |
| 454 case PermissionType::GEOLOCATION: |
| 455 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Accepted.Persisted.Geolocation", |
| 456 toggle_enabled); |
| 457 break; |
| 458 case PermissionType::NOTIFICATIONS: |
| 459 UMA_HISTOGRAM_BOOLEAN( |
| 460 "Permissions.Prompt.Accepted.Persisted.Notifications", |
| 461 toggle_enabled); |
| 462 break; |
| 463 case PermissionType::MIDI_SYSEX: |
| 464 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Accepted.Persisted.MidiSysEx", |
| 465 toggle_enabled); |
| 466 break; |
| 467 case PermissionType::PUSH_MESSAGING: |
| 468 UMA_HISTOGRAM_BOOLEAN( |
| 469 "Permissions.Prompt.Accepted.Persisted.PushMessaging", |
| 470 toggle_enabled); |
| 471 break; |
| 472 case PermissionType::PROTECTED_MEDIA_IDENTIFIER: |
| 473 UMA_HISTOGRAM_BOOLEAN( |
| 474 "Permissions.Prompt.Accepted.Persisted.ProtectedMedia", |
| 475 toggle_enabled); |
| 476 break; |
| 477 case PermissionType::DURABLE_STORAGE: |
| 478 UMA_HISTOGRAM_BOOLEAN( |
| 479 "Permissions.Prompt.Accepted.Persisted.DurableStorage", |
| 480 toggle_enabled); |
| 481 break; |
| 482 case PermissionType::AUDIO_CAPTURE: |
| 483 UMA_HISTOGRAM_BOOLEAN( |
| 484 "Permissions.Prompt.Accepted.Persisted.AudioCapture", toggle_enabled); |
| 485 break; |
| 486 case PermissionType::VIDEO_CAPTURE: |
| 487 UMA_HISTOGRAM_BOOLEAN( |
| 488 "Permissions.Prompt.Accepted.Persisted.VideoCapture", toggle_enabled); |
| 489 break; |
| 490 // The user is not prompted for these permissions, thus there is no accept |
| 491 // recorded for them. |
| 492 case PermissionType::MIDI: |
| 493 case PermissionType::BACKGROUND_SYNC: |
| 494 case PermissionType::NUM: |
| 495 NOTREACHED() << "PERMISSION " |
| 496 << PermissionUtil::GetPermissionString(permission) |
| 497 << " not accounted for"; |
| 498 } |
| 499 } |
| 500 |
| 501 void PermissionUmaUtil::PermissionPromptDeniedWithPersistenceToggle( |
| 502 content::PermissionType permission, |
| 503 bool toggle_enabled) { |
| 504 switch (permission) { |
| 505 case PermissionType::GEOLOCATION: |
| 506 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.Geolocation", |
| 507 toggle_enabled); |
| 508 break; |
| 509 case PermissionType::NOTIFICATIONS: |
| 510 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.Notifications", |
| 511 toggle_enabled); |
| 512 break; |
| 513 case PermissionType::MIDI_SYSEX: |
| 514 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.MidiSysEx", |
| 515 toggle_enabled); |
| 516 break; |
| 517 case PermissionType::PUSH_MESSAGING: |
| 518 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.PushMessaging", |
| 519 toggle_enabled); |
| 520 break; |
| 521 case PermissionType::PROTECTED_MEDIA_IDENTIFIER: |
| 522 UMA_HISTOGRAM_BOOLEAN( |
| 523 "Permissions.Prompt.Denied.Persisted.ProtectedMedia", toggle_enabled); |
| 524 break; |
| 525 case PermissionType::DURABLE_STORAGE: |
| 526 UMA_HISTOGRAM_BOOLEAN( |
| 527 "Permissions.Prompt.Denied.Persisted.DurableStorage", toggle_enabled); |
| 528 break; |
| 529 case PermissionType::AUDIO_CAPTURE: |
| 530 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.AudioCapture", |
| 531 toggle_enabled); |
| 532 break; |
| 533 case PermissionType::VIDEO_CAPTURE: |
| 534 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.VideoCapture", |
| 535 toggle_enabled); |
| 536 break; |
| 537 // The user is not prompted for these permissions, thus there is no deny |
| 538 // recorded for them. |
| 539 case PermissionType::MIDI: |
| 540 case PermissionType::BACKGROUND_SYNC: |
| 541 case PermissionType::NUM: |
| 542 NOTREACHED() << "PERMISSION " |
| 543 << PermissionUtil::GetPermissionString(permission) |
| 544 << " not accounted for"; |
| 545 } |
| 546 } |
| 547 |
450 bool PermissionUmaUtil::IsOptedIntoPermissionActionReporting(Profile* profile) { | 548 bool PermissionUmaUtil::IsOptedIntoPermissionActionReporting(Profile* profile) { |
451 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 549 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
452 switches::kEnablePermissionActionReporting)) | 550 switches::kEnablePermissionActionReporting)) |
453 return false; | 551 return false; |
454 | 552 |
455 DCHECK(profile); | 553 DCHECK(profile); |
456 if (profile->GetProfileType() == Profile::INCOGNITO_PROFILE) | 554 if (profile->GetProfileType() == Profile::INCOGNITO_PROFILE) |
457 return false; | 555 return false; |
458 if (!profile->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled)) | 556 if (!profile->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled)) |
459 return false; | 557 return false; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 if (!deprecated_metric.empty() && rappor_service) { | 661 if (!deprecated_metric.empty() && rappor_service) { |
564 rappor::SampleDomainAndRegistryFromGURL(rappor_service, deprecated_metric, | 662 rappor::SampleDomainAndRegistryFromGURL(rappor_service, deprecated_metric, |
565 requesting_origin); | 663 requesting_origin); |
566 | 664 |
567 std::string rappor_metric = deprecated_metric + "2"; | 665 std::string rappor_metric = deprecated_metric + "2"; |
568 rappor_service->RecordSample( | 666 rappor_service->RecordSample( |
569 rappor_metric, rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE, | 667 rappor_metric, rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE, |
570 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin)); | 668 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin)); |
571 } | 669 } |
572 } | 670 } |
OLD | NEW |