chromium/components/history/content/browser/visited_link_navigation_throttle.h

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_HISTORY_CONTENT_BROWSER_VISITED_LINK_NAVIGATION_THROTTLE_H_
#define COMPONENTS_HISTORY_CONTENT_BROWSER_VISITED_LINK_NAVIGATION_THROTTLE_H_

#include "components/history/core/browser/history_service_observer.h"
#include "content/public/browser/navigation_throttle.h"

namespace content {
class NavigationHandle;
}

namespace history {
class HistoryService;
}

// Navigation throttle responsible for identifying the <origin, salt> pair
// associated with an incoming navigation. The resulting salt is sent in the
// navigation's `commit_params` to be used by the renderer when determining
// whether a link is :visited.
//
// Links can be styled as :visited in any Document, including Documents
// that result from non-tab navigations.
// HistoryTabHelper::ReadyToCommitNavigation() could be used to perform a
// similar function to this throttle, but the HistoryTabHelper does not listen
// for non-tab navigations. As a result, we chose to implement this throttle
// class which will listen for all navigations and attempt to assign a salt
// value.
class VisitedLinkNavigationThrottle : public content::NavigationThrottle,
                                      public history::HistoryServiceObserver {};

#endif  // COMPONENTS_HISTORY_CONTENT_BROWSER_VISITED_LINK_NAVIGATION_THROTTLE_H_