diff --git a/platform/platform-api/src/com/intellij/ui/jcef/JBCefUtils.java b/platform/platform-api/src/com/intellij/ui/jcef/JBCefUtils.java index d7b62e207e93..6a381fd32884 100644 --- a/platform/platform-api/src/com/intellij/ui/jcef/JBCefUtils.java +++ b/platform/platform-api/src/com/intellij/ui/jcef/JBCefUtils.java @@ -1,7 +1,6 @@ // Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ui.jcef; -import org.cef.CefClient; import org.cef.browser.CefBrowser; import org.cef.browser.CefFrame; import org.cef.browser.CefMessageRouter; @@ -22,7 +21,7 @@ import java.util.function.Function; public class JBCefUtils { private static final Map id2msgRouter = new HashMap<>(); - public static void addJSHandler(@NotNull CefClient cefClient, @NotNull String jsRequestID, @NotNull Function handler) { + public static void addJSHandler(@NotNull JBCefClient cefClient, @NotNull String jsRequestID, @NotNull Function handler) { CefMessageRouter.CefMessageRouterConfig config = new CefMessageRouter.CefMessageRouterConfig(); config.jsQueryFunction = jsRequestID; config.jsCancelFunction = jsRequestID; @@ -39,14 +38,14 @@ public class JBCefUtils { return handler.apply(request); } }, true); - cefClient.addMessageRouter(msgRouter); + cefClient.getCefClient().addMessageRouter(msgRouter); id2msgRouter.put(jsRequestID, msgRouter); } - public static void removeJSHandler(@NotNull CefClient cefClient, @NotNull String jsRequestID) { + public static void removeJSHandler(@NotNull JBCefClient cefClient, @NotNull String jsRequestID) { CefMessageRouter r = id2msgRouter.get(jsRequestID); if (r != null) { - cefClient.removeMessageRouter(r); + cefClient.getCefClient().removeMessageRouter(r); id2msgRouter.remove(jsRequestID); } } diff --git a/plugins/markdown/src/org/intellij/plugins/markdown/ui/preview/jcef/MarkdownJCEFHtmlPanel.java b/plugins/markdown/src/org/intellij/plugins/markdown/ui/preview/jcef/MarkdownJCEFHtmlPanel.java index 790a733c0cd3..58dff35ae486 100644 --- a/plugins/markdown/src/org/intellij/plugins/markdown/ui/preview/jcef/MarkdownJCEFHtmlPanel.java +++ b/plugins/markdown/src/org/intellij/plugins/markdown/ui/preview/jcef/MarkdownJCEFHtmlPanel.java @@ -49,7 +49,7 @@ public class MarkdownJCEFHtmlPanel extends JCEFHtmlPanel implements MarkdownHtml public MarkdownJCEFHtmlPanel() { super(); - JBCefUtils.addJSHandler(getCefBrowser().getClient(), JS_REQ_SET_SCROLL_Y, + JBCefUtils.addJSHandler(getJBCefClient(), JS_REQ_SET_SCROLL_Y, (value) -> { try { myScrollPreservingListener.myScrollY = Integer.parseInt(value); @@ -58,7 +58,7 @@ public class MarkdownJCEFHtmlPanel extends JCEFHtmlPanel implements MarkdownHtml }); if (Registry.is("markdown.open.link.in.external.browser")) { - JBCefUtils.addJSHandler(getCefBrowser().getClient(), JS_REQ_OPEN_IN_BROWSER, + JBCefUtils.addJSHandler(getJBCefClient(), JS_REQ_OPEN_IN_BROWSER, (link) -> { MarkdownAccessor.getSafeOpenerAccessor().openLink(link); return true; @@ -124,8 +124,8 @@ public class MarkdownJCEFHtmlPanel extends JCEFHtmlPanel implements MarkdownHtml public void dispose() { super.dispose(); getJBCefClient().removeLoadHandler(myCefLoadHandler, getCefBrowser()); - JBCefUtils.removeJSHandler(getCefBrowser().getClient(), JS_REQ_SET_SCROLL_Y); - JBCefUtils.removeJSHandler(getCefBrowser().getClient(), JS_REQ_OPEN_IN_BROWSER); + JBCefUtils.removeJSHandler(getJBCefClient(), JS_REQ_SET_SCROLL_Y); + JBCefUtils.removeJSHandler(getJBCefClient(), JS_REQ_OPEN_IN_BROWSER); } @NotNull