Search in sources :

Example 1 with BrowserConnectionManager

use of com.intellij.javascript.debugger.browserConnection.BrowserConnectionManager in project intellij-plugins by JetBrains.

the class OpenDartObservatoryUrlAction method openUrlInChromeFamilyBrowser.

/**
   * Opens new tab in any already open Chrome-family browser, if none found - start any new Chrome-family browser
   */
public static void openUrlInChromeFamilyBrowser(@NotNull final String url) {
    try {
        final BrowserConnectionManager connectionManager = BrowserConnectionManager.getInstance();
        final Client chromeClient = connectionManager.findClient(client -> {
            final WebBrowser browser = connectionManager.getBrowser(client);
            return browser != null && browser.getFamily() == BrowserFamily.CHROME;
        });
        if (chromeClient != null) {
            BrowserConnectionManager.getInstance().openUrl(chromeClient, url);
        } else {
            openInAnyChromeFamilyBrowser(url);
        }
    } catch (Throwable t) {
        // ClassNotFound in Community Edition or if JavaScriptDebug plugin disabled
        openInAnyChromeFamilyBrowser(url);
    }
}
Also used : WebBrowser(com.intellij.ide.browsers.WebBrowser) BrowserConnectionManager(com.intellij.javascript.debugger.browserConnection.BrowserConnectionManager) Client(org.jetbrains.io.jsonRpc.Client)

Aggregations

WebBrowser (com.intellij.ide.browsers.WebBrowser)1 BrowserConnectionManager (com.intellij.javascript.debugger.browserConnection.BrowserConnectionManager)1 Client (org.jetbrains.io.jsonRpc.Client)1