Commit a0224d7b authored by Kelvin Jiang's avatar Kelvin Jiang Committed by Commit Bot

[Declarative net request] Add types and getMatchedRules placeholder

Add the function skeleton for getMatchedRules along with types required
for it in the .idl.

Once again, skipping presubmit as the idl parser fails weirdly as seen
in crbug.com/956368

NOPRESUBMIT=true

Bug: 967942
Change-Id: I76c79e3de1c008d43474dec4cbec3a7b476f5374
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1639518
Commit-Queue: Kelvin Jiang <kelvinjiang@chromium.org>
Reviewed-by: default avatarKaran Bhatia <karandeepb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#665667}
parent 9ce1f053
......@@ -327,4 +327,14 @@ void DeclarativeNetRequestGetDynamicRulesFunction::OnDynamicRulesFetched(
dnr_api::GetDynamicRules::Results::Create(read_json_result.rules)));
}
DeclarativeNetRequestGetMatchedRulesFunction::
DeclarativeNetRequestGetMatchedRulesFunction() = default;
DeclarativeNetRequestGetMatchedRulesFunction::
~DeclarativeNetRequestGetMatchedRulesFunction() = default;
ExtensionFunction::ResponseAction
DeclarativeNetRequestGetMatchedRulesFunction::Run() {
return RespondNow(NoArguments());
}
} // namespace extensions
......@@ -180,6 +180,23 @@ class DeclarativeNetRequestGetDynamicRulesFunction
DISALLOW_COPY_AND_ASSIGN(DeclarativeNetRequestGetDynamicRulesFunction);
};
class DeclarativeNetRequestGetMatchedRulesFunction
: public UIThreadExtensionFunction {
public:
DeclarativeNetRequestGetMatchedRulesFunction();
DECLARE_EXTENSION_FUNCTION("declarativeNetRequest.getMatchedRules",
DECLARATIVENETREQUEST_GETMATCHEDRULES)
protected:
~DeclarativeNetRequestGetMatchedRulesFunction() override;
// ExtensionFunction override:
ExtensionFunction::ResponseAction Run() override;
private:
DISALLOW_COPY_AND_ASSIGN(DeclarativeNetRequestGetMatchedRulesFunction);
};
} // namespace extensions
#endif // EXTENSIONS_BROWSER_API_DECLARATIVE_NET_REQUEST_DECLARATIVE_NET_REQUEST_API_H_
......@@ -1403,6 +1403,7 @@ enum HistogramValue {
BLUETOOTHPRIVATE_RECORDRECONNECTION = 1340,
LOGINSCREENUI_SHOW = 1341,
LOGINSCREENUI_CLOSE = 1342,
DECLARATIVENETREQUEST_GETMATCHEDRULES = 1343,
// Last entry: Add new entries above, then run:
// python tools/metrics/histograms/update_extension_histograms.py
ENUM_BOUNDARY
......
......@@ -156,6 +156,11 @@
"contexts": ["blessed_extension"],
"channel": "trunk"
},
"declarativeNetRequest.getMatchedRules": {
"dependencies": ["permission:declarativeNetRequest"],
"contexts": ["blessed_extension"],
"channel": "trunk"
},
"declarativeWebRequest": {
"dependencies": ["permission:declarativeWebRequest"],
"contexts": ["blessed_extension"]
......
......@@ -150,9 +150,57 @@ namespace declarativeNetRequest {
RuleAction action;
};
[nodoc]
enum SourceType {
// The rule is specified in a JSON file within the extension's package.
manifest,
// The rule is a dynamic rule added by the extension using
// $(ref:declarativeNetRequest.addDynamicRules).
dynamic
};
[nodoc]
dictionary MatchedRule {
// A matching rule's ID.
long ruleId;
// The source of the rule.
SourceType sourceType;
};
[nodoc]
dictionary MatchedRuleInfo {
MatchedRule rule;
// The time the rule was matched. Timestamps will correspond to the
// Javascript convention for times, i.e. number of milliseconds since the
// epoch.
double timeStamp;
// The tabId of the tab from which the request originated if the tab is
// still active. Else -1.
long tabId;
};
[nodoc]
dictionary MatchedRulesFilter {
// If specified, only matches rules for the given tab.
long? tabId;
// If specified, only matches rules after the given timestamp.
long? minTimeStamp;
};
[nodoc]
dictionary RulesMatchedDetails {
// Rules matching the given filter.
MatchedRuleInfo[] rulesMatchedInfo;
};
callback EmptyCallback = void();
callback GetAllowedPagesCallback = void(DOMString[] result);
callback GetRulesCallback = void(Rule[] rules);
callback GetMatchedRulesCallback = void(RulesMatchedDetails details);
interface Functions {
......@@ -216,6 +264,12 @@ namespace declarativeNetRequest {
// Returns the current set of allowed pages.
// |callback|: Called with the set of currently allowed pages.
static void getAllowedPages(GetAllowedPagesCallback callback);
// TODO(crbug.com/967942): Add documentation once implementation is
// complete.
[nodoc]
static void getMatchedRules(optional MatchedRulesFilter filter,
GetMatchedRulesCallback callback);
};
interface Properties {
......
......@@ -19550,6 +19550,7 @@ Called by update_net_error_codes.py.-->
<int value="1340" label="BLUETOOTHPRIVATE_RECORDRECONNECTION"/>
<int value="1341" label="LOGINSCREENUI_SHOW"/>
<int value="1342" label="LOGINSCREENUI_CLOSE"/>
<int value="1343" label="DECLARATIVENETREQUEST_GETMATCHEDRULES"/>
</enum>
<enum name="ExtensionIconState">
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