Fix emulator build error
[platform/framework/web/chromium-efl.git] / components / browsing_topics / browsing_topics_service.h
1 // Copyright 2022 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_BROWSING_TOPICS_BROWSING_TOPICS_SERVICE_H_
6 #define COMPONENTS_BROWSING_TOPICS_BROWSING_TOPICS_SERVICE_H_
7
8 #include "components/browsing_topics/annotator.h"
9 #include "components/browsing_topics/mojom/browsing_topics_internals.mojom-forward.h"
10 #include "components/browsing_topics/mojom/browsing_topics_internals.mojom.h"
11 #include "components/keyed_service/core/keyed_service.h"
12 #include "components/privacy_sandbox/canonical_topic.h"
13 #include "content/public/browser/render_frame_host.h"
14 #include "third_party/blink/public/mojom/browsing_topics/browsing_topics.mojom-forward.h"
15 #include "url/origin.h"
16
17 namespace browsing_topics {
18
19 // A profile keyed service for providing the topics to a requesting context or
20 // to other internal components (e.g. UX).
21 class BrowsingTopicsService : public KeyedService {
22  public:
23   // Writes the browsing topics for a particular requesting context into the
24   // output parameter `topics` and returns whether the access permission is
25   // allowed. `context_origin` and `main_frame` will potentially be used for the
26   // access permission check, for calculating the topics, and/or for the
27   // `BrowsingTopicsPageLoadDataTracker` to track the API usage. If `get_topics`
28   // is true, topics calculation result will be stored to `topics`. If `observe`
29   // is true, record the observation (i.e. the <calling context site,
30   // top level site> pair) to the `BrowsingTopicsSiteDataStorage` database.
31   virtual bool HandleTopicsWebApi(
32       const url::Origin& context_origin,
33       content::RenderFrameHost* main_frame,
34       ApiCallerSource caller_source,
35       bool get_topics,
36       bool observe,
37       std::vector<blink::mojom::EpochTopicPtr>& topics) = 0;
38
39   // Returns the number of distinct epochs versions for `main_frame_origin`.
40   // Must be called when topics are eligible (i.e. `HandleTopicsWebApi` would
41   // return true for the same main frame context).
42   virtual int NumVersionsInEpochs(
43       const url::Origin& main_frame_origin) const = 0;
44
45   // Get the topics state to show in the chrome://topics-internals page. If
46   // `calculate_now` is true, this will first trigger a calculation before
47   // invoking `callback` with the topics state.
48   virtual void GetBrowsingTopicsStateForWebUi(
49       bool calculate_now,
50       mojom::PageHandler::GetBrowsingTopicsStateCallback callback) = 0;
51
52   // Return the top topics from all the past epochs. Up to
53   // `kBrowsingTopicsNumberOfEpochsToExpose + 1` epochs' topics are kept in
54   // the browser. Padded top topics won't be returned.
55   virtual std::vector<privacy_sandbox::CanonicalTopic> GetTopTopicsForDisplay()
56       const = 0;
57
58   virtual Annotator* GetAnnotator() = 0;
59
60   // Removes topic from any existing epoch.
61   virtual void ClearTopic(
62       const privacy_sandbox::CanonicalTopic& canonical_topic) = 0;
63
64   // Clear the topics data (both raw and derived) for a specific context origin.
65   virtual void ClearTopicsDataForOrigin(const url::Origin& origin) = 0;
66
67   // Clear all topics data (both raw and derived).
68   virtual void ClearAllTopicsData() = 0;
69
70   ~BrowsingTopicsService() override = default;
71 };
72
73 }  // namespace browsing_topics
74
75 #endif  // COMPONENTS_BROWSING_TOPICS_BROWSING_TOPICS_SERVICE_H_