#include "services/network/network_service_network_delegate.h"
#include <optional>
#include <string>
#include "base/debug/dump_without_crashing.h"
#include "base/functional/bind.h"
#include "base/ranges/algorithm.h"
#include "base/strings/utf_string_conversions.h"
#include "base/types/optional_util.h"
#include "build/build_config.h"
#include "components/domain_reliability/monitor.h"
#include "net/base/features.h"
#include "net/base/isolation_info.h"
#include "net/base/load_flags.h"
#include "net/base/net_errors.h"
#include "net/cookies/cookie_setting_override.h"
#include "net/cookies/cookie_util.h"
#include "net/url_request/clear_site_data.h"
#include "net/url_request/referrer_policy.h"
#include "net/url_request/url_request.h"
#include "services/network/cookie_manager.h"
#include "services/network/cookie_settings.h"
#include "services/network/network_context.h"
#include "services/network/network_service.h"
#include "services/network/network_service_proxy_delegate.h"
#include "services/network/pending_callback_chain.h"
#include "services/network/public/cpp/features.h"
#include "services/network/url_loader.h"
#include "url/gurl.h"
#if BUILDFLAG(ENABLE_WEBSOCKETS)
#include "services/network/websocket.h"
#endif
namespace network {
NetworkServiceNetworkDelegate::NetworkServiceNetworkDelegate(
bool enable_referrers,
bool validate_referrer_policy_on_initial_request,
mojo::PendingRemote<mojom::ProxyErrorClient> proxy_error_client_remote,
NetworkContext* network_context)
: … { … }
NetworkServiceNetworkDelegate::~NetworkServiceNetworkDelegate() = default;
void NetworkServiceNetworkDelegate::MaybeTruncateReferrer(
net::URLRequest* const request,
const GURL& effective_url) { … }
int NetworkServiceNetworkDelegate::OnBeforeURLRequest(
net::URLRequest* request,
net::CompletionOnceCallback callback,
GURL* new_url) { … }
int NetworkServiceNetworkDelegate::OnBeforeStartTransaction(
net::URLRequest* request,
const net::HttpRequestHeaders& headers,
OnBeforeStartTransactionCallback callback) { … }
int NetworkServiceNetworkDelegate::OnHeadersReceived(
net::URLRequest* request,
net::CompletionOnceCallback callback,
const net::HttpResponseHeaders* original_response_headers,
scoped_refptr<net::HttpResponseHeaders>* override_response_headers,
const net::IPEndPoint& endpoint,
std::optional<GURL>* preserve_fragment_on_redirect_url) { … }
void NetworkServiceNetworkDelegate::OnBeforeRedirect(net::URLRequest* request,
const GURL& new_location) { … }
void NetworkServiceNetworkDelegate::OnResponseStarted(net::URLRequest* request,
int net_error) { … }
void NetworkServiceNetworkDelegate::OnCompleted(net::URLRequest* request,
bool started,
int net_error) { … }
void NetworkServiceNetworkDelegate::OnPACScriptError(
int line_number,
const std::u16string& error) { … }
std::optional<net::cookie_util::StorageAccessStatus>
NetworkServiceNetworkDelegate::OnGetStorageAccessStatus(
const net::URLRequest& request) const { … }
bool NetworkServiceNetworkDelegate::OnAnnotateAndMoveUserBlockedCookies(
const net::URLRequest& request,
const net::FirstPartySetMetadata& first_party_set_metadata,
net::CookieAccessResultList& maybe_included_cookies,
net::CookieAccessResultList& excluded_cookies) { … }
bool NetworkServiceNetworkDelegate::OnCanSetCookie(
const net::URLRequest& request,
const net::CanonicalCookie& cookie,
net::CookieOptions* options,
const net::FirstPartySetMetadata& first_party_set_metadata,
net::CookieInclusionStatus* inclusion_status) { … }
net::NetworkDelegate::PrivacySetting
NetworkServiceNetworkDelegate::OnForcePrivacyMode(
const net::URLRequest& request) const { … }
bool NetworkServiceNetworkDelegate::
OnCancelURLRequestWithPolicyViolatingReferrerHeader(
const net::URLRequest& request,
const GURL& target_url,
const GURL& referrer_url) const { … }
bool NetworkServiceNetworkDelegate::OnCanQueueReportingReport(
const url::Origin& origin) const { … }
void NetworkServiceNetworkDelegate::OnCanSendReportingReports(
std::set<url::Origin> origins,
base::OnceCallback<void(std::set<url::Origin>)> result_callback) const { … }
bool NetworkServiceNetworkDelegate::OnCanSetReportingClient(
const url::Origin& origin,
const GURL& endpoint) const { … }
bool NetworkServiceNetworkDelegate::OnCanUseReportingClient(
const url::Origin& origin,
const GURL& endpoint) const { … }
int NetworkServiceNetworkDelegate::HandleClearSiteDataHeader(
net::URLRequest* request,
net::CompletionOnceCallback callback,
const net::HttpResponseHeaders* original_response_headers) { … }
void NetworkServiceNetworkDelegate::FinishedClearSiteData(
base::WeakPtr<net::URLRequest> request,
net::CompletionOnceCallback callback) { … }
void NetworkServiceNetworkDelegate::FinishedCanSendReportingReports(
base::OnceCallback<void(std::set<url::Origin>)> result_callback,
const std::vector<url::Origin>& origins) { … }
void NetworkServiceNetworkDelegate::ForwardProxyErrors(int net_error) { … }
}