#include "components/url_rewrite/common/url_loader_throttle.h"
#include <string>
#include <string_view>
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "net/base/net_errors.h"
#include "services/network/public/cpp/resource_request.h"
#include "url/url_constants.h"
namespace url_rewrite {
namespace {
std::string ClearUrlQueryRef(const GURL& url) { … }
void ApplySubstituteQueryPattern(
network::ResourceRequest* request,
const mojom::UrlRequestRewriteSubstituteQueryPatternPtr&
substitute_query_pattern) { … }
void ApplyReplaceUrl(network::ResourceRequest* request,
const mojom::UrlRequestRewriteReplaceUrlPtr& replace_url) { … }
void ApplyRemoveHeader(
network::ResourceRequest* request,
const mojom::UrlRequestRewriteRemoveHeaderPtr& remove_header) { … }
void ApplyAppendToQuery(
network::ResourceRequest* request,
const mojom::UrlRequestRewriteAppendToQueryPtr& append_to_query) { … }
bool HostMatches(std::string_view url_host, std::string_view rule_host) { … }
bool RuleFiltersMatchUrl(const GURL& url,
const mojom::UrlRequestRulePtr& rule) { … }
bool IsRequestAllowed(network::ResourceRequest* request,
const mojom::UrlRequestRewriteRulesPtr& rules) { … }
}
URLLoaderThrottle::URLLoaderThrottle(
scoped_refptr<UrlRequestRewriteRules> rules,
IsHeaderCorsExemptCallback is_header_cors_exempt_callback)
: … { … }
URLLoaderThrottle::~URLLoaderThrottle() = default;
void URLLoaderThrottle::DetachFromCurrentSequence() { … }
void URLLoaderThrottle::WillStartRequest(network::ResourceRequest* request,
bool* defer) { … }
void URLLoaderThrottle::ApplyRule(network::ResourceRequest* request,
const mojom::UrlRequestRulePtr& rule) { … }
void URLLoaderThrottle::ApplyRewrite(
network::ResourceRequest* request,
const mojom::UrlRequestActionPtr& rewrite) { … }
void URLLoaderThrottle::ApplyAddHeaders(
network::ResourceRequest* request,
const mojom::UrlRequestRewriteAddHeadersPtr& add_headers) { … }
}