#include "extensions/browser/api/declarative_net_request/test_utils.h"
#include <string>
#include <tuple>
#include <utility>
#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/json/json_file_value_serializer.h"
#include "base/not_fatal_until.h"
#include "base/values.h"
#include "extensions/browser/api/declarative_net_request/composite_matcher.h"
#include "extensions/browser/api/declarative_net_request/file_backed_ruleset_source.h"
#include "extensions/browser/api/declarative_net_request/indexed_rule.h"
#include "extensions/browser/api/declarative_net_request/prefs_helper.h"
#include "extensions/browser/api/declarative_net_request/request_params.h"
#include "extensions/browser/api/declarative_net_request/rule_counts.h"
#include "extensions/browser/api/declarative_net_request/ruleset_matcher.h"
#include "extensions/browser/api/declarative_net_request/ruleset_source.h"
#include "extensions/browser/api/web_request/web_request_info.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/common/api/declarative_net_request.h"
#include "extensions/common/api/declarative_net_request/test_utils.h"
#include "extensions/common/extension.h"
#include "net/http/http_response_headers.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace extensions::declarative_net_request {
dnr_api;
RequestAction CreateRequestActionForTesting(RequestAction::Type type,
uint32_t rule_id,
uint32_t rule_priority,
RulesetID ruleset_id,
const ExtensionId& extension_id) { … }
bool operator==(const RequestAction::HeaderInfo& lhs,
const RequestAction::HeaderInfo& rhs) { … }
std::ostream& operator<<(std::ostream& output,
const RequestAction::HeaderInfo& header_info) { … }
bool operator==(const RequestAction& lhs, const RequestAction& rhs) { … }
std::ostream& operator<<(std::ostream& output, RequestAction::Type type) { … }
std::ostream& operator<<(std::ostream& output, const RequestAction& action) { … }
std::ostream& operator<<(std::ostream& output,
const std::optional<RequestAction>& action) { … }
std::ostream& operator<<(std::ostream& output, const ParseResult& result) { … }
std::ostream& operator<<(std::ostream& output, LoadRulesetResult result) { … }
std::ostream& operator<<(std::ostream& output, const RuleCounts& count) { … }
bool AreAllIndexedStaticRulesetsValid(
const Extension& extension,
content::BrowserContext* browser_context,
FileBackedRulesetSource::RulesetFilter ruleset_filter) { … }
bool CreateVerifiedMatcher(const std::vector<TestRule>& rules,
const FileBackedRulesetSource& source,
std::unique_ptr<RulesetMatcher>* matcher,
int* expected_checksum) { … }
FileBackedRulesetSource CreateTemporarySource(RulesetID id,
size_t rule_count_limit,
ExtensionId extension_id) { … }
dnr_api::ModifyHeaderInfo CreateModifyHeaderInfo(
dnr_api::HeaderOperation operation,
std::string header,
std::optional<std::string> value,
std::optional<std::string> regex_filter,
std::optional<std::string> regex_substitution) { … }
bool EqualsForTesting(const dnr_api::ModifyHeaderInfo& lhs,
const dnr_api::ModifyHeaderInfo& rhs) { … }
dnr_api::HeaderInfo CreateHeaderInfo(
std::string header,
std::optional<std::vector<std::string>> values,
std::optional<std::vector<std::string>> excluded_values) { … }
RulesetManagerObserver::RulesetManagerObserver(RulesetManager* manager)
: … { … }
RulesetManagerObserver::~RulesetManagerObserver() { … }
std::vector<GURL> RulesetManagerObserver::GetAndResetRequestSeen() { … }
void RulesetManagerObserver::WaitForExtensionsWithRulesetsCount(size_t count) { … }
void RulesetManagerObserver::OnRulesetCountChanged(size_t count) { … }
void RulesetManagerObserver::OnEvaluateRequest(const WebRequestInfo& request,
bool is_incognito_context) { … }
WarningServiceObserver::WarningServiceObserver(WarningService* warning_service,
const ExtensionId& extension_id)
: … { … }
WarningServiceObserver::~WarningServiceObserver() = default;
void WarningServiceObserver::WaitForWarning() { … }
void WarningServiceObserver::ExtensionWarningsChanged(
const ExtensionIdSet& affected_extensions) { … }
base::flat_set<int> GetDisabledRuleIdsFromMatcherForTesting(
const RulesetManager& ruleset_manager,
const Extension& extension,
const std::string& ruleset_id_string) { … }
RequestParams CreateRequestWithResponseHeaders(
const GURL& url,
const net::HttpResponseHeaders* headers) { … }
}