#include "chrome/browser/preloading/prerender/prerender_manager.h"
#include <memory>
#include <optional>
#include <string>
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/metrics/histogram_functions.h"
#include "chrome/browser/browser_features.h"
#include "chrome/browser/preloading/chrome_preloading.h"
#include "chrome/browser/preloading/prefetch/search_prefetch/field_trial_settings.h"
#include "chrome/browser/preloading/prefetch/search_prefetch/search_prefetch_service.h"
#include "chrome/browser/preloading/prefetch/search_prefetch/search_prefetch_service_factory.h"
#include "chrome/browser/preloading/prerender/prerender_utils.h"
#include "chrome/browser/profiles/profile.h"
#include "components/omnibox/browser/autocomplete_match.h"
#include "components/page_load_metrics/browser/navigation_handle_user_data.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/preloading.h"
#include "content/public/browser/preloading_data.h"
#include "content/public/browser/prerender_handle.h"
#include "content/public/browser/replaced_navigation_entry_data.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
#include "net/base/url_util.h"
#include "url/gurl.h"
namespace internal {
const char kHistogramPrerenderPredictionStatusDefaultSearchEngine[] = …;
const char kHistogramPrerenderPredictionStatusDirectUrlInput[] = …;
}
namespace {
PreloadingTriggeringOutcome;
void MarkPreloadingAttemptAsDuplicate(
content::PreloadingAttempt* preloading_attempt) { … }
content::PreloadingFailureReason ToPreloadingFailureReason(
PrerenderPredictionStatus status) { … }
void AttachBookmarkBarNavigationHandleUserData(
content::NavigationHandle& navigation_handle) { … }
}
PrerenderManager::~PrerenderManager() = default;
class PrerenderManager::SearchPrerenderTask { … };
void PrerenderManager::DidFinishNavigation(
content::NavigationHandle* navigation_handle) { … }
base::WeakPtr<content::PrerenderHandle>
PrerenderManager::StartPrerenderBookmark(const GURL& prerendering_url) { … }
base::WeakPtr<content::PrerenderHandle>
PrerenderManager::StartPrerenderNewTabPage(
const GURL& prerendering_url,
content::PreloadingPredictor predictor) { … }
void PrerenderManager::StopPrerenderNewTabPage(
base::WeakPtr<content::PrerenderHandle> prerender_handle) { … }
void PrerenderManager::StopPrerenderBookmark(
base::WeakPtr<content::PrerenderHandle> prerender_handle) { … }
base::WeakPtr<content::PrerenderHandle>
PrerenderManager::StartPrerenderDirectUrlInput(
const GURL& prerendering_url,
content::PreloadingAttempt& preloading_attempt) { … }
void PrerenderManager::StartPrerenderSearchResult(
const GURL& canonical_search_url,
const GURL& prerendering_url,
base::WeakPtr<content::PreloadingAttempt> preloading_attempt) { … }
void PrerenderManager::StopPrerenderSearchResult(
const GURL& canonical_search_url) { … }
bool PrerenderManager::HasSearchResultPagePrerendered() const { … }
base::WeakPtr<PrerenderManager> PrerenderManager::GetWeakPtr() { … }
const GURL PrerenderManager::GetPrerenderCanonicalSearchURLForTesting() const { … }
void PrerenderManager::ResetPrerenderHandlesOnPrimaryPageChanged(
content::NavigationHandle* navigation_handle) { … }
bool PrerenderManager::ResetSearchPrerenderTaskIfNecessary(
const GURL& canonical_search_url,
base::WeakPtr<content::PreloadingAttempt> preloading_attempt) { … }
PrerenderManager::PrerenderManager(content::WebContents* web_contents)
: … { … }
WEB_CONTENTS_USER_DATA_KEY_IMPL(PrerenderManager);