Class WebExtensionMatchPattern

java.lang.Object
org.javagi.base.ProxyInstance
org.webkitgtk.WebExtensionMatchPattern
All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class WebExtensionMatchPattern extends ProxyInstance

Represents a way to specify a group of URLs for use in WebExtensions.

All match patterns are specified as strings. Apart from the special <all_urls> pattern, match patterns consist of three parts: scheme, host, and path.

Generally, match patterns are returned from a WebKitWebExtension.

Since:
2.48
  • Constructor Details

    • WebExtensionMatchPattern

      public WebExtensionMatchPattern(MemorySegment address)
      Create a WebExtensionMatchPattern proxy instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the WebExtensionMatchPattern class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • allHostsAndSchemes

      public static WebExtensionMatchPattern allHostsAndSchemes()
      Returns a new WebKitWebExtensionMatchPattern that has * for scheme, host, and path.
      Returns:
      a newly created WebKitWebExtensionMatchPattern
      Since:
      2.48
    • allUrls

      public static WebExtensionMatchPattern allUrls()
      Returns a new WebKitWebExtensionMatchPattern for <all_urls>.
      Returns:
      a newly created WebKitWebExtensionMatchPattern
      Since:
      2.48
    • withScheme

      public static @Nullable WebExtensionMatchPattern withScheme(String scheme, String host, String path) throws GErrorException
      Returns a new WebKitWebExtensionMatchPattern for the specified scheme, host, and path strings.
      Parameters:
      scheme - A pattern URL scheme
      host - A pattern URL host
      path - A pattern URL path
      Returns:
      a newly created WebKitWebExtensionMatchPattern, or null if any of the pattern strings are invalid.
      Throws:
      GErrorException - see GError
      Since:
      2.48
    • withString

      public static @Nullable WebExtensionMatchPattern withString(String string) throws GErrorException
      Returns a new WebKitWebExtensionMatchPattern for the specified string.
      Parameters:
      string - A pattern string
      Returns:
      a newly created WebKitWebExtensionMatchPattern, or null if the pattern string is invalid.
      Throws:
      GErrorException - see GError
      Since:
      2.48
    • registerCustomURLScheme

      @Deprecated public static void registerCustomURLScheme(String urlScheme)
      Deprecated.
      Use webkit_web_extension_match_pattern_register_custom_url_scheme() instead.

      Registers a custom URL scheme that can be used in match patterns.

      This method should be used to register any custom URL schemes used by the app for the extension base URLs, other than webkit-extension, or if extensions should have access to other supported URL schemes when using <all_urls>.

      Parameters:
      urlScheme - The custom URL scheme to register
      Since:
      2.48
    • registerCustomUrlScheme

      public static void registerCustomUrlScheme(String urlScheme)

      Registers a custom URL scheme that can be used in match patterns.

      This method should be used to register any custom URL schemes used by the app for the extension base URLs, other than webkit-extension, or if extensions should have access to other supported URL schemes when using <all_urls>.

      Parameters:
      urlScheme - The custom URL scheme to register
      Since:
      2.52
    • getHost

      public String getHost()
      Gets the host part of the pattern string, unless webkit_web_extension_match_pattern_get_matches_all_urls is true.
      Returns:
      The host string.
      Since:
      2.48
    • getMatchesAllHosts

      public boolean getMatchesAllHosts()
      Gets whether the match pattern matches all host. This happens when the pattern is <all_urls>, or if * is set as the host string.
      Returns:
      Whether this match pattern matches all hosts.
      Since:
      2.48
    • getMatchesAllUrls

      public boolean getMatchesAllUrls()
      Gets whether the match pattern matches all URLs, in other words, whether the pattern is <all_urls>.
      Returns:
      Whether this match pattern matches all URLs.
      Since:
      2.48
    • getPath

      public String getPath()
      Gets the path part of the pattern string, unless getMatchesAllUrls() is true.
      Returns:
      The path string.
      Since:
      2.48
    • getScheme

      public String getScheme()
      Gets the scheme part of the pattern string, unless webkit_web_extension_match_pattern_get_matches_all_urls is true.
      Returns:
      The scheme string.
      Since:
      2.48
    • getString

      public String getString()
      Gets the original pattern string.
      Returns:
      The original pattern string.
      Since:
      2.48
    • matchesPattern

      public boolean matchesPattern(WebExtensionMatchPattern pattern, Set<WebExtensionMatchPatternOptions> options)
      Matches the this WebExtensionMatchPattern against the specified pattern with options.
      Parameters:
      pattern - The WebKitWebExtensionMatchPattern to match with matchPattern.
      options - The WebKitWebExtensionMatchPatternOptions use while matching.
      Returns:
      Whether the pattern matches the specified pattern.
      Since:
      2.48
    • matchesPattern

      public boolean matchesPattern(WebExtensionMatchPattern pattern, WebExtensionMatchPatternOptions... options)
      Matches the this WebExtensionMatchPattern against the specified pattern with options.
      Parameters:
      pattern - The WebKitWebExtensionMatchPattern to match with matchPattern.
      options - The WebKitWebExtensionMatchPatternOptions use while matching.
      Returns:
      Whether the pattern matches the specified pattern.
      Since:
      2.48
    • matchesUrl

      public boolean matchesUrl(String url, Set<WebExtensionMatchPatternOptions> options)
      Matches the this WebExtensionMatchPattern against the specified URL with options.
      Parameters:
      url - The URL to match against the pattern.
      options - The WebKitWebExtensionMatchPatternOptions use while matching.
      Returns:
      Whether the pattern matches the specified URL.
      Since:
      2.48
    • matchesUrl

      public boolean matchesUrl(String url, WebExtensionMatchPatternOptions... options)
      Matches the this WebExtensionMatchPattern against the specified URL with options.
      Parameters:
      url - The URL to match against the pattern.
      options - The WebKitWebExtensionMatchPatternOptions use while matching.
      Returns:
      Whether the pattern matches the specified URL.
      Since:
      2.48
    • ref

      Atomically acquires a reference on the given matchPattern.

      This function is MT-safe and may be called from any thread.

      Returns:
      The same this WebExtensionMatchPattern with an additional reference.
      Since:
      2.48
    • unref

      public void unref()

      Atomically releases a reference on the given matchPattern.

      If the reference was the last, the resources associated to the this WebExtensionMatchPattern are freed. This function is MT-safe and may be called from any thread.

      Since:
      2.48