chromium/chrome/browser/preloading/navigation_ablation_throttle.cc

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

#include "chrome/browser/preloading/navigation_ablation_throttle.h"

#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/pattern.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "components/search_engines/search_terms_data.h"
#include "components/search_engines/template_url_service.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/navigation_throttle.h"
#include "content/public/browser/web_contents.h"

namespace {
BASE_FEATURE();

// The amount of time to stall before resuming loading.
const base::FeatureParam<base::TimeDelta> kNavigationLatencyAblationDuration{};

// The `base::MatchPattern` pattern that identifies the URLs should be ablated.
const base::FeatureParam<std::string> kAblationTargetPattern{};

// Whether default search Search queries should be ablated.
const base::FeatureParam<bool> kShouldAblateDefaultSearchQueries{};

// Whether default search navigations to any of the related hosts should be
// ablated.
const base::FeatureParam<bool> kShouldAblateDefaultSearchHost{};

// Whether the corpus of URLs that are not part of the default search host
// corpus should be ablated.
const base::FeatureParam<bool> kShouldAblateNonDefaultSearchHost{};

// Different URLs re grouped into ablation types, which can be configured to be
// ablated or not.
enum class AblationType {};

// The name of the throttle for logging purposes.
constexpr char kNavigationAblationThrottleName[] =;

// Return the type of navigation based on whether `navigation_url` is a search
// query or related to the user's default search provider.
AblationType GetAblationType(const GURL& navigation_url,
                             content::BrowserContext* browser_context) {}

bool ShouldCreateThrottle(content::NavigationHandle* navigation) {}

// A navigation throttle that deferes during WillStartRequest and resumes after
// a fixed duration.
class NavigationAblationThrottle : public content::NavigationThrottle {};

}  // namespace

// static
std::unique_ptr<content::NavigationThrottle>
MaybeCreateNavigationAblationThrottle(content::NavigationHandle* navigation) {}