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.
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 Approach | Framework Approach | |
---|---|---|
Decision Logic | Imperative & Centralized: “Check A, then B, then C...” | Declarative & Orchestrated: “Here are the available notices and their rules; pick the best one.” |
State Management | Direct manipulation of individual preferences. | Abstracted via NoticeStorage , providing a clean, structured history. |
Extensibility | Difficult; requires modifying complex, shared logic. | Simple; add a new, self-contained definition to the NoticeCatalog . |
Developer Focus | Implementing complex eligibility trees and managing state. | Defining the notice, its target APIs, and its desired behavior. |
The framework provides the following functionality:
The framework's central NoticeService
handles notice scheduling and prioritization.
NoticeCatalog
to select the most appropriate one.The NoticeStorage
component handles all notice history and data collection.
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.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.
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.