ChromiumBrowser (com.equo.chromium 116.0.20 API)
com.equo.chromium

Interface ChromiumBrowser



  • public interface ChromiumBrowser
    It provides the methods for the creation of the different types of browsers SWT, Swing, Standalone, Windowless as well as the complementary methods for their management. All methods of this interface can be called from any thread unless otherwise indicated by the specific method.
    • Method Detail

      • getAllBrowsers

        static Collection<ChromiumBrowser> getAllBrowsers()
        Retrieves a collection of all ChromiumBrowser instances currently active within the application.
        Returns:
        Returns all active browsers.
        Since:
        116.0.1
      • windowless

        static ChromiumBrowser windowless(String url)
        Create a Windowless browser.
        Parameters:
        url - The url that will be loaded in the browser.
        Returns:
        Returns a new Windowless browser instance. If an instance of org.eclipse.swt.widgets.Display exists, returns SWT Windowless browser or Standalone Windowless browser otherwise.
        Since:
        116.0.1
      • windowless

        static ChromiumBrowser windowless(String url,
                                          int x,
                                          int y,
                                          int width,
                                          int height)
        Create a Windowless browser with specific window bounds.
        Parameters:
        url - The url that will be loaded in the browser.
        x - The x coordinate of the origin of the window.
        y - The y coordinate of the origin of the window.
        width - The width of the window.
        height - The height of the window.
        Returns:
        Returns a new Windowless browser instance. If an instance of org.eclipse.swt.widgets.Display exists, returns SWT Windowless browser or Standalone Windowless browser otherwise.
        Since:
        116.0.1
      • compatibleWithHost

        static CompatibleWithHost compatibleWithHost()
        Create a CompatibleWithHost constructor. This allows automatic checking of all necessary requirements for the specified toolkit, by default windowless using the specified default java system properties.
        Since:
        116.0.20
      • standalone

        static ChromiumBrowser standalone(String url)
        Create a Standalone browser.
        Parameters:
        url - The url that will be loaded in the browser.
        Returns:
        Returns a new Standalone browser instance.
        Throws:
        UnsupportedOperationException - if another type of toolkit has been initialized previously.
        Since:
        116.0.1
      • standalone

        static ChromiumBrowser standalone(String url,
                                          int x,
                                          int y,
                                          int width,
                                          int height)
        Create a Standalone browser with specific window bounds.
        Parameters:
        url - The url that will be loaded in the browser.
        x - The x coordinate of the origin of the window.
        y - The y coordinate of the origin of the window.
        width - The width of the window.
        height - The height of the window.
        Returns:
        Returns a new Standalone browser instance.
        Throws:
        UnsupportedOperationException - if another type of toolkit has been initialized previously.
        Since:
        116.0.1
      • standalone

        static ChromiumBrowser standalone(String url,
                                          org.cef.misc.Rectangle window)
        Create a Standalone browser with specific window bounds.
        Parameters:
        url - The url that will be loaded in the browser.
        window - Specifies the dimensions that the window will have.
        Returns:
        Returns a new Standalone browser instance.
        Throws:
        UnsupportedOperationException - if another type of toolkit has been initialized previously.
        Since:
        116.0.1
      • swing

        static ChromiumBrowser swing(Object container,
                                     String layout,
                                     String url)
        Create a Swing browser.
        Parameters:
        container - The parent container to contains the browser.
        layout - Where the window will be placed.
        url - The url that will be loaded in the browser.
        Returns:
        Returns a new Swing browser instance.
        Throws:
        UnsupportedOperationException - if another type of toolkit has been initialized previously.
        Since:
        116.0.1
      • swing

        static ChromiumBrowser swing(String url)
        Create a Swing browser.
        Parameters:
        url - The url that will be loaded in the browser.
        Returns:
        Returns a new Swing browser instance.
        Throws:
        UnsupportedOperationException - if another type of toolkit has been initialized previously.
        Since:
        116.0.1
      • swt

        static ChromiumBrowser swt(Object composite,
                                   int style)
        Create a SWT browser.
        Parameters:
        composite - The parent composite contains the browser.
        style - Composite style.
        Returns:
        Returns a new SWT browser instance.
        Throws:
        UnsupportedOperationException - if another type of toolkit has been initialized previously.
        Since:
        116.0.1
      • startBrowsers

        static void startBrowsers()
        Start the CEF event loop when creating in Standalone and Windowless browsers.
        Since:
        116.0.1
      • clearCookies

        static boolean clearCookies(String urlPattern,
                                    String namePattern)
        /** Delete cookies matching the url and name regex patterns. Negation patterns can be used to exclude cookies from deletion.
        Parameters:
        urlPattern - The pattern for the matching URL case. Null matches all, empty matches nothing.
        namePattern - The pattern for the matching cookie name case. Null matches all, empty matches nothing.
        Returns:
        Returns true if cookies were cleared and false otherwise.
        Since:
        116.0.1
      • setUrl

        boolean setUrl(String url)
        Sets the URL of the browser to the specified location.
        Parameters:
        url - The url that will be loaded in the browser.
        Returns:
        Returns true if the url was loaded and false otherwise.
        Since:
        116.0.1
      • setText

        boolean setText(String html)
        Sets the text content of the browser window to the specified string.
        Parameters:
        html - The html that will be loaded in the browser.
        Returns:
        Returns true if the html was loaded and false otherwise.
        Since:
        116.0.1
      • close

        boolean close()
        Returns:
        Returns true if the browser will be closed and false otherwise.
        Since:
        116.0.1
      • executeJavaScript

        void executeJavaScript(String script)
        Executes JavaScript code within the context of the browser window.
        Parameters:
        script - Script to be executed in the browser.
        Since:
        116.0.1
      • executeJavacript

        @Deprecated
        void executeJavacript(String script)
        Deprecated. Executes JavaScript code within the context of the browser window. Use executeJavaScript(String) instead.
        Parameters:
        script - Script to be executed in the browser.
        Since:
        116.0.1
      • find

        void find(String search,
                  boolean forward,
                  boolean matchCase)
        Finds text within the browser window based on the specified search criteria.
        Parameters:
        search - the text to search for.
        forward - indicates whether to search forward or backward in the document.
        matchCase - indicates whether the search should be case-sensitive.
        Since:
        116.0.1
      • zoom

        void zoom(double zoomLevel)
        Change the zoom level to the specified value. Specify 0.0 to reset the zoom level.
        Parameters:
        zoomLevel - The zoom level to the specified value.
        Since:
        116.0.1
      • getZoom

        double getZoom()
        Get the current zoom level.
        Returns:
        Returns the current zoom level.
        Since:
        116.0.1
      • addConsoleListener

        void addConsoleListener(ChromiumBrowser.ConsoleListener listener)
        Adds a listener to receive console events from the browser.
        Parameters:
        listener - The console listener to add.
        Since:
        116.0.1
      • removeConsoleListener

        void removeConsoleListener(ChromiumBrowser.ConsoleListener listener)
        Removes a previously added console listener from the browser.
        Parameters:
        listener - The console listener to remove.
        Since:
        116.0.1
      • getErrors

        List<Object> getErrors()
        Gets all errors when the rendering process terminates unexpectedly.
        Returns:
        Returns the status error list of how the process ended.
        Since:
        116.0.1
      • captureScreenshot

        CompletableFuture<byte[]> captureScreenshot()
        Capture screenshot from browser. This method cannot be called from the main thread.
        Returns:
        CompletableFuture which will contain Base64 encoded PNG image data.
        Since:
        116.0.1
      • captureScreenshot

        CompletableFuture<byte[]> captureScreenshot(int x,
                                                    int y,
                                                    int width,
                                                    int height,
                                                    int scale)
        Capture screenshots of a specific area. This method cannot be called from the main thread.
        Parameters:
        x - The x coordinate of the origin of the window.
        y - The y coordinate of the origin of the window.
        width - The width of the window.
        height - The height of the window.
        scale - The scale of the image.
        Returns:
        CompletableFuture which will contain Base64 encoded PNG image data.
        Since:
        116.0.1
      • ignoreCertificateErrors

        void ignoreCertificateErrors(boolean enable)
        Ignore certificate errors in the browser. If used when the browser is defined, a new request context is created for the browser and will not affect the others. Otherwise, if used with an already initialized browser, it will affect all other browser instances as the change to the global requestContent will be used. Default is false. For browser certificate errors to be ignored it must be called upon creation, otherwise it will have an effect on all other browsers. You can reset certificate errors by calling the method with false.
        Parameters:
        enable -
        Since:
        116.0.1
      • getUIComponent

        Object getUIComponent()
        Gets the Composite or Component UI object, depending on the current toolkit.
        Returns:
        Returns the Composite or Component UI object, depending on the current toolkit.
        Since:
        116.0.1
      • isLoading

        boolean isLoading()
        Checks whether the browser is currently loading a page.
        Returns:
        Returns true if the browser is loading a page or false otherwise.
        Since:
        116.0.1
      • goBack

        void goBack()
        Loads the previous location in the back-forward list.
        Since:
        116.0.1
      • goForward

        void goForward()
        Loads the next location in the back-forward list.
        Since:
        116.0.1
      • canGoBack

        boolean canGoBack()
        Checks whether there is a previous page to navigate back to in the browsing history.
        Returns:
        Returns true if the previous location can be loaded and false otherwise.
        Since:
        116.0.1
      • canGoForward

        boolean canGoForward()
        Checks whether there is a subsequent page to navigate forward to in the browsing history.
        Returns:
        Returns true if the next location can be loaded and false otherwise.
        Since:
        116.0.1
      • reload

        void reload()
        Reloads the currently loaded web page.
        Since:
        116.0.1
      • stop

        void stop()
        Cancels any pending navigation or download operation and stops any dynamic page elements, such as background sounds and animations.
        Since:
        116.0.1
      • text

        CompletableFuture<String> text()
        Gets a source text in the browser.
        Returns:
        Returns a source text in the browser.
        Since:
        116.0.1
      • getUrl

        String getUrl()
        Gets the current url.
        Returns:
        Returns the current url.
        Since:
        116.0.1
      • isCreated

        CompletableFuture<Boolean> isCreated()
        Checks whether the browser has been created.
        Returns:
        a CompletableFuture that will be completed with a boolean value indicating whether the browser has been created
        Since:
        116.0.1
      • showDevTools

        void showDevTools()
        Opens a new browser with the DevTools view of the current browser instance.
        Since:
        116.0.1
      • printToPdf

        CompletableFuture<Boolean> printToPdf(String path,
                                              PdfPrintSettings settings)
        Print the current browser contents as a PDF.
        Parameters:
        path - The path of the file to write to (will be overwritten if it already exists). Cannot be null.
        settings - The PDF print settings to use. If null then defaults will be used.
        Since:
        116.0.1
      • printToPdf

        CompletableFuture<Boolean> printToPdf(String path)
        Print the current browser contents as a PDF.
        Parameters:
        path - The path of the file to write to (will be overwritten if it already exists). Cannot be null.
        Since:
        116.0.1
      • getLocalStorage

        com.equo.chromium.Storage getLocalStorage()
        Returns an instance of LocalStorage.
        Since:
        116.0.5
      • getSessionStorage

        com.equo.chromium.Storage getSessionStorage()
        Returns an instance of SessionStorage.
        Since:
        116.0.5

Copyright © 2024. All rights reserved.