|
|
|
@ -15,6 +15,7 @@ import com.teamdev.jxbrowser.chromium.events.ScriptContextListener;
|
|
|
|
|
import com.teamdev.jxbrowser.engine.Engine; |
|
|
|
|
import com.teamdev.jxbrowser.engine.EngineOptions; |
|
|
|
|
import com.teamdev.jxbrowser.engine.RenderingMode; |
|
|
|
|
import com.teamdev.jxbrowser.event.Observer; |
|
|
|
|
import com.teamdev.jxbrowser.js.JsObject; |
|
|
|
|
import com.teamdev.jxbrowser.net.Scheme; |
|
|
|
|
import com.teamdev.jxbrowser.view.swing.BrowserView; |
|
|
|
@ -100,7 +101,7 @@ public class NewModernUIPane<T> extends ModernUIPane<T> {
|
|
|
|
|
EngineOptions options; |
|
|
|
|
if (scheme != null && requestCallback != null) { |
|
|
|
|
options = EngineOptions.newBuilder(RenderingMode.HARDWARE_ACCELERATED).addSwitch("--disable-google-traffic").addScheme(scheme, requestCallback).build(); |
|
|
|
|
} else { |
|
|
|
|
} else { |
|
|
|
|
options = EngineOptions.newBuilder(RenderingMode.HARDWARE_ACCELERATED).addSwitch("--disable-google-traffic").build(); |
|
|
|
|
} |
|
|
|
|
Engine engine = Engine.newInstance(options); |
|
|
|
@ -161,6 +162,29 @@ public class NewModernUIPane<T> extends ModernUIPane<T> {
|
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void disposeBrowser() { |
|
|
|
|
|
|
|
|
|
if (browser != null) { |
|
|
|
|
browser.close(); |
|
|
|
|
browser = null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void clearCache() { |
|
|
|
|
if (browser != null) { |
|
|
|
|
browser.engine().httpCache().clear(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void executeJavaScript(String javaScript) { |
|
|
|
|
if (browser != null) { |
|
|
|
|
browser.mainFrame().ifPresent(frame -> { |
|
|
|
|
frame.executeJavaScript(javaScript); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static class Builder<T> extends ModernUIPane.Builder<T> { |
|
|
|
|
|
|
|
|
|
private NewModernUIPane<T> pane = new NewModernUIPane<>(); |
|
|
|
@ -191,7 +215,7 @@ public class NewModernUIPane<T> extends ModernUIPane<T> {
|
|
|
|
|
@Override |
|
|
|
|
public NewModernUIPane.Builder<T> withURL(final String url) { |
|
|
|
|
pane.scheme = Scheme.of("file"); |
|
|
|
|
pane.requestCallback = new NxComplexInterceptRequestCallback(null); |
|
|
|
|
pane.requestCallback = new NxComplexInterceptRequestCallback(null); |
|
|
|
|
pane.browser.navigation().loadUrl(url); |
|
|
|
|
return this; |
|
|
|
|
} |
|
|
|
@ -301,6 +325,14 @@ public class NewModernUIPane<T> extends ModernUIPane<T> {
|
|
|
|
|
return prepare(callback); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public ModernUIPane.Builder<T> prepareForV7(Class event, Observer listener) { |
|
|
|
|
|
|
|
|
|
pane.browser.navigation().on(event, listener); |
|
|
|
|
|
|
|
|
|
return this; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public NewModernUIPane<T> build() { |
|
|
|
|
return pane; |
|
|
|
|