1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709
|
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_PERMISSIONS_PERMISSION_UMA_UTIL_H_
#define COMPONENTS_PERMISSIONS_PERMISSION_UMA_UTIL_H_
#include <vector>
#include "base/memory/raw_ptr.h"
#include "base/time/time.h"
#include "base/version.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "components/permissions/permission_request.h"
#include "components/permissions/prediction_service/prediction_service_messages.pb.h"
#include "components/permissions/request_type.h"
#include "content/public/browser/permission_result.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/blink/public/mojom/permissions_policy/permissions_policy_feature.mojom-forward.h"
namespace blink {
enum class PermissionType;
}
namespace content {
class BrowserContext;
class RenderFrameHost;
class WebContents;
class RenderFrameHost;
} // namespace content
class GURL;
namespace permissions {
enum class PermissionRequestGestureType;
enum class PermissionAction;
class PermissionRequest;
// Used for UMA to record the types of permission prompts shown.
// When updating, you also need to update:
// 1) The PermissionRequestType enum in tools/metrics/histograms/enums.xml.
// 2) The PermissionRequestTypes suffix list in
// tools/metrics/histograms/metadata/histogram_suffixes_list.xml.
// 3) GetPermissionRequestString below.
//
// The usual rules of updating UMA values applies to this enum:
// - don't remove values
// - only ever add values at the end
enum class RequestTypeForUma {
UNKNOWN = 0,
MULTIPLE = 1,
// UNUSED_PERMISSION = 2,
QUOTA = 3,
DOWNLOAD = 4,
// MEDIA_STREAM = 5,
REGISTER_PROTOCOL_HANDLER = 6,
PERMISSION_GEOLOCATION = 7,
PERMISSION_MIDI_SYSEX = 8,
PERMISSION_NOTIFICATIONS = 9,
PERMISSION_PROTECTED_MEDIA_IDENTIFIER = 10,
// PERMISSION_PUSH_MESSAGING = 11,
PERMISSION_FLASH = 12,
PERMISSION_MEDIASTREAM_MIC = 13,
PERMISSION_MEDIASTREAM_CAMERA = 14,
PERMISSION_ACCESSIBILITY_EVENTS = 15,
// PERMISSION_CLIPBOARD_READ = 16, // Replaced by
// PERMISSION_CLIPBOARD_READ_WRITE in M81.
// PERMISSION_SECURITY_KEY_ATTESTATION = 17,
PERMISSION_PAYMENT_HANDLER = 18,
PERMISSION_NFC = 19,
PERMISSION_CLIPBOARD_READ_WRITE = 20,
PERMISSION_VR = 21,
PERMISSION_AR = 22,
PERMISSION_STORAGE_ACCESS = 23,
PERMISSION_CAMERA_PAN_TILT_ZOOM = 24,
PERMISSION_WINDOW_MANAGEMENT = 25,
PERMISSION_LOCAL_FONTS = 26,
PERMISSION_IDLE_DETECTION = 27,
PERMISSION_FILE_HANDLING = 28,
// PERMISSION_U2F_API_REQUEST = 29,
PERMISSION_TOP_LEVEL_STORAGE_ACCESS = 30,
PERMISSION_MIDI = 31,
PERMISSION_FILE_SYSTEM_ACCESS = 32,
// NUM must be the last value in the enum.
NUM
};
// Any new values should be inserted immediately prior to NUM.
enum class PermissionSourceUI {
// Permission prompt.
PROMPT = 0,
// Origin info bubble.
// https://www.chromium.org/Home/chromium-security/enamel/goals-for-the-origin-info-bubble
OIB = 1,
// chrome://settings/content/siteDetails?site=[SITE]
// chrome://settings/content/[PERMISSION TYPE]
SITE_SETTINGS = 2,
// Page action bubble.
PAGE_ACTION = 3,
// Permission settings from Android.
// Currently this value is only used when revoking notification permission in
// Android O+ system channel settings.
ANDROID_SETTINGS = 4,
// Permission settings as part of the event's UI.
// Currently this value is only used when revoking notification permission
// through the notification UI.
INLINE_SETTINGS = 5,
// Permission settings changes as part of the abusive origins revocation.
AUTO_REVOCATION = 6,
// Always keep this at the end.
NUM,
};
// Any new values should be inserted immediately prior to NUM.
enum class PermissionEmbargoStatus {
NOT_EMBARGOED = 0,
// Removed: PERMISSIONS_BLACKLISTING = 1,
REPEATED_DISMISSALS = 2,
REPEATED_IGNORES = 3,
RECENT_DISPLAY = 4,
// Keep this at the end.
NUM,
};
// Used for UMA to record the strict level of permission policy which is
// configured to allow sub-frame origin. Any new values should be inserted
// immediately prior to NUM. All values here should have corresponding entries
// PermissionsPolicyConfiguration area of enums.xml.
enum class PermissionHeaderPolicyForUMA {
// No (or an invalid) Permissions-Policy header was present, results in an
// empty features list. It indicates none security-awareness of permissions
// policy configuration.
HEADER_NOT_PRESENT_OR_INVALID = 0,
// Permissions-Policy header was present, but it did not define an allowlist
// for the feature. It indicates less security-awareness of permissions policy
// configuration.
FEATURE_NOT_PRESENT = 1,
// The sub-frame origin is included in allow-list of permission
// policy. This indicates a good policy configuration.
FEATURE_ALLOWLIST_EXPLICITLY_MATCHES_ORIGIN = 2,
// Granted by setting value of permission policy to '*'. This also
// indicates a bad policy configuration.
FEATURE_ALLOWLIST_IS_WILDCARD = 3,
// The Permissions-Policy header was present and defined an empty
// allowlist for the feature. The feature will be disabled everywhere.
FEATURE_ALLOWLIST_IS_NONE = 4,
// The sub-frame origin is not explicitly declared in allow-list of top level
// permission policy. It generally indicates less security-awareness of
// policy configuration.
FEATURE_ALLOWLIST_DOES_NOT_MATCH_ORIGIN = 5,
// Always keep this at the end.
NUM,
};
// The kind of permission prompt UX used to surface a permission request.
// Enum used in UKMs and UMAs, do not re-order or change values. Deprecated
// items should only be commented out. New items should be added at the end,
// and the "PermissionPromptDisposition" histogram suffix needs to be updated to
// match (tools/metrics/histograms/metadata/histogram_suffixes_list.xml).
enum class PermissionPromptDisposition {
// Not all permission actions will have an associated permission prompt (e.g.
// changing permission via the settings page).
NOT_APPLICABLE = 0,
// Only used on desktop, a bubble under the site settings padlock.
ANCHORED_BUBBLE = 1,
// Only used on desktop, a static indicator on the right-hand side of the
// location bar.
LOCATION_BAR_RIGHT_STATIC_ICON = 2,
// Only used on desktop, an animated indicator on the right-hand side of the
// location bar.
LOCATION_BAR_RIGHT_ANIMATED_ICON = 3,
// Only used on Android, a modal dialog.
MODAL_DIALOG = 4,
// Only used on Android, an initially-collapsed infobar at the bottom of the
// page.
MINI_INFOBAR = 5,
// Only used on desktop, a chip on the left-hand side of the location bar that
// shows a bubble when clicked.
LOCATION_BAR_LEFT_CHIP = 6,
// There was no UI being shown. This is usually because the user closed an
// inactive tab that had a pending permission request.
NONE_VISIBLE = 7,
// Other custom modal dialogs.
CUSTOM_MODAL_DIALOG = 8,
// Only used on desktop, a less prominent version of chip on the left-hand
// side of the location bar that shows a bubble when clicked.
LOCATION_BAR_LEFT_QUIET_CHIP = 9,
// Only used on Android, a message bubble near top of the screen and below the
// location bar. Message UI is an alternative UI to infobar UI.
MESSAGE_UI = 10,
// Only used on desktop, a chip on the left-hand side of the location bar that
// automatically shows a bubble.
LOCATION_BAR_LEFT_QUIET_ABUSIVE_CHIP = 11,
// Only used on desktop, a chip on the left-hand side of the location bar that
// automatically shows a bubble.
LOCATION_BAR_LEFT_CHIP_AUTO_BUBBLE = 12,
// Only used on desktop, a bubble shown near the embedded permission element,
// after the user clicks on the element.
ELEMENT_ANCHORED_BUBBLE = 13,
};
// The reason why the permission prompt disposition was used. Enum used in UKMs,
// do not re-order or change values. Deprecated items should only be commented
// out.
enum class PermissionPromptDispositionReason {
// Disposition was selected in prefs.
USER_PREFERENCE_IN_SETTINGS = 0,
// Disposition was chosen because Safe Browsing classifies the origin
// as being spammy or abusive with permission requests.
SAFE_BROWSING_VERDICT = 1,
// Disposition was chosen based on grant likelihood predicted by the
// Web Permission Prediction Service.
PREDICTION_SERVICE = 2,
// Disposition was used as a fallback, if no selector made a decision.
DEFAULT_FALLBACK = 3,
// Disposition was chosen based on grant likelihood predicted by the On-Device
// Permission Prediction Model.
ON_DEVICE_PREDICTION_MODEL = 4,
};
enum class AdaptiveTriggers {
// None of the adaptive triggers were met. Currently this means two or less
// consecutive denies in a row.
NONE = 0,
// User denied permission prompt 3 or more times.
THREE_CONSECUTIVE_DENIES = 0x01,
};
// These values are logged to UMA. Entries should not be renumbered and
// numeric values should never be reused. Please keep in sync with
// "OneTimePermissionEvent" in tools/metrics/histograms/enums.xml.
enum class OneTimePermissionEvent {
// Recorded for each one time grant
GRANTED_ONE_TIME = 0,
// Recorded when the user manually revokes a one time grant
REVOKED_MANUALLY = 1,
// Recorded when a one time grant expires because all tabs are either closed
// or discarded.
ALL_TABS_CLOSED_OR_DISCARDED = 2,
// Recorded when a one time grant expires because the permission was unused in
// the background.
EXPIRED_IN_BACKGROUND = 3,
// Revoked because of the maximum one time permission lifetime
// `kOneTimePermissionMaximumLifetime`
EXPIRED_AFTER_MAXIMUM_LIFETIME = 4,
// Recorded when a one time grant expires because the device was suspended.
EXPIRED_ON_SUSPEND = 5,
kMaxValue = EXPIRED_ON_SUSPEND
};
enum class PermissionAutoRevocationHistory {
// Permission has not been automatically revoked.
NONE = 0,
// Permission has been automatically revoked.
PREVIOUSLY_AUTO_REVOKED = 0x01,
};
// This enum backs up the `AutoDSEPermissionRevertTransition` histogram enum.
// Never reuse values and mirror any updates to it.
// Describes the transition that has occured for the setting of a DSE origin
// when DSE autogrant becomes disabled.
enum class AutoDSEPermissionRevertTransition {
// The user has not previously made any decision so it results in an `ASK` end
// state.
NO_DECISION_ASK = 0,
// The user has decided to `ALLOW` the origin before it was the DSE origin and
// has not reverted this decision.
PRESERVE_ALLOW = 1,
// The user has previously `BLOCKED` the origin but has allowed it after it
// became the DSE origin. Resolve the conflict by setting it to `ASK` so the
// user will make a decision again.
CONFLICT_ASK = 2,
// The user has blocked the DSE origin and has not made a previous decision
// before the origin became the DSE origin.
PRESERVE_BLOCK_ASK = 3,
// The user has blocked the DSE origin and has `ALLOWED` it before it became
// the DSE origin, preserve the latest decision.
PRESERVE_BLOCK_ALLOW = 4,
// The user has blocked the DSE origin and has `BLOCKED` it before it became
// the DSE origin as well.
PRESERVE_BLOCK_BLOCK = 5,
// There has been an invalid transition.
INVALID_END_STATE = 6,
// Always keep at the end.
kMaxValue = INVALID_END_STATE,
};
// This enum backs up the 'PermissionPredictionSource` histogram enum. It
// indicates whether the permission prediction was done by the local on device
// model or by the server side model.
enum class PermissionPredictionSource {
ON_DEVICE = 0,
SERVER_SIDE = 1,
// Always keep at the end.
kMaxValue = SERVER_SIDE,
};
// This enum backs up the 'PageInfoDialogAccessType' histogram enum.
// It is used for collecting page info access type metrics in the context of
// the confirmation chip.
enum class PageInfoDialogAccessType {
// The user opened page info by clicking on the lock in a situation that is
// considered independent of the display of a confirmation chip.
LOCK_CLICK = 0,
// The user opened page info by clicking on the lock while a confirmation chip
// was being displayed.
LOCK_CLICK_DURING_CONFIRMATION_CHIP = 1,
// The user opened page info by clicking on the confirmation chip while it was
// being displayed.
CONFIRMATION_CHIP_CLICK = 2,
// The user opened page info by clicking on the lock within
// 'kConfirmationConsiderationDurationForUma' after confirmation chip has
// collapsed. This click may be considered influenced by the displaying of the
// confirmation chip.
LOCK_CLICK_SHORTLY_AFTER_CONFIRMATION_CHIP = 3,
// Always keep at the end.
kMaxValue = LOCK_CLICK_SHORTLY_AFTER_CONFIRMATION_CHIP
};
constexpr auto kConfirmationConsiderationDurationForUma = base::Seconds(20);
// This enum backs up the
// 'Permissions.PageInfo.ChangedWithin1m.{PermissionType}' histograms enum. It
// is used for collecting page info permission change metrics following in the
// first minute after a PermissionAction has been taken. Note that
// PermissionActions DISMISSED and IGNORED are not taken into account, as they
// don't have an effect on the content settings.
enum class PermissionChangeAction {
// PermissionAction was one of {GRANTED, GRANTED_ONCE} and the content
// setting is changed to CONTENT_SETTING_BLOCK.
REVOKED = 0,
// PermissionAction was DENIED and the content setting is changed to
// CONTENT_SETTING_ALLOW.
REALLOWED = 1,
// PermissionAction was one of {GRANTED, GRANTED_ONCE} and the content setting
// is changed to CONTENT_SETTING_DEFAULT.
RESET_FROM_ALLOWED = 2,
// PermissionAction was DENIED and the content setting is changed to
// CONTENT_SETTING_DEFAULT.
RESET_FROM_DENIED = 3,
// For one time grantable permissions, the user can toggle a remember checkbox
// in the secondary page info page which toggles grants between permanent
// grant and one time grant.
REMEMBER_CHECKBOX_TOGGLED = 4,
// Always keep at the end.
kMaxValue = REMEMBER_CHECKBOX_TOGGLED
};
// The reason the permission action `PermissionAction::IGNORED` was triggered.
enum class PermissionIgnoredReason {
// Ignore was triggered due to closure of the browser window
WINDOW_CLOSED = 0,
// Ignore was triggered due to closure of the tab
TAB_CLOSED = 1,
// Ignore was triggered due to navigation
NAVIGATION = 2,
// Catches all other cases
UNKNOWN = 3,
// Always keep at the end
NUM
};
// This enum backs up the
// 'Permissions.PageInfo.Changed.{PermissionType}.Reallowed.Outcome' histograms
// enum. It is used for collecting permission usage rates after permission
// status was reallowed via PageInfo. It is applicable only if permission is
// allowed as all other states are no-op for an origin.
//
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum class PermissionChangeInfo {
kInfobarShownPageReloadPermissionUsed = 0,
kInfobarShownPageReloadPermissionNotUsed = 1,
kInfobarShownNoPageReloadPermissionUsed = 2,
kInfobarShownNoPageReloadPermissionNotUsed = 3,
kInfobarNotShownPageReloadPermissionUsed = 4,
kInfobarNotShownPageReloadPermissionNotUsed = 5,
kInfobarNotShownNoPageReloadPermissionUsed = 6,
kInfobarNotShownNoPageReloadPermissionNotUsed = 7,
// Always keep at the end.
kMaxValue = kInfobarNotShownNoPageReloadPermissionNotUsed
};
// Provides a convenient way of logging UMA for permission related operations.
class PermissionUmaUtil {
public:
using PredictionGrantLikelihood =
PermissionPrediction_Likelihood_DiscretizedLikelihood;
static const char kPermissionsPromptShown[];
static const char kPermissionsPromptShownGesture[];
static const char kPermissionsPromptShownNoGesture[];
static const char kPermissionsPromptAccepted[];
static const char kPermissionsPromptAcceptedGesture[];
static const char kPermissionsPromptAcceptedNoGesture[];
static const char kPermissionsPromptAcceptedOnce[];
static const char kPermissionsPromptAcceptedOnceGesture[];
static const char kPermissionsPromptAcceptedOnceNoGesture[];
static const char kPermissionsPromptDenied[];
static const char kPermissionsPromptDeniedGesture[];
static const char kPermissionsPromptDeniedNoGesture[];
static const char kPermissionsExperimentalUsagePrefix[];
static const char kPermissionsActionPrefix[];
PermissionUmaUtil() = delete;
PermissionUmaUtil(const PermissionUmaUtil&) = delete;
PermissionUmaUtil& operator=(const PermissionUmaUtil&) = delete;
static void PermissionRequested(ContentSettingsType permission);
static void RecordPermissionRequestedFromFrame(
ContentSettingsType content_settings_type,
content::RenderFrameHost* rfh);
static void PermissionRequestPreignored(blink::PermissionType permission);
// Records the revocation UMA and UKM metrics for ContentSettingsTypes that
// have user facing permission prompts. The passed in `permission` must be
// such that PermissionUtil::IsPermission(permission) returns true.
static void PermissionRevoked(ContentSettingsType permission,
PermissionSourceUI source_ui,
const GURL& revoked_origin,
content::BrowserContext* browser_context);
static void RecordEmbargoPromptSuppression(
PermissionEmbargoStatus embargo_status);
static void RecordEmbargoPromptSuppressionFromSource(
content::PermissionStatusSource source);
static void RecordEmbargoStatus(PermissionEmbargoStatus embargo_status);
static void RecordPermissionRecoverySuccessRate(
ContentSettingsType permission,
bool is_used,
bool show_infobar,
bool page_reload);
// Recorded when a permission prompt creation is in progress.
static void RecordPermissionPromptAttempt(
const std::vector<PermissionRequest*>& requests,
bool IsLocationBarEditingOrEmpty);
// UMA specifically for when permission prompts are shown. This should be
// roughly equivalent to the metrics above, however it is
// useful to have separate UMA to a few reasons:
// - to account for, and get data on coalesced permission bubbles
// - there are other types of permissions prompts (e.g. download limiting)
// which don't go through PermissionContext
// - the above metrics don't always add up (e.g. sum of
// granted+denied+dismissed+ignored is not equal to requested), so it is
// unclear from those metrics alone how many prompts are seen by users.
static void PermissionPromptShown(
const std::vector<PermissionRequest*>& requests);
static void PermissionPromptResolved(
const std::vector<PermissionRequest*>& requests,
content::WebContents* web_contents,
PermissionAction permission_action,
base::TimeDelta time_to_decision,
PermissionPromptDisposition ui_disposition,
absl::optional<PermissionPromptDispositionReason> ui_reason,
absl::optional<PredictionGrantLikelihood> predicted_grant_likelihood,
absl::optional<bool> prediction_decision_held_back,
absl::optional<permissions::PermissionIgnoredReason> ignored_reason,
bool did_show_prompt,
bool did_click_manage,
bool did_click_learn_more);
static void RecordInfobarDetailsExpanded(bool expanded);
static void RecordCrowdDenyDelayedPushNotification(base::TimeDelta delay);
static void RecordCrowdDenyVersionAtAbuseCheckTime(
const absl::optional<base::Version>& version);
// Record UMAs related to the Android "Missing permissions" infobar.
static void RecordMissingPermissionInfobarShouldShow(
bool should_show,
const std::vector<ContentSettingsType>& content_settings_types);
static void RecordMissingPermissionInfobarAction(
PermissionAction action,
const std::vector<ContentSettingsType>& content_settings_types);
static void RecordPermissionUsage(ContentSettingsType permission_type,
content::BrowserContext* browser_context,
content::WebContents* web_contents,
const GURL& requesting_origin);
static void RecordTimeElapsedBetweenGrantAndUse(ContentSettingsType type,
base::TimeDelta delta);
static void RecordTimeElapsedBetweenGrantAndRevoke(ContentSettingsType type,
base::TimeDelta delta);
static void RecordAutoDSEPermissionReverted(
ContentSettingsType permission_type,
ContentSetting backed_up_setting,
ContentSetting effective_setting,
ContentSetting end_state_setting);
static void RecordDSEEffectiveSetting(ContentSettingsType permission_type,
ContentSetting setting);
static void RecordPermissionPredictionSource(
PermissionPredictionSource prediction_type);
static void RecordPermissionPredictionServiceHoldback(
RequestType request_type,
bool is_on_device,
bool is_heldback);
static void RecordPageInfoDialogAccessType(
PageInfoDialogAccessType access_type);
static std::string GetOneTimePermissionEventHistogram(
ContentSettingsType type);
static void RecordOneTimePermissionEvent(ContentSettingsType type,
OneTimePermissionEvent event);
static void RecordPageInfoPermissionChangeWithin1m(
ContentSettingsType type,
PermissionAction previous_action,
ContentSetting setting_after);
static void RecordPageInfoPermissionChange(ContentSettingsType type,
ContentSetting setting_before,
ContentSetting setting_after,
bool suppress_reload_page_bar);
static std::string GetPermissionActionString(
PermissionAction permission_action);
static std::string GetPromptDispositionString(
PermissionPromptDisposition ui_disposition);
static std::string GetPromptDispositionReasonString(
PermissionPromptDispositionReason ui_disposition_reason);
static std::string GetRequestTypeString(RequestType request_type);
static bool IsPromptDispositionQuiet(
PermissionPromptDisposition prompt_disposition);
static bool IsPromptDispositionLoud(
PermissionPromptDisposition prompt_disposition);
static void RecordIgnoreReason(
const std::vector<PermissionRequest*>& requests,
PermissionPromptDisposition prompt_disposition,
PermissionIgnoredReason reason);
// Record metrics related to usage of permissions delegation.
static void RecordPermissionsUsageSourceAndPolicyConfiguration(
ContentSettingsType content_settings_type,
content::RenderFrameHost* render_frame_host);
static void RecordCrossOriginFrameActionAndPolicyConfiguration(
ContentSettingsType content_settings_type,
PermissionAction action,
content::RenderFrameHost* render_frame_host);
static void RecordTopLevelPermissionsHeaderPolicyOnNavigation(
content::RenderFrameHost* render_frame_host);
// Logs a metric that captures how long since revocation, due to a site being
// considered unused, the user regrants a revoked permission.
static void RecordPermissionRegrantForUnusedSites(
const GURL& origin,
ContentSettingsType request_type,
PermissionSourceUI source_ui,
content::BrowserContext* browser_context,
base::Time current_time);
static absl::optional<uint32_t> GetDaysSinceUnusedSitePermissionRevocation(
const GURL& origin,
ContentSettingsType content_settings_type,
base::Time current_time,
HostContentSettingsMap* hcsm);
// A scoped class that will check the current resolved content setting on
// construction and report a revocation metric accordingly if the revocation
// condition is met (from ALLOW to something else).
class ScopedRevocationReporter {
public:
ScopedRevocationReporter(content::BrowserContext* browser_context,
const GURL& primary_url,
const GURL& secondary_url,
ContentSettingsType content_type,
PermissionSourceUI source_ui);
ScopedRevocationReporter(content::BrowserContext* browser_context,
const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern,
ContentSettingsType content_type,
PermissionSourceUI source_ui);
~ScopedRevocationReporter();
private:
raw_ptr<content::BrowserContext> browser_context_;
const GURL primary_url_;
const GURL secondary_url_;
ContentSettingsType content_type_;
PermissionSourceUI source_ui_;
bool is_initially_allowed_;
base::Time last_modified_date_;
};
private:
friend class PermissionUmaUtilTest;
// Records UMA and UKM metrics for ContentSettingsTypes that have user facing
// permission prompts. The passed in `permission` must be such that
// PermissionUtil::IsPermission(permission) returns true.
// web_contents may be null when for recording non-prompt actions.
static void RecordPermissionAction(
ContentSettingsType permission,
PermissionAction action,
PermissionSourceUI source_ui,
PermissionRequestGestureType gesture_type,
base::TimeDelta time_to_decision,
PermissionPromptDisposition ui_disposition,
absl::optional<PermissionPromptDispositionReason> ui_reason,
const GURL& requesting_origin,
content::WebContents* web_contents,
content::BrowserContext* browser_context,
content::RenderFrameHost* render_frame_host,
absl::optional<PredictionGrantLikelihood> predicted_grant_likelihood,
absl::optional<bool> prediction_decision_held_back);
// Records |count| total prior actions for a prompt of type |permission|
// for a single origin using |prefix| for the metric.
static void RecordPermissionPromptPriorCount(ContentSettingsType permission,
const std::string& prefix,
int count);
static void RecordPromptDecided(
const std::vector<PermissionRequest*>& requests,
bool accepted,
bool is_one_time);
};
} // namespace permissions
#endif // COMPONENTS_PERMISSIONS_PERMISSION_UMA_UTIL_H_
|