ChromeDeclarativeNetRequest class
Methods
-
getAvailableStaticRuleCount()
→ Future<int>
-
Returns the number of static rules an extension can enable before the
global static rule limit is
reached.
-
getDisabledRuleIds(GetDisabledRuleIdsOptions options)
→ Future<List<int>>
-
Returns the list of static rules in the given Ruleset that are
currently disabled.
|options|: Specifies the ruleset to query.
|Returns|: Promise that resolves with a list of ids that correspond to
the disabled rules in that ruleset.
-
getDynamicRules(GetRulesFilter? filter)
→ Future<List<Rule>>
-
Returns the current set of dynamic rules for the extension. Callers can
optionally filter the list of fetched rules by specifying a
filter.
|filter|: An object to filter the list of fetched rules.
|Returns|: Promise that resolves with the set of dynamic rules. The
Promise may be rejected in case of transient internal errors.
-
getEnabledRulesets()
→ Future<List<String>>
-
Returns the ids for the current set of enabled static rulesets.
|Returns|: Promise that resolves with a list of ids, where each id
corresponds to an enabled static Ruleset.
-
getMatchedRules(MatchedRulesFilter? filter)
→ Future<RulesMatchedDetails>
-
Returns all rules matched for the extension. Callers can optionally
filter the list of matched rules by specifying a
filter.
This method is only available to extensions with the
"declarativeNetRequestFeedback" permission or having the
"activeTab" permission granted for the tabId
specified in filter.
Note: Rules not associated with an active document that were matched more
than five minutes ago will not be returned.
|filter|: An object to filter the list of matched rules.
|Returns|: Promise that resolves once the list of matched rules has been
fetched. In case of an error, the Promise will be rejected. This can
happen for multiple reasons, such as insufficient permissions, or
exceeding the quota.
-
getSessionRules(GetRulesFilter? filter)
→ Future<List<Rule>>
-
Returns the current set of session scoped rules for the extension.
Callers can optionally filter the list of fetched rules by specifying a
filter.
|filter|: An object to filter the list of fetched rules.
|Returns|: Promise that resolves with the set of session scoped rules.
-
isRegexSupported(RegexOptions regexOptions)
→ Future<IsRegexSupportedResult>
-
Checks if the given regular expression will be supported as a
regexFilter rule condition.
|regexOptions|: The regular expression to check.
|Returns|: Promise that resolves with details consisting of whether the
regular expression is supported and the reason if not.
-
noSuchMethod(Invocation invocation)
→ dynamic
-
Invoked when a nonexistent method or property is accessed.
inherited
-
setExtensionActionOptions(ExtensionActionOptions options)
→ Future<void>
-
Configures if the action count for tabs should be displayed as the
extension action's badge text and provides a way for that action count to
be incremented.
-
testMatchOutcome(TestMatchRequestDetails request)
→ Future<TestMatchOutcomeResult>
-
Checks if any of the extension's declarativeNetRequest rules would match
a hypothetical request.
Note: Only available for unpacked extensions as this is only intended to
be used during extension development.
|requestDetails|: The request details to test.
|Returns|: Promise that resolves with the details of matched rules.
-
toString()
→ String
-
A string representation of this object.
inherited
-
updateDynamicRules(UpdateRuleOptions options)
→ Future<void>
-
Modifies the current set of dynamic rules for the extension.
The rules with IDs listed in
options.removeRuleIds are first
removed, and then the rules given in options.addRules are
added. Notes:
-
updateEnabledRulesets(UpdateRulesetOptions options)
→ Future<void>
-
Updates the set of enabled static rulesets for the extension. The
rulesets with IDs listed in
options.disableRulesetIds are
first removed, and then the rulesets listed in
options.enableRulesetIds are added.
Note that the set of enabled static rulesets is persisted across sessions
but not across extension updates, i.e. the rule_resources
manifest key will determine the set of enabled static rulesets on each
extension update.
|Returns|: Promise that resolves once the update is complete. In case of
an error, the promise will be rejected and no change will be made to the
set of enabled rulesets. This can happen for multiple reasons, such as
invalid ruleset IDs, rule count limit exceeded, or internal errors.
-
updateSessionRules(UpdateRuleOptions options)
→ Future<void>
-
Modifies the current set of session scoped rules for the extension.
The rules with IDs listed in
options.removeRuleIds are first
removed, and then the rules given in options.addRules are
added. Notes:
-
updateStaticRules(UpdateStaticRulesOptions options)
→ Future<void>
-
Disables and enables individual static rules in a Ruleset.
Changes to rules belonging to a disabled Ruleset will take
effect the next time that it becomes enabled.
|Returns|: Promise that resolves when the update is complete. In case of
an error, the promise will be rejected and no change will be made to the
enabled static rules.