#include "extensions/browser/api/declarative_net_request/composite_matcher.h"
#include <cstdint>
#include <functional>
#include <iterator>
#include <optional>
#include <set>
#include <utility>
#include <vector>
#include "base/containers/contains.h"
#include "base/metrics/histogram_macros.h"
#include "base/ranges/algorithm.h"
#include "base/time/time.h"
#include "base/timer/elapsed_timer.h"
#include "components/url_pattern_index/flat/url_pattern_index_generated.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/request_action.h"
#include "extensions/browser/api/declarative_net_request/request_params.h"
#include "extensions/browser/api/declarative_net_request/utils.h"
#include "extensions/common/api/declarative_net_request/constants.h"
namespace extensions::declarative_net_request {
flat_rule;
PageAccess;
ActionInfo;
namespace {
bool AreIDsUnique(const CompositeMatcher::MatcherList& matchers) { … }
class ScopedGetBeforeRequestActionTimer { … };
}
ActionInfo::ActionInfo() = default;
ActionInfo::ActionInfo(std::optional<RequestAction> action,
bool notify_request_withheld)
: … { … }
ActionInfo::~ActionInfo() = default;
ActionInfo::ActionInfo(ActionInfo&&) = default;
ActionInfo& ActionInfo::operator=(ActionInfo&& other) = default;
CompositeMatcher::CompositeMatcher(MatcherList matchers,
const ExtensionId& extension_id,
HostPermissionsAlwaysRequired mode)
: … { … }
CompositeMatcher::~CompositeMatcher() = default;
const RulesetMatcher* CompositeMatcher::GetMatcherWithID(RulesetID id) const { … }
void CompositeMatcher::AddOrUpdateRuleset(
std::unique_ptr<RulesetMatcher> matcher) { … }
void CompositeMatcher::AddOrUpdateRulesets(MatcherList matchers) { … }
void CompositeMatcher::RemoveRulesetsWithIDs(const std::set<RulesetID>& ids) { … }
std::set<RulesetID> CompositeMatcher::ComputeStaticRulesetIDs() const { … }
ActionInfo CompositeMatcher::GetAction(
const RequestParams& params,
RulesetMatchingStage stage,
PermissionsData::PageAccess page_access) const { … }
std::vector<RequestAction> CompositeMatcher::GetModifyHeadersActions(
const RequestParams& params,
RulesetMatchingStage stage) const { … }
bool CompositeMatcher::HasAnyExtraHeadersMatcher() const { … }
void CompositeMatcher::OnRenderFrameCreated(content::RenderFrameHost* host) { … }
void CompositeMatcher::OnRenderFrameDeleted(content::RenderFrameHost* host) { … }
void CompositeMatcher::OnDidFinishNavigation(
content::NavigationHandle* navigation_handle) { … }
bool CompositeMatcher::HasRulesets(RulesetMatchingStage stage) const { … }
void CompositeMatcher::OnMatchersModified() { … }
bool CompositeMatcher::ComputeHasAnyExtraHeadersMatcher() const { … }
}