#include "extensions/common/api/declarative_net_request/test_utils.h"
#include <utility>
#include "base/files/file_util.h"
#include "base/json/json_file_value_serializer.h"
#include "extensions/common/api/declarative_net_request.h"
#include "extensions/common/constants.h"
#include "extensions/common/manifest_constants.h"
namespace extensions {
keys;
dnr_api;
namespace declarative_net_request {
namespace {
const base::FilePath::CharType kBackgroundScriptFilepath[] = …);
base::Value ToValue(const std::string& t) { … }
base::Value ToValue(int t) { … }
base::Value ToValue(bool t) { … }
base::Value ToValue(const DictionarySource& source) { … }
base::Value ToValue(const TestRulesetInfo& info) { … }
template <typename T>
base::Value::List ToValue(const std::vector<T>& vec) { … }
template <typename T>
void SetValue(base::Value::Dict& dict,
const char* key,
const std::optional<T>& value) { … }
}
TestRuleCondition::TestRuleCondition() = default;
TestRuleCondition::~TestRuleCondition() = default;
TestRuleCondition::TestRuleCondition(const TestRuleCondition&) = default;
TestRuleCondition& TestRuleCondition::operator=(const TestRuleCondition&) =
default;
base::Value::Dict TestRuleCondition::ToValue() const { … }
TestRuleQueryKeyValue::TestRuleQueryKeyValue() = default;
TestRuleQueryKeyValue::~TestRuleQueryKeyValue() = default;
TestRuleQueryKeyValue::TestRuleQueryKeyValue(const TestRuleQueryKeyValue&) =
default;
TestRuleQueryKeyValue& TestRuleQueryKeyValue::operator=(
const TestRuleQueryKeyValue&) = default;
base::Value::Dict TestRuleQueryKeyValue::ToValue() const { … }
TestRuleQueryTransform::TestRuleQueryTransform() = default;
TestRuleQueryTransform::~TestRuleQueryTransform() = default;
TestRuleQueryTransform::TestRuleQueryTransform(const TestRuleQueryTransform&) =
default;
TestRuleQueryTransform& TestRuleQueryTransform::operator=(
const TestRuleQueryTransform&) = default;
base::Value::Dict TestRuleQueryTransform::ToValue() const { … }
TestRuleTransform::TestRuleTransform() = default;
TestRuleTransform::~TestRuleTransform() = default;
TestRuleTransform::TestRuleTransform(const TestRuleTransform&) = default;
TestRuleTransform& TestRuleTransform::operator=(const TestRuleTransform&) =
default;
base::Value::Dict TestRuleTransform::ToValue() const { … }
TestRuleRedirect::TestRuleRedirect() = default;
TestRuleRedirect::~TestRuleRedirect() = default;
TestRuleRedirect::TestRuleRedirect(const TestRuleRedirect&) = default;
TestRuleRedirect& TestRuleRedirect::operator=(const TestRuleRedirect&) =
default;
base::Value::Dict TestRuleRedirect::ToValue() const { … }
TestHeaderInfo::TestHeaderInfo(std::string header,
std::string operation,
std::optional<std::string> value)
: … { … }
TestHeaderInfo::~TestHeaderInfo() = default;
TestHeaderInfo::TestHeaderInfo(const TestHeaderInfo&) = default;
TestHeaderInfo& TestHeaderInfo::operator=(const TestHeaderInfo&) = default;
base::Value::Dict TestHeaderInfo::ToValue() const { … }
TestHeaderCondition::TestHeaderCondition(
std::string header,
std::vector<std::string> values,
std::vector<std::string> excluded_values)
: … { … }
TestHeaderCondition::~TestHeaderCondition() = default;
TestHeaderCondition::TestHeaderCondition(const TestHeaderCondition&) = default;
TestHeaderCondition& TestHeaderCondition::operator=(
const TestHeaderCondition&) = default;
base::Value::Dict TestHeaderCondition::ToValue() const { … }
TestRuleAction::TestRuleAction() = default;
TestRuleAction::~TestRuleAction() = default;
TestRuleAction::TestRuleAction(const TestRuleAction&) = default;
TestRuleAction& TestRuleAction::operator=(const TestRuleAction&) = default;
base::Value::Dict TestRuleAction::ToValue() const { … }
TestRule::TestRule() = default;
TestRule::~TestRule() = default;
TestRule::TestRule(const TestRule&) = default;
TestRule& TestRule::operator=(const TestRule&) = default;
base::Value::Dict TestRule::ToValue() const { … }
TestRule CreateGenericRule(int id) { … }
TestRule CreateRegexRule(int id) { … }
TestRulesetInfo::TestRulesetInfo(const std::string& manifest_id_and_path,
base::Value::List rules_value,
bool enabled)
: … { … }
TestRulesetInfo::TestRulesetInfo(const std::string& manifest_id,
const std::string& relative_file_path,
base::Value::List rules_value,
bool enabled)
: … { … }
TestRulesetInfo::TestRulesetInfo(const std::string& manifest_id,
const std::string& relative_file_path,
const base::Value& rules_value,
bool enabled)
: … { … }
TestRulesetInfo::TestRulesetInfo(const TestRulesetInfo& info)
: … { … }
base::Value::Dict TestRulesetInfo::GetManifestValue() const { … }
base::Value::Dict CreateManifest(
const std::vector<TestRulesetInfo>& ruleset_info,
const std::vector<std::string>& hosts,
unsigned flags,
const std::string& extension_name) { … }
base::Value::List ToListValue(const std::vector<std::string>& vec) { … }
base::Value::List ToListValue(const std::vector<TestRule>& rules) { … }
void WriteManifestAndRulesets(const base::FilePath& extension_dir,
const std::vector<TestRulesetInfo>& ruleset_info,
const std::vector<std::string>& hosts,
unsigned flags,
const std::string& extension_name) { … }
void WriteManifestAndRuleset(const base::FilePath& extension_dir,
const TestRulesetInfo& info,
const std::vector<std::string>& hosts,
unsigned flags,
const std::string& extension_name) { … }
}
}