chromium/out/Default/gen/extensions/common/api/declarative_net_request.h

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// GENERATED FROM THE API DEFINITION IN
//   extensions/common/api/declarative_net_request.idl
// by tools/json_schema_compiler.
// DO NOT EDIT.

#ifndef EXTENSIONS_COMMON_API_DECLARATIVE_NET_REQUEST_H__
#define EXTENSIONS_COMMON_API_DECLARATIVE_NET_REQUEST_H__

#include <stdint.h>

#include <map>
#include <memory>
#include <optional>
#include <string>
#include <vector>

#include "base/values.h"
#include <string_view>
#include "base/types/expected.h"
#include "extensions/common/api/extension_types.h"


namespace extensions {
namespace api {
namespace declarative_net_request {

//
// Properties
//

// The minimum number of static rules guaranteed to an extension across its
// enabled static rulesets. Any rules above this limit will count towards the <a
// href="#global-static-rule-limit">global static rule limit</a>.
extern const int GUARANTEED_MINIMUM_STATIC_RULES;

// The maximum number of combined dynamic and session scoped rules an extension
// can add.
extern const int MAX_NUMBER_OF_DYNAMIC_AND_SESSION_RULES;

// The maximum number of dynamic rules that an extension can add.
extern const int MAX_NUMBER_OF_DYNAMIC_RULES;

// The maximum number of "unsafe" dynamic rules that an extension can add.
extern const int MAX_NUMBER_OF_UNSAFE_DYNAMIC_RULES;

// The maximum number of session scoped rules that an extension can add.
extern const int MAX_NUMBER_OF_SESSION_RULES;

// The maximum number of "unsafe" session scoped rules that an extension can
// add.
extern const int MAX_NUMBER_OF_UNSAFE_SESSION_RULES;

// Time interval within which <code>MAX_GETMATCHEDRULES_CALLS_PER_INTERVAL
// getMatchedRules</code> calls can be made, specified in minutes. Additional
// calls will fail immediately and set $(ref:runtime.lastError). Note:
// <code>getMatchedRules</code> calls associated with a user gesture are exempt
// from the quota.
extern const int GETMATCHEDRULES_QUOTA_INTERVAL;

// The number of times <code>getMatchedRules</code> can be called within a
// period of <code>GETMATCHEDRULES_QUOTA_INTERVAL</code>.
extern const int MAX_GETMATCHEDRULES_CALLS_PER_INTERVAL;

// The maximum number of regular expression rules that an extension can add.
// This limit is evaluated separately for the set of dynamic rules and those
// specified in the rule resources file.
extern const int MAX_NUMBER_OF_REGEX_RULES;

// The maximum number of static <code>Rulesets</code> an extension can specify
// as part of the <code>"rule_resources"</code> manifest key.
extern const int MAX_NUMBER_OF_STATIC_RULESETS;

// The maximum number of static <code>Rulesets</code> an extension can enable at
// any one time.
extern const int MAX_NUMBER_OF_ENABLED_STATIC_RULESETS;

// Ruleset ID for the dynamic rules added by the extension.
extern const char DYNAMIC_RULESET_ID[];

// Ruleset ID for the session-scoped rules added by the extension.
extern const char SESSION_RULESET_ID[];

//
// Types
//

// This describes the resource type of the network request.
enum class ResourceType {};


const char* ToString(ResourceType as_enum);
ResourceType ParseResourceType(std::string_view as_string);
std::u16string GetResourceTypeParseError(std::string_view as_string);

// This describes the HTTP request method of a network request.
enum class RequestMethod {};


const char* ToString(RequestMethod as_enum);
RequestMethod ParseRequestMethod(std::string_view as_string);
std::u16string GetRequestMethodParseError(std::string_view as_string);

// This describes whether the request is first or third party to the frame in
// which it originated. A request is said to be first party if it has the same
// domain (eTLD+1) as the frame in which the request originated.
enum class DomainType {};


const char* ToString(DomainType as_enum);
DomainType ParseDomainType(std::string_view as_string);
std::u16string GetDomainTypeParseError(std::string_view as_string);

// This describes the possible operations for a "modifyHeaders" rule.
enum class HeaderOperation {};


const char* ToString(HeaderOperation as_enum);
HeaderOperation ParseHeaderOperation(std::string_view as_string);
std::u16string GetHeaderOperationParseError(std::string_view as_string);

// Describes the kind of action to take if a given RuleCondition matches.
enum class RuleActionType {};


const char* ToString(RuleActionType as_enum);
RuleActionType ParseRuleActionType(std::string_view as_string);
std::u16string GetRuleActionTypeParseError(std::string_view as_string);

// Describes the reason why a given regular expression isn't supported.
enum class UnsupportedRegexReason {};


const char* ToString(UnsupportedRegexReason as_enum);
UnsupportedRegexReason ParseUnsupportedRegexReason(std::string_view as_string);
std::u16string GetUnsupportedRegexReasonParseError(std::string_view as_string);

struct Ruleset {};

struct QueryKeyValue {};

struct QueryTransform {};

struct URLTransform {};

struct Redirect {};

struct HeaderInfo {};

struct RuleCondition {};

struct HeaderRegexOptions {};

struct ModifyHeaderInfo {};

struct RuleAction {};

struct Rule {};

struct MatchedRule {};

struct GetRulesFilter {};

struct MatchedRuleInfo {};

struct MatchedRulesFilter {};

struct RulesMatchedDetails {};

struct RequestDetails {};

struct TestMatchRequestDetails {};

struct MatchedRuleInfoDebug {};

struct DNRInfo {};

struct RegexOptions {};

struct IsRegexSupportedResult {};

struct TestMatchOutcomeResult {};

struct UpdateRuleOptions {};

struct UpdateRulesetOptions {};

struct UpdateStaticRulesOptions {};

struct GetDisabledRuleIdsOptions {};

struct TabActionCountUpdate {};

struct ExtensionActionOptions {};


//
// Manifest Keys
//

struct ManifestKeys {};

//
// Functions
//

namespace UpdateDynamicRules {

struct Params {};

namespace Results {

base::Value::List Create();
}  // namespace Results

}  // namespace UpdateDynamicRules

namespace GetDynamicRules {

struct Params {};

namespace Results {

base::Value::List Create(const std::vector<Rule>& rules);
}  // namespace Results

}  // namespace GetDynamicRules

namespace UpdateSessionRules {

struct Params {};

namespace Results {

base::Value::List Create();
}  // namespace Results

}  // namespace UpdateSessionRules

namespace GetSessionRules {

struct Params {};

namespace Results {

base::Value::List Create(const std::vector<Rule>& rules);
}  // namespace Results

}  // namespace GetSessionRules

namespace UpdateEnabledRulesets {

struct Params {};

namespace Results {

base::Value::List Create();
}  // namespace Results

}  // namespace UpdateEnabledRulesets

namespace GetEnabledRulesets {

namespace Results {

base::Value::List Create(const std::vector<std::string>& ruleset_ids);
}  // namespace Results

}  // namespace GetEnabledRulesets

namespace UpdateStaticRules {

struct Params {};

namespace Results {

base::Value::List Create();
}  // namespace Results

}  // namespace UpdateStaticRules

namespace GetDisabledRuleIds {

struct Params {};

namespace Results {

base::Value::List Create(const std::vector<int>& disabled_rule_ids);
}  // namespace Results

}  // namespace GetDisabledRuleIds

namespace GetMatchedRules {

struct Params {};

namespace Results {

base::Value::List Create(const RulesMatchedDetails& details);
}  // namespace Results

}  // namespace GetMatchedRules

namespace SetExtensionActionOptions {

struct Params {};

namespace Results {

base::Value::List Create();
}  // namespace Results

}  // namespace SetExtensionActionOptions

namespace IsRegexSupported {

struct Params {};

namespace Results {

base::Value::List Create(const IsRegexSupportedResult& result);
}  // namespace Results

}  // namespace IsRegexSupported

namespace GetAvailableStaticRuleCount {

namespace Results {

base::Value::List Create(int count);
}  // namespace Results

}  // namespace GetAvailableStaticRuleCount

namespace TestMatchOutcome {

struct Params {};

namespace Results {

base::Value::List Create(const TestMatchOutcomeResult& result);
}  // namespace Results

}  // namespace TestMatchOutcome

//
// Events
//

namespace OnRuleMatchedDebug {

extern const char kEventName[];  // "declarativeNetRequest.onRuleMatchedDebug"

// The rule that has been matched along with information about the associated
// request.
base::Value::List Create(const MatchedRuleInfoDebug& info);
}  // namespace OnRuleMatchedDebug

}  // namespace declarative_net_request
}  // namespace api
}  // namespace extensions

#endif  // EXTENSIONS_COMMON_API_DECLARATIVE_NET_REQUEST_H__