#include "chrome/browser/history_clusters/history_clusters_tab_helper.h"
#include <functional>
#include <memory>
#include <utility>
#include "base/time/time.h"
#include "build/build_config.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/history/history_utils.h"
#include "chrome/browser/history_clusters/history_clusters_metrics_logger.h"
#include "chrome/browser/history_clusters/history_clusters_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/webui_url_constants.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/history/core/browser/history_types.h"
#include "components/history/core/browser/url_row.h"
#include "components/history_clusters/core/history_clusters_service.h"
#include "components/history_clusters/core/url_constants.h"
#include "components/keyed_service/core/service_access_type.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/web_contents.h"
#if BUILDFLAG(IS_ANDROID)
#include "chrome/browser/android/tab_android.h"
#include "chrome/browser/ui/android/tab_model/tab_model_jni_bridge.h"
#else
#include "base/containers/contains.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "components/ntp_tiles/custom_links_store.h"
#endif
namespace {
bool IsPageInTabGroup(content::WebContents* contents) { … }
bool IsPageBookmarked(content::WebContents* contents, const GURL& url) { … }
base::TimeDelta TimeElapsedBetweenVisits(const history::VisitRow& visit1,
const history::VisitRow& visit2) { … }
bool IsHistoryPage(GURL url, const GURL& history_url) { … }
}
HistoryClustersTabHelper::HistoryClustersTabHelper(
content::WebContents* web_contents)
: … { … }
HistoryClustersTabHelper::~HistoryClustersTabHelper() = default;
void HistoryClustersTabHelper::OnOmniboxUrlCopied() { … }
void HistoryClustersTabHelper::OnOmniboxUrlShared() { … }
void HistoryClustersTabHelper::OnUpdatedHistoryForNavigation(
int64_t navigation_id,
base::Time timestamp,
const GURL& url) { … }
void HistoryClustersTabHelper::TagNavigationAsExpectingUkmNavigationComplete(
int64_t navigation_id) { … }
history::VisitContextAnnotations
HistoryClustersTabHelper::OnUkmNavigationComplete(
int64_t navigation_id,
base::TimeDelta total_foreground_duration,
const page_load_metrics::PageEndReason page_end_reason) { … }
void HistoryClustersTabHelper::DidStartNavigation(
content::NavigationHandle* navigation_handle) { … }
void HistoryClustersTabHelper::DidFinishNavigation(
content::NavigationHandle* navigation_handle) { … }
void HistoryClustersTabHelper::WebContentsDestroyed() { … }
void HistoryClustersTabHelper::OnVisibilityChanged(
content::Visibility visibility) { … }
void HistoryClustersTabHelper::StartNewNavigationIfNeeded(
int64_t navigation_id) { … }
void HistoryClustersTabHelper::RecordPageEndMetricsIfNeeded(
int64_t navigation_id) { … }
history_clusters::HistoryClustersService*
HistoryClustersTabHelper::GetHistoryClustersService() { … }
history::HistoryService* HistoryClustersTabHelper::GetHistoryService() { … }
WEB_CONTENTS_USER_DATA_KEY_IMPL(HistoryClustersTabHelper);