chromium/extensions/browser/api/declarative_webrequest/webrequest_condition_attribute.cc

// Copyright 2012 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_webrequest/webrequest_condition_attribute.h"

#include <stddef.h>

#include <utility>
#include <vector>

#include "base/check.h"
#include "base/containers/contains.h"
#include "base/lazy_instance.h"
#include "base/memory/ptr_util.h"
#include "base/notreached.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_util.h"
#include "base/values.h"
#include "extensions/browser/api/declarative/deduping_factory.h"
#include "extensions/browser/api/declarative_webrequest/request_stage.h"
#include "extensions/browser/api/declarative_webrequest/webrequest_condition.h"
#include "extensions/browser/api/declarative_webrequest/webrequest_constants.h"
#include "extensions/browser/api/extensions_api_client.h"
#include "extensions/browser/api/web_request/web_request_api_helpers.h"
#include "extensions/browser/api/web_request/web_request_info.h"
#include "extensions/browser/api/web_request/web_request_resource_type.h"
#include "extensions/common/error_utils.h"
#include "net/base/net_errors.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_util.h"

CaseInsensitiveCompareASCII;
Value;

helpers;
keys;

namespace extensions {

namespace {
// Error messages.
const char kInvalidValue[] =;

struct WebRequestConditionAttributeFactory {};

base::LazyInstance<WebRequestConditionAttributeFactory>::Leaky
    g_web_request_condition_attribute_factory =;

}  // namespace

//
// WebRequestConditionAttribute
//

WebRequestConditionAttribute::WebRequestConditionAttribute() = default;

WebRequestConditionAttribute::~WebRequestConditionAttribute() = default;

bool WebRequestConditionAttribute::Equals(
    const WebRequestConditionAttribute* other) const {}

// static
scoped_refptr<const WebRequestConditionAttribute>
WebRequestConditionAttribute::Create(
    const std::string& name,
    const base::Value* value,
    std::string* error) {}

//
// WebRequestConditionAttributeResourceType
//

WebRequestConditionAttributeResourceType::
    WebRequestConditionAttributeResourceType(
        const std::vector<WebRequestResourceType>& types)
    :{}

WebRequestConditionAttributeResourceType::
~WebRequestConditionAttributeResourceType() {}

// static
scoped_refptr<const WebRequestConditionAttribute>
WebRequestConditionAttributeResourceType::Create(
    const std::string& instance_type,
    const base::Value* value,
    std::string* error,
    bool* bad_message) {}

int WebRequestConditionAttributeResourceType::GetStages() const {}

bool WebRequestConditionAttributeResourceType::IsFulfilled(
    const WebRequestData& request_data) const {}

WebRequestConditionAttribute::Type
WebRequestConditionAttributeResourceType::GetType() const {}

std::string WebRequestConditionAttributeResourceType::GetName() const {}

bool WebRequestConditionAttributeResourceType::Equals(
    const WebRequestConditionAttribute* other) const {}

//
// WebRequestConditionAttributeContentType
//

WebRequestConditionAttributeContentType::
WebRequestConditionAttributeContentType(
    const std::vector<std::string>& content_types,
    bool inclusive)
    :{}

WebRequestConditionAttributeContentType::
~WebRequestConditionAttributeContentType() {}

// static
scoped_refptr<const WebRequestConditionAttribute>
WebRequestConditionAttributeContentType::Create(
      const std::string& name,
      const base::Value* value,
      std::string* error,
      bool* bad_message) {}

int WebRequestConditionAttributeContentType::GetStages() const {}

bool WebRequestConditionAttributeContentType::IsFulfilled(
    const WebRequestData& request_data) const {}

WebRequestConditionAttribute::Type
WebRequestConditionAttributeContentType::GetType() const {}

std::string WebRequestConditionAttributeContentType::GetName() const {}

bool WebRequestConditionAttributeContentType::Equals(
    const WebRequestConditionAttribute* other) const {}

// Manages a set of tests to be applied to name-value pairs representing
// headers. This is a helper class to header-related condition attributes.
// It contains a set of test groups. A name-value pair satisfies the whole
// set of test groups iff it passes at least one test group.
class HeaderMatcher {};

// HeaderMatcher implementation.

HeaderMatcher::~HeaderMatcher() = default;

// static
std::unique_ptr<const HeaderMatcher> HeaderMatcher::Create(
    const base::Value::List& tests) {}

bool HeaderMatcher::TestNameValue(const std::string& name,
                                  const std::string& value) const {}

HeaderMatcher::HeaderMatcher(
    std::vector<std::unique_ptr<const HeaderMatchTest>> tests)
    :{}

// HeaderMatcher::StringMatchTest implementation.

// static
std::unique_ptr<HeaderMatcher::StringMatchTest>
HeaderMatcher::StringMatchTest::Create(const base::Value& data,
                                       MatchType type,
                                       bool case_sensitive) {}

HeaderMatcher::StringMatchTest::~StringMatchTest() = default;

bool HeaderMatcher::StringMatchTest::Matches(
    const std::string& str) const {}

HeaderMatcher::StringMatchTest::StringMatchTest(const std::string& data,
                                                MatchType type,
                                                bool case_sensitive)
    :{}

// HeaderMatcher::HeaderMatchTest implementation.

HeaderMatcher::HeaderMatchTest::HeaderMatchTest(
    std::vector<std::unique_ptr<const StringMatchTest>> name_match,
    std::vector<std::unique_ptr<const StringMatchTest>> value_match)
    :{}

HeaderMatcher::HeaderMatchTest::~HeaderMatchTest() = default;

// static
std::unique_ptr<const HeaderMatcher::HeaderMatchTest>
HeaderMatcher::HeaderMatchTest::Create(const base::Value::Dict& tests) {}

bool HeaderMatcher::HeaderMatchTest::Matches(const std::string& name,
                                             const std::string& value) const {}

//
// WebRequestConditionAttributeRequestHeaders
//

WebRequestConditionAttributeRequestHeaders::
    WebRequestConditionAttributeRequestHeaders(
        std::unique_ptr<const HeaderMatcher> header_matcher,
        bool positive)
    :{}

WebRequestConditionAttributeRequestHeaders::
~WebRequestConditionAttributeRequestHeaders() {}

namespace {

std::unique_ptr<const HeaderMatcher> PrepareHeaderMatcher(
    const std::string& name,
    const base::Value* value,
    std::string* error) {}

}  // namespace

// static
scoped_refptr<const WebRequestConditionAttribute>
WebRequestConditionAttributeRequestHeaders::Create(
    const std::string& name,
    const base::Value* value,
    std::string* error,
    bool* bad_message) {}

int WebRequestConditionAttributeRequestHeaders::GetStages() const {}

bool WebRequestConditionAttributeRequestHeaders::IsFulfilled(
    const WebRequestData& request_data) const {}

WebRequestConditionAttribute::Type
WebRequestConditionAttributeRequestHeaders::GetType() const {}

std::string WebRequestConditionAttributeRequestHeaders::GetName() const {}

bool WebRequestConditionAttributeRequestHeaders::Equals(
    const WebRequestConditionAttribute* other) const {}

//
// WebRequestConditionAttributeResponseHeaders
//

WebRequestConditionAttributeResponseHeaders::
    WebRequestConditionAttributeResponseHeaders(
        std::unique_ptr<const HeaderMatcher> header_matcher,
        bool positive)
    :{}

WebRequestConditionAttributeResponseHeaders::
~WebRequestConditionAttributeResponseHeaders() {}

// static
scoped_refptr<const WebRequestConditionAttribute>
WebRequestConditionAttributeResponseHeaders::Create(
    const std::string& name,
    const base::Value* value,
    std::string* error,
    bool* bad_message) {}

int WebRequestConditionAttributeResponseHeaders::GetStages() const {}

bool WebRequestConditionAttributeResponseHeaders::IsFulfilled(
    const WebRequestData& request_data) const {}

WebRequestConditionAttribute::Type
WebRequestConditionAttributeResponseHeaders::GetType() const {}

std::string WebRequestConditionAttributeResponseHeaders::GetName() const {}

bool WebRequestConditionAttributeResponseHeaders::Equals(
    const WebRequestConditionAttribute* other) const {}

//
// WebRequestConditionAttributeStages
//

WebRequestConditionAttributeStages::
WebRequestConditionAttributeStages(int allowed_stages)
    :{}

WebRequestConditionAttributeStages::
~WebRequestConditionAttributeStages() {}

namespace {

// Reads strings stored in |value|, which is expected to be a Value of type
// LIST, and sets corresponding bits (see RequestStage) in |out_stages|.
// Returns true on success, false otherwise.
bool ParseListOfStages(const base::Value& value, int* out_stages) {}

}  // namespace

// static
scoped_refptr<const WebRequestConditionAttribute>
WebRequestConditionAttributeStages::Create(const std::string& name,
                                           const base::Value* value,
                                           std::string* error,
                                           bool* bad_message) {}

int WebRequestConditionAttributeStages::GetStages() const {}

bool WebRequestConditionAttributeStages::IsFulfilled(
    const WebRequestData& request_data) const {}

WebRequestConditionAttribute::Type
WebRequestConditionAttributeStages::GetType() const {}

std::string WebRequestConditionAttributeStages::GetName() const {}

bool WebRequestConditionAttributeStages::Equals(
    const WebRequestConditionAttribute* other) const {}

}  // namespace extensions