tree: cac5c2cef75c52feefffa31459b4c061165ec49b [path history] [tgz]
  1. docs/
  2. mocks/
  3. BUILD.gn
  4. DEPS
  5. desktop_entrypoint_handlers.cc
  6. desktop_entrypoint_handlers.h
  7. desktop_entrypoint_handlers_browsertest.cc
  8. desktop_entrypoint_handlers_helper.cc
  9. desktop_entrypoint_handlers_helper.h
  10. desktop_view_manager.cc
  11. desktop_view_manager.h
  12. desktop_view_manager_browsertest.cc
  13. desktop_view_manager_interface.h
  14. desktop_view_manager_test_peer.h
  15. desktop_view_manager_unittest.cc
  16. histograms_unittest.cc
  17. notice.mojom
  18. notice_catalog.cc
  19. notice_catalog.h
  20. notice_catalog_unittest.cc
  21. notice_definitions.cc
  22. notice_definitions.h
  23. notice_model.cc
  24. notice_model.h
  25. notice_model_unittest.cc
  26. notice_service.cc
  27. notice_service.h
  28. notice_service_browsertest.cc
  29. notice_service_factory.cc
  30. notice_service_factory.h
  31. notice_service_interface.h
  32. notice_service_unittest.cc
  33. notice_storage.cc
  34. notice_storage.h
  35. notice_storage_fuzztest.cc
  36. notice_storage_unittest.cc
  37. OWNERS
  38. README.md
chrome/browser/privacy_sandbox/notice/README.md

Privacy Sandbox Notice Framework

This framework provides a centralized system for managing user-facing Privacy Sandbox notices in Chrome. It offers a scalable and maintainable approach to presenting notices.

High-Level Approach

The Notice Framework shifts notice management from an imperative to a declarative model. Instead of implementing step-by-step logic to check eligibility and manage state, developers define a notice and its rules in the NoticeCatalog. The framework then handles prioritization, conflict resolution, state tracking, and metrics.

The core differences are:

Traditional ApproachFramework Approach
Decision LogicImperative & Centralized: “Check A, then B, then C...”Declarative & Orchestrated: “Here are the available notices and their rules; pick the best one.”
State ManagementDirect manipulation of individual preferences.Abstracted via NoticeStorage, providing a clean, structured history.
ExtensibilityDifficult; requires modifying complex, shared logic.Simple; add a new, self-contained definition to the NoticeCatalog.
Developer FocusImplementing complex eligibility trees and managing state.Defining the notice, its target APIs, and its desired behavior.

Key Components

The framework provides the following functionality:

1. Orchestration

The framework's central NoticeService handles notice scheduling and prioritization.

  • Conflict Resolution: If multiple notices are eligible to be shown, the orchestrator uses rules and priorities defined in the NoticeCatalog to select the most appropriate one.
  • Notice Grouping and Prioritization: The framework can group related notices that belong to a single user flow (e.g., a multi-step consent). Each notice in a group is assigned a priority, ensuring that the orchestrator displays them in the correct sequence. This mechanism also allows for delivering tailored versions of a notice for different UI surfaces (e.g., desktop vs. mobile).
  • Dependency Management: The framework supports defining API prerequisites for notices. This is used to manage notice flows where a user must have acknowledged a notice for one API before becoming eligible for a notice about another.

2. State Management and Metrics

The NoticeStorage component handles all notice history and data collection.

  • Persistent History: NoticeStorage tracks the event history for each notice (e.g., when it was shown, what action was taken) for each user profile. This removes the need for direct PrefService management.
  • Standardized Histograms: The framework automatically records a standard set of UMA metrics for every notice, including user interaction counts and timing durations. This provides consistent data without requiring custom histogram code.

3. API and Notice Versioning

The orchestration logic is designed to manage notice requirements as APIs evolve. By defining separate notices for different API versions and using dependency rules in the NoticeCatalog, the orchestrator can distinguish between new and existing users. This allows it to serve a full notice to new users or a smaller, delta notice to users who have already acknowledged a previous version.

4. Custom Eligibility Logic

For complex eligibility scenarios not covered by the framework's standard rules, you can attach a custom C++ callback to a NoticeApi definition in the NoticeCatalog. The orchestrator executes this callback during its eligibility evaluation, allowing for fine-grained, feature-specific control over when a notice can be shown.

Documentation

  • Getting Started Guide: A step-by-step guide to adding a new notice. This is the best place to start if you need to implement a notice.
  • Architecture Deep Dive: For a detailed understanding of the framework's internal components (Orchestrator, Catalog, etc.) and how they interact.