RuleCondition constructor

RuleCondition({
  1. String? urlFilter,
  2. String? regexFilter,
  3. bool? isUrlFilterCaseSensitive,
  4. List<String>? initiatorDomains,
  5. List<String>? excludedInitiatorDomains,
  6. List<String>? requestDomains,
  7. List<String>? excludedRequestDomains,
  8. List<String>? domains,
  9. List<String>? excludedDomains,
  10. List<ResourceType>? resourceTypes,
  11. List<ResourceType>? excludedResourceTypes,
  12. List<RequestMethod>? requestMethods,
  13. List<RequestMethod>? excludedRequestMethods,
  14. DomainType? domainType,
  15. List<int>? tabIds,
  16. List<int>? excludedTabIds,
  17. List<HeaderInfo>? responseHeaders,
  18. List<String>? excludedResponseHeaders,
})

Implementation

RuleCondition({
  /// The pattern which is matched against the network request url.
  /// Supported constructs:
  ///
  /// **'*'**  : Wildcard: Matches any number of characters.
  ///
  /// **'|'**  : Left/right anchor: If used at either end of the pattern,
  ///               specifies the beginning/end of the url respectively.
  ///
  /// **'||'** : Domain name anchor: If used at the beginning of the pattern,
  ///               specifies the start of a (sub-)domain of the URL.
  ///
  /// **'^'**  : Separator character: This matches anything except a letter, a
  ///               digit or one of the following: _ - . %. This can also
  /// match
  ///               the end of the URL.
  ///
  /// Therefore `urlFilter` is composed of the following parts:
  /// (optional Left/Domain name anchor) + pattern + (optional Right anchor).
  ///
  /// If omitted, all urls are matched. An empty string is not allowed.
  ///
  /// A pattern beginning with `||*` is not allowed. Use
  /// `*` instead.
  ///
  /// Note: Only one of `urlFilter` or `regexFilter` can
  /// be specified.
  ///
  /// Note: The `urlFilter` must be composed of only ASCII
  /// characters. This is matched against a url where the host is encoded in
  /// the punycode format (in case of internationalized domains) and any other
  /// non-ascii characters are url encoded in utf-8.
  /// For example, when the request url is
  /// http://abc.&#x0440;&#x0444;?q=&#x0444;, the
  /// `urlFilter` will be matched against the url
  /// http://abc.xn--p1ai/?q=%D1%84.
  String? urlFilter,

  /// Regular expression to match against the network request url. This
  /// follows
  /// the <a href = "https://github.com/google/re2/wiki/Syntax">RE2
  /// syntax</a>.
  ///
  /// Note: Only one of `urlFilter` or `regexFilter` can
  /// be specified.
  ///
  /// Note: The `regexFilter` must be composed of only ASCII
  /// characters. This is matched against a url where the host is encoded in
  /// the punycode format (in case of internationalized domains) and any other
  /// non-ascii characters are url encoded in utf-8.
  String? regexFilter,

  /// Whether the `urlFilter` or `regexFilter`
  /// (whichever is specified) is case sensitive. Default is false.
  bool? isUrlFilterCaseSensitive,

  /// The rule will only match network requests originating from the list of
  /// `initiatorDomains`. If the list is omitted, the rule is
  /// applied to requests from all domains. An empty list is not allowed.
  ///
  /// Notes:
  /// <ul>
  ///  <li>Sub-domains like "a.example.com" are also allowed.</li>
  ///  <li>The entries must consist of only ascii characters.</li>
  ///  <li>Use punycode encoding for internationalized domains.</li>
  ///  <li>
  ///    This matches against the request initiator and not the request url.
  ///  </li>
  ///  <li>Sub-domains of the listed domains are also matched.</li>
  /// </ul>
  List<String>? initiatorDomains,

  /// The rule will not match network requests originating from the list of
  /// `excludedInitiatorDomains`. If the list is empty or omitted,
  /// no domains are excluded. This takes precedence over
  /// `initiatorDomains`.
  ///
  /// Notes:
  /// <ul>
  ///  <li>Sub-domains like "a.example.com" are also allowed.</li>
  ///  <li>The entries must consist of only ascii characters.</li>
  ///  <li>Use punycode encoding for internationalized domains.</li>
  ///  <li>
  ///    This matches against the request initiator and not the request url.
  ///  </li>
  ///  <li>Sub-domains of the listed domains are also excluded.</li>
  /// </ul>
  List<String>? excludedInitiatorDomains,

  /// The rule will only match network requests when the domain matches one
  /// from the list of `requestDomains`. If the list is omitted,
  /// the rule is applied to requests from all domains. An empty list is not
  /// allowed.
  ///
  /// Notes:
  /// <ul>
  ///  <li>Sub-domains like "a.example.com" are also allowed.</li>
  ///  <li>The entries must consist of only ascii characters.</li>
  ///  <li>Use punycode encoding for internationalized domains.</li>
  ///  <li>Sub-domains of the listed domains are also matched.</li>
  /// </ul>
  List<String>? requestDomains,

  /// The rule will not match network requests when the domains matches one
  /// from the list of `excludedRequestDomains`. If the list is
  /// empty or omitted, no domains are excluded. This takes precedence over
  /// `requestDomains`.
  ///
  /// Notes:
  /// <ul>
  ///  <li>Sub-domains like "a.example.com" are also allowed.</li>
  ///  <li>The entries must consist of only ascii characters.</li>
  ///  <li>Use punycode encoding for internationalized domains.</li>
  ///  <li>Sub-domains of the listed domains are also excluded.</li>
  /// </ul>
  List<String>? excludedRequestDomains,

  /// The rule will only match network requests originating from the list of
  /// `domains`.
  List<String>? domains,

  /// The rule will not match network requests originating from the list of
  /// `excludedDomains`.
  List<String>? excludedDomains,

  /// List of resource types which the rule can match. An empty list is not
  /// allowed.
  ///
  /// Note: this must be specified for `allowAllRequests` rules and
  /// may only include the `sub_frame` and `main_frame`
  /// resource types.
  List<ResourceType>? resourceTypes,

  /// List of resource types which the rule won't match. Only one of
  /// `resourceTypes` and `excludedResourceTypes` should
  /// be specified. If neither of them is specified, all resource types except
  /// "main_frame" are blocked.
  List<ResourceType>? excludedResourceTypes,

  /// List of HTTP request methods which the rule can match. An empty list is
  /// not allowed.
  ///
  /// Note: Specifying a `requestMethods` rule condition will also
  /// exclude non-HTTP(s) requests, whereas specifying
  /// `excludedRequestMethods` will not.
  List<RequestMethod>? requestMethods,

  /// List of request methods which the rule won't match. Only one of
  /// `requestMethods` and `excludedRequestMethods`
  /// should be specified. If neither of them is specified, all request
  /// methods
  /// are matched.
  List<RequestMethod>? excludedRequestMethods,

  /// Specifies whether the network request is first-party or third-party to
  /// the domain from which it originated. If omitted, all requests are
  /// accepted.
  DomainType? domainType,

  /// List of [tabs.Tab.id] which the rule should match. An ID of
  /// [tabs.TAB_ID_NONE] matches requests which don't originate from a
  /// tab. An empty list is not allowed. Only supported for session-scoped
  /// rules.
  List<int>? tabIds,

  /// List of [tabs.Tab.id] which the rule should not match. An ID of
  /// [tabs.TAB_ID_NONE] excludes requests which don't originate from a
  /// tab. Only supported for session-scoped rules.
  List<int>? excludedTabIds,

  /// Rule matches if the request matches any response header in this list (if
  /// specified).
  /// TODO(crbug,com/1141166): Add documentation once feature is complete.
  List<HeaderInfo>? responseHeaders,

  /// Rule does not match if the request has any of the specified headers.
  /// TODO(crbug,com/1141166): Add documentation once feature is complete.
  List<String>? excludedResponseHeaders,
}) : _wrapped = $js.RuleCondition(
        urlFilter: urlFilter,
        regexFilter: regexFilter,
        isUrlFilterCaseSensitive: isUrlFilterCaseSensitive,
        initiatorDomains: initiatorDomains?.toJSArray((e) => e),
        excludedInitiatorDomains:
            excludedInitiatorDomains?.toJSArray((e) => e),
        requestDomains: requestDomains?.toJSArray((e) => e),
        excludedRequestDomains: excludedRequestDomains?.toJSArray((e) => e),
        domains: domains?.toJSArray((e) => e),
        excludedDomains: excludedDomains?.toJSArray((e) => e),
        resourceTypes: resourceTypes?.toJSArray((e) => e.toJS),
        excludedResourceTypes:
            excludedResourceTypes?.toJSArray((e) => e.toJS),
        requestMethods: requestMethods?.toJSArray((e) => e.toJS),
        excludedRequestMethods:
            excludedRequestMethods?.toJSArray((e) => e.toJS),
        domainType: domainType?.toJS,
        tabIds: tabIds?.toJSArray((e) => e),
        excludedTabIds: excludedTabIds?.toJSArray((e) => e),
        responseHeaders: responseHeaders?.toJSArray((e) => e.toJS),
        excludedResponseHeaders: excludedResponseHeaders?.toJSArray((e) => e),
      );