Commit 88d49de1 authored by Kelvin Jiang's avatar Kelvin Jiang Committed by Commit Bot

[DNR] add idl types for modifyHeaders rules

Flatbuffer schemas/parsing will be added in follow up CLs

Bug: 947591
Change-Id: I89ec2f438b480923274b044ccba64a5ce7eccd6c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2094214Reviewed-by: default avatarKaran Bhatia <karandeepb@chromium.org>
Commit-Queue: Kelvin Jiang <kelvinjiang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748983}
parent f9e8b878
......@@ -280,6 +280,7 @@ FlatRulesetIndexer::GetBuilders(const IndexedRule& indexed_rule) {
return {index_builders_[flat::IndexType_allow_all_requests].get()};
case dnr_api::RULE_ACTION_TYPE_REMOVEHEADERS:
return GetRemoveHeaderBuilders(indexed_rule.remove_headers_set);
case dnr_api::RULE_ACTION_TYPE_MODIFYHEADERS:
case dnr_api::RULE_ACTION_TYPE_NONE:
break;
}
......
......@@ -391,6 +391,7 @@ bool DoesActionSupportPriority(dnr_api::RuleActionType type) {
return true;
case dnr_api::RULE_ACTION_TYPE_REMOVEHEADERS:
return false;
case dnr_api::RULE_ACTION_TYPE_MODIFYHEADERS:
case dnr_api::RULE_ACTION_TYPE_NONE:
break;
}
......@@ -412,6 +413,7 @@ uint8_t GetActionTypePriority(dnr_api::RuleActionType action_type) {
return 1;
case dnr_api::RULE_ACTION_TYPE_REMOVEHEADERS:
return 0;
case dnr_api::RULE_ACTION_TYPE_MODIFYHEADERS:
case dnr_api::RULE_ACTION_TYPE_NONE:
break;
}
......
......@@ -260,6 +260,7 @@ flat::ActionType ConvertToFlatActionType(dnr_api::RuleActionType action_type) {
return flat::ActionType_upgrade_scheme;
case dnr_api::RULE_ACTION_TYPE_ALLOWALLREQUESTS:
return flat::ActionType_allow_all_requests;
case dnr_api::RULE_ACTION_TYPE_MODIFYHEADERS:
case dnr_api::RULE_ACTION_TYPE_NONE:
break;
}
......
......@@ -40,6 +40,13 @@ namespace declarativeNetRequest {
setCookie
};
// This describes the possible opeations for a "modifyHeaders" rule.
// TODO(crbug.com/947591): Add documentation once implementation is complete.
[nodoc]
enum HeaderOperation {
remove
};
// Describes the kind of action to take if a given RuleCondition matches.
enum RuleActionType {
// Block the network request.
......@@ -54,6 +61,11 @@ namespace declarativeNetRequest {
upgradeScheme,
// Remove request/response headers from the network request.
removeHeaders,
// Modify request/response headers from the network request.
// TODO(crbug.com/947591): Add documentation once implementation is
// complete.
[nodoc]
modifyHeaders,
// Allow all requests within a frame hierarchy, including the frame request
// itself.
allowAllRequests
......@@ -213,6 +225,13 @@ namespace declarativeNetRequest {
DomainType? domainType;
};
// TODO(crbug.com/947591): Add documentation once implementation is complete.
[nodoc]
dictionary ModifyHeaderInfo {
DOMString header;
HeaderOperation operation;
};
dictionary RuleAction {
// The type of action to perform.
RuleActionType type;
......@@ -224,6 +243,20 @@ namespace declarativeNetRequest {
// The headers to remove from the request. Only valid if RuleActionType is
// "removeHeaders".
RemoveHeaderType[]? removeHeadersList;
// The request headers to modify for the request. Only valid if
// RuleActionType is "modifyHeaders".
// TODO(crbug.com/947591): Add documentation once implementation is
// complete.
[nodoc]
ModifyHeaderInfo[]? requestHeaders;
// The response headers to modify for the request. Only valid if
// RuleActionType is "modifyHeaders".
// TODO(crbug.com/947591): Add documentation once implementation is
// complete.
[nodoc]
ModifyHeaderInfo[]? responseHeaders;
};
dictionary Rule {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment