mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-22 06:21:25 +07:00
GTW-9956 Add the ability not to follow links on JCEF
GitOrigin-RevId: f7a7ed1e37e4f3d98ea7c53f48a4f6ebcd8512ce
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9767264fbd
commit
33f6503243
@@ -85,6 +85,7 @@ a:com.intellij.ui.jcef.JBCefBrowserBase
|
||||
- p:<init>(com.intellij.ui.jcef.JBCefBrowserBuilder):V
|
||||
- p:createDefaultContextMenuHandler():com.intellij.ui.jcef.JBCefBrowserBase$DefaultCefContextMenuHandler
|
||||
- createImmediately():V
|
||||
- disableNavigation():V
|
||||
- dispose():V
|
||||
- p:dispose(java.lang.Runnable):V
|
||||
- getBrowserComponent():java.awt.Component
|
||||
|
||||
@@ -25,4 +25,5 @@ public interface CefDelegate {
|
||||
@NotNull CefClient createClient();
|
||||
boolean isInitialized(@NotNull CefBrowser browser);
|
||||
@NotNull CefMessageRouter createMessageRouter(@Nullable CefMessageRouter.CefMessageRouterConfig config);
|
||||
void disableNavigation(@NotNull CefBrowser browser);
|
||||
}
|
||||
|
||||
@@ -507,6 +507,33 @@ public abstract class JBCefBrowserBase implements JBCefDisposable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables navigation in the browser, initiated by user actions (clicks/gestures).
|
||||
* Equivalent to the following code, but also works in remote development environments:
|
||||
* <pre>{@code
|
||||
* browser.getJBCefClient().addRequestHandler(new CefRequestHandlerAdapter() {
|
||||
* @Override
|
||||
* public boolean onBeforeBrowse(CefBrowser browser, CefFrame frame, CefRequest request, boolean user_gesture, boolean is_redirect) {
|
||||
* return user_gesture;
|
||||
* }
|
||||
* }, browser.getCefBrowser());
|
||||
* }</pre>
|
||||
*/
|
||||
public void disableNavigation() {
|
||||
CefDelegate delegate = getCefDelegate();
|
||||
if (delegate != null) {
|
||||
delegate.disableNavigation(myCefBrowser);
|
||||
}
|
||||
else {
|
||||
myCefClient.addRequestHandler(new CefRequestHandlerAdapter() {
|
||||
@Override
|
||||
public boolean onBeforeBrowse(CefBrowser browser, CefFrame frame, CefRequest request, boolean user_gesture, boolean is_redirect) {
|
||||
return user_gesture;
|
||||
}
|
||||
}, myCefBrowser);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the root browser component to be inserted into the UI.
|
||||
* This component adapts the internal JCEF component to IJ.
|
||||
|
||||
Reference in New Issue
Block a user