[Topics] add {observe: true/false} option
It'd be useful to split apart the get/set functionalities:
https://github.com/patcg-individual-drafts/topics/pull/80
Also remove dead code: ../modules/browsing_topics/idls.gni
Bug: 1334682
Change-Id: I9ebb0b4bdb7c3f398b6a69ab632eecfd2af494eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3696816
Reviewed-by: Joe Mason <[email protected]>
Reviewed-by: Josh Karlin <[email protected]>
Reviewed-by: Avi Drissman <[email protected]>
Commit-Queue: Yao Xiao <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1051859}
diff --git a/components/browsing_topics/browsing_topics_service_impl.cc b/components/browsing_topics/browsing_topics_service_impl.cc
index 60e2f7a..2852fe1 100644
--- a/components/browsing_topics/browsing_topics_service_impl.cc
+++ b/components/browsing_topics/browsing_topics_service_impl.cc
@@ -226,7 +226,8 @@
std::vector<blink::mojom::EpochTopicPtr>
BrowsingTopicsServiceImpl::GetBrowsingTopicsForJsApi(
const url::Origin& context_origin,
- content::RenderFrameHost* main_frame) {
+ content::RenderFrameHost* main_frame,
+ bool observe) {
if (!browsing_topics_state_loaded_) {
RecordBrowsingTopicsApiResultUkmMetrics(
EmptyApiResultReason::kStateNotReady, main_frame);
@@ -254,9 +255,11 @@
HashedDomain hashed_context_domain = HashContextDomainForStorage(
browsing_topics_state_.hmac_key(), context_domain);
- // Track the API usage context after the permissions check.
- BrowsingTopicsPageLoadDataTracker::GetOrCreateForPage(main_frame->GetPage())
- ->OnBrowsingTopicsApiUsed(hashed_context_domain, history_service_);
+ if (observe) {
+ // Track the API usage context after the permissions check.
+ BrowsingTopicsPageLoadDataTracker::GetOrCreateForPage(main_frame->GetPage())
+ ->OnBrowsingTopicsApiUsed(hashed_context_domain, history_service_);
+ }
std::string top_domain =
net::registry_controlled_domains::GetDomainAndRegistry(