diff --git a/.github/workflows/build-jcef.yml b/.github/workflows/build-jcef.yml
index c6f849d5..7c2c63c4 100644
--- a/.github/workflows/build-jcef.yml
+++ b/.github/workflows/build-jcef.yml
@@ -11,7 +11,7 @@ jobs:
matrix:
platform: [amd64, arm64]
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- name: Install deps and build
run: |
sudo apt update
@@ -40,7 +40,7 @@ jobs:
matrix:
platform: [amd64, arm64]
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- uses: ilammy/msvc-dev-cmd@v1
- name: Build
run: |
@@ -61,3 +61,35 @@ jobs:
jcef_build/windows_${{ matrix.platform }}.tar.gz
jcef_build/windows_${{ matrix.platform }}.tar.gz.sha256
if-no-files-found: error
+
+ java-cef-macos:
+ runs-on: [macos-12]
+ strategy:
+ matrix:
+ platform: [amd64, arm64]
+ steps:
+ - uses: actions/checkout@v4
+ - name: Set up Python 3.9
+ uses: actions/setup-python@v4
+ with:
+ python-version: '3.9'
+ - run: |
+ brew install ninja
+ brew install python
+ brew install coreutils
+ sudo xcode-select --switch /Applications/Xcode_13.1.app
+ mkdir jcef_build && cd jcef_build
+ cmake -G "Ninja" -DPROJECT_ARCH=${{ matrix.platform }} -DCMAKE_BUILD_TYPE=Release ..
+ ninja -j4
+ mv native/Release macos_${{ matrix.platform }}
+ tar -czf macos_${{ matrix.platform }}.tar.gz macos_${{ matrix.platform }}
+ sha256sum macos_${{ matrix.platform }}.tar.gz > macos_${{ matrix.platform }}.tar.gz.sha256
+
+ - uses: actions/upload-artifact@v3
+ if: ${{ github.ref == 'refs/heads/master' }}
+ with:
+ name: 'macos_${{ matrix.platform }}'
+ path: |
+ jcef_build/macos_${{ matrix.platform }}.tar.gz
+ jcef_build/macos_${{ matrix.platform }}.tar.gz.sha256
+ if-no-files-found: error
diff --git a/build.xml b/build.xml
index 010b5c57..a9227e30 100644
--- a/build.xml
+++ b/build.xml
@@ -30,7 +30,6 @@
-
@@ -47,11 +46,6 @@
-
-
-
-
-
@@ -64,7 +58,6 @@
icon="third_party/cef/res/CefIcon.icns">
-
diff --git a/cmake/DownloadCEF.cmake b/cmake/DownloadCEF.cmake
index b2d11930..a64592bc 100644
--- a/cmake/DownloadCEF.cmake
+++ b/cmake/DownloadCEF.cmake
@@ -8,7 +8,7 @@
# Visit https://cef-builds.spotifycdn.com/index.html for the list of
# supported platforms and versions.
-function(DownloadCEF platform branch version download_dir)
+function(DownloadCEF platform version download_dir)
# Specify the binary distribution type and download directory.
set(CEF_DISTRIBUTION "cef_binary_${version}_${platform}")
set(CEF_DOWNLOAD_DIR "${download_dir}")
@@ -21,19 +21,19 @@ function(DownloadCEF platform branch version download_dir)
set(CEF_DOWNLOAD_FILENAME "${CEF_DISTRIBUTION}.tar.bz2")
set(CEF_DOWNLOAD_PATH "${CEF_DOWNLOAD_DIR}/${CEF_DOWNLOAD_FILENAME}")
if(NOT EXISTS "${CEF_DOWNLOAD_PATH}")
- set(CEF_DOWNLOAD_URL "https://mcef-download.cinemamod.com/cef-builds/${branch}/${CEF_DOWNLOAD_FILENAME}")
+ set(CEF_DOWNLOAD_URL "https://cef-builds.spotifycdn.com/${CEF_DOWNLOAD_FILENAME}")
string(REPLACE "+" "%2B" CEF_DOWNLOAD_URL_ESCAPED ${CEF_DOWNLOAD_URL})
# Download the SHA1 hash for the binary distribution.
- # message(STATUS "Downloading ${CEF_DOWNLOAD_PATH}.sha1 from ${CEF_DOWNLOAD_URL_ESCAPED}...")
- # file(DOWNLOAD "${CEF_DOWNLOAD_URL_ESCAPED}.sha1" "${CEF_DOWNLOAD_PATH}.sha1")
- # file(READ "${CEF_DOWNLOAD_PATH}.sha1" CEF_SHA1)
+ message(STATUS "Downloading ${CEF_DOWNLOAD_PATH}.sha1 from ${CEF_DOWNLOAD_URL_ESCAPED}...")
+ file(DOWNLOAD "${CEF_DOWNLOAD_URL_ESCAPED}.sha1" "${CEF_DOWNLOAD_PATH}.sha1")
+ file(READ "${CEF_DOWNLOAD_PATH}.sha1" CEF_SHA1)
# Download the binary distribution and verify the hash.
message(STATUS "Downloading ${CEF_DOWNLOAD_PATH}...")
file(
DOWNLOAD "${CEF_DOWNLOAD_URL_ESCAPED}" "${CEF_DOWNLOAD_PATH}"
- # EXPECTED_HASH SHA1=${CEF_SHA1}
+ EXPECTED_HASH SHA1=${CEF_SHA1}
SHOW_PROGRESS
)
endif()
diff --git a/java/org/cef/CefClient.java b/java/org/cef/CefClient.java
index 0c88e8dc..39034ea6 100644
--- a/java/org/cef/CefClient.java
+++ b/java/org/cef/CefClient.java
@@ -4,46 +4,22 @@
package org.cef;
-import org.cef.browser.CefBrowser;
-import org.cef.browser.CefBrowserFactory;
-import org.cef.browser.CefFrame;
-import org.cef.browser.CefMessageRouter;
-import org.cef.browser.CefRequestContext;
-import org.cef.callback.CefAuthCallback;
-import org.cef.callback.CefBeforeDownloadCallback;
-import org.cef.callback.CefCallback;
-import org.cef.callback.CefContextMenuParams;
-import org.cef.callback.CefDownloadItem;
-import org.cef.callback.CefDownloadItemCallback;
-import org.cef.callback.CefDragData;
-import org.cef.callback.CefFileDialogCallback;
-import org.cef.callback.CefJSDialogCallback;
-import org.cef.callback.CefMenuModel;
-import org.cef.callback.CefPrintDialogCallback;
-import org.cef.callback.CefPrintJobCallback;
+import org.cef.browser.*;
+import org.cef.callback.*;
import org.cef.handler.*;
import org.cef.misc.BoolRef;
import org.cef.misc.CefAudioParameters;
import org.cef.misc.CefPrintSettings;
-import org.cef.misc.StringRef;
import org.cef.network.CefRequest;
import org.cef.network.CefRequest.TransitionType;
-import org.cef.network.CefResponse;
-import org.cef.network.CefURLRequest;
-
-import java.awt.Dimension;
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
+
+import java.awt.*;
import java.nio.ByteBuffer;
import java.util.Collection;
import java.util.HashMap;
import java.util.Vector;
import java.util.function.Consumer;
-import javax.swing.SwingUtilities;
-
/**
* Client that owns a browser and renderer.
*/
diff --git a/java/org/cef/browser/CefBrowserFactory.java b/java/org/cef/browser/CefBrowserFactory.java
index 38bfd596..853ce9b2 100644
--- a/java/org/cef/browser/CefBrowserFactory.java
+++ b/java/org/cef/browser/CefBrowserFactory.java
@@ -13,8 +13,6 @@
public class CefBrowserFactory {
public static CefBrowser create(CefClient client, String url, boolean isOffscreenRendered,
boolean isTransparent, CefRequestContext context, CefBrowserSettings settings) {
- if (isOffscreenRendered)
- return new CefBrowserOsr(client, url, isTransparent, context, settings);
- return new CefBrowserWr(client, url, context, settings);
+ return new CefBrowserOsr(client, url, isTransparent, context, settings);
}
}
diff --git a/java/org/cef/browser/CefBrowserOsr.java b/java/org/cef/browser/CefBrowserOsr.java
index 335bd8db..2fd33b1b 100644
--- a/java/org/cef/browser/CefBrowserOsr.java
+++ b/java/org/cef/browser/CefBrowserOsr.java
@@ -4,6 +4,7 @@
package org.cef.browser;
+import org.cef.CefBrowserSettings;
import org.cef.CefClient;
import org.cef.callback.CefDragData;
import org.cef.handler.CefRenderHandler;
@@ -18,9 +19,6 @@
import java.nio.ByteBuffer;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
import java.util.function.Consumer;
/**
@@ -40,8 +38,8 @@ public class CefBrowserOsr extends CefBrowser_N implements CefRenderHandler {
private CopyOnWriteArrayList> onPaintListeners =
new CopyOnWriteArrayList<>();
- CefBrowserOsr(CefClient client, String url, boolean transparent, CefRequestContext context,
- CefBrowserSettings settings) {
+ protected CefBrowserOsr(CefClient client, String url, boolean transparent, CefRequestContext context,
+ CefBrowserSettings settings) {
this(client, url, transparent, context, null, null, settings);
}
@@ -50,8 +48,6 @@ private CefBrowserOsr(CefClient client, String url, boolean transparent,
CefBrowserSettings settings) {
super(client, url, context, parent, inspectAt, settings);
isTransparent_ = transparent;
- renderer_ = new CefRenderer(transparent);
- createGLCanvas();
}
@Override
@@ -160,7 +156,7 @@ private void createBrowserIfRequired(boolean hasParent) {
getInspectAt());
} else {
createBrowser(getClient(), windowHandle, getUrl(), true, isTransparent_,
- getRequestContext());
+ null, getRequestContext());
}
} else if (hasParent && justCreated_) {
notifyAfterParentChanged();
diff --git a/java/org/cef/browser/CefBrowser_N.java b/java/org/cef/browser/CefBrowser_N.java
index ed60c2be..72502f64 100644
--- a/java/org/cef/browser/CefBrowser_N.java
+++ b/java/org/cef/browser/CefBrowser_N.java
@@ -7,12 +7,7 @@
import org.cef.CefBrowserSettings;
import org.cef.CefClient;
import org.cef.browser.CefDevToolsClient.DevToolsException;
-import org.cef.browser.CefRequestContext;
-import org.cef.callback.CefDragData;
-import org.cef.callback.CefNativeAdapter;
-import org.cef.callback.CefPdfPrintCallback;
-import org.cef.callback.CefRunFileDialogCallback;
-import org.cef.callback.CefStringVisitor;
+import org.cef.callback.*;
import org.cef.event.CefKeyEvent;
import org.cef.event.CefMouseEvent;
import org.cef.event.CefMouseWheelEvent;
@@ -22,16 +17,10 @@
import org.cef.handler.CefWindowHandler;
import org.cef.misc.CefPdfPrintSettings;
import org.cef.network.CefRequest;
-import java.util.concurrent.CompletableFuture;
-import java.awt.Component;
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.awt.Window;
-import java.awt.event.WindowEvent;
+import java.awt.*;
import java.util.Vector;
-
-import javax.swing.SwingUtilities;
+import java.util.concurrent.CompletableFuture;
/**
* This class represents all methods which are connected to the
@@ -209,7 +198,7 @@ protected final void createDevTools(CefBrowser_N parent, CefClientHandler client
if (getNativeRef("CefBrowser") == 0 && !isPending_) {
try {
isPending_ = N_CreateDevTools(
- parent, clientHandler, windowHandle, osr, transparent, inspectAt);
+ parent, clientHandler, windowHandle, osr, transparent, null, inspectAt);
} catch (UnsatisfiedLinkError err) {
err.printStackTrace();
}
@@ -339,26 +328,6 @@ public CefFrame getFocusedFrame() {
}
}
- @Override
- public CefFrame getFrame(long identifier) {
- try {
- return N_GetFrame(identifier);
- } catch (UnsatisfiedLinkError ule) {
- ule.printStackTrace();
- return null;
- }
- }
-
- @Override
- public CefFrame getFrame(String name) {
- try {
- return N_GetFrame2(name);
- } catch (UnsatisfiedLinkError ule) {
- ule.printStackTrace();
- return null;
- }
- }
-
@Override
public CefFrame getFrameByIdentifier(String identifier) {
try {
@@ -871,9 +840,9 @@ private final native void N_Find(
private final native void N_ReplaceMisspelling(String word);
private final native void N_WasResized(int width, int height);
private final native void N_Invalidate();
- private final native void N_SendKeyEvent(KeyEvent e);
- private final native void N_SendMouseEvent(MouseEvent e);
- private final native void N_SendMouseWheelEvent(MouseWheelEvent e);
+ private final native void N_SendKeyEvent(CefKeyEvent e);
+ private final native void N_SendMouseEvent(CefMouseEvent e);
+ private final native void N_SendMouseWheelEvent(CefMouseWheelEvent e);
private final native void N_DragTargetDragEnter(
CefDragData dragData, Point pos, int modifiers, int allowed_ops);
private final native void N_DragTargetDragOver(Point pos, int modifiers, int allowed_ops);
diff --git a/java/tests/detailed/BrowserFrame.java b/java/tests/detailed/BrowserFrame.java
deleted file mode 100644
index 25beacf3..00000000
--- a/java/tests/detailed/BrowserFrame.java
+++ /dev/null
@@ -1,136 +0,0 @@
-// Copyright (c) 2018 The Chromium Embedded Framework Authors. All rights
-// reserved. Use of this source code is governed by a BSD-style license that
-// can be found in the LICENSE file.
-
-package tests.detailed;
-
-import org.cef.CefApp;
-import org.cef.browser.CefBrowser;
-import org.cef.handler.CefLifeSpanHandlerAdapter;
-
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-
-import javax.swing.JFrame;
-import javax.swing.SwingUtilities;
-
-public class BrowserFrame extends JFrame {
- private volatile boolean isClosed_ = false;
- private CefBrowser browser_ = null;
- private static int browserCount_ = 0;
- private Runnable afterParentChangedAction_ = null;
-
- public BrowserFrame() {
- this(null);
- }
-
- public BrowserFrame(String title) {
- super(title);
-
- // Browser window closing works as follows:
- // 1. Clicking the window X button calls WindowAdapter.windowClosing.
- // 2. WindowAdapter.windowClosing calls CefBrowser.close(false).
- // 3. CEF calls CefLifeSpanHandler.doClose() which calls CefBrowser.doClose()
- // which returns true (canceling the close).
- // 4. CefBrowser.doClose() triggers another call to WindowAdapter.windowClosing.
- // 5. WindowAdapter.windowClosing calls CefBrowser.close(true).
- // 6. For windowed browsers CEF destroys the native window handle. For OSR
- // browsers CEF calls CefLifeSpanHandler.doClose() which calls
- // CefBrowser.doClose() again which returns false (allowing the close).
- // 7. CEF calls CefLifeSpanHandler.onBeforeClose and the browser is destroyed.
- //
- // On macOS pressing Cmd+Q results in a call to CefApp.handleBeforeTerminate
- // which calls CefBrowser.close(true) for each existing browser. CEF then calls
- // CefLifeSpanHandler.onBeforeClose and the browser is destroyed.
- //
- // Application shutdown works as follows:
- // 1. CefLifeSpanHandler.onBeforeClose calls CefApp.getInstance().dispose()
- // when the last browser window is destroyed.
- // 2. CefAppHandler.stateHasChanged terminates the application by calling
- // System.exit(0) when the state changes to CefAppState.TERMINATED.
- addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- if (browser_ == null) {
- // If there's no browser we can dispose immediately.
- isClosed_ = true;
- System.out.println("BrowserFrame.windowClosing Frame.dispose");
- dispose();
- return;
- }
-
- boolean isClosed = isClosed_;
-
- if (isClosed) {
- // Cause browser.doClose() to return false so that OSR browsers
- // can close.
- browser_.setCloseAllowed();
- }
-
- // Results in another call to this method.
- System.out.println("BrowserFrame.windowClosing CefBrowser.close(" + isClosed + ")");
- browser_.close(isClosed);
- if (!isClosed_) {
- isClosed_ = true;
- }
- if (isClosed) {
- // Dispose after the 2nd call to this method.
- System.out.println("BrowserFrame.windowClosing Frame.dispose");
- dispose();
- }
- }
- });
- }
-
- public void setBrowser(CefBrowser browser) {
- if (browser_ == null) browser_ = browser;
-
- browser_.getClient().removeLifeSpanHandler();
- browser_.getClient().addLifeSpanHandler(new CefLifeSpanHandlerAdapter() {
- @Override
- public void onAfterCreated(CefBrowser browser) {
- System.out.println("BrowserFrame.onAfterCreated id=" + browser.getIdentifier());
- browserCount_++;
- }
-
- @Override
- public void onAfterParentChanged(CefBrowser browser) {
- System.out.println(
- "BrowserFrame.onAfterParentChanged id=" + browser.getIdentifier());
- if (afterParentChangedAction_ != null) {
- SwingUtilities.invokeLater(afterParentChangedAction_);
- afterParentChangedAction_ = null;
- }
- }
-
- @Override
- public boolean doClose(CefBrowser browser) {
- boolean result = browser.doClose();
- System.out.println("BrowserFrame.doClose id=" + browser.getIdentifier()
- + " CefBrowser.doClose=" + result);
- return result;
- }
-
- @Override
- public void onBeforeClose(CefBrowser browser) {
- System.out.println("BrowserFrame.onBeforeClose id=" + browser.getIdentifier());
- if (--browserCount_ == 0) {
- System.out.println("BrowserFrame.onBeforeClose CefApp.dispose");
- CefApp.getInstance().dispose();
- }
- }
- });
- }
-
- public void removeBrowser(Runnable r) {
- System.out.println("BrowserFrame.removeBrowser");
- afterParentChangedAction_ = r;
- // The removeNotify() notification should be sent as a result of calling remove().
- // However, it isn't in all cases so we do it manually here.
- browser_ = null;
- }
-
- public CefBrowser getBrowser() {
- return browser_;
- }
-}
diff --git a/java/tests/detailed/MainFrame.java b/java/tests/detailed/MainFrame.java
deleted file mode 100644
index 5b1efeb5..00000000
--- a/java/tests/detailed/MainFrame.java
+++ /dev/null
@@ -1,284 +0,0 @@
-// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
-// reserved. Use of this source code is governed by a BSD-style license that
-// can be found in the LICENSE file.
-
-package tests.detailed;
-
-import org.cef.CefApp;
-import org.cef.CefApp.CefVersion;
-import org.cef.CefClient;
-import org.cef.CefSettings;
-import org.cef.CefSettings.ColorType;
-import org.cef.OS;
-import org.cef.browser.CefBrowser;
-import org.cef.browser.CefFrame;
-import org.cef.browser.CefMessageRouter;
-import org.cef.browser.CefRequestContext;
-import org.cef.handler.CefDisplayHandlerAdapter;
-import org.cef.handler.CefFocusHandlerAdapter;
-import org.cef.handler.CefLoadHandlerAdapter;
-import org.cef.handler.CefRequestContextHandlerAdapter;
-import org.cef.network.CefCookieManager;
-
-import java.awt.BorderLayout;
-import java.awt.KeyboardFocusManager;
-import java.awt.event.FocusAdapter;
-import java.awt.event.FocusEvent;
-import java.io.File;
-import java.lang.Thread.UncaughtExceptionHandler;
-
-import javax.swing.JFrame;
-import javax.swing.JPanel;
-
-import tests.detailed.dialog.DownloadDialog;
-import tests.detailed.handler.AppHandler;
-import tests.detailed.handler.ContextMenuHandler;
-import tests.detailed.handler.DragHandler;
-import tests.detailed.handler.JSDialogHandler;
-import tests.detailed.handler.KeyboardHandler;
-import tests.detailed.handler.MessageRouterHandler;
-import tests.detailed.handler.MessageRouterHandlerEx;
-import tests.detailed.handler.RequestHandler;
-import tests.detailed.ui.ControlPanel;
-import tests.detailed.ui.MenuBar;
-import tests.detailed.ui.StatusPanel;
-import tests.detailed.util.DataUri;
-
-public class MainFrame extends BrowserFrame {
- private static final long serialVersionUID = -2295538706810864538L;
- public static void main(String[] args) {
- // Perform startup initialization on platforms that require it.
- if (!CefApp.startup(args)) {
- System.out.println("Startup initialization failed!");
- return;
- }
-
- // OSR mode is enabled by default on Linux.
- // and disabled by default on Windows and Mac OS X.
- boolean osrEnabledArg = false;
- boolean transparentPaintingEnabledArg = false;
- boolean createImmediately = false;
- for (String arg : args) {
- arg = arg.toLowerCase();
- if (arg.equals("--off-screen-rendering-enabled")) {
- osrEnabledArg = true;
- } else if (arg.equals("--transparent-painting-enabled")) {
- transparentPaintingEnabledArg = true;
- } else if (arg.equals("--create-immediately")) {
- createImmediately = true;
- }
- }
-
- System.out.println("Offscreen rendering " + (osrEnabledArg ? "enabled" : "disabled"));
-
- // MainFrame keeps all the knowledge to display the embedded browser
- // frame.
- final MainFrame frame = new MainFrame(
- osrEnabledArg, transparentPaintingEnabledArg, createImmediately, args);
- frame.setSize(800, 600);
- frame.setVisible(true);
- }
-
- private final CefClient client_;
- private String errorMsg_ = "";
- private ControlPanel control_pane_;
- private StatusPanel status_panel_;
- private boolean browserFocus_ = true;
- private boolean osr_enabled_;
- private boolean transparent_painting_enabled_;
-
- public MainFrame(boolean osrEnabled, boolean transparentPaintingEnabled,
- boolean createImmediately, String[] args) {
- this.osr_enabled_ = osrEnabled;
- this.transparent_painting_enabled_ = transparentPaintingEnabled;
-
- CefApp myApp;
- if (CefApp.getState() != CefApp.CefAppState.INITIALIZED) {
- // 1) CefApp is the entry point for JCEF. You can pass
- // application arguments to it, if you want to handle any
- // chromium or CEF related switches/attributes in
- // the native world.
- CefSettings settings = new CefSettings();
- settings.windowless_rendering_enabled = osrEnabled;
- // try to load URL "about:blank" to see the background color
- settings.background_color = settings.new ColorType(100, 255, 242, 211);
- myApp = CefApp.getInstance(args, settings);
-
- CefVersion version = myApp.getVersion();
- System.out.println("Using:\n" + version);
-
- // We're registering our own AppHandler because we want to
- // add an own schemes (search:// and client://) and its corresponding
- // protocol handlers. So if you enter "search:something on the web", your
- // search request "something on the web" is forwarded to www.google.com
- CefApp.addAppHandler(new AppHandler(args));
- } else {
- myApp = CefApp.getInstance();
- }
-
- // By calling the method createClient() the native part
- // of JCEF/CEF will be initialized and an instance of
- // CefClient will be created. You can create one to many
- // instances of CefClient.
- client_ = myApp.createClient();
-
- // 2) You have the ability to pass different handlers to your
- // instance of CefClient. Each handler is responsible to
- // deal with different informations (e.g. keyboard input).
- //
- // For each handler (with more than one method) adapter
- // classes exists. So you don't need to override methods
- // you're not interested in.
- DownloadDialog downloadDialog = new DownloadDialog(this);
- client_.addContextMenuHandler(new ContextMenuHandler(this));
- client_.addDownloadHandler(downloadDialog);
- client_.addDragHandler(new DragHandler());
- client_.addJSDialogHandler(new JSDialogHandler());
- client_.addKeyboardHandler(new KeyboardHandler());
- client_.addRequestHandler(new RequestHandler(this));
-
- // Beside the normal handler instances, we're registering a MessageRouter
- // as well. That gives us the opportunity to reply to JavaScript method
- // calls (JavaScript binding). We're using the default configuration, so
- // that the JavaScript binding methods "cefQuery" and "cefQueryCancel"
- // are used.
- CefMessageRouter msgRouter = CefMessageRouter.create();
- msgRouter.addHandler(new MessageRouterHandler(), true);
- msgRouter.addHandler(new MessageRouterHandlerEx(client_), false);
- client_.addMessageRouter(msgRouter);
-
- // 2.1) We're overriding CefDisplayHandler as nested anonymous class
- // to update our address-field, the title of the panel as well
- // as for updating the status-bar on the bottom of the browser
- client_.addDisplayHandler(new CefDisplayHandlerAdapter() {
- @Override
- public void onAddressChange(CefBrowser browser, CefFrame frame, String url) {
- control_pane_.setAddress(browser, url);
- }
- @Override
- public void onTitleChange(CefBrowser browser, String title) {
- setTitle(title);
- }
- @Override
- public void onStatusMessage(CefBrowser browser, String value) {
- status_panel_.setStatusText(value);
- }
- });
-
- // 2.2) To disable/enable navigation buttons and to display a prgress bar
- // which indicates the load state of our website, we're overloading
- // the CefLoadHandler as nested anonymous class. Beside this, the
- // load handler is responsible to deal with (load) errors as well.
- // For example if you navigate to a URL which does not exist, the
- // browser will show up an error message.
- client_.addLoadHandler(new CefLoadHandlerAdapter() {
- @Override
- public void onLoadingStateChange(CefBrowser browser, boolean isLoading,
- boolean canGoBack, boolean canGoForward) {
- control_pane_.update(browser, isLoading, canGoBack, canGoForward);
- status_panel_.setIsInProgress(isLoading);
-
- if (!isLoading && !errorMsg_.isEmpty()) {
- browser.loadURL(DataUri.create("text/html", errorMsg_));
- errorMsg_ = "";
- }
- }
-
- @Override
- public void onLoadError(CefBrowser browser, CefFrame frame, ErrorCode errorCode,
- String errorText, String failedUrl) {
- if (errorCode != ErrorCode.ERR_NONE && errorCode != ErrorCode.ERR_ABORTED) {
- errorMsg_ = "";
- errorMsg_ += "Error while loading ";
- errorMsg_ += "";
- errorMsg_ += "" + errorCode + " ";
- errorMsg_ += "Failed to load " + failedUrl + " ";
- errorMsg_ += "" + (errorText == null ? "" : errorText) + "
";
- errorMsg_ += "";
- browser.stopLoad();
- }
- }
- });
-
- // Create the browser.
- CefBrowser browser = client_.createBrowser(
- "http://www.google.com", osrEnabled, null);
- setBrowser(browser);
-
- // Set up the UI for this example implementation.
- JPanel contentPanel = createContentPanel();
- getContentPane().add(contentPanel, BorderLayout.CENTER);
-
- // Clear focus from the browser when the address field gains focus.
- control_pane_.getAddressField().addFocusListener(new FocusAdapter() {
- @Override
- public void focusGained(FocusEvent e) {
- if (!browserFocus_) return;
- browserFocus_ = false;
- KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
- control_pane_.getAddressField().requestFocus();
- }
- });
-
- // Clear focus from the address field when the browser gains focus.
- client_.addFocusHandler(new CefFocusHandlerAdapter() {
- @Override
- public void onGotFocus(CefBrowser browser) {
- if (browserFocus_) return;
- browserFocus_ = true;
- KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
- browser.setFocus(true);
- }
-
- @Override
- public void onTakeFocus(CefBrowser browser, boolean next) {
- browserFocus_ = false;
- }
- });
-
- if (createImmediately) browser.createImmediately();
-
- // Add the browser to the UI.
-
- MenuBar menuBar = new MenuBar(
- this, browser, control_pane_, downloadDialog, CefCookieManager.getGlobalManager());
-
- menuBar.addBookmark("Binding Test", "client://tests/binding_test.html");
- menuBar.addBookmark("Binding Test 2", "client://tests/binding_test2.html");
- menuBar.addBookmark("Download Test", "https://cef-builds.spotifycdn.com/index.html");
- menuBar.addBookmark("Login Test (username:pumpkin, password:pie)",
- "http://www.colostate.edu/~ric/protect/your.html");
- menuBar.addBookmark("Certificate-error Test", "https://www.k2go.de");
- menuBar.addBookmark("Resource-Handler Test", "http://www.foo.bar/");
- menuBar.addBookmark("Resource-Handler Set Error Test", "http://seterror.test/");
- menuBar.addBookmark(
- "Scheme-Handler Test 1: (scheme \"client\")", "client://tests/handler.html");
- menuBar.addBookmark(
- "Scheme-Handler Test 2: (scheme \"search\")", "search://do a barrel roll/");
- menuBar.addBookmark("Spellcheck Test", "client://tests/spellcheck.html");
- menuBar.addBookmark("LocalStorage Test", "client://tests/localstorage.html");
- menuBar.addBookmark("Transparency Test", "client://tests/transparency.html");
- menuBar.addBookmarkSeparator();
- menuBar.addBookmark(
- "javachromiumembedded", "https://bitbucket.org/chromiumembedded/java-cef");
- menuBar.addBookmark("chromiumembedded", "https://bitbucket.org/chromiumembedded/cef");
- setJMenuBar(menuBar);
- }
-
- private JPanel createContentPanel() {
- JPanel contentPanel = new JPanel(new BorderLayout());
- control_pane_ = new ControlPanel(getBrowser());
- status_panel_ = new StatusPanel();
- contentPanel.add(control_pane_, BorderLayout.NORTH);
- contentPanel.add(status_panel_, BorderLayout.SOUTH);
- return contentPanel;
- }
-
- public boolean isOsrEnabled() {
- return osr_enabled_;
- }
-
- public boolean isTransparentPaintingEnabled() {
- return transparent_painting_enabled_;
- }
-}
diff --git a/java/tests/detailed/dialog/CertErrorDialog.java b/java/tests/detailed/dialog/CertErrorDialog.java
deleted file mode 100644
index 4c78ea79..00000000
--- a/java/tests/detailed/dialog/CertErrorDialog.java
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
-// reserved. Use of this source code is governed by a BSD-style license that
-// can be found in the LICENSE file.
-
-package tests.detailed.dialog;
-
-import org.cef.callback.CefCallback;
-import org.cef.handler.CefLoadHandler.ErrorCode;
-
-import java.awt.Frame;
-
-import javax.swing.JOptionPane;
-
-public class CertErrorDialog implements Runnable {
- private final Frame owner_;
- private final ErrorCode cert_error_;
- private final String request_url_;
- private final CefCallback callback_;
-
- public CertErrorDialog(
- Frame owner, ErrorCode cert_error, String request_url, CefCallback callback) {
- owner_ = owner;
- cert_error_ = cert_error;
- request_url_ = request_url;
- callback_ = callback;
- }
-
- @Override
- public void run() {
- int dialogResult = JOptionPane.showConfirmDialog(owner_,
- "An certificate error (" + cert_error_ + ") occurreed "
- + "while requesting\n" + request_url_ + "\nDo you want to proceed anyway?",
- "Certificate error", JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE);
- if (dialogResult == JOptionPane.YES_OPTION) {
- callback_.Continue();
- } else {
- callback_.cancel();
- }
- }
-}
diff --git a/java/tests/detailed/dialog/CookieManagerDialog.java b/java/tests/detailed/dialog/CookieManagerDialog.java
deleted file mode 100644
index 279ebbf2..00000000
--- a/java/tests/detailed/dialog/CookieManagerDialog.java
+++ /dev/null
@@ -1,148 +0,0 @@
-// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
-// reserved. Use of this source code is governed by a BSD-style license that
-// can be found in the LICENSE file.
-
-package tests.detailed.dialog;
-
-import org.cef.callback.CefCookieVisitor;
-import org.cef.misc.BoolRef;
-import org.cef.network.CefCookie;
-import org.cef.network.CefCookieManager;
-
-import java.awt.BorderLayout;
-import java.awt.Frame;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.Date;
-import java.util.Vector;
-
-import javax.swing.BoxLayout;
-import javax.swing.JButton;
-import javax.swing.JDialog;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTable;
-import javax.swing.table.AbstractTableModel;
-
-@SuppressWarnings("serial")
-public class CookieManagerDialog extends JDialog {
- private static int testCookieId = 1;
- private final CefCookieManager manager;
- private final CookieTableModel tblModel = new CookieTableModel();
-
- public CookieManagerDialog(Frame owner, String title, CefCookieManager cookieManager) {
- super(owner, title, false);
- setLayout(new BorderLayout());
- setSize(800, 600);
- manager = cookieManager;
-
- JTable cookieTable = new JTable(tblModel);
- cookieTable.setFillsViewportHeight(true);
-
- JPanel controlPanel = new JPanel();
- controlPanel.setLayout(new BoxLayout(controlPanel, BoxLayout.X_AXIS));
- JButton delButton = new JButton("Delete cookies");
- delButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- tblModel.removeCookies();
- }
- });
- controlPanel.add(delButton);
-
- JButton testCreateCookie = new JButton("Add test cookie");
- testCreateCookie.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- Date now = new Date();
- Date expires = new Date(now.getTime() + 86400000);
- String name = "testNo" + testCookieId++;
- CefCookie cookie = new CefCookie(name, "testCookie", ".test.cookie", "/", false,
- true, now, now, true, expires);
- if (manager.setCookie("http://my.test.cookie", cookie)) {
- tblModel.visit(cookie, 1, 1, new BoolRef());
- }
- }
- });
- controlPanel.add(testCreateCookie);
-
- JButton doneButton = new JButton("Done");
- doneButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- setVisible(false);
- }
- });
- controlPanel.add(doneButton);
-
- add(new JScrollPane(cookieTable));
- add(controlPanel, BorderLayout.SOUTH);
-
- if (manager == null) throw new NullPointerException("Cookie manager is null");
- manager.visitAllCookies(tblModel);
- }
-
- private class CookieTableModel extends AbstractTableModel implements CefCookieVisitor {
- private final String[] columnNames;
- private Vector rowData = new Vector<>();
-
- public CookieTableModel() {
- super();
- columnNames = new String[] {"Name", "Value", "Domain", "Path", "Secure", "HTTP only",
- "Created", "Last Access", "Expires"};
- }
-
- // add an entry to the table
- @Override
- public boolean visit(CefCookie cookie, int count, int total, BoolRef delete) {
- Object[] entry = {cookie.name, cookie.value, cookie.domain, cookie.path,
- new Boolean(cookie.secure), new Boolean(cookie.httponly), cookie.creation,
- cookie.lastAccess, cookie.expires};
- int row = rowData.size();
- rowData.addElement(entry);
- fireTableRowsInserted(row, row);
-
- return true;
- }
-
- public void removeCookies() {
- int cnt = rowData.size();
- if (cnt > 0) {
- rowData.clear();
- manager.deleteCookies("", "");
- fireTableRowsDeleted(0, cnt - 1);
- }
- }
-
- @Override
- public int getRowCount() {
- return rowData.size();
- }
-
- @Override
- public int getColumnCount() {
- return columnNames.length;
- }
-
- @Override
- public String getColumnName(int column) {
- return columnNames[column];
- }
-
- @Override
- public Class> getColumnClass(int columnIndex) {
- if (rowData.size() > 0) return rowData.get(0)[columnIndex].getClass();
- return Object.class;
- }
-
- @Override
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- return false;
- }
-
- @Override
- public Object getValueAt(int rowIndex, int columnIndex) {
- return rowData.get(rowIndex)[columnIndex];
- }
- }
-}
diff --git a/java/tests/detailed/dialog/DevToolsDialog.java b/java/tests/detailed/dialog/DevToolsDialog.java
deleted file mode 100644
index 74a3a766..00000000
--- a/java/tests/detailed/dialog/DevToolsDialog.java
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
-// reserved. Use of this source code is governed by a BSD-style license that
-// can be found in the LICENSE file.
-
-package tests.detailed.dialog;
-
-import org.cef.browser.CefBrowser;
-
-import java.awt.BorderLayout;
-import java.awt.Frame;
-import java.awt.Point;
-import java.awt.event.ComponentAdapter;
-import java.awt.event.ComponentEvent;
-
-import javax.swing.JDialog;
-
-@SuppressWarnings("serial")
-public class DevToolsDialog extends JDialog {
- private final CefBrowser devTools_;
- public DevToolsDialog(Frame owner, String title, CefBrowser browser) {
- this(owner, title, browser, null);
- }
-
- public DevToolsDialog(Frame owner, String title, CefBrowser browser, Point inspectAt) {
- super(owner, title, false);
-
- setLayout(new BorderLayout());
- setSize(800, 600);
- setLocation(owner.getLocation().x + 20, owner.getLocation().y + 20);
-
- devTools_ = browser.getDevTools(inspectAt);
-
- addComponentListener(new ComponentAdapter() {
- @Override
- public void componentHidden(ComponentEvent e) {
- dispose();
- }
- });
- }
-
- @Override
- public void dispose() {
- devTools_.close(true);
- super.dispose();
- }
-}
diff --git a/java/tests/detailed/dialog/DownloadDialog.java b/java/tests/detailed/dialog/DownloadDialog.java
deleted file mode 100644
index f9717a50..00000000
--- a/java/tests/detailed/dialog/DownloadDialog.java
+++ /dev/null
@@ -1,162 +0,0 @@
-// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
-// reserved. Use of this source code is governed by a BSD-style license that
-// can be found in the LICENSE file.
-
-package tests.detailed.dialog;
-
-import org.cef.browser.CefBrowser;
-import org.cef.callback.CefBeforeDownloadCallback;
-import org.cef.callback.CefDownloadItem;
-import org.cef.callback.CefDownloadItemCallback;
-import org.cef.handler.CefDownloadHandler;
-
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Frame;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.swing.BoxLayout;
-import javax.swing.JButton;
-import javax.swing.JDialog;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-
-@SuppressWarnings("serial")
-public class DownloadDialog extends JDialog implements CefDownloadHandler {
- private final Frame owner_;
- private final Map downloadObjects_ =
- new HashMap();
- private final JPanel downloadPanel_ = new JPanel();
- private final DownloadDialog dialog_;
-
- public DownloadDialog(Frame owner) {
- super(owner, "Downloads", false);
- setVisible(false);
- setSize(400, 300);
-
- owner_ = owner;
- dialog_ = this;
- downloadPanel_.setLayout(new BoxLayout(downloadPanel_, BoxLayout.Y_AXIS));
- add(downloadPanel_);
- }
-
- private class DownloadObject extends JPanel {
- private boolean isHidden_ = true;
- private final int identifier_;
- private JLabel fileName_ = new JLabel();
- private JLabel status_ = new JLabel();
- private JButton dlAbort_ = new JButton();
- private JButton dlRemoveEntry_ = new JButton("x");
- private CefDownloadItemCallback callback_;
- private Color bgColor_;
-
- DownloadObject(CefDownloadItem downloadItem, String suggestedName) {
- super();
- setOpaque(true);
- setLayout(new BorderLayout());
- setMaximumSize(new Dimension(dialog_.getWidth() - 10, 80));
- identifier_ = downloadItem.getId();
- bgColor_ = identifier_ % 2 == 0 ? Color.WHITE : Color.YELLOW;
- setBackground(bgColor_);
-
- fileName_.setText(suggestedName);
- add(fileName_, BorderLayout.NORTH);
-
- status_.setAlignmentX(LEFT_ALIGNMENT);
- add(status_, BorderLayout.CENTER);
-
- JPanel controlPane = new JPanel();
- controlPane.setLayout(new BoxLayout(controlPane, BoxLayout.X_AXIS));
- controlPane.setOpaque(true);
- controlPane.setBackground(bgColor_);
- dlAbort_.setText("Abort");
- dlAbort_.setEnabled(false);
- dlAbort_.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- if (callback_ != null) {
- fileName_.setText("ABORTED - " + fileName_.getText());
- callback_.cancel();
- }
- }
- });
- controlPane.add(dlAbort_);
-
- dlRemoveEntry_.setEnabled(false);
- dlRemoveEntry_.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- DownloadObject removed = downloadObjects_.remove(identifier_);
- if (removed != null) {
- downloadPanel_.remove(removed);
- dialog_.repaint();
- }
- }
- });
- controlPane.add(dlRemoveEntry_);
- add(controlPane, BorderLayout.SOUTH);
-
- update(downloadItem, null);
- }
-
- // The method humanReadableByteCount() is based on
- // http://stackoverflow.com/questions/3758606/how-to-convert-byte-size-into-human-readable-format-in-java
- String humanReadableByteCount(long bytes) {
- int unit = 1024;
- if (bytes < unit) return bytes + " B";
-
- int exp = (int) (Math.log(bytes) / Math.log(unit));
- String pre = "" + ("kMGTPE").charAt(exp - 1);
- return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre);
- }
-
- void update(CefDownloadItem downloadItem, CefDownloadItemCallback callback) {
- int percentComplete = downloadItem.getPercentComplete();
- String rcvBytes = humanReadableByteCount(downloadItem.getReceivedBytes());
- String totalBytes = humanReadableByteCount(downloadItem.getTotalBytes());
- String speed = humanReadableByteCount(downloadItem.getCurrentSpeed()) + "it/s";
-
- if (downloadItem.getReceivedBytes() >= 5 && isHidden_) {
- dialog_.setVisible(true);
- dialog_.toFront();
- owner_.toBack();
- isHidden_ = false;
- }
- Runtime.getRuntime().runFinalization();
-
- callback_ = callback;
- status_.setText(rcvBytes + " of " + totalBytes + " - " + percentComplete + "%"
- + " - " + speed);
- dlAbort_.setEnabled(downloadItem.isInProgress());
- dlRemoveEntry_.setEnabled(!downloadItem.isInProgress() || downloadItem.isCanceled()
- || downloadItem.isComplete());
- if (!downloadItem.isInProgress() && !downloadItem.isCanceled()
- && !downloadItem.isComplete()) {
- fileName_.setText("FAILED - " + fileName_.getText());
- callback.cancel();
- }
- }
- }
-
- @Override
- public void onBeforeDownload(CefBrowser browser, CefDownloadItem downloadItem,
- String suggestedName, CefBeforeDownloadCallback callback) {
- callback.Continue(suggestedName, true);
-
- DownloadObject dlObject = new DownloadObject(downloadItem, suggestedName);
- downloadObjects_.put(downloadItem.getId(), dlObject);
- downloadPanel_.add(dlObject);
- }
-
- @Override
- public void onDownloadUpdated(
- CefBrowser browser, CefDownloadItem downloadItem, CefDownloadItemCallback callback) {
- DownloadObject dlObject = downloadObjects_.get(downloadItem.getId());
- if (dlObject == null) return;
- dlObject.update(downloadItem, callback);
- }
-}
diff --git a/java/tests/detailed/dialog/PasswordDialog.java b/java/tests/detailed/dialog/PasswordDialog.java
deleted file mode 100644
index 61662f48..00000000
--- a/java/tests/detailed/dialog/PasswordDialog.java
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
-// reserved. Use of this source code is governed by a BSD-style license that
-// can be found in the LICENSE file.
-
-package tests.detailed.dialog;
-
-import org.cef.callback.CefAuthCallback;
-
-import java.awt.Frame;
-import java.awt.GridLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.JButton;
-import javax.swing.JDialog;
-import javax.swing.JLabel;
-import javax.swing.JPasswordField;
-import javax.swing.JTextField;
-
-@SuppressWarnings("serial")
-public class PasswordDialog extends JDialog implements Runnable {
- private final JTextField username_ = new JTextField(20);
- private final JPasswordField password_ = new JPasswordField(20);
- private final CefAuthCallback callback_;
-
- public PasswordDialog(Frame owner, CefAuthCallback callback) {
- super(owner, "Authentication required", true);
- callback_ = callback;
- setSize(400, 100);
- setLayout(new GridLayout(0, 2));
- add(new JLabel("Username:"));
- add(username_);
- add(new JLabel("Password:"));
- add(password_);
-
- JButton abortButton = new JButton("Abort");
- abortButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- callback_.cancel();
- setVisible(false);
- dispose();
- }
- });
- add(abortButton);
-
- JButton okButton = new JButton("OK");
- okButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- if (username_.getText().isEmpty()) return;
- String password = new String(password_.getPassword());
- callback_.Continue(username_.getText(), password);
- setVisible(false);
- dispose();
- }
- });
- add(okButton);
- }
-
- @Override
- public void run() {
- setVisible(true);
- }
-}
diff --git a/java/tests/detailed/dialog/SearchDialog.java b/java/tests/detailed/dialog/SearchDialog.java
deleted file mode 100644
index 88838c36..00000000
--- a/java/tests/detailed/dialog/SearchDialog.java
+++ /dev/null
@@ -1,107 +0,0 @@
-// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
-// reserved. Use of this source code is governed by a BSD-style license that
-// can be found in the LICENSE file.
-
-package tests.detailed.dialog;
-
-import org.cef.browser.CefBrowser;
-
-import java.awt.BorderLayout;
-import java.awt.Frame;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.Box;
-import javax.swing.BoxLayout;
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JDialog;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JTextField;
-
-@SuppressWarnings("serial")
-public class SearchDialog extends JDialog {
- private final CefBrowser browser_;
- private final JTextField searchField_ = new JTextField(30);
- private final JCheckBox caseCheckBox_ = new JCheckBox("Case sensitive");
- private final JButton prevButton_ = new JButton("Prev");
- private final JButton nextButton_ = new JButton("Next");
-
- public SearchDialog(Frame owner, CefBrowser browser) {
- super(owner, "Find...", false);
- browser_ = browser;
-
- setLayout(new BorderLayout());
- setSize(400, 100);
-
- JPanel searchPanel = new JPanel();
- searchPanel.setLayout(new BoxLayout(searchPanel, BoxLayout.X_AXIS));
- searchPanel.add(Box.createHorizontalStrut(5));
- searchPanel.add(new JLabel("Search:"));
- searchPanel.add(searchField_);
-
- JPanel controlPanel = new JPanel();
- controlPanel.setLayout(new BoxLayout(controlPanel, BoxLayout.X_AXIS));
- controlPanel.add(Box.createHorizontalStrut(5));
-
- JButton searchButton = new JButton("Search");
- searchButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- if (searchField_.getText() == null || searchField_.getText().isEmpty()) return;
-
- setTitle("Find \"" + searchField_.getText() + "\"");
- boolean matchCase = caseCheckBox_.isSelected();
- browser_.find(searchField_.getText(), true, matchCase, false);
- prevButton_.setEnabled(true);
- nextButton_.setEnabled(true);
- }
- });
- controlPanel.add(searchButton);
-
- prevButton_.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- boolean matchCase = caseCheckBox_.isSelected();
- setTitle("Find \"" + searchField_.getText() + "\"");
- browser_.find(searchField_.getText(), false, matchCase, true);
- }
- });
- prevButton_.setEnabled(false);
- controlPanel.add(prevButton_);
-
- nextButton_.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- boolean matchCase = caseCheckBox_.isSelected();
- setTitle("Find \"" + searchField_.getText() + "\"");
- browser_.find(searchField_.getText(), true, matchCase, true);
- }
- });
- nextButton_.setEnabled(false);
- controlPanel.add(nextButton_);
-
- controlPanel.add(Box.createHorizontalStrut(50));
-
- JButton doneButton = new JButton("Done");
- doneButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- setVisible(false);
- dispose();
- }
- });
- controlPanel.add(doneButton);
-
- add(searchPanel, BorderLayout.NORTH);
- add(caseCheckBox_);
- add(controlPanel, BorderLayout.SOUTH);
- }
-
- @Override
- public void dispose() {
- browser_.stopFinding(true);
- super.dispose();
- }
-}
diff --git a/java/tests/detailed/dialog/ShowTextDialog.java b/java/tests/detailed/dialog/ShowTextDialog.java
deleted file mode 100644
index 70813046..00000000
--- a/java/tests/detailed/dialog/ShowTextDialog.java
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
-// reserved. Use of this source code is governed by a BSD-style license that
-// can be found in the LICENSE file.
-
-package tests.detailed.dialog;
-
-import org.cef.callback.CefStringVisitor;
-
-import java.awt.BorderLayout;
-import java.awt.Frame;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.BoxLayout;
-import javax.swing.JButton;
-import javax.swing.JDialog;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-
-@SuppressWarnings("serial")
-public class ShowTextDialog extends JDialog implements CefStringVisitor {
- private final JTextArea textArea_ = new JTextArea();
-
- public ShowTextDialog(Frame owner, String title) {
- super(owner, title, false);
- setLayout(new BorderLayout());
- setSize(800, 600);
-
- JPanel controlPanel = new JPanel();
- controlPanel.setLayout(new BoxLayout(controlPanel, BoxLayout.X_AXIS));
- JButton doneButton = new JButton("Done");
- doneButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- setVisible(false);
- dispose();
- }
- });
- controlPanel.add(doneButton);
-
- add(new JScrollPane(textArea_));
- add(controlPanel, BorderLayout.SOUTH);
- }
-
- @Override
- public void visit(String string) {
- if (!isVisible()) {
- setVisible(true);
- }
- textArea_.append(string);
- }
-}
diff --git a/java/tests/detailed/dialog/UrlRequestDialog.java b/java/tests/detailed/dialog/UrlRequestDialog.java
deleted file mode 100644
index b1cc175e..00000000
--- a/java/tests/detailed/dialog/UrlRequestDialog.java
+++ /dev/null
@@ -1,395 +0,0 @@
-// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
-// reserved. Use of this source code is governed by a BSD-style license that
-// can be found in the LICENSE file.
-
-package tests.detailed.dialog;
-
-import org.cef.network.CefPostData;
-import org.cef.network.CefPostDataElement;
-import org.cef.network.CefRequest;
-import org.cef.network.CefRequest.CefUrlRequestFlags;
-
-import java.awt.BorderLayout;
-import java.awt.Frame;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.GridLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.Vector;
-
-import javax.swing.BorderFactory;
-import javax.swing.ButtonGroup;
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JDialog;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JRadioButton;
-import javax.swing.JScrollPane;
-import javax.swing.JTable;
-import javax.swing.JTextField;
-import javax.swing.SwingUtilities;
-import javax.swing.table.AbstractTableModel;
-
-@SuppressWarnings("serial")
-public class UrlRequestDialog extends JDialog {
- private final Vector requestMethods = new Vector<>();
- private final Map requestFlags = new HashMap<>();
- private final TableModel headerTblModel = new TableModel(true);
- private final TableModel postDataModel = new TableModel(false);
- private final JTextField urlField;
- private final JTextField cookieUrl;
- private final Frame owner_;
-
- private CefRequest createRequest() {
- String url = urlField.getText();
- if (url.isEmpty() || url.trim().equalsIgnoreCase("http://")) {
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- JOptionPane.showMessageDialog(owner_,
- "Please specify at least an URL. Otherwise the CefRequest is invalid");
- }
- });
- return null;
- }
-
- CefRequest request = CefRequest.create();
- if (request == null) return null;
-
- String firstPartyForCookie = cookieUrl.getText();
- if (firstPartyForCookie.isEmpty() || firstPartyForCookie.trim().equalsIgnoreCase("http://"))
- firstPartyForCookie = url;
-
- String method = "GET";
- for (int i = 0; i < requestMethods.size(); i++) {
- JRadioButton button = requestMethods.get(i);
- if (button.isSelected()) {
- method = button.getText();
- break;
- }
- }
-
- CefPostData postData = null;
- int postDataRows = postDataModel.getRowCount();
- if (postDataRows > 0) {
- postData = CefPostData.create();
- } else if (method.equalsIgnoreCase("POST") || method.equalsIgnoreCase("PUT")) {
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- JOptionPane.showMessageDialog(
- owner_, "The methods POST and PUT require at least one row of data.");
- }
- });
- return null;
- }
-
- if (postData != null) {
- for (int i = 0; i < postDataRows; i++) {
- String value = (String) postDataModel.getValueAt(i, 0);
- if (value.trim().isEmpty()) continue;
-
- CefPostDataElement elem = CefPostDataElement.create();
- if (elem != null) {
- File f = new File(value);
- if (f.isFile()) {
- elem.setToFile(value);
- } else {
- byte[] byteStr = value.getBytes();
- elem.setToBytes(byteStr.length, byteStr);
- }
- postData.addElement(elem);
- }
- }
- }
-
- Map headerMap = null;
- int headerRows = headerTblModel.getRowCount();
- if (headerRows > 0) {
- headerMap = new HashMap<>();
- for (int i = 0; i < headerRows; i++) {
- String key = (String) headerTblModel.getValueAt(i, 0);
- String value = (String) headerTblModel.getValueAt(i, 1);
- if (key.trim().isEmpty()) continue;
-
- headerMap.put(key, value);
- }
- }
-
- int flags = 0;
- Set> entrySet = requestFlags.entrySet();
- for (Entry entry : entrySet) {
- if (entry.getKey().isSelected()) {
- flags |= entry.getValue();
- }
- }
-
- request.set(url, method, postData, headerMap);
- request.setFirstPartyForCookies(firstPartyForCookie);
- request.setFlags(flags);
- return request;
- }
-
- public UrlRequestDialog(Frame owner, String title) {
- super(owner, title, false);
- setSize(1200, 600);
- setLayout(new BorderLayout());
-
- owner_ = owner;
-
- // URL for the request
- urlField = new JTextField("http://");
- JPanel urlPanel = createPanelWithTitle("Request URL", 1, 0);
- urlPanel.add(urlField);
-
- // URL for the cookies
- cookieUrl = new JTextField("http://");
- JPanel cookiePanel = createPanelWithTitle("Cookie-URL", 1, 0);
- cookiePanel.add(cookieUrl);
-
- // Radio buttons for the request method
- ButtonGroup requestModeGrp = new ButtonGroup();
- JPanel requestModePanel = createPanelWithTitle("HTTP Request Mode", 1, 0);
- addRequestMode(requestModePanel, requestModeGrp, "GET", true);
- addRequestMode(requestModePanel, requestModeGrp, "HEAD", false);
- addRequestMode(requestModePanel, requestModeGrp, "POST", false);
- addRequestMode(requestModePanel, requestModeGrp, "PUT", false);
- addRequestMode(requestModePanel, requestModeGrp, "DELETE", false);
-
- // Checkboxes for the flags
- JPanel flagsPanel = createPanelWithTitle("Flags", 0, 1);
- addRequestFlag(flagsPanel, "Skip cache", CefUrlRequestFlags.UR_FLAG_SKIP_CACHE,
- "If set the cache will be skipped when handling the request", false);
- addRequestFlag(flagsPanel, "Allow cached credentials",
- CefUrlRequestFlags.UR_FLAG_ALLOW_CACHED_CREDENTIALS,
- "If set user name, password, and cookies may be sent with the request, "
- + "and cookies may be saved from the response.",
- false);
- addRequestFlag(flagsPanel, "Report Upload Progress",
- CefUrlRequestFlags.UR_FLAG_REPORT_UPLOAD_PROGRESS,
- "If set upload progress events will be generated when a request has a body", false);
- addRequestFlag(flagsPanel, "Report RawHeaders",
- CefUrlRequestFlags.UR_FLAG_REPORT_RAW_HEADERS,
- "If set the headers sent and received for the request will be recorded", false);
- addRequestFlag(flagsPanel, "No download data", CefUrlRequestFlags.UR_FLAG_NO_DOWNLOAD_DATA,
- "If set the CefURLRequestClient.onDownloadData method will not be called", false);
- addRequestFlag(flagsPanel, "No retry on 5xx", CefUrlRequestFlags.UR_FLAG_NO_RETRY_ON_5XX,
- "If set 5XX redirect errors will be propagated to the observer instead of automatically re-tried.",
- false);
-
- // Table for header values
- JPanel headerValues = createPanelWithTable("Header Values", headerTblModel);
- headerTblModel.addEntry("User-Agent", "Mozilla/5.0 JCEF Example Agent");
- headerTblModel.addEntry("Accept",
- "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
-
- // Table for post-data
- JPanel postData = createPanelWithTable("Post Data", postDataModel);
-
- // Create view
- JPanel headerPanel = new JPanel(new GridBagLayout());
- GridBagConstraints c = new GridBagConstraints();
- c.fill = GridBagConstraints.HORIZONTAL;
- c.weightx = 0.5;
- c.gridx = 0;
- c.gridy = 0;
- headerPanel.add(urlPanel, c);
- c.gridx = 1;
- headerPanel.add(cookiePanel, c);
- c.gridx = 0;
- c.gridy = 1;
- c.gridwidth = 2;
- c.weightx = 0.0;
- headerPanel.add(requestModePanel, c);
-
- JPanel centerPanel = new JPanel(new GridLayout(2, 0));
- centerPanel.add(headerValues);
- centerPanel.add(postData);
-
- JButton abortButton = new JButton("Abort");
- abortButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- setVisible(false);
- dispose();
- }
- });
-
- JButton sendButton = new JButton("Send");
- sendButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- CefRequest request = createRequest();
- if (request == null) return;
-
- UrlRequestDialogReply handleRequest =
- new UrlRequestDialogReply(owner_, getTitle() + " - Result");
- handleRequest.send(request);
- handleRequest.setVisible(true);
- setVisible(false);
- dispose();
- }
- });
-
- JPanel bottomPanel = new JPanel(new GridLayout(0, 2));
- bottomPanel.add(abortButton);
- bottomPanel.add(sendButton);
-
- add(headerPanel, BorderLayout.PAGE_START);
- add(flagsPanel, BorderLayout.LINE_START);
- add(centerPanel, BorderLayout.CENTER);
- add(bottomPanel, BorderLayout.PAGE_END);
- }
-
- private void addRequestMode(
- JPanel panel, ButtonGroup buttonGrp, String requestMode, boolean selected) {
- JRadioButton button = new JRadioButton(requestMode, selected);
- buttonGrp.add(button);
- panel.add(button);
- requestMethods.addElement(button);
- }
-
- private void addRequestFlag(
- JPanel panel, String flag, int value, String tooltip, boolean selected) {
- JCheckBox checkBox = new JCheckBox(flag, selected);
- checkBox.setToolTipText(tooltip);
- panel.add(checkBox);
- requestFlags.put(checkBox, value);
- }
-
- private JPanel createPanelWithTitle(String title, int rows, int cols) {
- JPanel result = new JPanel(new GridLayout(rows, cols));
- result.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(title),
- BorderFactory.createEmptyBorder(10, 10, 10, 10)));
- return result;
- }
-
- private JPanel createPanelWithTable(String title, TableModel tblModel) {
- final TableModel localTblModel = tblModel;
- JPanel result = new JPanel(new BorderLayout());
- result.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(title),
- BorderFactory.createEmptyBorder(10, 10, 10, 10)));
-
- JTable table = new JTable(tblModel);
- table.setFillsViewportHeight(true);
- JScrollPane scrollPane = new JScrollPane(table);
-
- JPanel buttonPane = new JPanel(new GridLayout(0, 2));
- JButton addButton = new JButton("Add entry");
- addButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- localTblModel.newDefaultEntry();
- }
- });
- buttonPane.add(addButton);
-
- JButton delButton = new JButton("Remove entry");
- delButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- localTblModel.removeSelected();
- }
- });
- buttonPane.add(delButton);
-
- result.add(scrollPane, BorderLayout.CENTER);
- result.add(buttonPane, BorderLayout.PAGE_END);
-
- return result;
- }
-
- private class TableModel extends AbstractTableModel {
- private final String[] columnNames;
- private Vector rowData = new Vector<>();
- private final boolean hasKeyColumn_;
-
- public TableModel(boolean hasKeyColumn) {
- super();
- hasKeyColumn_ = hasKeyColumn;
- if (hasKeyColumn)
- columnNames = new String[] {"Key", "Value", ""};
- else
- columnNames = new String[] {"Value", ""};
- }
-
- public void newDefaultEntry() {
- int row = rowData.size();
- if (hasKeyColumn_) {
- Object[] rowEntry = {"key", "value", new Boolean(false)};
- rowData.addElement(rowEntry);
- } else {
- Object[] rowEntry = {"value", new Boolean(false)};
- rowData.addElement(rowEntry);
- }
- fireTableRowsInserted(row, row);
- }
-
- public void removeSelected() {
- int idx = hasKeyColumn_ ? 2 : 1;
- for (int i = 0; i < rowData.size(); ++i) {
- if ((Boolean) rowData.get(i)[idx]) {
- rowData.remove(i);
- fireTableRowsDeleted(i, i);
- i--;
- }
- }
- }
-
- public void addEntry(String key, String value) {
- int row = rowData.size();
- if (hasKeyColumn_) {
- Object[] rowEntry = {key, value, new Boolean(false)};
- rowData.addElement(rowEntry);
- } else {
- Object[] rowEntry = {value, new Boolean(false)};
- rowData.addElement(rowEntry);
- }
- fireTableRowsInserted(row, row);
- }
-
- @Override
- public int getRowCount() {
- return rowData.size();
- }
-
- @Override
- public int getColumnCount() {
- return columnNames.length;
- }
-
- @Override
- public String getColumnName(int column) {
- return columnNames[column];
- }
-
- @Override
- public Class> getColumnClass(int columnIndex) {
- if (rowData.size() > 0) return rowData.get(0)[columnIndex].getClass();
- return Object.class;
- }
-
- @Override
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- return true;
- }
-
- @Override
- public Object getValueAt(int rowIndex, int columnIndex) {
- return rowData.get(rowIndex)[columnIndex];
- }
-
- @Override
- public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
- rowData.get(rowIndex)[columnIndex] = aValue;
- fireTableCellUpdated(rowIndex, columnIndex);
- }
- }
-}
diff --git a/java/tests/detailed/dialog/UrlRequestDialogReply.java b/java/tests/detailed/dialog/UrlRequestDialogReply.java
deleted file mode 100644
index 861388d3..00000000
--- a/java/tests/detailed/dialog/UrlRequestDialogReply.java
+++ /dev/null
@@ -1,188 +0,0 @@
-// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
-// reserved. Use of this source code is governed by a BSD-style license that
-// can be found in the LICENSE file.
-
-package tests.detailed.dialog;
-
-import org.cef.callback.CefAuthCallback;
-import org.cef.callback.CefURLRequestClient;
-import org.cef.network.CefRequest;
-import org.cef.network.CefResponse;
-import org.cef.network.CefURLRequest;
-import org.cef.network.CefURLRequest.Status;
-
-import java.awt.BorderLayout;
-import java.awt.Frame;
-import java.awt.GridLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.io.ByteArrayOutputStream;
-import java.io.UnsupportedEncodingException;
-
-import javax.swing.BorderFactory;
-import javax.swing.BoxLayout;
-import javax.swing.JButton;
-import javax.swing.JDialog;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.SwingUtilities;
-
-@SuppressWarnings("serial")
-public class UrlRequestDialogReply extends JDialog implements CefURLRequestClient {
- private long nativeRef_ = 0;
- private final JLabel statusLabel_ = new JLabel("HTTP-Request status: ");
- private final JTextArea sentRequest_ = new JTextArea();
- private final JTextArea repliedResult_ = new JTextArea();
- private final JButton cancelButton_ = new JButton("Cancel");
- private CefURLRequest urlRequest_ = null;
- private final Frame owner_;
- private ByteArrayOutputStream byteStream_ = new ByteArrayOutputStream();
-
- public UrlRequestDialogReply(Frame owner, String title) {
- super(owner, title, false);
- setLayout(new BorderLayout());
- setSize(800, 600);
-
- owner_ = owner;
-
- JPanel controlPanel = new JPanel();
- controlPanel.setLayout(new BoxLayout(controlPanel, BoxLayout.X_AXIS));
- JButton doneButton = new JButton("Done");
- doneButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- urlRequest_.dispose();
- setVisible(false);
- dispose();
- }
- });
- controlPanel.add(doneButton);
-
- cancelButton_.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- if (urlRequest_ != null) {
- urlRequest_.cancel();
- }
- }
- });
- cancelButton_.setEnabled(false);
- controlPanel.add(cancelButton_);
-
- JPanel requestPane = createPanelWithTitle("Sent HTTP-Request", 1, 0);
- requestPane.add(new JScrollPane(sentRequest_));
-
- JPanel replyPane = createPanelWithTitle("Reply from the server", 1, 0);
- replyPane.add(new JScrollPane(repliedResult_));
-
- JPanel contentPane = new JPanel(new GridLayout(2, 0));
- contentPane.add(requestPane);
- contentPane.add(replyPane);
-
- add(statusLabel_, BorderLayout.PAGE_START);
- add(contentPane, BorderLayout.CENTER);
- add(controlPanel, BorderLayout.PAGE_END);
- }
-
- private JPanel createPanelWithTitle(String title, int rows, int cols) {
- JPanel result = new JPanel(new GridLayout(rows, cols));
- result.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(title),
- BorderFactory.createEmptyBorder(10, 10, 10, 10)));
- return result;
- }
-
- public void send(CefRequest request) {
- if (request == null) {
- statusLabel_.setText("HTTP-Request status: FAILED");
- sentRequest_.append("Can't send CefRequest because it is NULL");
- cancelButton_.setEnabled(false);
- return;
- }
-
- urlRequest_ = CefURLRequest.create(request, this);
- if (urlRequest_ == null) {
- statusLabel_.setText("HTTP-Request status: FAILED");
- sentRequest_.append("Can't send CefRequest because creation of CefURLRequest failed.");
- repliedResult_.append(
- "The native code (CEF) returned a NULL-Pointer for CefURLRequest.");
- cancelButton_.setEnabled(false);
- } else {
- sentRequest_.append(request.toString());
- cancelButton_.setEnabled(true);
- updateStatus("", false);
- }
- }
-
- private void updateStatus(final String updateMsg, final boolean printByteStream) {
- final Status status = urlRequest_.getRequestStatus();
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- statusLabel_.setText("HTTP-Request status: " + status);
- if (status != Status.UR_UNKNOWN && status != Status.UR_IO_PENDING) {
- cancelButton_.setEnabled(false);
- }
- repliedResult_.append(updateMsg);
- if (printByteStream) {
- try {
- repliedResult_.append("\n\n" + byteStream_.toString("UTF-8"));
- } catch (UnsupportedEncodingException e) {
- repliedResult_.append("\n\n" + byteStream_.toString());
- }
- }
- }
- };
-
- if (SwingUtilities.isEventDispatchThread()) {
- runnable.run();
- } else {
- SwingUtilities.invokeLater(runnable);
- }
- }
-
- // CefURLRequestClient
-
- @Override
- public void setNativeRef(String identifer, long nativeRef) {
- nativeRef_ = nativeRef;
- }
-
- @Override
- public long getNativeRef(String identifer) {
- return nativeRef_;
- }
-
- @Override
- public void onRequestComplete(CefURLRequest request) {
- String updateStr = "onRequestCompleted\n\n";
- CefResponse response = request.getResponse();
- boolean isText = response.getHeaderByName("Content-Type").startsWith("text");
- updateStr += response.toString();
- updateStatus(updateStr, isText);
- }
-
- @Override
- public void onUploadProgress(CefURLRequest request, int current, int total) {
- updateStatus("onUploadProgress: " + current + "/" + total + " bytes\n", false);
- }
-
- @Override
- public void onDownloadProgress(CefURLRequest request, int current, int total) {
- updateStatus("onDownloadProgress: " + current + "/" + total + " bytes\n", false);
- }
-
- @Override
- public void onDownloadData(CefURLRequest request, byte[] data, int data_length) {
- byteStream_.write(data, 0, data_length);
- updateStatus("onDownloadData: " + data_length + " bytes\n", false);
- }
-
- @Override
- public boolean getAuthCredentials(boolean isProxy, String host, int port, String realm,
- String scheme, CefAuthCallback callback) {
- SwingUtilities.invokeLater(new PasswordDialog(owner_, callback));
- return true;
- }
-}
diff --git a/java/tests/detailed/handler/AppHandler.java b/java/tests/detailed/handler/AppHandler.java
deleted file mode 100644
index 45ec49bb..00000000
--- a/java/tests/detailed/handler/AppHandler.java
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
-// reserved. Use of this source code is governed by a BSD-style license that
-// can be found in the LICENSE file.
-
-package tests.detailed.handler;
-
-import org.cef.CefApp;
-import org.cef.CefApp.CefAppState;
-import org.cef.browser.CefBrowser;
-import org.cef.browser.CefFrame;
-import org.cef.callback.CefSchemeHandlerFactory;
-import org.cef.callback.CefSchemeRegistrar;
-import org.cef.handler.CefAppHandlerAdapter;
-import org.cef.handler.CefResourceHandler;
-import org.cef.network.CefRequest;
-
-public class AppHandler extends CefAppHandlerAdapter {
- // We're registering our own schemes to demonstrate how to use
- // CefAppHandler.onRegisterCustomSchemes() in combination with
- // CefApp.registerSchemeHandlerFactory().
- public AppHandler(String[] args) {
- super(args);
- }
-
- // (1) First of all we have to register our custom schemes by implementing
- // the method "onRegisterCustomSchemes. The scheme names are added by
- // calling CefSchemeRegistrar.addCustomScheme.
- @Override
- public void onRegisterCustomSchemes(CefSchemeRegistrar registrar) {
- if (registrar.addCustomScheme(
- SearchSchemeHandler.scheme, true, false, false, false, true, false, false)) {
- System.out.println("Added scheme " + SearchSchemeHandler.scheme + "://");
- }
- if (registrar.addCustomScheme(
- ClientSchemeHandler.scheme, true, false, false, false, true, false, false)) {
- System.out.println("Added scheme " + ClientSchemeHandler.scheme + "://");
- }
- }
-
- // (2) At the next step we have to register a SchemeHandlerFactory which is
- // called if an user enters our registered scheme.
- //
- // This is done via the CefApp.registerSchemeHandlerFactory() method.
- // A good place to call this function is from
- // CefAppHandler.onContextInitialized().
- //
- // The empty |domain_name| value will cause the factory to match all
- // domain names. A set |domain_name| will only be valid for the entered
- // domain.
- @Override
- public void onContextInitialized() {
- CefApp cefApp = CefApp.getInstance();
- cefApp.registerSchemeHandlerFactory(
- SearchSchemeHandler.scheme, SearchSchemeHandler.domain, new SchemeHandlerFactory());
- cefApp.registerSchemeHandlerFactory(
- ClientSchemeHandler.scheme, ClientSchemeHandler.domain, new SchemeHandlerFactory());
- }
-
- // (3) The SchemeHandlerFactory creates a new ResourceHandler instance for each
- // request the user has send to the browser. The ResourceHandler is the
- // responsible class to process and return the result of a received
- // request.
- private class SchemeHandlerFactory implements CefSchemeHandlerFactory {
- @Override
- public CefResourceHandler create(
- CefBrowser browser, CefFrame frame, String schemeName, CefRequest request) {
- if (schemeName.equals(SearchSchemeHandler.scheme))
- return new SearchSchemeHandler(browser);
- else if (schemeName.equals(ClientSchemeHandler.scheme))
- return new ClientSchemeHandler();
- return null;
- }
- }
-
- @Override
- public void stateHasChanged(CefAppState state) {
- System.out.println("AppHandler.stateHasChanged: " + state);
- if (state == CefAppState.TERMINATED) System.exit(0);
- }
-}
diff --git a/java/tests/detailed/handler/ClientSchemeHandler.java b/java/tests/detailed/handler/ClientSchemeHandler.java
deleted file mode 100644
index 2ee156ff..00000000
--- a/java/tests/detailed/handler/ClientSchemeHandler.java
+++ /dev/null
@@ -1,134 +0,0 @@
-// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
-// reserved. Use of this source code is governed by a BSD-style license that
-// can be found in the LICENSE file.
-
-package tests.detailed.handler;
-
-import org.cef.callback.CefCallback;
-import org.cef.handler.CefResourceHandlerAdapter;
-import org.cef.misc.IntRef;
-import org.cef.misc.StringRef;
-import org.cef.network.CefRequest;
-import org.cef.network.CefResponse;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * The example for the second scheme with domain handling is a more
- * complex example and is taken from the parent project CEF. Please
- * see CEF: "cefclient/scheme_test.cpp" for futher details
- */
-public class ClientSchemeHandler extends CefResourceHandlerAdapter {
- public static final String scheme = "client";
- public static final String domain = "tests";
-
- private byte[] data_;
- private String mime_type_;
- private int offset_ = 0;
-
- public ClientSchemeHandler() {
- super();
- }
-
- @Override
- public synchronized boolean processRequest(CefRequest request, CefCallback callback) {
- boolean handled = false;
- String url = request.getURL();
- if (url.indexOf("handler.html") != -1) {
- // Build the response html
- String html;
- html = "Client Scheme Handler "
- + ""
- + "This contents of this page page are served by the "
- + "ClientSchemeHandler class handling the client:// protocol."
- + " You should see an image:"
- + "";
-
- // Output a string representation of the request
- html += request.toString();
-
- html += " Try the test form:"
- + "";
-
- data_ = html.getBytes();
-
- handled = true;
- // Set the resulting mime type
- mime_type_ = "text/html";
- } else if (url.endsWith(".png")) {
- handled = loadContent(url.substring(url.lastIndexOf('/') + 1));
- mime_type_ = "image/png";
- } else if (url.endsWith(".html")) {
- handled = loadContent(url.substring(url.lastIndexOf('/') + 1));
- mime_type_ = "text/html";
- if (!handled) {
- String html = "Error 404 ";
- html += "Error 404 ";
- html += "File " + url.substring(url.lastIndexOf('/') + 1) + " ";
- html += "does not exist";
- data_ = html.getBytes();
- handled = true;
- }
- }
-
- if (handled) {
- // Indicate the headers are available.
- callback.Continue();
- return true;
- }
-
- return false;
- }
-
- @Override
- public void getResponseHeaders(
- CefResponse response, IntRef response_length, StringRef redirectUrl) {
- response.setMimeType(mime_type_);
- response.setStatus(200);
-
- // Set the resulting response length
- response_length.set(data_.length);
- }
-
- @Override
- public synchronized boolean readResponse(
- byte[] data_out, int bytes_to_read, IntRef bytes_read, CefCallback callback) {
- boolean has_data = false;
-
- if (offset_ < data_.length) {
- // Copy the next block of data into the buffer.
- int transfer_size = Math.min(bytes_to_read, (data_.length - offset_));
- System.arraycopy(data_, offset_, data_out, 0, transfer_size);
- offset_ += transfer_size;
-
- bytes_read.set(transfer_size);
- has_data = true;
- } else {
- offset_ = 0;
- bytes_read.set(0);
- }
-
- return has_data;
- }
-
- private boolean loadContent(String resName) {
- InputStream inStream = getClass().getResourceAsStream(resName);
- if (inStream != null) {
- try {
- ByteArrayOutputStream outFile = new ByteArrayOutputStream();
- int readByte = -1;
- while ((readByte = inStream.read()) >= 0) outFile.write(readByte);
- data_ = outFile.toByteArray();
- return true;
- } catch (IOException e) {
- }
- }
- return false;
- }
-}
diff --git a/java/tests/detailed/handler/ContextMenuHandler.java b/java/tests/detailed/handler/ContextMenuHandler.java
deleted file mode 100644
index c18c76b8..00000000
--- a/java/tests/detailed/handler/ContextMenuHandler.java
+++ /dev/null
@@ -1,101 +0,0 @@
-// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
-// reserved. Use of this source code is governed by a BSD-style license that
-// can be found in the LICENSE file.
-
-package tests.detailed.handler;
-
-import org.cef.browser.CefBrowser;
-import org.cef.browser.CefFrame;
-import org.cef.callback.CefContextMenuParams;
-import org.cef.callback.CefMenuModel;
-import org.cef.callback.CefMenuModel.MenuId;
-import org.cef.handler.CefContextMenuHandler;
-
-import java.awt.Frame;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Vector;
-
-import tests.detailed.dialog.SearchDialog;
-import tests.detailed.dialog.ShowTextDialog;
-
-public class ContextMenuHandler implements CefContextMenuHandler {
- private final Frame owner_;
- private Map suggestions_ = new HashMap();
-
- public ContextMenuHandler(Frame owner) {
- owner_ = owner;
- }
-
- @Override
- public void onBeforeContextMenu(
- CefBrowser browser, CefFrame frame, CefContextMenuParams params, CefMenuModel model) {
- model.clear();
-
- // Navigation menu
- model.addItem(MenuId.MENU_ID_BACK, "Back");
- model.setEnabled(MenuId.MENU_ID_BACK, browser.canGoBack());
-
- model.addItem(MenuId.MENU_ID_FORWARD, "Forward");
- model.setEnabled(MenuId.MENU_ID_FORWARD, browser.canGoForward());
-
- model.addSeparator();
- model.addItem(MenuId.MENU_ID_FIND, "Find...");
- if (params.hasImageContents() && params.getSourceUrl() != null)
- model.addItem(MenuId.MENU_ID_USER_FIRST, "Download Image...");
- model.addItem(MenuId.MENU_ID_VIEW_SOURCE, "View Source...");
-
- Vector suggestions = new Vector();
- params.getDictionarySuggestions(suggestions);
-
- // Spell checking menu
- model.addSeparator();
- if (suggestions.size() == 0) {
- model.addItem(MenuId.MENU_ID_NO_SPELLING_SUGGESTIONS, "No suggestions");
- model.setEnabled(MenuId.MENU_ID_NO_SPELLING_SUGGESTIONS, false);
- return;
- }
-
- int id = MenuId.MENU_ID_SPELLCHECK_SUGGESTION_0;
- for (String suggestedWord : suggestions) {
- model.addItem(id, suggestedWord);
- suggestions_.put(id, suggestedWord);
- if (++id > MenuId.MENU_ID_SPELLCHECK_SUGGESTION_LAST) break;
- }
- }
-
- @Override
- public boolean onContextMenuCommand(CefBrowser browser, CefFrame frame,
- CefContextMenuParams params, int commandId, int eventFlags) {
- switch (commandId) {
- case MenuId.MENU_ID_VIEW_SOURCE:
- ShowTextDialog visitor =
- new ShowTextDialog(owner_, "Source of \"" + browser.getURL() + "\"");
- browser.getSource(visitor);
- return true;
- case MenuId.MENU_ID_FIND:
- SearchDialog search = new SearchDialog(owner_, browser);
- search.setVisible(true);
- return true;
- case MenuId.MENU_ID_USER_FIRST:
- browser.startDownload(params.getSourceUrl());
- return true;
- default:
- if (commandId >= MenuId.MENU_ID_SPELLCHECK_SUGGESTION_0) {
- String newWord = suggestions_.get(commandId);
- if (newWord != null) {
- System.err.println(
- "replacing " + params.getMisspelledWord() + " with " + newWord);
- browser.replaceMisspelling(newWord);
- return true;
- }
- }
- return false;
- }
- }
-
- @Override
- public void onContextMenuDismissed(CefBrowser browser, CefFrame frame) {
- suggestions_.clear();
- }
-}
diff --git a/java/tests/detailed/handler/DragHandler.java b/java/tests/detailed/handler/DragHandler.java
deleted file mode 100644
index ee7d36aa..00000000
--- a/java/tests/detailed/handler/DragHandler.java
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
-// reserved. Use of this source code is governed by a BSD-style license that
-// can be found in the LICENSE file.
-
-package tests.detailed.handler;
-
-import org.cef.browser.CefBrowser;
-import org.cef.callback.CefDragData;
-import org.cef.handler.CefDragHandler;
-
-public class DragHandler implements CefDragHandler {
- @Override
- public boolean onDragEnter(CefBrowser browser, CefDragData dragData, int mask) {
- System.out.println("DRAG:");
- System.out.print(" flags:");
- if ((mask & CefDragHandler.DragOperationMask.DRAG_OPERATION_COPY) != 0)
- System.out.print(" COPY");
- if ((mask & CefDragHandler.DragOperationMask.DRAG_OPERATION_LINK) != 0)
- System.out.print(" LINK");
- if ((mask & CefDragHandler.DragOperationMask.DRAG_OPERATION_GENERIC) != 0)
- System.out.print(" GENERIC");
- if ((mask & CefDragHandler.DragOperationMask.DRAG_OPERATION_PRIVATE) != 0)
- System.out.print(" PRIVATE");
- if ((mask & CefDragHandler.DragOperationMask.DRAG_OPERATION_MOVE) != 0)
- System.out.print(" MOVE");
- if ((mask & CefDragHandler.DragOperationMask.DRAG_OPERATION_DELETE) != 0)
- System.out.print(" DELETE");
- System.out.println("\n " + dragData);
- return false;
- }
-}
diff --git a/java/tests/detailed/handler/JSDialogHandler.java b/java/tests/detailed/handler/JSDialogHandler.java
deleted file mode 100644
index 417a55fb..00000000
--- a/java/tests/detailed/handler/JSDialogHandler.java
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
-// reserved. Use of this source code is governed by a BSD-style license that
-// can be found in the LICENSE file.
-
-package tests.detailed.handler;
-
-import org.cef.browser.CefBrowser;
-import org.cef.callback.CefJSDialogCallback;
-import org.cef.handler.CefJSDialogHandlerAdapter;
-import org.cef.misc.BoolRef;
-
-public class JSDialogHandler extends CefJSDialogHandlerAdapter {
- @Override
- public boolean onJSDialog(CefBrowser browser, String origin_url, JSDialogType dialog_type,
- String message_text, String default_prompt_text, CefJSDialogCallback callback,
- BoolRef suppress_message) {
- if (message_text.equalsIgnoreCase("Never displayed")) {
- suppress_message.set(true);
- System.out.println(
- "The " + dialog_type + " from origin \"" + origin_url + "\" was suppressed.");
- System.out.println(
- " The content of the suppressed dialog was: \"" + message_text + "\"");
- }
- return false;
- }
-}
diff --git a/java/tests/detailed/handler/KeyboardHandler.java b/java/tests/detailed/handler/KeyboardHandler.java
deleted file mode 100644
index 6785b550..00000000
--- a/java/tests/detailed/handler/KeyboardHandler.java
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
-// reserved. Use of this source code is governed by a BSD-style license that
-// can be found in the LICENSE file.
-
-package tests.detailed.handler;
-
-import org.cef.browser.CefBrowser;
-import org.cef.handler.CefKeyboardHandlerAdapter;
-
-public class KeyboardHandler extends CefKeyboardHandlerAdapter {
- @Override
- public boolean onKeyEvent(CefBrowser browser, CefKeyEvent event) {
- if (!event.focus_on_editable_field && event.windows_key_code == 0x20) {
- // Special handling for the space character when an input element does not
- // have focus. Handling the event in OnPreKeyEvent() keeps the event from
- // being processed in the renderer. If we instead handled the event in the
- // OnKeyEvent() method the space key would cause the window to scroll in
- // addition to showing the alert box.
- if (event.type == CefKeyEvent.EventType.KEYEVENT_RAWKEYDOWN) {
- browser.executeJavaScript("alert('You pressed the space bar!');", "", 0);
- }
- return true;
- } else if (event.type == CefKeyEvent.EventType.KEYEVENT_RAWKEYDOWN && event.is_system_key) {
- // CMD+[key] is not working on a Mac.
- // This switch statement delegates the common keyboard shortcuts to the browser
- switch (event.unmodified_character) {
- case 'a':
- browser.getFocusedFrame().selectAll();
- break;
- case 'c':
- browser.getFocusedFrame().copy();
- break;
- case 'v':
- browser.getFocusedFrame().paste();
- break;
- case 'x':
- browser.getFocusedFrame().cut();
- break;
- case 'z':
- browser.getFocusedFrame().undo();
- break;
- case 'Z':
- browser.getFocusedFrame().redo();
- break;
- default:
- return false;
- }
- return true;
- }
- return false;
- }
-}
diff --git a/java/tests/detailed/handler/MessageRouterHandler.java b/java/tests/detailed/handler/MessageRouterHandler.java
deleted file mode 100644
index 1d37c85a..00000000
--- a/java/tests/detailed/handler/MessageRouterHandler.java
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
-// reserved. Use of this source code is governed by a BSD-style license that
-// can be found in the LICENSE file.
-
-package tests.detailed.handler;
-
-import org.cef.browser.CefBrowser;
-import org.cef.browser.CefFrame;
-import org.cef.callback.CefQueryCallback;
-import org.cef.handler.CefMessageRouterHandlerAdapter;
-
-public class MessageRouterHandler extends CefMessageRouterHandlerAdapter {
- @Override
- public boolean onQuery(CefBrowser browser, CefFrame frame, long query_id, String request,
- boolean persistent, CefQueryCallback callback) {
- if (request.indexOf("BindingTest:") == 0) {
- // Reverse the message and return it to the JavaScript caller.
- String msg = request.substring(12);
- callback.success(new StringBuilder(msg).reverse().toString());
- return true;
- }
- // Not handled.
- return false;
- }
-}
diff --git a/java/tests/detailed/handler/MessageRouterHandlerEx.java b/java/tests/detailed/handler/MessageRouterHandlerEx.java
deleted file mode 100644
index bc4b780b..00000000
--- a/java/tests/detailed/handler/MessageRouterHandlerEx.java
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
-// reserved. Use of this source code is governed by a BSD-style license that
-// can be found in the LICENSE file.
-
-package tests.detailed.handler;
-
-import org.cef.CefClient;
-import org.cef.browser.CefBrowser;
-import org.cef.browser.CefFrame;
-import org.cef.browser.CefMessageRouter;
-import org.cef.browser.CefMessageRouter.CefMessageRouterConfig;
-import org.cef.callback.CefQueryCallback;
-import org.cef.handler.CefMessageRouterHandlerAdapter;
-
-public class MessageRouterHandlerEx extends CefMessageRouterHandlerAdapter {
- private final CefClient client_;
- private final CefMessageRouterConfig config_ =
- new CefMessageRouterConfig("myQuery", "myQueryAbort");
- private CefMessageRouter router_ = null;
-
- public MessageRouterHandlerEx(final CefClient client) {
- client_ = client;
- }
-
- @Override
- public boolean onQuery(CefBrowser browser, CefFrame frame, long query_id, String request,
- boolean persistent, CefQueryCallback callback) {
- if (request.startsWith("hasExtension")) {
- if (router_ != null)
- callback.success("");
- else
- callback.failure(0, "");
- } else if (request.startsWith("enableExt")) {
- if (router_ != null) {
- callback.failure(-1, "Already enabled");
- } else {
- router_ = CefMessageRouter.create(config_, new JavaVersionMessageRouter());
- client_.addMessageRouter(router_);
- callback.success("");
- }
- } else if (request.startsWith("disableExt")) {
- if (router_ == null) {
- callback.failure(-2, "Already disabled");
- } else {
- client_.removeMessageRouter(router_);
- router_.dispose();
- router_ = null;
- callback.success("");
- }
- } else {
- // not handled
- return false;
- }
- return true;
- }
-
- private class JavaVersionMessageRouter extends CefMessageRouterHandlerAdapter {
- @Override
- public boolean onQuery(CefBrowser browser, CefFrame frame, long query_id, String request,
- boolean persistent, CefQueryCallback callback) {
- if (request.startsWith("jcefJava")) {
- callback.success(System.getProperty("java.version"));
- return true;
- }
- return false;
- };
- }
-}
diff --git a/java/tests/detailed/handler/RequestHandler.java b/java/tests/detailed/handler/RequestHandler.java
deleted file mode 100644
index d80e1251..00000000
--- a/java/tests/detailed/handler/RequestHandler.java
+++ /dev/null
@@ -1,167 +0,0 @@
-// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
-// reserved. Use of this source code is governed by a BSD-style license that
-// can be found in the LICENSE file.
-
-package tests.detailed.handler;
-
-import org.cef.browser.CefBrowser;
-import org.cef.browser.CefFrame;
-import org.cef.callback.CefAuthCallback;
-import org.cef.callback.CefCallback;
-import org.cef.handler.CefLoadHandler.ErrorCode;
-import org.cef.handler.CefRequestHandler;
-import org.cef.handler.CefResourceHandler;
-import org.cef.handler.CefResourceRequestHandler;
-import org.cef.handler.CefResourceRequestHandlerAdapter;
-import org.cef.misc.BoolRef;
-import org.cef.network.CefPostData;
-import org.cef.network.CefPostDataElement;
-import org.cef.network.CefRequest;
-
-import java.awt.Frame;
-import java.util.HashMap;
-import java.util.Vector;
-
-import javax.swing.JOptionPane;
-import javax.swing.SwingUtilities;
-
-import tests.detailed.dialog.CertErrorDialog;
-import tests.detailed.dialog.PasswordDialog;
-
-public class RequestHandler extends CefResourceRequestHandlerAdapter implements CefRequestHandler {
- private final Frame owner_;
-
- public RequestHandler(Frame owner) {
- owner_ = owner;
- }
-
- @Override
- public boolean onBeforeBrowse(CefBrowser browser, CefFrame frame, CefRequest request,
- boolean user_gesture, boolean is_redirect) {
- CefPostData postData = request.getPostData();
- if (postData != null) {
- Vector elements = new Vector();
- postData.getElements(elements);
- for (CefPostDataElement el : elements) {
- int numBytes = el.getBytesCount();
- if (numBytes <= 0) continue;
-
- byte[] readBytes = new byte[numBytes];
- if (el.getBytes(numBytes, readBytes) <= 0) continue;
-
- String readString = new String(readBytes);
- if (readString.indexOf("ignore") > -1) {
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- JOptionPane.showMessageDialog(owner_,
- "The request was rejected because you've entered \"ignore\" into the form.");
- }
- });
- return true;
- }
- }
- }
- return false;
- }
-
- @Override
- public boolean onOpenURLFromTab(
- CefBrowser browser, CefFrame frame, String target_url, boolean user_gesture) {
- return false;
- }
-
- @Override
- public CefResourceRequestHandler getResourceRequestHandler(CefBrowser browser, CefFrame frame,
- CefRequest request, boolean isNavigation, boolean isDownload, String requestInitiator,
- BoolRef disableDefaultHandling) {
- return this;
- }
-
- @Override
- public boolean onBeforeResourceLoad(CefBrowser browser, CefFrame frame, CefRequest request) {
- // If you send a HTTP-POST request to http://www.google.com/
- // google rejects your request because they don't allow HTTP-POST.
- //
- // This test extracts the value of the test form.
- // (see "Show Form" entry within BrowserMenuBar)
- // and sends its value as HTTP-GET request to Google.
- if (request.getMethod().equalsIgnoreCase("POST")
- && request.getURL().equals("http://www.google.com/")) {
- String forwardTo = "http://www.google.com/#q=";
- CefPostData postData = request.getPostData();
- boolean sendAsGet = false;
- if (postData != null) {
- Vector elements = new Vector();
- postData.getElements(elements);
- for (CefPostDataElement el : elements) {
- int numBytes = el.getBytesCount();
- if (numBytes <= 0) continue;
-
- byte[] readBytes = new byte[numBytes];
- if (el.getBytes(numBytes, readBytes) <= 0) continue;
-
- String readString = new String(readBytes).trim();
- String[] stringPairs = readString.split("&");
- for (String s : stringPairs) {
- int startPos = s.indexOf('=');
- if (s.startsWith("searchFor"))
- forwardTo += s.substring(startPos + 1);
- else if (s.startsWith("sendAsGet")) {
- sendAsGet = true;
- }
- }
- }
- if (sendAsGet) postData.removeElements();
- }
- if (sendAsGet) {
- request.setFlags(0);
- request.setMethod("GET");
- request.setURL(forwardTo);
- request.setFirstPartyForCookies(forwardTo);
- HashMap headerMap = new HashMap<>();
- request.getHeaderMap(headerMap);
- headerMap.remove("Content-Type");
- headerMap.remove("Origin");
- request.setHeaderMap(headerMap);
- }
- }
- return false;
- }
-
- @Override
- public CefResourceHandler getResourceHandler(
- CefBrowser browser, CefFrame frame, CefRequest request) {
- // the non existing domain "foo.bar" is handled by the ResourceHandler implementation
- // E.g. if you try to load the URL http://www.foo.bar, you'll be forwarded
- // to the ResourceHandler class.
- if (request.getURL().endsWith("foo.bar/")) {
- return new ResourceHandler();
- }
-
- if (request.getURL().endsWith("seterror.test/")) {
- return new ResourceSetErrorHandler();
- }
-
- return null;
- }
-
- @Override
- public boolean getAuthCredentials(CefBrowser browser, String origin_url, boolean isProxy,
- String host, int port, String realm, String scheme, CefAuthCallback callback) {
- SwingUtilities.invokeLater(new PasswordDialog(owner_, callback));
- return true;
- }
-
- @Override
- public boolean onCertificateError(
- CefBrowser browser, ErrorCode cert_error, String request_url, CefCallback callback) {
- SwingUtilities.invokeLater(new CertErrorDialog(owner_, cert_error, request_url, callback));
- return true;
- }
-
- @Override
- public void onRenderProcessTerminated(CefBrowser browser, TerminationStatus status) {
- System.out.println("render process terminated: " + status);
- }
-}
diff --git a/java/tests/detailed/handler/ResourceHandler.java b/java/tests/detailed/handler/ResourceHandler.java
deleted file mode 100644
index 4a36e0ee..00000000
--- a/java/tests/detailed/handler/ResourceHandler.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package tests.detailed.handler;
-
-import org.cef.callback.CefCallback;
-import org.cef.handler.CefLoadHandler;
-import org.cef.handler.CefResourceHandlerAdapter;
-import org.cef.misc.IntRef;
-import org.cef.misc.StringRef;
-import org.cef.network.CefRequest;
-import org.cef.network.CefResponse;
-
-import java.nio.ByteBuffer;
-
-public class ResourceHandler extends CefResourceHandlerAdapter {
- private int startPos = 0;
- private static final String html = new String("\n"
- + " \n"
- + " ResourceHandler Test \n"
- + " \n"
- + " \n"
- + " ResourceHandler Test \n"
- + " You have entered the URL: http://www.foo.bar. This page is generated by the application itself and \n"
- + " no HTTP request was sent to the internet.\n"
- + "
See class tests.handler.ResourceHandler and the RequestHandler implementation for details.
\n"
- + " \n"
- + "");
-
- @Override
- public boolean processRequest(CefRequest request, CefCallback callback) {
- System.out.println("processRequest: " + request);
-
- startPos = 0;
- callback.Continue();
- return true;
- }
-
- @Override
- public void getResponseHeaders(
- CefResponse response, IntRef response_length, StringRef redirectUrl) {
- System.out.println("getResponseHeaders: " + response);
-
- response_length.set(html.length());
- response.setMimeType("text/html");
- response.setStatus(200);
- }
-
- @Override
- public boolean readResponse(
- byte[] data_out, int bytes_to_read, IntRef bytes_read, CefCallback callback) {
- int length = html.length();
- if (startPos >= length) return false;
-
- // Extract up to bytes_to_read bytes from the html data
- int endPos = startPos + bytes_to_read;
- String dataToSend =
- (endPos > length) ? html.substring(startPos) : html.substring(startPos, endPos);
-
- // Copy extracted bytes into data_out and set the read length
- // to bytes_read.
- ByteBuffer result = ByteBuffer.wrap(data_out);
- result.put(dataToSend.getBytes());
- bytes_read.set(dataToSend.length());
-
- startPos = endPos;
- return true;
- }
-
- @Override
- public void cancel() {
- System.out.println("cancel");
- startPos = 0;
- }
-}
diff --git a/java/tests/detailed/handler/ResourceSetErrorHandler.java b/java/tests/detailed/handler/ResourceSetErrorHandler.java
deleted file mode 100644
index bc3dd129..00000000
--- a/java/tests/detailed/handler/ResourceSetErrorHandler.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package tests.detailed.handler;
-
-import org.cef.callback.CefCallback;
-import org.cef.handler.CefLoadHandler.ErrorCode;
-import org.cef.handler.CefResourceHandlerAdapter;
-import org.cef.misc.IntRef;
-import org.cef.misc.StringRef;
-import org.cef.network.CefRequest;
-import org.cef.network.CefResponse;
-
-public class ResourceSetErrorHandler extends CefResourceHandlerAdapter {
- @Override
- public boolean processRequest(CefRequest request, CefCallback callback) {
- System.out.println("processRequest: " + request);
- callback.Continue();
- return true;
- }
-
- @Override
- public void getResponseHeaders(
- CefResponse response, IntRef response_length, StringRef redirectUrl) {
- response.setError(ErrorCode.ERR_NOT_IMPLEMENTED);
- System.out.println("getResponseHeaders: " + response);
- }
-}
\ No newline at end of file
diff --git a/java/tests/detailed/handler/SearchSchemeHandler.java b/java/tests/detailed/handler/SearchSchemeHandler.java
deleted file mode 100644
index 8a5c80e1..00000000
--- a/java/tests/detailed/handler/SearchSchemeHandler.java
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
-// reserved. Use of this source code is governed by a BSD-style license that
-// can be found in the LICENSE file.
-
-package tests.detailed.handler;
-
-import org.cef.browser.CefBrowser;
-import org.cef.callback.CefCallback;
-import org.cef.handler.CefResourceHandlerAdapter;
-import org.cef.network.CefRequest;
-
-/**
- * In this case we create a new CefRequest object with
- * http://www.google.com/#q=
- * as target and forward it to the CefBrowser instance.
- * The "search://"-request is aborted by returning false.
- */
-public class SearchSchemeHandler extends CefResourceHandlerAdapter {
- public static final String scheme = "search";
- public static final String domain = "";
-
- private final CefBrowser browser_;
-
- public SearchSchemeHandler(CefBrowser browser) {
- browser_ = browser;
- }
-
- @Override
- public boolean processRequest(CefRequest request, CefCallback callback) {
- // cut away "scheme://"
- String requestUrl = request.getURL();
- String newUrl = requestUrl.substring(scheme.length() + 3);
- // cut away a trailing "/" if any
- if (newUrl.indexOf('/') == newUrl.length() - 1) {
- newUrl = newUrl.substring(0, newUrl.length() - 1);
- }
- newUrl = "http://www.google.com/#q=" + newUrl;
-
- CefRequest newRequest = CefRequest.create();
- if (newRequest != null) {
- newRequest.setMethod("GET");
- newRequest.setURL(newUrl);
- newRequest.setFirstPartyForCookies(newUrl);
- browser_.loadRequest(newRequest);
- }
- return false;
- }
-}
diff --git a/java/tests/detailed/handler/binding_test.html b/java/tests/detailed/handler/binding_test.html
deleted file mode 100644
index 9ee0775e..00000000
--- a/java/tests/detailed/handler/binding_test.html
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-Binding Test
-
-
-
-
-
-
-
diff --git a/java/tests/detailed/handler/binding_test2.html b/java/tests/detailed/handler/binding_test2.html
deleted file mode 100644
index 8a61a96f..00000000
--- a/java/tests/detailed/handler/binding_test2.html
+++ /dev/null
@@ -1,81 +0,0 @@
-
-
-Binding Test - Part 2
-
-
-
-
-
-
-JavaScript Binding Test - Part 2
-While this page was loaded, the JavaScript function
-
window.cefRequest(request: 'hasExtension')
-was executed for enabling/disabling the buttons below.
-
-If you press "Enable myQuery", the JavaScript function
-window.cefRequest(request: 'enableExt')
-is executed. This causes Java to create a second instance of
-CefMessageRouter
-In this case the name of the JavaScript query function is set to "myQuery" and
- a handler for the request 'jcefJava' is registered. Pressing the "Test"
- button will execute the JavaScript code
-window.myRequest(request: 'jcefJava')
-which returns your current Java version on success or an error message in case
- of an error.
-
-Please note: If you leave this page (myQuery enabled) and you return
- after a while - without closing the browser - the JavaScript binding is
- still enabled.
-Second message router:
-
-
-
-
-
-
-
-
diff --git a/java/tests/detailed/handler/localstorage.html b/java/tests/detailed/handler/localstorage.html
deleted file mode 100644
index 87c6e68c..00000000
--- a/java/tests/detailed/handler/localstorage.html
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-Click the "Add Line" button to add a line or the "Clear" button to clear.
-This data will persist across sessions if a cache path was specified.
-
-
-
-
-
-
diff --git a/java/tests/detailed/handler/logo.png b/java/tests/detailed/handler/logo.png
deleted file mode 100644
index a2a15f44..00000000
Binary files a/java/tests/detailed/handler/logo.png and /dev/null differ
diff --git a/java/tests/detailed/handler/spellcheck.html b/java/tests/detailed/handler/spellcheck.html
deleted file mode 100644
index 6334135a..00000000
--- a/java/tests/detailed/handler/spellcheck.html
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-Spellcheck Test
-
-
-
-The next paragraph contains some text to be validated against the spell-checker.
- Click into the following box. To replace a misspelled word use the
-right-mouse-click.
-
-This is a misspelled paragrapph. Withh maany errors Click into this bogx
-to ttest it.
-
-
diff --git a/java/tests/detailed/handler/transparency.html b/java/tests/detailed/handler/transparency.html
deleted file mode 100644
index a8dd3b46..00000000
--- a/java/tests/detailed/handler/transparency.html
+++ /dev/null
@@ -1,63 +0,0 @@
-
-
-
-Transparency Examples
-
-
-
-
-Image Transparency
-Hover over an image to make it fully opaque.
-
-
-
-Block Transparency
-White 0% White 25% White 50% White 75% White 100%
-
-Black 0% Black 25% Black 50% Black 75% Black 100%
-
-
-
diff --git a/java/tests/detailed/ui/ControlPanel.java b/java/tests/detailed/ui/ControlPanel.java
deleted file mode 100644
index c3923dcc..00000000
--- a/java/tests/detailed/ui/ControlPanel.java
+++ /dev/null
@@ -1,182 +0,0 @@
-// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
-// reserved. Use of this source code is governed by a BSD-style license that
-// can be found in the LICENSE file.
-
-package tests.detailed.ui;
-
-import org.cef.OS;
-import org.cef.browser.CefBrowser;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import javax.swing.Box;
-import javax.swing.BoxLayout;
-import javax.swing.JButton;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JTextField;
-
-@SuppressWarnings("serial")
-public class ControlPanel extends JPanel {
- private final JButton backButton_;
- private final JButton forwardButton_;
- private final JButton reloadButton_;
- private final JTextField address_field_;
- private final JLabel zoom_label_;
- private double zoomLevel_ = 0;
- private final CefBrowser browser_;
-
- public ControlPanel(CefBrowser browser) {
- assert browser != null;
- browser_ = browser;
-
- setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
-
- add(Box.createHorizontalStrut(5));
- add(Box.createHorizontalStrut(5));
-
- backButton_ = new JButton("Back");
- backButton_.setFocusable(false);
- backButton_.setAlignmentX(LEFT_ALIGNMENT);
- backButton_.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- browser_.goBack();
- }
- });
- add(backButton_);
- add(Box.createHorizontalStrut(5));
-
- forwardButton_ = new JButton("Forward");
- forwardButton_.setFocusable(false);
- forwardButton_.setAlignmentX(LEFT_ALIGNMENT);
- forwardButton_.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- browser_.goForward();
- }
- });
- add(forwardButton_);
- add(Box.createHorizontalStrut(5));
-
- reloadButton_ = new JButton("Reload");
- reloadButton_.setFocusable(false);
- reloadButton_.setAlignmentX(LEFT_ALIGNMENT);
- reloadButton_.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- if (reloadButton_.getText().equalsIgnoreCase("reload")) {
- int mask = OS.isMacintosh() ? ActionEvent.META_MASK : ActionEvent.CTRL_MASK;
- if ((e.getModifiers() & mask) != 0) {
- System.out.println("Reloading - ignoring cached values");
- browser_.reloadIgnoreCache();
- } else {
- System.out.println("Reloading - using cached values");
- browser_.reload();
- }
- } else {
- browser_.stopLoad();
- }
- }
- });
- add(reloadButton_);
- add(Box.createHorizontalStrut(5));
-
- JLabel addressLabel = new JLabel("Address:");
- addressLabel.setAlignmentX(LEFT_ALIGNMENT);
- add(addressLabel);
- add(Box.createHorizontalStrut(5));
-
- address_field_ = new JTextField(100);
- address_field_.setAlignmentX(LEFT_ALIGNMENT);
- address_field_.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- browser_.loadURL(getAddress());
- }
- });
- add(address_field_);
- add(Box.createHorizontalStrut(5));
-
- JButton goButton = new JButton("Go");
- goButton.setFocusable(false);
- goButton.setAlignmentX(LEFT_ALIGNMENT);
- goButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- browser_.loadURL(getAddress());
- }
- });
- add(goButton);
- add(Box.createHorizontalStrut(5));
-
- JButton minusButton = new JButton("-");
- minusButton.setFocusable(false);
- minusButton.setAlignmentX(CENTER_ALIGNMENT);
- minusButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- browser_.setZoomLevel(--zoomLevel_);
- zoom_label_.setText(new Double(zoomLevel_).toString());
- }
- });
- add(minusButton);
-
- zoom_label_ = new JLabel("0.0");
- add(zoom_label_);
-
- JButton plusButton = new JButton("+");
- plusButton.setFocusable(false);
- plusButton.setAlignmentX(CENTER_ALIGNMENT);
- plusButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- browser_.setZoomLevel(++zoomLevel_);
- zoom_label_.setText(new Double(zoomLevel_).toString());
- }
- });
- add(plusButton);
- }
-
- public void update(
- CefBrowser browser, boolean isLoading, boolean canGoBack, boolean canGoForward) {
- if (browser == browser_) {
- backButton_.setEnabled(canGoBack);
- forwardButton_.setEnabled(canGoForward);
- reloadButton_.setText(isLoading ? "Abort" : "Reload");
- }
- }
-
- public String getAddress() {
- String address = address_field_.getText();
- // If the URI format is unknown "new URI" will throw an
- // exception. In this case we interpret the value of the
- // address field as search request. Therefore we simply add
- // the "search" scheme.
- try {
- address = address.replaceAll(" ", "%20");
- URI test = new URI(address);
- if (test.getScheme() != null) return address;
- if (test.getHost() != null && test.getPath() != null) return address;
- String specific = test.getSchemeSpecificPart();
- if (specific.indexOf('.') == -1)
- throw new URISyntaxException(specific, "No dot inside domain");
- } catch (URISyntaxException e1) {
- address = "search://" + address;
- }
- return address;
- }
-
- public void setAddress(CefBrowser browser, String address) {
- if (browser == browser_) address_field_.setText(address);
- }
-
- public JTextField getAddressField() {
- return address_field_;
- }
-}
diff --git a/java/tests/detailed/ui/MenuBar.java b/java/tests/detailed/ui/MenuBar.java
deleted file mode 100644
index 2734d525..00000000
--- a/java/tests/detailed/ui/MenuBar.java
+++ /dev/null
@@ -1,602 +0,0 @@
-// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
-// reserved. Use of this source code is governed by a BSD-style license that
-// can be found in the LICENSE file.
-
-package tests.detailed.ui;
-
-import org.cef.OS;
-import org.cef.browser.CefBrowser;
-import org.cef.browser.CefDevToolsClient;
-import org.cef.callback.CefPdfPrintCallback;
-import org.cef.callback.CefRunFileDialogCallback;
-import org.cef.callback.CefStringVisitor;
-import org.cef.handler.CefDialogHandler.FileDialogMode;
-import org.cef.misc.CefPdfPrintSettings;
-import org.cef.network.CefCookieManager;
-import org.cef.network.CefRequest;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.Container;
-import java.awt.Dimension;
-import java.awt.FlowLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.ComponentAdapter;
-import java.awt.event.ComponentEvent;
-import java.awt.event.WindowEvent;
-import java.awt.image.BufferedImage;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.PrintWriter;
-import java.io.UnsupportedEncodingException;
-import java.util.Vector;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-
-import javax.swing.ImageIcon;
-import javax.swing.JButton;
-import javax.swing.JCheckBoxMenuItem;
-import javax.swing.JFileChooser;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JMenu;
-import javax.swing.JMenuBar;
-import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JRootPane;
-import javax.swing.SwingUtilities;
-
-import tests.detailed.BrowserFrame;
-import tests.detailed.MainFrame;
-import tests.detailed.dialog.CookieManagerDialog;
-import tests.detailed.dialog.DevToolsDialog;
-import tests.detailed.dialog.DownloadDialog;
-import tests.detailed.dialog.SearchDialog;
-import tests.detailed.dialog.ShowTextDialog;
-import tests.detailed.dialog.UrlRequestDialog;
-import tests.detailed.util.DataUri;
-
-@SuppressWarnings("serial")
-public class MenuBar extends JMenuBar {
- class SaveAs implements CefStringVisitor {
- private PrintWriter fileWriter_;
-
- public SaveAs(String fName) throws FileNotFoundException, UnsupportedEncodingException {
- fileWriter_ = new PrintWriter(fName, "UTF-8");
- }
-
- @Override
- public void visit(String string) {
- fileWriter_.write(string);
- fileWriter_.close();
- }
- }
-
- private final MainFrame owner_;
- private final CefBrowser browser_;
- private String last_selected_file_ = "";
- private final JMenu bookmarkMenu_;
- private final ControlPanel control_pane_;
- private final DownloadDialog downloadDialog_;
- private final CefCookieManager cookieManager_;
- private boolean reparentPending_ = false;
- private CefDevToolsClient devToolsClient_;
-
- public MenuBar(MainFrame owner, CefBrowser browser, ControlPanel control_pane,
- DownloadDialog downloadDialog, CefCookieManager cookieManager) {
- owner_ = owner;
- browser_ = browser;
- control_pane_ = control_pane;
- downloadDialog_ = downloadDialog;
- cookieManager_ = cookieManager;
-
- setEnabled(browser_ != null);
-
- JMenu fileMenu = new JMenu("File");
-
- JMenuItem openFileItem = new JMenuItem("Open file...");
- openFileItem.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent arg0) {
- JFileChooser fc = new JFileChooser(new File(last_selected_file_));
- // Show open dialog; this method does not return until the dialog is closed.
- fc.showOpenDialog(owner_);
- File selectedFile = fc.getSelectedFile();
- if (selectedFile != null) {
- last_selected_file_ = selectedFile.getAbsolutePath();
- browser_.loadURL("file:///" + selectedFile.getAbsolutePath());
- }
- }
- });
- fileMenu.add(openFileItem);
-
- JMenuItem openFileDialog = new JMenuItem("Save as...");
- openFileDialog.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- CefRunFileDialogCallback callback = new CefRunFileDialogCallback() {
- @Override
- public void onFileDialogDismissed(Vector filePaths) {
- if (!filePaths.isEmpty()) {
- try {
- SaveAs saveContent = new SaveAs(filePaths.get(0));
- browser_.getSource(saveContent);
- } catch (FileNotFoundException | UnsupportedEncodingException e) {
- browser_.executeJavaScript("alert(\"Can't save file\");",
- control_pane_.getAddress(), 0);
- }
- }
- }
- };
- browser_.runFileDialog(FileDialogMode.FILE_DIALOG_SAVE, owner_.getTitle(),
- "index.html", null, 0, callback);
- }
- });
- fileMenu.add(openFileDialog);
-
- JMenuItem printItem = new JMenuItem("Print...");
- printItem.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- browser_.print();
- }
- });
- fileMenu.add(printItem);
-
- JMenuItem printToPdfItem = new JMenuItem("Print to PDF");
- printToPdfItem.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- JFileChooser fc = new JFileChooser();
- fc.showSaveDialog(owner_);
- File selectedFile = fc.getSelectedFile();
- if (selectedFile != null) {
- CefPdfPrintSettings pdfSettings = new CefPdfPrintSettings();
- pdfSettings.display_header_footer = true;
- // letter page size
- pdfSettings.paper_width = 8.5;
- pdfSettings.paper_height = 11;
- browser.printToPDF(
- selectedFile.getAbsolutePath(), pdfSettings, new CefPdfPrintCallback() {
- @Override
- public void onPdfPrintFinished(String path, boolean ok) {
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- if (ok) {
- JOptionPane.showMessageDialog(owner_,
- "PDF saved to " + path, "Success",
- JOptionPane.INFORMATION_MESSAGE);
- } else {
- JOptionPane.showMessageDialog(owner_, "PDF failed",
- "Failed", JOptionPane.ERROR_MESSAGE);
- }
- }
- });
- }
- });
- }
- }
- });
- fileMenu.add(printToPdfItem);
-
- JMenuItem searchItem = new JMenuItem("Search...");
- searchItem.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- new SearchDialog(owner_, browser_).setVisible(true);
- }
- });
- fileMenu.add(searchItem);
-
- fileMenu.addSeparator();
-
- JMenuItem viewSource = new JMenuItem("View source");
- viewSource.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- browser_.viewSource();
- }
- });
- fileMenu.add(viewSource);
-
- JMenuItem getSource = new JMenuItem("Get source...");
- getSource.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- ShowTextDialog visitor = new ShowTextDialog(
- owner_, "Source of \"" + control_pane_.getAddress() + "\"");
- browser_.getSource(visitor);
- }
- });
- fileMenu.add(getSource);
-
- JMenuItem getText = new JMenuItem("Get text...");
- getText.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- ShowTextDialog visitor = new ShowTextDialog(
- owner_, "Content of \"" + control_pane_.getAddress() + "\"");
- browser_.getText(visitor);
- }
- });
- fileMenu.add(getText);
-
- fileMenu.addSeparator();
-
- JMenuItem showDownloads = new JMenuItem("Show Downloads");
- showDownloads.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- downloadDialog_.setVisible(true);
- }
- });
- fileMenu.add(showDownloads);
-
- JMenuItem showCookies = new JMenuItem("Show Cookies");
- showCookies.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- CookieManagerDialog cookieManager =
- new CookieManagerDialog(owner_, "Cookie Manager", cookieManager_);
- cookieManager.setVisible(true);
- }
- });
- fileMenu.add(showCookies);
-
- fileMenu.addSeparator();
-
- JMenuItem exitItem = new JMenuItem("Exit");
- exitItem.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- owner_.dispatchEvent(new WindowEvent(owner_, WindowEvent.WINDOW_CLOSING));
- }
- });
- fileMenu.add(exitItem);
-
- bookmarkMenu_ = new JMenu("Bookmarks");
-
- JMenuItem addBookmarkItem = new JMenuItem("Add bookmark");
- addBookmarkItem.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- addBookmark(owner_.getTitle(), control_pane_.getAddress());
- }
- });
- bookmarkMenu_.add(addBookmarkItem);
- bookmarkMenu_.addSeparator();
-
- JMenu testMenu = new JMenu("Tests");
-
- JMenuItem testJSItem = new JMenuItem("JavaScript alert");
- testJSItem.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- browser_.executeJavaScript("alert('Hello World');", control_pane_.getAddress(), 1);
- }
- });
- testMenu.add(testJSItem);
-
- JMenuItem jsAlertItem = new JMenuItem("JavaScript alert (will be suppressed)");
- jsAlertItem.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- browser_.executeJavaScript("alert('Never displayed');", "http://dontshow.me", 1);
- }
- });
- testMenu.add(jsAlertItem);
-
- JMenuItem testShowText = new JMenuItem("Show Text");
- testShowText.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- browser_.loadURL(DataUri.create(
- "text/html", "Hello World "));
- }
- });
- testMenu.add(testShowText);
-
- JMenuItem showForm = new JMenuItem("RequestHandler Test");
- showForm.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- String form = "RequestHandler test ";
- form += "RequestHandler test ";
- form += "";
- form += " ";
- form += " ";
- form += " Use GET instead of POST";
- form += "This form tries to send the content of the text field as HTTP-POST request to http://www.google.com.
";
- form += "Testcase 1 ";
- form += "Try to enter the word \"ignore\" into the text field and press \"submit\". ";
- form += "The request will be rejected by the application.";
- form += "See implementation of tests.RequestHandler.onBeforeBrowse(CefBrowser, CefRequest, boolean) for details
";
- form += "Testcase 2 ";
- form += "Due Google doesn't allow the POST method, the server replies with a 405 error.";
- form += "If you activate the checkbox \"Use GET instead of POST\", the application will change the POST request into a GET request.";
- form += "See implementation of tests.RequestHandler.onBeforeResourceLoad(CefBrowser, CefRequest) for details
";
- form += " ";
- form += "";
- browser_.loadURL(DataUri.create("text/html", form));
- }
- });
- testMenu.add(showForm);
-
- JMenuItem httpRequest = new JMenuItem("Manual HTTP request");
- httpRequest.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- String searchFor = JOptionPane.showInputDialog(owner_, "Search on google:");
- if (searchFor != null && !searchFor.isEmpty()) {
- CefRequest myRequest = CefRequest.create();
- myRequest.setMethod("GET");
- myRequest.setURL("http://www.google.com/#q=" + searchFor);
- myRequest.setFirstPartyForCookies("http://www.google.com/#q=" + searchFor);
- browser_.loadRequest(myRequest);
- }
- }
- });
- testMenu.add(httpRequest);
-
- JMenuItem showInfo = new JMenuItem("Show Info");
- showInfo.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- String info = "Browser status ";
- info += "Browser status ";
- info += "CanGoBack " + browser_.canGoBack() + " ";
- info += "CanGoForward " + browser_.canGoForward() + " ";
- info += "IsLoading " + browser_.isLoading() + " ";
- info += "isPopup " + browser_.isPopup() + " ";
- info += "hasDocument " + browser_.hasDocument() + " ";
- info += "Url " + browser_.getURL() + " ";
- info += "Zoom-Level " + browser_.getZoomLevel() + " ";
- info += "
";
- String js = "var x=window.open(); x.document.open(); x.document.write('" + info
- + "'); x.document.close();";
- browser_.executeJavaScript(js, "", 0);
- }
- });
- testMenu.add(showInfo);
-
- final JMenuItem showDevTools = new JMenuItem("Show DevTools");
- showDevTools.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- DevToolsDialog devToolsDlg = new DevToolsDialog(owner_, "DEV Tools", browser_);
- devToolsDlg.addComponentListener(new ComponentAdapter() {
- @Override
- public void componentHidden(ComponentEvent e) {
- showDevTools.setEnabled(true);
- }
- });
- devToolsDlg.setVisible(true);
- showDevTools.setEnabled(false);
- }
- });
- testMenu.add(showDevTools);
-
- JMenu devToolsProtocolMenu = new JMenu("DevTools Protocol");
- JMenuItem autoDarkMode = devToolsProtocolMenu.add(new JCheckBoxMenuItem("Auto Dark Mode"));
- autoDarkMode.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- // Toggle the auto dark mode override
- String params = String.format("{ \"enabled\": %s }", autoDarkMode.isSelected());
- executeDevToolsMethod("Emulation.setAutoDarkModeOverride", params);
- }
- });
- JMenuItem checkContrast = devToolsProtocolMenu.add(new JMenuItem("Check Contrast"));
- checkContrast.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- // Check contrast, which usually triggers a series of Audits.issueAdded events
- executeDevToolsMethod("Audits.checkContrast");
- }
- });
- JMenuItem enableCSS = devToolsProtocolMenu.add(new JMenuItem("Enable CSS Agent"));
- enableCSS.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- // Enable the CSS agent, which usually triggers a series of CSS.styleSheetAdded
- // events. We can only enable the CSS agent if the DOM agent is enabled first, so we
- // need to chain the two commands.
- executeDevToolsMethod("DOM.enable")
- .thenCompose(unused -> executeDevToolsMethod("CSS.enable"));
- }
- });
- testMenu.add(devToolsProtocolMenu);
-
- JMenuItem testURLRequest = new JMenuItem("URL Request");
- testURLRequest.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- UrlRequestDialog dlg = new UrlRequestDialog(owner_, "URL Request Test");
- dlg.setVisible(true);
- }
- });
- testMenu.add(testURLRequest);
-
- JMenuItem reparent = new JMenuItem("Reparent");
- reparent.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- final BrowserFrame newFrame = new BrowserFrame("New Window");
- newFrame.setLayout(new BorderLayout());
- final JButton reparentButton = new JButton("Reparent <");
- reparentButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- if (reparentPending_) return;
- reparentPending_ = true;
-
- if (reparentButton.getText().equals("Reparent <")) {
- owner_.removeBrowser(new Runnable() {
- public void run() {
- newFrame.setBrowser(browser_);
- reparentButton.setText("Reparent >");
- reparentPending_ = false;
- }
- });
- } else {
- newFrame.removeBrowser(new Runnable() {
- public void run() {
- JRootPane rootPane = (JRootPane) owner_.getComponent(0);
- Container container = rootPane.getContentPane();
- JPanel panel = (JPanel) container.getComponent(0);
- owner_.setBrowser(browser_);
- owner_.revalidate();
- reparentButton.setText("Reparent <");
- reparentPending_ = false;
- }
- });
- }
- }
- });
- newFrame.add(reparentButton, BorderLayout.NORTH);
- newFrame.setSize(400, 400);
- newFrame.setVisible(true);
- }
- });
- testMenu.add(reparent);
-
- JMenuItem newwindow = new JMenuItem("New window");
- newwindow.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- final MainFrame frame = new MainFrame(OS.isLinux(), false, false, 0, null);
- frame.setSize(800, 600);
- frame.setVisible(true);
- }
- });
- testMenu.add(newwindow);
-
- JMenuItem screenshotSync = new JMenuItem("Screenshot (on AWT thread, native res)");
- screenshotSync.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- long start = System.nanoTime();
- CompletableFuture shot = browser.createScreenshot(true);
- System.out.println("Took screenshot from the AWT event thread in "
- + TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start) + " msecs");
- try {
- displayScreenshot(shot.get());
- } catch (InterruptedException | ExecutionException exc) {
- // cannot happen, future is already resolved in this case
- }
- }
- });
- screenshotSync.setEnabled(owner.isOsrEnabled());
- testMenu.add(screenshotSync);
-
- JMenuItem screenshotSyncScaled = new JMenuItem("Screenshot (on AWT thread, scaled)");
- screenshotSyncScaled.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- long start = System.nanoTime();
- CompletableFuture shot = browser.createScreenshot(false);
- System.out.println("Took screenshot from the AWT event thread in "
- + TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start) + " msecs");
- try {
- displayScreenshot(shot.get());
- } catch (InterruptedException | ExecutionException exc) {
- // cannot happen, future is already resolved in this case
- }
- }
- });
- screenshotSyncScaled.setEnabled(owner.isOsrEnabled());
- testMenu.add(screenshotSyncScaled);
-
- JMenuItem screenshotAsync = new JMenuItem("Screenshot (from other thread, scaled)");
- screenshotAsync.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- long start = System.nanoTime();
- CompletableFuture shot = browser.createScreenshot(false);
- shot.thenAccept((image) -> {
- System.out.println("Took screenshot asynchronously in "
- + TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start) + " msecs");
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- displayScreenshot(image);
- }
- });
- });
- }
- });
- screenshotAsync.setEnabled(owner.isOsrEnabled());
- testMenu.add(screenshotAsync);
-
- add(fileMenu);
- add(bookmarkMenu_);
- add(testMenu);
- }
-
- public void addBookmark(String name, String URL) {
- if (bookmarkMenu_ == null) return;
-
- // Test if the bookmark already exists. If yes, update URL
- Component[] entries = bookmarkMenu_.getMenuComponents();
- for (Component itemEntry : entries) {
- if (!(itemEntry instanceof JMenuItem)) continue;
-
- JMenuItem item = (JMenuItem) itemEntry;
- if (item.getText().equals(name)) {
- item.setActionCommand(URL);
- return;
- }
- }
-
- JMenuItem menuItem = new JMenuItem(name);
- menuItem.setActionCommand(URL);
- menuItem.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- browser_.loadURL(e.getActionCommand());
- }
- });
- bookmarkMenu_.add(menuItem);
- validate();
- }
-
- private void displayScreenshot(BufferedImage aScreenshot) {
- JFrame frame = new JFrame("Screenshot");
- ImageIcon image = new ImageIcon();
- image.setImage(aScreenshot);
- frame.setLayout(new FlowLayout());
- JLabel label = new JLabel(image);
- label.setPreferredSize(new Dimension(aScreenshot.getWidth(), aScreenshot.getHeight()));
- frame.add(label);
- frame.setVisible(true);
- frame.pack();
- }
-
- private CompletableFuture executeDevToolsMethod(String methodName) {
- return executeDevToolsMethod(methodName, null);
- }
-
- private CompletableFuture executeDevToolsMethod(
- String methodName, String paramsAsJson) {
- if (devToolsClient_ == null) {
- devToolsClient_ = browser_.getDevToolsClient();
- devToolsClient_.addEventListener(
- (method, json) -> System.out.println("CDP event " + method + ": " + json));
- }
-
- return devToolsClient_.executeDevToolsMethod(methodName, paramsAsJson)
- .handle((error, json) -> {
- System.out.println(
- "CDP result of " + methodName + ": " + (error != null ? error : json));
- return null;
- });
- }
-
- public void addBookmarkSeparator() {
- bookmarkMenu_.addSeparator();
- }
-}
diff --git a/java/tests/detailed/ui/StatusPanel.java b/java/tests/detailed/ui/StatusPanel.java
deleted file mode 100644
index 6f9026ed..00000000
--- a/java/tests/detailed/ui/StatusPanel.java
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
-// reserved. Use of this source code is governed by a BSD-style license that
-// can be found in the LICENSE file.
-
-package tests.detailed.ui;
-
-import java.awt.Dimension;
-
-import javax.swing.Box;
-import javax.swing.BoxLayout;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JProgressBar;
-
-@SuppressWarnings("serial")
-public class StatusPanel extends JPanel {
- private final JProgressBar progressBar_;
- private final JLabel status_field_;
-
- public StatusPanel() {
- setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
-
- add(Box.createHorizontalStrut(5));
- add(Box.createHorizontalStrut(5));
-
- progressBar_ = new JProgressBar();
- Dimension progressBarSize = progressBar_.getMaximumSize();
- progressBarSize.width = 100;
- progressBar_.setMinimumSize(progressBarSize);
- progressBar_.setMaximumSize(progressBarSize);
- add(progressBar_);
- add(Box.createHorizontalStrut(5));
-
- status_field_ = new JLabel("Info");
- status_field_.setAlignmentX(LEFT_ALIGNMENT);
- add(status_field_);
- add(Box.createHorizontalStrut(5));
- add(Box.createVerticalStrut(21));
- }
-
- public void setIsInProgress(boolean inProgress) {
- progressBar_.setIndeterminate(inProgress);
- }
-
- public void setStatusText(String text) {
- status_field_.setText(text);
- }
-}
diff --git a/java/tests/detailed/util/DataUri.java b/java/tests/detailed/util/DataUri.java
deleted file mode 100644
index 895ad858..00000000
--- a/java/tests/detailed/util/DataUri.java
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (c) 2019 The Chromium Embedded Framework Authors. All rights
-// reserved. Use of this source code is governed by a BSD-style license that
-// can be found in the LICENSE file.
-
-package tests.detailed.util;
-
-/**
- * Utility class for creating data: URIs that can be passed to CefBrowser.loadURL.
- */
-public class DataUri {
- public static String create(String mimeType, String contents) {
- return "data:" + mimeType + ";base64,"
- + java.util.Base64.getEncoder().encodeToString(contents.getBytes());
- }
-};
diff --git a/java/tests/junittests/DisplayHandlerTest.java b/java/tests/junittests/DisplayHandlerTest.java
deleted file mode 100644
index 81b873af..00000000
--- a/java/tests/junittests/DisplayHandlerTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright (c) 2019 The Chromium Embedded Framework Authors. All rights
-// reserved. Use of this source code is governed by a BSD-style license that
-// can be found in the LICENSE file.
-
-package tests.junittests;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import org.cef.browser.CefBrowser;
-import org.cef.browser.CefFrame;
-import org.cef.handler.CefDisplayHandlerAdapter;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-
-// Test the DisplayHandler implementation.
-@ExtendWith(TestSetupExtension.class)
-class DisplayHandlerTest {
- private final String testUrl_ = "http://test.com/test.html";
- private final String testContent_ =
- "Test Title Test!";
-
- private boolean gotCallback_ = false;
-
- @Test
- void onTitleChange() {
- TestFrame frame = new TestFrame() {
- @Override
- protected void setupTest() {
- client_.addDisplayHandler(new CefDisplayHandlerAdapter() {
- @Override
- public void onTitleChange(CefBrowser browser, String title) {
- assertFalse(gotCallback_);
- gotCallback_ = true;
- assertEquals("Test Title", title);
- terminateTest();
- }
- });
-
- addResource(testUrl_, testContent_, "text/html");
-
- createBrowser(testUrl_);
-
- super.setupTest();
- }
- };
-
- frame.awaitCompletion();
-
- assertTrue(gotCallback_);
- }
-
- @Test
- void onAddressChange() {
- TestFrame frame = new TestFrame() {
- @Override
- protected void setupTest() {
- client_.addDisplayHandler(new CefDisplayHandlerAdapter() {
- @Override
- public void onAddressChange(CefBrowser browser, CefFrame frame, String url) {
- assertFalse(gotCallback_);
- gotCallback_ = true;
- assertEquals(url, testUrl_);
- terminateTest();
- }
- });
-
- addResource(testUrl_, testContent_, "text/html");
-
- createBrowser(testUrl_);
-
- super.setupTest();
- }
- };
-
- frame.awaitCompletion();
-
- assertTrue(gotCallback_);
- }
-}
diff --git a/java/tests/junittests/DragDataTest.java b/java/tests/junittests/DragDataTest.java
deleted file mode 100644
index bd904309..00000000
--- a/java/tests/junittests/DragDataTest.java
+++ /dev/null
@@ -1,165 +0,0 @@
-// Copyright (c) 2019 The Chromium Embedded Framework Authors. All rights
-// reserved. Use of this source code is governed by a BSD-style license that
-// can be found in the LICENSE file.
-
-package tests.junittests;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import org.cef.callback.CefDragData;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-
-import java.util.Vector;
-
-// Test the TestFrame implementation.
-@ExtendWith(TestSetupExtension.class)
-class DragDataTest {
- @Test
- void createEmpty() {
- CefDragData dragData = CefDragData.create();
- assertNotNull(dragData);
- assertFalse(dragData.isReadOnly());
-
- assertFalse(dragData.isLink());
- assertFalse(dragData.isFile());
- assertTrue(dragData.isFragment()); // Default state.
-
- assertEquals("", dragData.getLinkURL());
- assertEquals("", dragData.getLinkTitle());
- assertEquals("", dragData.getLinkMetadata());
- assertEquals("", dragData.getFragmentText());
- assertEquals("", dragData.getFragmentHtml());
- assertEquals("", dragData.getFragmentBaseURL());
- assertEquals(0, dragData.getFileContents(null));
- assertEquals("", dragData.getFileName());
- assertFalse(dragData.getFileNames(null));
-
- // Explicit cleanup to avoid memory leaks.
- dragData.dispose();
- }
-
- @Test
- void createLink() {
- CefDragData dragData = CefDragData.create();
- assertNotNull(dragData);
- assertFalse(dragData.isReadOnly());
-
- final String linkURL = "http://test.com/test.html";
- dragData.setLinkURL(linkURL);
- assertEquals(linkURL, dragData.getLinkURL());
-
- final String linkTitle = "Test Title";
- dragData.setLinkTitle(linkTitle);
- assertEquals(linkTitle, dragData.getLinkTitle());
-
- final String linkMetadata = "something";
- dragData.setLinkMetadata(linkMetadata);
- assertEquals(linkMetadata, dragData.getLinkMetadata());
-
- assertTrue(dragData.isLink());
- assertFalse(dragData.isFile());
- assertFalse(dragData.isFragment());
-
- // Explicit cleanup to avoid memory leaks.
- dragData.dispose();
- }
-
- @Test
- void createFile() {
- CefDragData dragData = CefDragData.create();
- assertNotNull(dragData);
- assertFalse(dragData.isReadOnly());
-
- final String path1 = "/path/to/file1.txt";
- final String path2 = "/path/to/file2.txt";
-
- dragData.addFile(path1, "File 1");
- dragData.addFile(path2, "File 2");
-
- Vector fileNames = new Vector<>();
- assertTrue(dragData.getFileNames(fileNames));
-
- assertEquals(2, fileNames.size());
- assertEquals(path1, fileNames.get(0));
- assertEquals(path2, fileNames.get(1));
-
- assertFalse(dragData.isLink());
- assertTrue(dragData.isFile());
- assertFalse(dragData.isFragment());
-
- // Explicit cleanup to avoid memory leaks.
- dragData.dispose();
- }
-
- @Test
- void createFragment() {
- CefDragData dragData = CefDragData.create();
- assertNotNull(dragData);
- assertFalse(dragData.isReadOnly());
-
- final String fragmentText = "something";
- dragData.setFragmentText(fragmentText);
- assertEquals(fragmentText, dragData.getFragmentText());
-
- final String fragmentHtml = "something ";
- dragData.setFragmentHtml(fragmentHtml);
- assertEquals(fragmentHtml, dragData.getFragmentHtml());
-
- final String fragmentBaseURL = "http://test.com/test.html";
- dragData.setFragmentBaseURL(fragmentBaseURL);
- assertEquals(fragmentBaseURL, dragData.getFragmentBaseURL());
-
- assertFalse(dragData.isLink());
- assertFalse(dragData.isFile());
- assertTrue(dragData.isFragment());
-
- // Explicit cleanup to avoid memory leaks.
- dragData.dispose();
- }
-
- @Test
- void cloneObject() {
- CefDragData dragData = CefDragData.create();
- assertNotNull(dragData);
- assertFalse(dragData.isReadOnly());
-
- final String fragmentText = "something";
- final String fragmentBaseURL = "http://test.com/test.html";
- dragData.setFragmentText(fragmentText);
- dragData.setFragmentBaseURL(fragmentBaseURL);
-
- CefDragData dragData2 = dragData.clone();
- assertFalse(dragData2.isReadOnly());
- assertEquals(fragmentText, dragData2.getFragmentText());
- assertEquals(fragmentBaseURL, dragData2.getFragmentBaseURL());
-
- assertFalse(dragData2.isLink());
- assertFalse(dragData2.isFile());
- assertTrue(dragData2.isFragment());
-
- // Explicit cleanup to avoid memory leaks.
- dragData.dispose();
- dragData2.dispose();
- }
-
- @Test
- void disposeObject() {
- CefDragData dragData = CefDragData.create();
- assertNotNull(dragData);
- assertFalse(dragData.isReadOnly());
-
- final String fragmentText = "something";
- dragData.setFragmentText(fragmentText);
- assertEquals(fragmentText, dragData.getFragmentText());
-
- // Explicit cleanup to avoid memory leaks.
- // After dispose() the Java object is no longer backed by a CEF object.
- dragData.dispose();
-
- assertEquals(null, dragData.getFragmentText());
- }
-}
diff --git a/java/tests/junittests/TestFrame.java b/java/tests/junittests/TestFrame.java
deleted file mode 100644
index bdbc26a9..00000000
--- a/java/tests/junittests/TestFrame.java
+++ /dev/null
@@ -1,297 +0,0 @@
-// Copyright (c) 2019 The Chromium Embedded Framework Authors. All rights
-// reserved. Use of this source code is governed by a BSD-style license that
-// can be found in the LICENSE file.
-
-package tests.junittests;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-import static tests.junittests.TestSetupContext.debugPrint;
-
-import org.cef.CefApp;
-import org.cef.CefClient;
-import org.cef.browser.CefBrowser;
-import org.cef.browser.CefFrame;
-import org.cef.callback.CefAuthCallback;
-import org.cef.callback.CefCallback;
-import org.cef.handler.CefCookieAccessFilter;
-import org.cef.handler.CefLifeSpanHandler;
-import org.cef.handler.CefLoadHandler;
-import org.cef.handler.CefRequestHandler;
-import org.cef.handler.CefResourceHandler;
-import org.cef.handler.CefResourceRequestHandler;
-import org.cef.misc.BoolRef;
-import org.cef.misc.StringRef;
-import org.cef.network.CefRequest;
-import org.cef.network.CefRequest.TransitionType;
-import org.cef.network.CefResponse;
-import org.cef.network.CefURLRequest;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.util.HashMap;
-import java.util.concurrent.CountDownLatch;
-
-import javax.swing.JFrame;
-
-// Base class for browsers that run tests.
-class TestFrame extends JFrame implements CefLifeSpanHandler, CefLoadHandler, CefRequestHandler,
- CefResourceRequestHandler {
- private static final long serialVersionUID = -5570653778104813836L;
- private boolean isClosed_ = false;
- private CountDownLatch countdown_ = new CountDownLatch(1);
-
- // Resources that have been populated for the test.
- private class ResourceContent {
- String content;
- String mimeType;
- HashMap headerMap;
- }
- private HashMap resourceMap_ = null;
-
- protected final CefClient client_;
- protected CefBrowser browser_ = null;
-
- TestFrame() {
- client_ = CefApp.getInstance().createClient();
- assertNotNull(client_);
-
- // Browser window closing works as follows:
- // 1. Sending WindowEvent.WINDOW_CLOSING calls WindowAdapter.windowClosing.
- // 2. WindowAdapter.windowClosing calls CefBrowser.close(false).
- // 3. CEF calls CefLifeSpanHandler.doClose() which calls CefBrowser.doClose()
- // which returns true (canceling the close).
- // 4. CefBrowser.doClose() triggers another call to WindowAdapter.windowClosing.
- // 5. WindowAdapter.windowClosing calls CefBrowser.close(true).
- // 6. For windowed browsers CEF destroys the native window handle. For OSR
- // browsers CEF calls CefLifeSpanHandler.doClose() which calls
- // CefBrowser.doClose() again which returns false (allowing the close).
- // 7. CEF calls CefLifeSpanHandler.onBeforeClose and the browser is destroyed.
- addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- boolean isClosed = isClosed_;
-
- if (isClosed) {
- // Cause browser.doClose() to return false so that OSR browsers
- // can close.
- browser_.setCloseAllowed();
- }
-
- // Results in another call to this method.
- if (debugPrint())
- System.out.println("windowClosing CefBrowser.close(" + isClosed + ")");
- browser_.close(isClosed);
- if (!isClosed_) {
- isClosed_ = true;
- }
- if (isClosed) {
- // Dispose after the 2nd call to this method.
- if (debugPrint()) System.out.println("windowClosing Frame.dispose");
- dispose();
- }
- }
- });
-
- client_.addLifeSpanHandler(this);
- client_.addLoadHandler(this);
- client_.addRequestHandler(this);
-
- setupTest();
- }
-
- protected void createBrowser(String startURL) {
- assertNull(browser_);
- browser_ = client_.createBrowser(startURL, false /* isTransparent */);
- assertNotNull(browser_);
-
- pack();
- setSize(800, 600);
- setVisible(true);
- }
-
- // Override this method to perform test setup.
- protected void setupTest() {}
-
- // Override this method to perform test cleanup.
- protected void cleanupTest() {
- if (debugPrint()) System.out.println("cleanupTest");
- client_.dispose();
- // Allow the test to complete.
- countdown_.countDown();
- }
-
- // Call this method to terminate the test by dispatching a window close event.
- protected final void terminateTest() {
- if (debugPrint()) System.out.println("terminateTest");
- if (!isClosed_) {
- dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
- }
- }
-
- // Block until the test completes.
- public final void awaitCompletion() {
- try {
- countdown_.await();
- } catch (InterruptedException e) {
- }
- if (debugPrint()) System.out.println("awaitCompletion returned");
- }
-
- protected void addResource(String url, String content, String mimeType) {
- addResource(url, content, mimeType, null);
- }
-
- // Add a resource that will be returned via getResourceHandler().
- protected void addResource(
- String url, String content, String mimeType, HashMap headerMap) {
- if (resourceMap_ == null) resourceMap_ = new HashMap<>();
-
- assertNull(resourceMap_.get(url));
-
- ResourceContent rc = new ResourceContent();
- rc.content = content;
- rc.mimeType = mimeType;
- rc.headerMap = headerMap;
-
- resourceMap_.put(url, rc);
- }
-
- // CefLifeSpanHandler methods:
-
- @Override
- public void onAfterCreated(CefBrowser browser) {
- if (debugPrint()) System.out.println("onAfterCreated id=" + browser.getIdentifier());
- }
-
- @Override
- public boolean onBeforePopup(
- CefBrowser browser, CefFrame frame, String target_url, String target_frame_name) {
- return false;
- }
-
- @Override
- public void onAfterParentChanged(CefBrowser browser) {}
-
- @Override
- public boolean doClose(CefBrowser browser) {
- boolean result = browser.doClose();
- if (debugPrint()) {
- System.out.println(
- "doClose id=" + browser.getIdentifier() + " CefBrowser.doClose=" + result);
- }
- return result;
- }
-
- @Override
- public void onBeforeClose(CefBrowser browser) {
- if (debugPrint()) System.out.println("onBeforeClose id=" + browser.getIdentifier());
- cleanupTest();
- }
-
- // CefLoadHandler methods:
-
- @Override
- public void onLoadingStateChange(
- CefBrowser browser, boolean isLoading, boolean canGoBack, boolean canGoForward) {}
-
- @Override
- public void onLoadStart(CefBrowser browser, CefFrame frame, TransitionType transitionType) {}
-
- @Override
- public void onLoadEnd(CefBrowser browser, CefFrame frame, int httpStatusCode) {}
-
- @Override
- public void onLoadError(CefBrowser browser, CefFrame frame, ErrorCode errorCode,
- String errorText, String failedUrl) {}
-
- // CefRequestHandler methods:
-
- @Override
- public boolean onBeforeBrowse(CefBrowser browser, CefFrame frame, CefRequest request,
- boolean user_gesture, boolean is_redirect) {
- return false;
- }
-
- @Override
- public boolean onOpenURLFromTab(
- CefBrowser browser, CefFrame frame, String target_url, boolean user_gesture) {
- return false;
- }
-
- @Override
- public CefResourceRequestHandler getResourceRequestHandler(CefBrowser browser, CefFrame frame,
- CefRequest request, boolean isNavigation, boolean isDownload, String requestInitiator,
- BoolRef disableDefaultHandling) {
- return this;
- }
-
- @Override
- public boolean getAuthCredentials(CefBrowser browser, String origin_url, boolean isProxy,
- String host, int port, String realm, String scheme, CefAuthCallback callback) {
- return false;
- }
-
- @Override
- public boolean onCertificateError(CefBrowser browser, CefLoadHandler.ErrorCode cert_error,
- String request_url, CefCallback callback) {
- return false;
- }
-
- @Override
- public void onRenderProcessTerminated(CefBrowser browser, TerminationStatus status) {}
-
- // CefResourceRequestHandler methods:
-
- @Override
- public CefCookieAccessFilter getCookieAccessFilter(
- CefBrowser browser, CefFrame frame, CefRequest request) {
- return null;
- }
-
- @Override
- public boolean onBeforeResourceLoad(CefBrowser browser, CefFrame frame, CefRequest request) {
- return false;
- }
-
- @Override
- public CefResourceHandler getResourceHandler(
- CefBrowser browser, CefFrame frame, CefRequest request) {
- if (resourceMap_ != null) {
- String url = request.getURL();
-
- // Ignore the query component, if any.
- int idx = url.indexOf('?');
- if (idx > 0) url = url.substring(0, idx);
-
- ResourceContent rc = resourceMap_.get(url);
- if (rc != null) {
- if (debugPrint()) System.out.println("Found resource for: " + url);
- return new TestResourceHandler(rc.content, rc.mimeType, rc.headerMap);
- }
- }
-
- return null;
- }
-
- @Override
- public void onResourceRedirect(CefBrowser browser, CefFrame frame, CefRequest request,
- CefResponse response, StringRef new_url) {}
-
- @Override
- public boolean onResourceResponse(
- CefBrowser browser, CefFrame frame, CefRequest request, CefResponse response) {
- return false;
- }
-
- @Override
- public void onResourceLoadComplete(CefBrowser browser, CefFrame frame, CefRequest request,
- CefResponse response, CefURLRequest.Status status, long receivedContentLength) {}
-
- @Override
- public void onProtocolExecution(
- CefBrowser browser, CefFrame frame, CefRequest request, BoolRef allowOsExecution) {}
-}
diff --git a/java/tests/junittests/TestFrameTest.java b/java/tests/junittests/TestFrameTest.java
deleted file mode 100644
index e8f36c16..00000000
--- a/java/tests/junittests/TestFrameTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (c) 2019 The Chromium Embedded Framework Authors. All rights
-// reserved. Use of this source code is governed by a BSD-style license that
-// can be found in the LICENSE file.
-
-package tests.junittests;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import org.cef.browser.CefBrowser;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-
-// Test the TestFrame implementation.
-@ExtendWith(TestSetupExtension.class)
-class TestFrameTest {
- private boolean gotSetupTest_ = false;
- private boolean gotCleanupTest_ = false;
- private boolean gotLoadingStateChange_ = false;
-
- @Test
- void minimal() {
- final String testUrl = "http://test.com/test.html";
- TestFrame frame = new TestFrame() {
- @Override
- protected void setupTest() {
- assertFalse(gotSetupTest_);
- gotSetupTest_ = true;
-
- addResource(testUrl, "Test!", "text/html");
-
- createBrowser(testUrl);
-
- super.setupTest();
- }
-
- @Override
- protected void cleanupTest() {
- assertFalse(gotCleanupTest_);
- gotCleanupTest_ = true;
-
- super.cleanupTest();
- }
-
- @Override
- public void onLoadingStateChange(CefBrowser browser, boolean isLoading,
- boolean canGoBack, boolean canGoForward) {
- if (!isLoading) {
- assertFalse(gotLoadingStateChange_);
- gotLoadingStateChange_ = true;
- terminateTest();
- }
- }
- };
-
- frame.awaitCompletion();
-
- assertTrue(gotSetupTest_);
- assertTrue(gotLoadingStateChange_);
- assertTrue(gotCleanupTest_);
- }
-}
diff --git a/java/tests/junittests/TestResourceHandler.java b/java/tests/junittests/TestResourceHandler.java
deleted file mode 100644
index 23594f4f..00000000
--- a/java/tests/junittests/TestResourceHandler.java
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright (c) 2019 The Chromium Embedded Framework Authors. All rights
-// reserved. Use of this source code is governed by a BSD-style license that
-// can be found in the LICENSE file.
-
-package tests.junittests;
-
-import org.cef.callback.CefCallback;
-import org.cef.handler.CefResourceHandlerAdapter;
-import org.cef.misc.IntRef;
-import org.cef.misc.StringRef;
-import org.cef.network.CefRequest;
-import org.cef.network.CefResponse;
-
-import java.nio.ByteBuffer;
-import java.util.HashMap;
-
-class TestResourceHandler extends CefResourceHandlerAdapter {
- private int offset_ = 0;
- private final String content_;
- private final String mimeType_;
- private final HashMap headerMap_;
-
- TestResourceHandler(String content, String mimeType, HashMap headerMap) {
- content_ = content;
- mimeType_ = mimeType;
- headerMap_ = headerMap;
- }
-
- @Override
- public boolean processRequest(CefRequest request, CefCallback callback) {
- callback.Continue();
- return true;
- }
-
- @Override
- public void getResponseHeaders(
- CefResponse response, IntRef response_length, StringRef redirectUrl) {
- response_length.set(content_.length());
- response.setMimeType(mimeType_);
- response.setStatus(200);
-
- if (headerMap_ != null) {
- HashMap headerMap = new HashMap<>();
- response.getHeaderMap(headerMap);
- headerMap.putAll(headerMap_);
- response.setHeaderMap(headerMap);
- }
- }
-
- @Override
- public boolean readResponse(
- byte[] data_out, int bytes_to_read, IntRef bytes_read, CefCallback callback) {
- int length = content_.length();
- if (offset_ >= length) return false;
-
- // Extract up to |bytes_to_read| bytes from |content_|.
- int endPos = offset_ + bytes_to_read;
- String dataToSend = (endPos > length) ? content_.substring(offset_)
- : content_.substring(offset_, endPos);
-
- // Copy extracted bytes into |data_out| and set the read length to |bytes_read|.
- ByteBuffer result = ByteBuffer.wrap(data_out);
- result.put(dataToSend.getBytes());
- bytes_read.set(dataToSend.length());
-
- offset_ = endPos;
- return true;
- }
-}
diff --git a/java/tests/junittests/TestSetupContext.java b/java/tests/junittests/TestSetupContext.java
deleted file mode 100644
index 758fbffc..00000000
--- a/java/tests/junittests/TestSetupContext.java
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (c) 2019 The Chromium Embedded Framework Authors. All rights
-// reserved. Use of this source code is governed by a BSD-style license that
-// can be found in the LICENSE file.
-
-package tests.junittests;
-
-import org.junit.jupiter.api.extension.ExtensionContext;
-
-import java.util.Optional;
-
-// Stores global test setup state for access from package classes.
-class TestSetupContext {
- private static boolean debugPrint_ = false;
-
- // Debug print statements may be enabled via `--config debugPrint=true`.
- static boolean debugPrint() {
- return debugPrint_;
- }
-
- // Initialize from global configuration parameters.
- static void initialize(ExtensionContext context) {
- Optional debugPrint = context.getConfigurationParameter("debugPrint");
- if (debugPrint.isPresent() && debugPrint.get().equalsIgnoreCase("true")) {
- debugPrint_ = true;
- }
- }
-}
diff --git a/java/tests/junittests/TestSetupExtension.java b/java/tests/junittests/TestSetupExtension.java
deleted file mode 100644
index 66887719..00000000
--- a/java/tests/junittests/TestSetupExtension.java
+++ /dev/null
@@ -1,90 +0,0 @@
-// Copyright (c) 2019 The Chromium Embedded Framework Authors. All rights
-// reserved. Use of this source code is governed by a BSD-style license that
-// can be found in the LICENSE file.
-
-package tests.junittests;
-
-import static org.junit.jupiter.api.extension.ExtensionContext.Namespace.GLOBAL;
-
-import org.cef.CefApp;
-import org.cef.CefApp.CefAppState;
-import org.cef.CefSettings;
-import org.cef.handler.CefAppHandlerAdapter;
-import org.junit.jupiter.api.extension.BeforeAllCallback;
-import org.junit.jupiter.api.extension.ExtensionContext;
-
-import java.util.concurrent.CountDownLatch;
-
-// All test cases must install this extension for CEF to be properly initialized
-// and shut down.
-//
-// For example:
-//
-// @ExtendWith(TestSetupExtension.class)
-// class FooTest {
-// @Test
-// void testCaseThatRequiresCEF() {}
-// }
-//
-// This code is based on https://stackoverflow.com/a/51556718.
-public class TestSetupExtension
- implements BeforeAllCallback, ExtensionContext.Store.CloseableResource {
- private static boolean initialized_ = false;
- private static CountDownLatch countdown_ = new CountDownLatch(1);
-
- @Override
- public void beforeAll(ExtensionContext context) {
- if (!initialized_) {
- initialized_ = true;
- initialize(context);
- }
- }
-
- // Executed before any tests are run.
- private void initialize(ExtensionContext context) {
- TestSetupContext.initialize(context);
-
- if (TestSetupContext.debugPrint()) {
- System.out.println("TestSetupExtension.initialize");
- }
-
- // Register a callback hook for when the root test context is shut down.
- context.getRoot().getStore(GLOBAL).put("jcef_test_setup", this);
-
- // Perform startup initialization on platforms that require it.
- if (!CefApp.startup(null)) {
- System.out.println("Startup initialization failed!");
- return;
- }
-
- CefApp.addAppHandler(new CefAppHandlerAdapter(null) {
- @Override
- public void stateHasChanged(org.cef.CefApp.CefAppState state) {
- if (state == CefAppState.TERMINATED) {
- // Signal completion of CEF shutdown.
- countdown_.countDown();
- }
- }
- });
-
- // Initialize the singleton CefApp instance.
- CefSettings settings = new CefSettings();
- CefApp.getInstance(settings);
- }
-
- // Executed after all tests have completed.
- @Override
- public void close() {
- if (TestSetupContext.debugPrint()) {
- System.out.println("TestSetupExtension.close");
- }
-
- CefApp.getInstance().dispose();
-
- // Wait for CEF shutdown to complete.
- try {
- countdown_.await();
- } catch (InterruptedException e) {
- }
- }
-}
diff --git a/java/tests/simple/MainFrame.java b/java/tests/simple/MainFrame.java
deleted file mode 100644
index 822c4c8f..00000000
--- a/java/tests/simple/MainFrame.java
+++ /dev/null
@@ -1,190 +0,0 @@
-// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
-// reserved. Use of this source code is governed by a BSD-style license that
-// can be found in the LICENSE file.
-
-package tests.simple;
-
-import org.cef.CefApp;
-import org.cef.CefApp.CefAppState;
-import org.cef.CefClient;
-import org.cef.CefSettings;
-import org.cef.OS;
-import org.cef.browser.CefBrowser;
-import org.cef.browser.CefFrame;
-import org.cef.handler.CefAppHandlerAdapter;
-import org.cef.handler.CefDisplayHandlerAdapter;
-import org.cef.handler.CefFocusHandlerAdapter;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.KeyboardFocusManager;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.FocusAdapter;
-import java.awt.event.FocusEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-
-import javax.swing.JFrame;
-import javax.swing.JTextField;
-
-/**
- * This is a simple example application using JCEF.
- * It displays a JFrame with a JTextField at its top and a CefBrowser in its
- * center. The JTextField is used to enter and assign an URL to the browser UI.
- * No additional handlers or callbacks are used in this example.
- *
- * The number of used JCEF classes is reduced (nearly) to its minimum and should
- * assist you to get familiar with JCEF.
- *
- * For a more feature complete example have also a look onto the example code
- * within the package "tests.detailed".
- */
-public class MainFrame extends JFrame {
- private static final long serialVersionUID = -5570653778104813836L;
- private final JTextField address_;
- private final CefApp cefApp_;
- private final CefClient client_;
- private final CefBrowser browser_;
- private boolean browserFocus_ = true;
-
- /**
- * To display a simple browser window, it suffices completely to create an
- * instance of the class CefBrowser and to assign its UI component to your
- * application (e.g. to your content pane).
- * But to be more verbose, this CTOR keeps an instance of each object on the
- * way to the browser UI.
- */
- private MainFrame(String startURL, boolean useOSR, boolean isTransparent) {
- // (1) The entry point to JCEF is always the class CefApp. There is only one
- // instance per application and therefore you have to call the method
- // "getInstance()" instead of a CTOR.
- //
- // CefApp is responsible for the global CEF context. It loads all
- // required native libraries, initializes CEF accordingly, starts a
- // background task to handle CEF's message loop and takes care of
- // shutting down CEF after disposing it.
- CefApp.addAppHandler(new CefAppHandlerAdapter(null) {
- @Override
- public void stateHasChanged(org.cef.CefApp.CefAppState state) {
- // Shutdown the app if the native CEF part is terminated
- if (state == CefAppState.TERMINATED) System.exit(0);
- }
- });
- CefSettings settings = new CefSettings();
- settings.windowless_rendering_enabled = useOSR;
- cefApp_ = CefApp.getInstance(settings);
-
- // (2) JCEF can handle one to many browser instances simultaneous. These
- // browser instances are logically grouped together by an instance of
- // the class CefClient. In your application you can create one to many
- // instances of CefClient with one to many CefBrowser instances per
- // client. To get an instance of CefClient you have to use the method
- // "createClient()" of your CefApp instance. Calling an CTOR of
- // CefClient is not supported.
- //
- // CefClient is a connector to all possible events which come from the
- // CefBrowser instances. Those events could be simple things like the
- // change of the browser title or more complex ones like context menu
- // events. By assigning handlers to CefClient you can control the
- // behavior of the browser. See tests.detailed.MainFrame for an example
- // of how to use these handlers.
- client_ = cefApp_.createClient();
-
- // (3) One CefBrowser instance is responsible to control what you'll see on
- // the UI component of the instance. It can be displayed off-screen
- // rendered or windowed rendered. To get an instance of CefBrowser you
- // have to call the method "createBrowser()" of your CefClient
- // instances.
- //
- // CefBrowser has methods like "goBack()", "goForward()", "loadURL()",
- // and many more which are used to control the behavior of the displayed
- // content. The UI is held within a UI-Compontent which can be accessed
- // by calling the method "getUIComponent()" on the instance of CefBrowser.
- // The UI component is inherited from a java.awt.Component and therefore
- // it can be embedded into any AWT UI.
- browser_ = client_.createBrowser(startURL, isTransparent);
-
- // (4) For this minimal browser, we need only a text field to enter an URL
- // we want to navigate to and a CefBrowser window to display the content
- // of the URL. To respond to the input of the user, we're registering an
- // anonymous ActionListener. This listener is performed each time the
- // user presses the "ENTER" key within the address field.
- // If this happens, the entered value is passed to the CefBrowser
- // instance to be loaded as URL.
- address_ = new JTextField(startURL, 100);
- address_.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- browser_.loadURL(address_.getText());
- }
- });
-
- // Update the address field when the browser URL changes.
- client_.addDisplayHandler(new CefDisplayHandlerAdapter() {
- @Override
- public void onAddressChange(CefBrowser browser, CefFrame frame, String url) {
- address_.setText(url);
- }
- });
-
- // Clear focus from the browser when the address field gains focus.
- address_.addFocusListener(new FocusAdapter() {
- @Override
- public void focusGained(FocusEvent e) {
- if (!browserFocus_) return;
- browserFocus_ = false;
- KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
- address_.requestFocus();
- }
- });
-
- // Clear focus from the address field when the browser gains focus.
- client_.addFocusHandler(new CefFocusHandlerAdapter() {
- @Override
- public void onGotFocus(CefBrowser browser) {
- if (browserFocus_) return;
- browserFocus_ = true;
- KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
- browser.setFocus(true);
- }
-
- @Override
- public void onTakeFocus(CefBrowser browser, boolean next) {
- browserFocus_ = false;
- }
- });
-
- // (5) All UI components are assigned to the default content pane of this
- // JFrame and afterwards the frame is made visible to the user.
- getContentPane().add(address_, BorderLayout.NORTH);
- pack();
- setSize(800, 600);
- setVisible(true);
-
- // (6) To take care of shutting down CEF accordingly, it's important to call
- // the method "dispose()" of the CefApp instance if the Java
- // application will be closed. Otherwise you'll get asserts from CEF.
- addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- CefApp.getInstance().dispose();
- dispose();
- }
- });
- }
-
- public static void main(String[] args) {
- // Perform startup initialization on platforms that require it.
- if (!CefApp.startup(args)) {
- System.out.println("Startup initialization failed!");
- return;
- }
-
- // The simple example application is created as anonymous class and points
- // to Google as the very first loaded page. Windowed rendering mode is used by
- // default. If you want to test OSR mode set |useOsr| to true and recompile.
- boolean useOsr = false;
- new MainFrame("http://www.google.com", useOsr, false);
- }
-}
diff --git a/native/CefBrowser_N.cpp b/native/CefBrowser_N.cpp
index d8d920dc..fbc2d6c4 100644
--- a/native/CefBrowser_N.cpp
+++ b/native/CefBrowser_N.cpp
@@ -1050,21 +1050,6 @@ void executeDevToolsMethod(CefRefPtr host,
// }
//}
-jobject NewJNILongVector(JNIEnv* env, const std::vector& vals) {
- ScopedJNIObjectLocal jvector(env, "java/util/Vector");
- if (!jvector)
- return nullptr;
-
- std::vector::const_iterator iter;
- for (iter = vals.begin(); iter != vals.end(); ++iter) {
- ScopedJNIObjectLocal argument(
- env, NewJNIObject(env, "java/lang/Long", "(J)V", (jlong)*iter));
- JNI_CALL_VOID_METHOD(env, jvector, "addElement", "(Ljava/lang/Object;)V",
- argument.get());
- }
- return jvector.Release();
-}
-
CefPdfPrintSettings GetJNIPdfPrintSettings(JNIEnv* env, jobject obj) {
CefString tmp;
CefPdfPrintSettings settings;
@@ -1332,36 +1317,6 @@ Java_org_cef_browser_CefBrowser_1N_N_1GetFocusedFrame(JNIEnv* env,
return jframe.Release();
}
-JNIEXPORT jobject JNICALL
-Java_org_cef_browser_CefBrowser_1N_N_1GetFrame(JNIEnv* env,
- jobject obj,
- jlong identifier) {
- CefRefPtr browser = JNI_GET_BROWSER_OR_RETURN(env, obj, nullptr);
- CefRefPtr frame = browser->GetFrame(identifier);
- if (!frame)
- return nullptr;
- ScopedJNIFrame jframe(env, frame);
- return jframe.Release();
-}
-
-JNIEXPORT jobject JNICALL
-Java_org_cef_browser_CefBrowser_1N_N_1GetFrame2(JNIEnv* env,
- jobject obj,
- jstring name) {
- CefRefPtr browser = JNI_GET_BROWSER_OR_RETURN(env, obj, nullptr);
- CefRefPtr frame = browser->GetFrame(GetJNIString(env, name));
- if (!frame)
- return nullptr;
- ScopedJNIFrame jframe(env, frame);
- return jframe.Release();
-}
-
-JNIEXPORT jint JNICALL
-Java_org_cef_browser_CefBrowser_1N_N_1GetFrameCount(JNIEnv* env, jobject obj) {
- CefRefPtr browser = JNI_GET_BROWSER_OR_RETURN(env, obj, -1);
- return (jint)browser->GetFrameCount();
-}
-
JNIEXPORT jobject JNICALL
Java_org_cef_browser_CefBrowser_1N_N_1GetFrameByIdentifier(JNIEnv* env,
jobject obj,