chromium/components/safe_browsing/content/browser/browser_url_loader_throttle.cc

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

#include "components/safe_browsing/content/browser/browser_url_loader_throttle.h"

#include "base/check_op.h"
#include "base/functional/bind.h"
#include "base/memory/ptr_util.h"
#include "base/memory/scoped_refptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "components/safe_browsing/buildflags.h"
#include "components/safe_browsing/content/browser/async_check_tracker.h"
#include "components/safe_browsing/core/browser/hashprefix_realtime/hash_realtime_service.h"
#include "components/safe_browsing/core/browser/realtime/url_lookup_service_base.h"
#include "components/safe_browsing/core/browser/safe_browsing_url_checker_impl.h"
#include "components/safe_browsing/core/browser/url_checker_delegate.h"
#include "components/safe_browsing/core/common/features.h"
#include "components/safe_browsing/core/common/utils.h"
#include "components/safe_browsing/core/common/web_ui_constants.h"
#include "components/sessions/content/session_tab_helper.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/url_constants.h"
#include "net/base/load_flags.h"
#include "net/url_request/redirect_info.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/mojom/fetch_api.mojom.h"
#include "services/network/public/mojom/url_response_head.mojom.h"

namespace {

constexpr char kFullURLLookup[] =;

constexpr char kFromCacheUmaSuffix[] =;
constexpr char kFromNetworkUmaSuffix[] =;

void LogTotalDelay2Metrics(const std::string& url_check_type,
                           base::TimeDelta total_delay) {}

void LogTotalDelay2MetricsWithResponseType(bool is_response_from_cache,
                                           base::TimeDelta total_delay) {}

// Returns true if the URL is known to be safe. We also require that this URL
// never redirects to a potentially unsafe URL, because the redirected URLs are
// also skipped if this function returns true.
bool KnownSafeUrl(const GURL& url) {}

}  // namespace

namespace safe_browsing {

BrowserURLLoaderThrottle::SkipCheckChecker::SkipCheckChecker(
    UrlCheckerHolder::GetDelegateCallback delegate_getter,
    int frame_tree_node_id)
    :{}

BrowserURLLoaderThrottle::SkipCheckChecker::~SkipCheckChecker() = default;

void BrowserURLLoaderThrottle::SkipCheckChecker::CheckOriginalUrl(
    OnCompleteCheckCallback callback,
    const GURL& url,
    bool originated_from_service_worker) {}

void BrowserURLLoaderThrottle::SkipCheckChecker::CheckRedirectUrl(
    OnCompleteCheckCallback callback) {}

// static
std::unique_ptr<BrowserURLLoaderThrottle> BrowserURLLoaderThrottle::Create(
    UrlCheckerHolder::GetDelegateCallback delegate_getter,
    const base::RepeatingCallback<content::WebContents*()>& web_contents_getter,
    int frame_tree_node_id,
    std::optional<int64_t> navigation_id,
    base::WeakPtr<RealTimeUrlLookupServiceBase> url_lookup_service,
    base::WeakPtr<HashRealTimeService> hash_realtime_service,
    hash_realtime_utils::HashRealTimeSelection hash_realtime_selection,
    base::WeakPtr<AsyncCheckTracker> async_check_tracker) {}

BrowserURLLoaderThrottle::BrowserURLLoaderThrottle(
    UrlCheckerHolder::GetDelegateCallback delegate_getter,
    const base::RepeatingCallback<content::WebContents*()>& web_contents_getter,
    int frame_tree_node_id,
    std::optional<int64_t> navigation_id,
    base::WeakPtr<RealTimeUrlLookupServiceBase> url_lookup_service,
    base::WeakPtr<HashRealTimeService> hash_realtime_service,
    hash_realtime_utils::HashRealTimeSelection hash_realtime_selection,
    base::WeakPtr<AsyncCheckTracker> async_check_tracker)
    :{}

BrowserURLLoaderThrottle::~BrowserURLLoaderThrottle() {}

void BrowserURLLoaderThrottle::WillStartRequest(
    network::ResourceRequest* request,
    bool* defer) {}

void BrowserURLLoaderThrottle::OnSkipCheckCompleteOnOriginalUrl(
    const net::HttpRequestHeaders& headers,
    int load_flags,
    bool has_user_gesture,
    const GURL& url,
    const std::string& method,
    bool should_skip) {}

void BrowserURLLoaderThrottle::WillRedirectRequest(
    net::RedirectInfo* redirect_info,
    const network::mojom::URLResponseHead& /* response_head */,
    bool* defer,
    std::vector<std::string>* /* to_be_removed_headers */,
    net::HttpRequestHeaders* /* modified_headers */,
    net::HttpRequestHeaders* /* modified_cors_exempt_headers */) {}

void BrowserURLLoaderThrottle::OnSkipCheckCompleteOnRedirectUrl(
    const GURL& url,
    const std::string& method,
    bool should_skip) {}

void BrowserURLLoaderThrottle::WillProcessResponse(
    const GURL& response_url,
    network::mojom::URLResponseHead* response_head,
    bool* defer) {}

const char* BrowserURLLoaderThrottle::NameForLoggingWillProcessResponse() {}

UrlCheckerHolder* BrowserURLLoaderThrottle::GetSyncSBCheckerForTesting() {}

UrlCheckerHolder* BrowserURLLoaderThrottle::GetAsyncSBCheckerForTesting() {}

void BrowserURLLoaderThrottle::SetOnSyncSBCheckerCreatedCallbackForTesting(
    base::OnceClosure callback) {}

void BrowserURLLoaderThrottle::SetOnAsyncSBCheckerCreatedCallbackForTesting(
    base::OnceClosure callback) {}

void BrowserURLLoaderThrottle::OnCompleteSyncCheck(
    UrlCheckerHolder::OnCompleteCheckResult result) {}

void BrowserURLLoaderThrottle::OnCompleteAsyncCheck(
    UrlCheckerHolder::OnCompleteCheckResult result) {}

void BrowserURLLoaderThrottle::BlockUrlLoader(bool showed_interstitial) {}

std::string BrowserURLLoaderThrottle::GetUrlCheckTypeForLogging(
    SafeBrowsingUrlCheckerImpl::PerformedCheck performed_check) {}

void BrowserURLLoaderThrottle::SkipChecks() {}

void BrowserURLLoaderThrottle::DeleteUrlChecker() {}

void BrowserURLLoaderThrottle::MaybeTransferAsyncChecker() {}

}  // namespace safe_browsing