chromium/extensions/browser/api/declarative_net_request/request_params.cc

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

#include "extensions/browser/api/declarative_net_request/request_params.h"

#include <algorithm>
#include <string_view>

#include "base/check.h"
#include "base/containers/flat_map.h"
#include "base/dcheck_is_on.h"
#include "base/functional/bind.h"
#include "base/no_destructor.h"
#include "base/ranges/algorithm.h"
#include "base/strings/pattern.h"
#include "base/strings/string_util.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/api/declarative_net_request/constants.h"
#include "extensions/browser/api/declarative_net_request/flat/extension_ruleset_generated.h"
#include "extensions/browser/api/declarative_net_request/utils.h"
#include "extensions/browser/api/web_request/web_request_info.h"
#include "extensions/browser/api/web_request/web_request_resource_type.h"
#include "extensions/browser/extensions_browser_client.h"
#include "extensions/common/constants.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "net/http/http_response_headers.h"
#include "third_party/blink/public/mojom/loader/resource_load_info.mojom-shared.h"
#include "url/gurl.h"

namespace extensions::declarative_net_request {

namespace {
flat_rule;

// Returns whether the request to `url` is third party to its `document_origin`.
// TODO(crbug.com/40508457): Look into caching this.
bool IsThirdPartyRequest(const GURL& url, const url::Origin& document_origin) {}

bool IsThirdPartyRequest(const url::Origin& origin,
                         const url::Origin& document_origin) {}

content::GlobalRenderFrameHostId GetFrameRoutingId(
    content::RenderFrameHost* host) {}

// Returns if any value for `header` in `response_headers` matches the value
// pattern from `flat_pattern`.
// Note: Matches are case-insensitive, and supports * (0 or more characters) and
// ? (0 or 1 characters) matching.
bool HasHeaderValue(const net::HttpResponseHeaders& response_headers,
                    std::string_view header,
                    const flatbuffers::String* flat_pattern) {}

// Returns true if the request's response headers matches at least one condition
// in `header_conditions`. A header matches a condition if:
// - the header exists AND
// - contains a value in condition->values() if specified AND
// - does not contain any values in condition->excluded_values() if specified.
bool MatchesHeaderConditions(
    const net::HttpResponseHeaders& response_headers,
    const flatbuffers::Vector<flatbuffers::Offset<flat::HeaderCondition>>&
        header_conditions) {}

bool DoEmbedderConditionsMatch(
    int tab_id,
    scoped_refptr<const net::HttpResponseHeaders> response_headers,
    const flatbuffers::Vector<uint8_t>& conditions_buffer) {}

}  // namespace

RequestParams::RequestParams(
    const WebRequestInfo& info,
    scoped_refptr<const net::HttpResponseHeaders> response_headers)
    :{}

RequestParams::RequestParams(
    content::RenderFrameHost* host,
    bool is_post_navigation,
    scoped_refptr<const net::HttpResponseHeaders> response_headers)
    :{}

RequestParams::RequestParams(
    const GURL& url,
    const url::Origin& initiator,
    const api::declarative_net_request::ResourceType request_type,
    const api::declarative_net_request::RequestMethod request_method,
    int tab_id,
    scoped_refptr<const net::HttpResponseHeaders> response_headers)
    :{}

RequestParams::RequestParams() = default;
RequestParams::~RequestParams() = default;

}  // namespace extensions::declarative_net_request