Fix emulator build error
[platform/framework/web/chromium-efl.git] / components / browsing_topics / browsing_topics_page_load_data_tracker.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_PAGE_LOAD_DATA_TRACKER_H_
6 #define COMPONENTS_BROWSING_TOPICS_BROWSING_TOPICS_PAGE_LOAD_DATA_TRACKER_H_
7
8 #include "base/containers/flat_set.h"
9 #include "components/browsing_topics/common/common_types.h"
10 #include "content/public/browser/page_user_data.h"
11
12 namespace history {
13 class HistoryService;
14 }  // namespace history
15
16 namespace browsing_topics {
17
18 // Tracks page-level (i.e. primary main frame document) signals to determine
19 // whether the page is eligible to be included in browsing topics calculation.
20 // Also tracks the context domains that have used the Topics API in the page.
21 class BrowsingTopicsPageLoadDataTracker
22     : public content::PageUserData<BrowsingTopicsPageLoadDataTracker> {
23  public:
24   BrowsingTopicsPageLoadDataTracker(const BrowsingTopicsPageLoadDataTracker&) =
25       delete;
26   BrowsingTopicsPageLoadDataTracker& operator=(
27       const BrowsingTopicsPageLoadDataTracker&) = delete;
28
29   ~BrowsingTopicsPageLoadDataTracker() override;
30
31   // Called when the document.browsingTopics() API is used in the page.
32   void OnBrowsingTopicsApiUsed(const HashedDomain& hashed_context_domain,
33                                const std::string& context_domain,
34                                history::HistoryService* history_service);
35
36  private:
37   friend class PageUserData;
38
39   explicit BrowsingTopicsPageLoadDataTracker(content::Page& page);
40
41   // |eligible_to_commit_| means all the commit time prerequisites are met
42   // (i.e. IP was publicly routable AND permissions policy is "allow").
43   bool eligible_to_commit_ = false;
44
45   HashedHost hashed_main_frame_host_;
46
47   ukm::SourceId source_id_;
48
49   base::flat_set<HashedDomain> observed_hashed_context_domains_;
50
51   PAGE_USER_DATA_KEY_DECL();
52 };
53
54 }  // namespace browsing_topics
55
56 #endif  // COMPONENTS_BROWSING_TOPICS_BROWSING_TOPICS_PAGE_LOAD_DATA_TRACKER_H_