#include "extensions/browser/api/declarative_net_request/extension_url_pattern_index_matcher.h"
#include <algorithm>
#include <limits>
#include <list>
#include <string>
#include <utility>
#include <vector>
#include "base/check_op.h"
#include "base/notreached.h"
#include "extensions/browser/api/declarative_net_request/request_action.h"
#include "extensions/browser/api/declarative_net_request/request_params.h"
#include "extensions/common/api/declarative_net_request.h"
namespace extensions::declarative_net_request {
flat_rule;
dnr_api;
namespace {
FindRuleStrategy;
std::vector<url_pattern_index::UrlPatternIndexMatcher> GetMatchers(
const ExtensionUrlPatternIndexMatcher::UrlPatternIndexList* index_list) { … }
bool IsExtraHeadersMatcherInternal(
const std::vector<url_pattern_index::UrlPatternIndexMatcher>& matchers) { … }
size_t GetRulesCountInternal(
const std::vector<url_pattern_index::UrlPatternIndexMatcher>& matchers) { … }
}
ExtensionUrlPatternIndexMatcher::ExtensionUrlPatternIndexMatcher(
const ExtensionId& extension_id,
RulesetID ruleset_id,
const ExtensionUrlPatternIndexMatcher::UrlPatternIndexList*
before_request_index_list,
const ExtensionUrlPatternIndexMatcher::UrlPatternIndexList*
headers_received_index_list,
const ExtensionMetadataList* metadata_list)
: … { … }
ExtensionUrlPatternIndexMatcher::~ExtensionUrlPatternIndexMatcher() = default;
bool ExtensionUrlPatternIndexMatcher::IsExtraHeadersMatcher() const { … }
size_t ExtensionUrlPatternIndexMatcher::GetRulesCount() const { … }
size_t ExtensionUrlPatternIndexMatcher::GetBeforeRequestRulesCount() const { … }
size_t ExtensionUrlPatternIndexMatcher::GetHeadersReceivedRulesCount() const { … }
std::optional<RequestAction>
ExtensionUrlPatternIndexMatcher::GetAllowAllRequestsAction(
const RequestParams& params,
RulesetMatchingStage stage) const { … }
std::vector<RequestAction>
ExtensionUrlPatternIndexMatcher::GetModifyHeadersActions(
const RequestParams& params,
RulesetMatchingStage stage,
std::optional<uint64_t> min_priority) const { … }
std::optional<RequestAction>
ExtensionUrlPatternIndexMatcher::GetActionIgnoringAncestors(
const RequestParams& params,
RulesetMatchingStage stage) const { … }
std::optional<RequestAction> ExtensionUrlPatternIndexMatcher::GetActionHelper(
const RequestParams& params,
const std::vector<UrlPatternIndexMatcher>& matchers) const { … }
const flat_rule::UrlRule* ExtensionUrlPatternIndexMatcher::GetMatchingRule(
const RequestParams& params,
const std::vector<UrlPatternIndexMatcher>& matchers,
flat::IndexType index,
FindRuleStrategy strategy) const { … }
std::vector<const url_pattern_index::flat::UrlRule*>
ExtensionUrlPatternIndexMatcher::GetAllMatchingRules(
const RequestParams& params,
const std::vector<UrlPatternIndexMatcher>& matchers,
flat::IndexType index) const { … }
const std::vector<url_pattern_index::UrlPatternIndexMatcher>&
ExtensionUrlPatternIndexMatcher::GetMatchersForStage(
RulesetMatchingStage stage) const { … }
void ExtensionUrlPatternIndexMatcher::SetDisabledRuleIds(
base::flat_set<int> disabled_rule_ids) { … }
const base::flat_set<int>&
ExtensionUrlPatternIndexMatcher::GetDisabledRuleIdsForTesting() const { … }
}