#ifndef COMPONENTS_BROWSING_TOPICS_BROWSING_TOPICS_PAGE_LOAD_DATA_TRACKER_H_
#define COMPONENTS_BROWSING_TOPICS_BROWSING_TOPICS_PAGE_LOAD_DATA_TRACKER_H_
#include "base/containers/flat_set.h"
#include "components/browsing_topics/common/common_types.h"
#include "content/public/browser/page_user_data.h"
namespace history {
class HistoryService;
}
namespace browsing_topics {
class BrowsingTopicsPageLoadDataTracker
: public content::PageUserData<BrowsingTopicsPageLoadDataTracker> {
public:
BrowsingTopicsPageLoadDataTracker(const BrowsingTopicsPageLoadDataTracker&) =
delete;
BrowsingTopicsPageLoadDataTracker& operator=(
const BrowsingTopicsPageLoadDataTracker&) = delete;
~BrowsingTopicsPageLoadDataTracker() override;
void OnBrowsingTopicsApiUsed(const HashedDomain& hashed_context_domain,
const std::string& context_domain,
history::HistoryService* history_service,
bool observe);
const std::set<HashedHost>& redirect_hosts_with_topics_invoked() const {
return redirect_hosts_with_topics_invoked_;
}
HashedHost hashed_main_frame_host() const { return hashed_main_frame_host_; }
ukm::SourceId source_id_before_redirects() const {
return source_id_before_redirects_;
}
bool topics_invoked() const { return topics_invoked_; }
private:
friend class PageUserData;
explicit BrowsingTopicsPageLoadDataTracker(content::Page& page);
BrowsingTopicsPageLoadDataTracker(
content::Page& page,
std::set<HashedHost> redirect_hosts_with_topics_invoked,
ukm::SourceId source_id_before_redirects);
bool eligible_to_observe_ = false;
HashedHost hashed_main_frame_host_;
std::set<HashedHost> redirect_hosts_with_topics_invoked_;
ukm::SourceId source_id_;
base::flat_set<HashedDomain> observed_hashed_context_domains_;
ukm::SourceId source_id_before_redirects_;
bool topics_invoked_ = false;
PAGE_USER_DATA_KEY_DECL();
};
}
#endif