diff --git a/.gitignore b/.gitignore
index e7bc7d07..dcaa1219 100644
--- a/.gitignore
+++ b/.gitignore
@@ -55,3 +55,4 @@ Thumbs.db
/tools/buildtools/linux64/clang-format
/tools/buildtools/mac/clang-format
/tools/buildtools/win/clang-format.exe
+/target/
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9f7cc449..d98e7c93 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -130,14 +130,20 @@ set_property(GLOBAL PROPERTY OS_FOLDERS ON)
# Specify the CEF distribution version.
if(NOT DEFINED CEF_VERSION)
- set(CEF_VERSION "100.0.14+g4e5ba66+chromium-100.0.4896.75")
+ set(CEF_VERSION "141.0.10+g1d65b0d+chromium-141.0.7390.123")
endif()
# Determine the platform.
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
if("${PROJECT_ARCH}" STREQUAL "arm64")
set(CEF_PLATFORM "macosarm64")
+ elseif("${PROJECT_ARCH}" STREQUAL "x86_64")
+ set(CEF_PLATFORM "macosx64")
+ elseif("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "arm64")
+ set(PROJECT_ARCH "arm64")
+ set(CEF_PLATFORM "macosarm64")
else()
+ set(PROJECT_ARCH "x86_64")
set(CEF_PLATFORM "macosx64")
endif()
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
@@ -192,6 +198,20 @@ endif()
message(STATUS "Using Python: ${PYTHON_EXECUTABLE}")
+#
+# Enactor custom tweak.
+#
+
+# In order to fix the macos compilation issue with latest xcode
+# cef_mac.h line 63 has been commented. This modified file should be copied from the enactor folder
+
+if(OS_MACOSX)
+ message("MacOS copy cef_mac.h...")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E copy
+ ${CMAKE_SOURCE_DIR}/enactor/cef_mac.h
+ ${CEF_ROOT}/include/internal/cef_mac.h)
+endif()
#
# Java configuration.
@@ -258,12 +278,19 @@ file(COPY "${CEF_ROOT}/README.txt" DESTINATION "${CMAKE_BINARY_DIR}")
if(OS_WINDOWS)
set(GS_PLATFORM "win32")
set(GS_HASHPATH "win/clang-format.exe.sha1")
+ set(GS_OUTPATH "win/clang-format.exe")
elseif(OS_MACOSX)
set(GS_PLATFORM "darwin")
- set(GS_HASHPATH "mac/clang-format.sha1")
+ if("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "arm64")
+ set(GS_HASHPATH "mac/clang-format.arm64.sha1")
+ else()
+ set(GS_HASHPATH "mac/clang-format.x64.sha1")
+ endif()
+ set(GS_OUTPATH "mac/clang-format")
elseif(OS_LINUX)
set(GS_PLATFORM "linux*")
set(GS_HASHPATH "linux64/clang-format.sha1")
+ set(GS_OUTPATH "linux64/clang-format")
endif()
message(STATUS "Downloading clang-format from Google Storage...")
@@ -275,6 +302,7 @@ execute_process(
"--no_auth"
"--bucket" "chromium-clang-format"
"-s" "tools/buildtools/${GS_HASHPATH}"
+ "-o" "tools/buildtools/${GS_OUTPATH}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE EXECUTE_RV
)
@@ -302,3 +330,14 @@ message(STATUS "Python executable: ${PYTHON_EXECUTABLE}")
message(STATUS "Java directory: ${JAVA_DIR}")
message(STATUS "JNI libraries: ${JNI_LIBRARIES}")
message(STATUS "JNI include directories: ${JNI_INCLUDE_DIRS}")
+
+# Enactor manifest generation
+
+string(REGEX REPLACE ".*chromium-([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+).*" "\\1"
+ CMAKE_CHROMIUM_VERSION "${CEF_VERSION}")
+
+set(xml_path "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/manifest.xml")
+set(chromium.version "${CMAKE_CHROMIUM_VERSION}")
+set(jcef.version "${JCEF_VERSION}")
+configure_file("manifest.xml.in" "manifest.xml")
+
diff --git a/README.md b/README.md
index b0f854d4..ea351ea3 100644
--- a/README.md
+++ b/README.md
@@ -4,6 +4,7 @@ The Java Chromium Embedded Framework (JCEF) is a simple framework for embedding
* Building JCEF - https://bitbucket.org/chromiumembedded/java-cef/wiki/BranchesAndBuilding
* Support Forum - http://magpcss.org/ceforum/viewforum.php?f=17
+* Issue Tracker - https://github.com/chromiumembedded/java-cef/issues
* Downloads - https://github.com/jcefmaven/jcefbuild
* Maven/Gradle Artifacts - https://github.com/jcefmaven/jcefmaven
* Donations - http://www.magpcss.org/ceforum/donate.php
@@ -29,7 +30,7 @@ The JCEF project is an extension of the Chromium Embedded Framework (CEF) projec
JCEF is still very much a work in progress. Some ways that you can help out:
-\- Vote for issues in the [JCEF issue tracker](https://bitbucket.org/chromiumembedded/java-cef/issues?status=new&status=open) that are important to you. This helps with development prioritization.
+\- Vote for issues in the [JCEF issue tracker](https://github.com/chromiumembedded/java-cef/issues) that are important to you. This helps with development prioritization.
\- Report any bugs that you find or feature requests that are important to you. Make sure to first search for existing issues before creating new ones. Please use the [JCEF Forum](http://magpcss.org/ceforum/viewforum.php?f=17) and not the issue tracker for usage questions. Each JCEF issue should:
@@ -40,7 +41,7 @@ JCEF is still very much a work in progress. Some ways that you can help out:
\- Write unit tests for new or existing functionality.
-\- Pull requests and patches are welcome. View open issues in the [JCEF issue tracker](https://bitbucket.org/chromiumembedded/java-cef/issues?status=new&status=open) or search for TODO(cef) in the source code for ideas.
+\- Pull requests and patches are welcome. View open issues in the [JCEF issue tracker](https://github.com/chromiumembedded/java-cef/issues) or search for TODO(cef) in the source code for ideas.
If you would like to contribute source code changes to JCEF please follow the below guidelines:
@@ -51,4 +52,4 @@ If you would like to contribute source code changes to JCEF please follow the be
* Be submitted against the current [JCEF master branch](https://bitbucket.org/chromiumembedded/java-cef/src/?at=master) unless explicitly fixing a bug in a CEF release branch.
* Follow the style of existing JCEF source files. In general JCEF uses the [Chromium coding style](http://www.chromium.org/developers/coding-style).
* Include new or modified unit tests as appropriate to the functionality.
-* Not include unnecessary or unrelated changes.
\ No newline at end of file
+* Not include unnecessary or unrelated changes.
diff --git a/assemble-linux.xml b/assemble-linux.xml
new file mode 100644
index 00000000..f32ffb35
--- /dev/null
+++ b/assemble-linux.xml
@@ -0,0 +1,28 @@
+
+
+ java-cef
+
+ zip
+
+ false
+
+
+
+ ${basedir}/binary_distrib/${distribution.folder}/bin/lib/${distribution.folder}
+
+ **/*
+
+
+
+
+
+ ${basedir}/jcef_build/manifest.xml
+
+
+
+
diff --git a/assemble-mac-os.xml b/assemble-mac-os.xml
new file mode 100644
index 00000000..799bb8a4
--- /dev/null
+++ b/assemble-mac-os.xml
@@ -0,0 +1,28 @@
+
+
+ java-cef
+
+ zip
+
+ false
+
+
+
+ ${basedir}/jcef_build/native/Release
+
+ **/*
+
+
+
+
+
+ ${basedir}/jcef_build/manifest.xml
+
+
+
+
diff --git a/assemble-striped-linux.xml b/assemble-striped-linux.xml
new file mode 100644
index 00000000..88a34aa9
--- /dev/null
+++ b/assemble-striped-linux.xml
@@ -0,0 +1,35 @@
+
+
+ java-cef
+
+ zip
+
+ false
+
+
+
+ ${basedir}/binary_distrib/${distribution.folder}/bin/lib/${distribution.folder}
+
+ *
+ strip/*
+
+
+ libcef.so
+ libEGL.so
+ libGLESv2.so
+ libjcef.so
+
+
+
+
+
+ ${basedir}/jcef_build/manifest.xml
+
+
+
+
diff --git a/assemble-windows.xml b/assemble-windows.xml
new file mode 100644
index 00000000..87b45adb
--- /dev/null
+++ b/assemble-windows.xml
@@ -0,0 +1,30 @@
+
+
+ java-cef
+
+ zip
+
+ false
+
+
+
+
+
+ ${basedir}/binary_distrib/${distribution.folder}/bin/lib/${distribution.folder}
+
+ **/*
+
+
+
+
+
+ ${basedir}/jcef_build/manifest.xml
+
+
+
+
diff --git a/enactor/cef_mac.h b/enactor/cef_mac.h
new file mode 100644
index 00000000..899eb94f
--- /dev/null
+++ b/enactor/cef_mac.h
@@ -0,0 +1,115 @@
+// Copyright (c) 2010 Marshall A. Greenblatt. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the name Chromium Embedded
+// Framework nor the names of its contributors may be used to endorse
+// or promote products derived from this software without specific prior
+// written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef CEF_INCLUDE_INTERNAL_CEF_MAC_H_
+#define CEF_INCLUDE_INTERNAL_CEF_MAC_H_
+#pragma once
+
+#include "include/internal/cef_types_mac.h"
+#include "include/internal/cef_types_wrappers.h"
+
+// Handle types.
+#define CefCursorHandle cef_cursor_handle_t
+#define CefEventHandle cef_event_handle_t
+#define CefWindowHandle cef_window_handle_t
+
+///
+/// Class representing CefExecuteProcess arguments.
+///
+class CefMainArgs : public cef_main_args_t {
+ public:
+ CefMainArgs() : cef_main_args_t{} {}
+ CefMainArgs(const cef_main_args_t& r) : cef_main_args_t(r) {}
+ CefMainArgs(int argc_arg, char** argv_arg)
+ : cef_main_args_t{argc_arg, argv_arg} {}
+};
+
+struct CefWindowInfoTraits {
+ typedef cef_window_info_t struct_type;
+
+ static inline void init(struct_type* s) { s->size = sizeof(struct_type); }
+
+ static inline void clear(struct_type* s) {
+ cef_string_clear(&s->window_name);
+ }
+
+ static inline void set(const struct_type* src,
+ struct_type* target,
+ bool copy) {
+ cef_string_set(src->window_name.str, src->window_name.length,
+ &target->window_name, copy);
+ target->bounds = src->bounds;
+ target->hidden = src->hidden;
+ target->parent_view = src->parent_view;
+ target->windowless_rendering_enabled = src->windowless_rendering_enabled;
+ target->shared_texture_enabled = src->shared_texture_enabled;
+ target->external_begin_frame_enabled = src->external_begin_frame_enabled;
+ target->view = src->view;
+ target->runtime_style = src->runtime_style;
+ }
+};
+
+///
+/// Class representing window information.
+///
+class CefWindowInfo : public CefStructBase {
+ public:
+ using base_type = CefStructBase;
+ using base_type::CefStructBase;
+ using base_type::operator=;
+
+ ///
+ /// Create the browser as a child view.
+ ///
+ void SetAsChild(CefWindowHandle parent, const CefRect& bounds) {
+ parent_view = parent;
+ this->bounds = bounds;
+ hidden = false;
+ }
+
+ ///
+ /// Create the browser using windowless (off-screen) rendering. No view
+ /// will be created for the browser and all rendering will occur via the
+ /// CefRenderHandler interface. The |parent| value will be used to identify
+ /// monitor info and to act as the parent view for dialogs, context menus,
+ /// etc. If |parent| is not provided then the main screen monitor will be used
+ /// and some functionality that requires a parent view may not function
+ /// correctly. In order to create windowless browsers the
+ /// CefSettings.windowless_rendering_enabled value must be set to true.
+ /// Transparent painting is enabled by default but can be disabled by setting
+ /// CefBrowserSettings.background_color to an opaque value.
+ ///
+ void SetAsWindowless(CefWindowHandle parent) {
+ windowless_rendering_enabled = true;
+ parent_view = parent;
+ runtime_style = CEF_RUNTIME_STYLE_ALLOY;
+ }
+};
+
+#endif // CEF_INCLUDE_INTERNAL_CEF_MAC_H_
diff --git a/java/org/cef/CefApp.java b/java/org/cef/CefApp.java
index afd10f04..e623b834 100644
--- a/java/org/cef/CefApp.java
+++ b/java/org/cef/CefApp.java
@@ -102,6 +102,12 @@ public enum CefAppState {
*/
INITIALIZED,
+ /**
+ * CEF initialization has failed (for example due to a second process using
+ * the same root_cache_path).
+ */
+ INITIALIZATION_FAILED,
+
/**
* CefApp is in its shutdown process. All CefClients and CefBrowser
* instances will be disposed. No new CefClient or CefBrowser is allowed to
@@ -424,7 +430,11 @@ public void run() {
}
}
- if (N_Initialize(appHandler_, settings)) setState(CefAppState.INITIALIZED);
+ if (N_Initialize(appHandler_, settings)) {
+ setState(CefAppState.INITIALIZED);
+ } else {
+ setState(CefAppState.INITIALIZATION_FAILED);
+ }
}
};
if (SwingUtilities.isEventDispatchThread())
diff --git a/java/org/cef/CefBrowserSettings.java b/java/org/cef/CefBrowserSettings.java
new file mode 100644
index 00000000..8733a418
--- /dev/null
+++ b/java/org/cef/CefBrowserSettings.java
@@ -0,0 +1,31 @@
+// Copyright (c) 2024 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 org.cef;
+
+/**
+ * Browser initialization settings. Specify NULL or 0 to get the recommended
+ * default values. The consequences of using custom values may not be well
+ * tested. Many of these and other settings can also configured using command-
+ * line switches.
+ */
+public class CefBrowserSettings {
+ /**
+ * The maximum rate in frames per second (fps) that CefRenderHandler::OnPaint
+ * will be called for a windowless browser. The actual fps may be lower if
+ * the browser cannot generate frames at the requested rate. The minimum
+ * value is 1 and the maximum value is 60 (default 30). This value can also
+ * be changed dynamically via {@code CefBrowser#setWindowlessFrameRate}
+ */
+ public int windowless_frame_rate = 0;
+
+ public CefBrowserSettings() {}
+
+ @Override
+ public CefBrowserSettings clone() {
+ CefBrowserSettings tmp = new CefBrowserSettings();
+ tmp.windowless_frame_rate = windowless_frame_rate;
+ return tmp;
+ }
+}
diff --git a/java/org/cef/CefClient.java b/java/org/cef/CefClient.java
index f72b4d19..687be93d 100644
--- a/java/org/cef/CefClient.java
+++ b/java/org/cef/CefClient.java
@@ -4,11 +4,7 @@
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.browser.*;
import org.cef.callback.CefAuthCallback;
import org.cef.callback.CefBeforeDownloadCallback;
import org.cef.callback.CefCallback;
@@ -60,6 +56,7 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.Vector;
+import java.util.function.Consumer;
import javax.swing.SwingUtilities;
@@ -141,7 +138,16 @@ public CefBrowser createBrowser(String url, boolean isOffscreenRendered, boolean
CefRequestContext context) {
if (isDisposed_)
throw new IllegalStateException("Can't create browser. CefClient is disposed");
- return CefBrowserFactory.create(this, url, isOffscreenRendered, isTransparent, context);
+ return CefBrowserFactory.create(
+ this, url, isOffscreenRendered, isTransparent, context, null);
+ }
+
+ public CefBrowser createBrowser(String url, boolean isOffscreenRendered, boolean isTransparent,
+ CefRequestContext context, CefBrowserSettings settings) {
+ if (isDisposed_)
+ throw new IllegalStateException("Can't create browser. CefClient is disposed");
+ return CefBrowserFactory.create(
+ this, url, isOffscreenRendered, isTransparent, context, settings);
}
@Override
@@ -274,11 +280,11 @@ public void removeDialogHandler() {
@Override
public boolean onFileDialog(CefBrowser browser, FileDialogMode mode, String title,
- String defaultFilePath, Vector acceptFilters, int selectedAcceptFilter,
- CefFileDialogCallback callback) {
+ String defaultFilePath, Vector acceptFilters, Vector acceptExtensions,
+ Vector acceptDescriptions, CefFileDialogCallback callback) {
if (dialogHandler_ != null && browser != null) {
return dialogHandler_.onFileDialog(browser, mode, title, defaultFilePath, acceptFilters,
- selectedAcceptFilter, callback);
+ acceptExtensions, acceptDescriptions, callback);
}
return false;
}
@@ -306,6 +312,12 @@ public void onTitleChange(CefBrowser browser, String title) {
displayHandler_.onTitleChange(browser, title);
}
+ @Override
+ public void onFullscreenModeChange(CefBrowser browser, boolean fullscreen) {
+ if (displayHandler_ != null && browser != null)
+ displayHandler_.onFullscreenModeChange(browser, fullscreen);
+ }
+
@Override
public boolean onTooltip(CefBrowser browser, String text) {
if (displayHandler_ != null && browser != null) {
@@ -360,10 +372,12 @@ public void removeDownloadHandler() {
}
@Override
- public void onBeforeDownload(CefBrowser browser, CefDownloadItem downloadItem,
+ public boolean onBeforeDownload(CefBrowser browser, CefDownloadItem downloadItem,
String suggestedName, CefBeforeDownloadCallback callback) {
if (downloadHandler_ != null && browser != null)
- downloadHandler_.onBeforeDownload(browser, downloadItem, suggestedName, callback);
+ return downloadHandler_.onBeforeDownload(
+ browser, downloadItem, suggestedName, callback);
+ return false;
}
@Override
@@ -754,6 +768,15 @@ public void onPaint(CefBrowser browser, boolean popup, Rectangle[] dirtyRects,
realHandler.onPaint(browser, popup, dirtyRects, buffer, width, height);
}
+ @Override
+ public void addOnPaintListener(Consumer listener) {}
+
+ @Override
+ public void setOnPaintListener(Consumer listener) {}
+
+ @Override
+ public void removeOnPaintListener(Consumer listener) {}
+
@Override
public boolean startDragging(CefBrowser browser, CefDragData dragData, int mask, int x, int y) {
if (browser == null) return false;
@@ -820,14 +843,6 @@ public boolean getAuthCredentials(CefBrowser browser, String origin_url, boolean
return false;
}
- @Override
- public boolean onQuotaRequest(
- CefBrowser browser, String origin_url, long new_size, CefCallback callback) {
- if (requestHandler_ != null && browser != null)
- return requestHandler_.onQuotaRequest(browser, origin_url, new_size, callback);
- return false;
- }
-
@Override
public boolean onCertificateError(
CefBrowser browser, ErrorCode cert_error, String request_url, CefCallback callback) {
@@ -837,8 +852,10 @@ public boolean onCertificateError(
}
@Override
- public void onRenderProcessTerminated(CefBrowser browser, TerminationStatus status) {
- if (requestHandler_ != null) requestHandler_.onRenderProcessTerminated(browser, status);
+ public void onRenderProcessTerminated(
+ CefBrowser browser, TerminationStatus status, int error_code, String error_string) {
+ if (requestHandler_ != null)
+ requestHandler_.onRenderProcessTerminated(browser, status, error_code, error_string);
}
// CefWindowHandler
diff --git a/java/org/cef/CefSettings.java b/java/org/cef/CefSettings.java
index 5d756d99..a08ff038 100644
--- a/java/org/cef/CefSettings.java
+++ b/java/org/cef/CefSettings.java
@@ -102,10 +102,39 @@ public ColorType clone() {
* The location where cache data will be stored on disk. If empty an in-memory
* cache will be used for some features and a temporary disk cache for others.
* HTML5 databases such as localStorage will only persist across sessions if a
- * cache path is specified.
+ * cache path is specified. If this is set and root_cache_path is also set, the cache_path
+ * directory must reside within root_cache_path.
*/
public String cache_path = null;
+ /**
+ * The root directory for installation-specific data and the parent directory
+ * for profile-specific data. All CefSettings.cache_path and
+ * CefRequestContextSettings.cache_path values must have this parent
+ * directory in common. If this value is empty and CefSettings.cache_path is
+ * non-empty then it will default to the CefSettings.cache_path value. Any
+ * non-empty value must be an absolute path. If both values are empty then
+ * the default platform-specific directory will be used
+ * ("~/.config/cef_user_data" directory on Linux, "~/Library/Application
+ * Support/CEF/User Data" directory on MacOS, "AppData\Local\CEF\User Data"
+ * directory under the user profile directory on Windows). Use of the default
+ * directory is not recommended in production applications (see below).
+ *
+ * Multiple application instances writing to the same root_cache_path
+ * directory could result in data corruption. A process singleton lock based
+ * on the root_cache_path value is therefore used to protect against this.
+ * This singleton behavior applies to all CEF-based applications using
+ * version 120 or newer. You should customize root_cache_path for your
+ * application and implement CefAppHandler::
+ * onAlreadyRunningAppRelaunch, which will then be called on any app relaunch
+ * with the same root_cache_path value.
+ *
+ * Failure to set the root_cache_path value correctly may result in startup
+ * crashes or other unexpected behaviors (for example, the sandbox blocking
+ * read/write access to certain files).
+ */
+ public String root_cache_path = null;
+
/**
* To persist session cookies (cookies without an expiry date or validity
* interval) by default when using the global cookie manager set this value to
@@ -181,15 +210,6 @@ public ColorType clone() {
*/
public String locales_dir_path = null;
- /**
- * Set to true to disable loading of pack files for resources and locales.
- * A resource bundle handler must be provided for the browser and render
- * processes via CefApp::GetResourceBundleHandler() if loading of pack files
- * is disabled. Also configurable using the "disable-pack-loading" command-
- * line switch.
- */
- public boolean pack_loading_disabled = false;
-
/**
* Set to a value between 1024 and 65535 to enable remote debugging on the
* specified port. For example, if 8080 is specified the remote debugging URL
@@ -199,6 +219,22 @@ public ColorType clone() {
*/
public int remote_debugging_port = 0;
+ /**
+ * Specify an ID to enable Chrome policy management via Platform and OS-user
+ * policies. On Windows, this is a registry key like
+ * "SOFTWARE\\Policies\\Google\\Chrome". On MacOS, this is a bundle ID like
+ * "com.google.Chrome". On Linux, this is an absolute directory path like
+ * "/etc/opt/chrome/policies". Only supported with Chrome style. See
+ * https://support.google.com/chrome/a/answer/9037717 for details.
+ *
+ * Chrome Browser Cloud Management integration, when enabled via the
+ * "enable-chrome-browser-cloud-management" command-line flag, will also use
+ * the specified ID. See https://support.google.com/chrome/a/answer/9116814
+ * for details.
+ */
+ public String chrome_policy_id;
+
+
/**
* The number of stack trace frames to capture for uncaught exceptions.
* Specify a positive value to enable the CefV8ContextHandler::
@@ -239,6 +275,7 @@ public CefSettings clone() {
tmp.windowless_rendering_enabled = windowless_rendering_enabled;
tmp.command_line_args_disabled = command_line_args_disabled;
tmp.cache_path = cache_path;
+ tmp.root_cache_path = root_cache_path;
tmp.persist_session_cookies = persist_session_cookies;
tmp.user_agent = user_agent;
tmp.user_agent_product = user_agent_product;
@@ -248,7 +285,7 @@ public CefSettings clone() {
tmp.javascript_flags = javascript_flags;
tmp.resources_dir_path = resources_dir_path;
tmp.locales_dir_path = locales_dir_path;
- tmp.pack_loading_disabled = pack_loading_disabled;
+ tmp.chrome_policy_id = chrome_policy_id;
tmp.remote_debugging_port = remote_debugging_port;
tmp.uncaught_exception_stack_size = uncaught_exception_stack_size;
if (background_color != null) tmp.background_color = background_color.clone();
diff --git a/java/org/cef/SystemBootstrap.java b/java/org/cef/SystemBootstrap.java
index 0a217ac4..342aaa82 100644
--- a/java/org/cef/SystemBootstrap.java
+++ b/java/org/cef/SystemBootstrap.java
@@ -13,7 +13,9 @@ public class SystemBootstrap {
/**
* Simple interface for how a library by name should be loaded.
*/
- static public interface Loader { public void loadLibrary(String libname); }
+ static public interface Loader {
+ public void loadLibrary(String libname);
+ }
/**
* Default implementation is to call System.loadLibrary
diff --git a/java/org/cef/browser/CefBrowser.java b/java/org/cef/browser/CefBrowser.java
index 14eeab26..29a6b0dc 100644
--- a/java/org/cef/browser/CefBrowser.java
+++ b/java/org/cef/browser/CefBrowser.java
@@ -49,6 +49,14 @@ public interface CefBrowser {
*/
public CefRenderHandler getRenderHandler();
+ /**
+ * Retrieves the request context used by this browser instance. May be the
+ * global request context if this browser does not have a specific request
+ * context.
+ */
+ public CefRequestContext getRequestContext();
+
+
/**
* Get an implementation of CefWindowHandler if any.
* @return An instance of CefWindowHandler or null.
@@ -125,20 +133,20 @@ public interface CefBrowser {
* @param identifier The unique frame identifier
* @return The frame or NULL if not found
*/
- public CefFrame getFrame(long identifier);
+ public CefFrame getFrameByIdentifier(String identifier);
/**
* Returns the frame with the specified name, or NULL if not found.
* @param name The specified name
* @return The frame or NULL if not found
*/
- public CefFrame getFrame(String name);
+ public CefFrame getFrameByName(String name);
/**
* Returns the identifiers of all existing frames.
* @return All identifiers of existing frames.
*/
- public Vector getFrameIdentifiers();
+ public Vector getFrameIdentifiers();
/**
* Returns the names of all existing frames.
@@ -337,18 +345,31 @@ public void runFileDialog(FileDialogMode mode, String title, String defaultFileP
public void stopFinding(boolean clearSelection);
/**
- * Get an instance of the dev tools to be displayed in its own window or to be
- * embedded within your UI. Only one instance per browser is available.
+ * Get an instance of the DevTools to be displayed in its own window.
*/
- public CefBrowser getDevTools();
+ public void openDevTools();
/**
- * Get an instance of the dev tools to be displayed in its own window or to be
- * embedded within your UI. Only one instance per browser is available.
+ * Open an instance of the DevTools to be displayed in its own window.
*
* @param inspectAt a position in the UI which should be inspected.
*/
- public CefBrowser getDevTools(Point inspectAt);
+ public void openDevTools(Point inspectAt);
+
+ /**
+ * Close the DevTools.
+ */
+ public void closeDevTools();
+
+ /**
+ * Get an instance of a client that can be used to leverage the DevTools
+ * protocol. Only one instance per browser is available.
+ *
+ * @see {@link CefDevToolsClient}
+ * @return DevTools client, or null if this browser is not yet created
+ * or if it is closed or closing
+ */
+ public CefDevToolsClient getDevToolsClient();
/**
* If a misspelled word is currently selected in an editable node calling
@@ -363,7 +384,7 @@ public void runFileDialog(FileDialogMode mode, String title, String defaultFileP
*
* If executed on the AWT Event Thread, this returns an immediately resolved {@link
* java.util.concurrent.CompletableFuture}. If executed from another thread, the {@link
- * java.util.concurrent.CompletableFuture} returned is resolved as soon as the screenshot
+ * java.util.concurrent.CompletableFuture} returned is resolved as soon as the screenshot
* has been taken (which must happen on the event thread).
*
* The generated screenshot can either be returned as-is, containing all natively-rendered
@@ -380,4 +401,26 @@ public void runFileDialog(FileDialogMode mode, String title, String defaultFileP
* @throws UnsupportedOperationException if not supported
*/
public CompletableFuture createScreenshot(boolean nativeResolution);
+
+ /**
+ * Set the maximum rate in frames per second (fps) that {@code CefRenderHandler::onPaint}
+ * will be called for a windowless browser. The actual fps may be
+ * lower if the browser cannot generate frames at the requested rate. The
+ * minimum value is 1, and the maximum value is 60 (default 30).
+ *
+ * @param frameRate the maximum frame rate
+ * @throws UnsupportedOperationException if not supported
+ */
+ public void setWindowlessFrameRate(int frameRate);
+
+ /**
+ * Returns the maximum rate in frames per second (fps) that {@code CefRenderHandler::onPaint}
+ * will be called for a windowless browser. The actual fps may be lower if the browser cannot
+ * generate frames at the requested rate. The minimum value is 1, and the maximum value is 60
+ * (default 30).
+ *
+ * @return the framerate, 0 if an error occurs
+ * @throws UnsupportedOperationException if not supported
+ */
+ public CompletableFuture getWindowlessFrameRate();
}
diff --git a/java/org/cef/browser/CefBrowserFactory.java b/java/org/cef/browser/CefBrowserFactory.java
index 708d0f24..299dfcfb 100644
--- a/java/org/cef/browser/CefBrowserFactory.java
+++ b/java/org/cef/browser/CefBrowserFactory.java
@@ -4,6 +4,7 @@
package org.cef.browser;
+import org.cef.CefBrowserSettings;
import org.cef.CefClient;
/**
@@ -11,8 +12,9 @@
*/
public class CefBrowserFactory {
public static CefBrowser create(CefClient client, String url, boolean isOffscreenRendered,
- boolean isTransparent, CefRequestContext context) {
- if (isOffscreenRendered) return new CefBrowserOsr(client, url, isTransparent, context);
- return new CefBrowserWr(client, url, context);
+ boolean isTransparent, CefRequestContext context, CefBrowserSettings settings) {
+ if (isOffscreenRendered)
+ return new CefBrowserOsr(client, url, isTransparent, context, settings);
+ return new CefBrowserWr(client, url, context, settings);
}
}
diff --git a/java/org/cef/browser/CefBrowserOsr.java b/java/org/cef/browser/CefBrowserOsr.java
index f0672f9b..b999b6ba 100644
--- a/java/org/cef/browser/CefBrowserOsr.java
+++ b/java/org/cef/browser/CefBrowserOsr.java
@@ -15,6 +15,7 @@
import com.jogamp.opengl.awt.GLCanvas;
import com.jogamp.opengl.util.GLBuffers;
+import org.cef.CefBrowserSettings;
import org.cef.CefClient;
import org.cef.OS;
import org.cef.callback.CefDragData;
@@ -60,9 +61,11 @@
import java.util.Arrays;
import java.util.concurrent.Callable;
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;
import javax.swing.MenuSelectionManager;
import javax.swing.SwingUtilities;
@@ -84,13 +87,18 @@ class CefBrowserOsr extends CefBrowser_N implements CefRenderHandler {
private int depth_per_component = 8;
private boolean isTransparent_;
- CefBrowserOsr(CefClient client, String url, boolean transparent, CefRequestContext context) {
- this(client, url, transparent, context, null, null);
+ private CopyOnWriteArrayList> onPaintListeners =
+ new CopyOnWriteArrayList<>();
+
+ CefBrowserOsr(CefClient client, String url, boolean transparent, CefRequestContext context,
+ CefBrowserSettings settings) {
+ this(client, url, transparent, context, null, null, settings);
}
private CefBrowserOsr(CefClient client, String url, boolean transparent,
- CefRequestContext context, CefBrowserOsr parent, Point inspectAt) {
- super(client, url, context, parent, inspectAt);
+ CefRequestContext context, CefBrowserOsr parent, Point inspectAt,
+ CefBrowserSettings settings) {
+ super(client, url, context, parent, inspectAt, settings);
isTransparent_ = transparent;
renderer_ = new CefRenderer(transparent);
createGLCanvas();
@@ -117,7 +125,7 @@ public CefRenderHandler getRenderHandler() {
protected CefBrowser_N createDevToolsBrowser(CefClient client, String url,
CefRequestContext context, CefBrowser_N parent, Point inspectAt) {
return new CefBrowserOsr(
- client, url, isTransparent_, context, (CefBrowserOsr) this, inspectAt);
+ client, url, isTransparent_, context, (CefBrowserOsr) this, inspectAt, null);
}
private synchronized long getWindowHandle() {
@@ -354,6 +362,22 @@ public void onPopupSize(CefBrowser browser, Rectangle size) {
renderer_.onPopupSize(size);
}
+ @Override
+ public void addOnPaintListener(Consumer listener) {
+ onPaintListeners.add(listener);
+ }
+
+ @Override
+ public void setOnPaintListener(Consumer listener) {
+ onPaintListeners.clear();
+ onPaintListeners.add(listener);
+ }
+
+ @Override
+ public void removeOnPaintListener(Consumer listener) {
+ onPaintListeners.remove(listener);
+ }
+
@Override
public void onPaint(CefBrowser browser, boolean popup, Rectangle[] dirtyRects,
ByteBuffer buffer, int width, int height) {
@@ -376,6 +400,13 @@ public void run() {
canvas_.display();
}
});
+ if (!onPaintListeners.isEmpty()) {
+ CefPaintEvent paintEvent =
+ new CefPaintEvent(browser, popup, dirtyRects, buffer, width, height);
+ for (Consumer l : onPaintListeners) {
+ l.accept(paintEvent);
+ }
+ }
}
@Override
@@ -401,11 +432,25 @@ protected void registerListeners() {}
protected void unregisterListeners() {}
};
+ private static int getDndAction(int mask) {
+ // Default to copy if multiple operations are specified.
+ int action = DnDConstants.ACTION_NONE;
+ if ((mask & CefDragData.DragOperations.DRAG_OPERATION_COPY)
+ == CefDragData.DragOperations.DRAG_OPERATION_COPY) {
+ action = DnDConstants.ACTION_COPY;
+ } else if ((mask & CefDragData.DragOperations.DRAG_OPERATION_MOVE)
+ == CefDragData.DragOperations.DRAG_OPERATION_MOVE) {
+ action = DnDConstants.ACTION_MOVE;
+ } else if ((mask & CefDragData.DragOperations.DRAG_OPERATION_LINK)
+ == CefDragData.DragOperations.DRAG_OPERATION_LINK) {
+ action = DnDConstants.ACTION_LINK;
+ }
+ return action;
+ }
+
@Override
public boolean startDragging(CefBrowser browser, CefDragData dragData, int mask, int x, int y) {
- int action = (mask & CefDragData.DragOperations.DRAG_OPERATION_MOVE) == 0
- ? DnDConstants.ACTION_COPY
- : DnDConstants.ACTION_MOVE;
+ int action = getDndAction(mask);
MouseEvent triggerEvent =
new MouseEvent(canvas_, MouseEvent.MOUSE_DRAGGED, 0, 0, x, y, 0, false);
DragGestureEvent ev = new DragGestureEvent(
@@ -416,7 +461,7 @@ public boolean startDragging(CefBrowser browser, CefDragData dragData, int mask,
new StringSelection(dragData.getFragmentText()), new DragSourceAdapter() {
@Override
public void dragDropEnd(DragSourceDropEvent dsde) {
- dragSourceEndedAt(dsde.getLocation(), mask);
+ dragSourceEndedAt(dsde.getLocation(), action);
dragSourceSystemDragEnded();
}
});
diff --git a/java/org/cef/browser/CefBrowserWr.java b/java/org/cef/browser/CefBrowserWr.java
index b142bc5c..677ddce7 100644
--- a/java/org/cef/browser/CefBrowserWr.java
+++ b/java/org/cef/browser/CefBrowserWr.java
@@ -4,6 +4,7 @@
package org.cef.browser;
+import org.cef.CefBrowserSettings;
import org.cef.CefClient;
import org.cef.OS;
import org.cef.handler.CefWindowHandler;
@@ -166,14 +167,15 @@ public int getClickCount(int event, int button) {
}
};
- CefBrowserWr(CefClient client, String url, CefRequestContext context) {
- this(client, url, context, null, null);
+ CefBrowserWr(
+ CefClient client, String url, CefRequestContext context, CefBrowserSettings settings) {
+ this(client, url, context, null, null, settings);
}
@SuppressWarnings("serial")
private CefBrowserWr(CefClient client, String url, CefRequestContext context,
- CefBrowserWr parent, Point inspectAt) {
- super(client, url, context, parent, inspectAt);
+ CefBrowserWr parent, Point inspectAt, CefBrowserSettings settings) {
+ super(client, url, context, parent, inspectAt, settings);
delayedUpdate_.setRepeats(false);
// Disabling lightweight of popup menu is required because
@@ -318,7 +320,7 @@ public CefWindowHandler getWindowHandler() {
@Override
protected CefBrowser_N createDevToolsBrowser(CefClient client, String url,
CefRequestContext context, CefBrowser_N parent, Point inspectAt) {
- return new CefBrowserWr(client, url, context, (CefBrowserWr) this, inspectAt);
+ return new CefBrowserWr(client, url, context, (CefBrowserWr) this, inspectAt, null);
}
private synchronized long getWindowHandle() {
@@ -378,7 +380,7 @@ private void doUpdate() {
}
} else {
synchronized (content_rect_) {
- Rectangle bounds = component_.getBounds();
+ Rectangle bounds = null != canvas_ ? canvas_.getBounds() : component_.getBounds();
content_rect_ = new Rectangle((int) (bounds.getX() * scaleFactor_),
(int) (bounds.getY() * scaleFactor_),
(int) (bounds.getWidth() * scaleFactor_),
@@ -421,4 +423,16 @@ private boolean createBrowserIfRequired(boolean hasParent) {
public CompletableFuture createScreenshot(boolean nativeResolution) {
throw new UnsupportedOperationException("Unsupported for windowed rendering");
}
+
+ @Override
+ public void setWindowlessFrameRate(int frameRate) {
+ throw new UnsupportedOperationException(
+ "You can only set windowless framerate on OSR browser");
+ }
+
+ @Override
+ public CompletableFuture getWindowlessFrameRate() {
+ throw new UnsupportedOperationException(
+ "You can only get windowless framerate on OSR browser");
+ }
}
diff --git a/java/org/cef/browser/CefBrowser_N.java b/java/org/cef/browser/CefBrowser_N.java
index 406d0256..c89e2968 100644
--- a/java/org/cef/browser/CefBrowser_N.java
+++ b/java/org/cef/browser/CefBrowser_N.java
@@ -4,8 +4,9 @@
package org.cef.browser;
+import org.cef.CefBrowserSettings;
import org.cef.CefClient;
-import org.cef.browser.CefRequestContext;
+import org.cef.browser.CefDevToolsClient.DevToolsException;
import org.cef.callback.CefDragData;
import org.cef.callback.CefNativeAdapter;
import org.cef.callback.CefPdfPrintCallback;
@@ -18,7 +19,6 @@
import org.cef.misc.CefPdfPrintSettings;
import org.cef.network.CefRequest;
-import java.awt.Canvas;
import java.awt.Component;
import java.awt.Point;
import java.awt.Rectangle;
@@ -28,6 +28,7 @@
import java.awt.event.MouseWheelEvent;
import java.awt.event.WindowEvent;
import java.util.Vector;
+import java.util.concurrent.CompletableFuture;
import javax.swing.SwingUtilities;
@@ -44,26 +45,32 @@ abstract class CefBrowser_N extends CefNativeAdapter implements CefBrowser {
private final CefRequestContext request_context_;
private volatile CefBrowser_N parent_ = null;
private volatile Point inspectAt_ = null;
- private volatile CefBrowser_N devTools_ = null;
+ private volatile CefDevToolsClient devToolsClient_ = null;
private boolean closeAllowed_ = false;
private volatile boolean isClosed_ = false;
private volatile boolean isClosing_ = false;
+ private final CefBrowserSettings settings_;
protected CefBrowser_N(CefClient client, String url, CefRequestContext context,
- CefBrowser_N parent, Point inspectAt) {
+ CefBrowser_N parent, Point inspectAt, CefBrowserSettings settings) {
client_ = client;
url_ = url;
request_context_ = context;
parent_ = parent;
inspectAt_ = inspectAt;
+ if (settings != null)
+ settings_ = settings.clone();
+ else
+ settings_ = new CefBrowserSettings();
}
protected String getUrl() {
return url_;
}
- protected CefRequestContext getRequestContext() {
- return request_context_;
+ @Override
+ public CefRequestContext getRequestContext() {
+ return request_context_ != null ? request_context_ : CefRequestContext.getGlobalContext();
}
protected CefBrowser_N getParentBrowser() {
@@ -127,22 +134,52 @@ public synchronized void onBeforeClose() {
if (request_context_ != null) request_context_.dispose();
if (parent_ != null) {
parent_.closeDevTools();
- parent_.devTools_ = null;
parent_ = null;
}
+ if (devToolsClient_ != null) {
+ devToolsClient_.close();
+ }
+ }
+
+ @Override
+ public void openDevTools() {
+ openDevTools(null);
}
@Override
- public CefBrowser getDevTools() {
- return getDevTools(null);
+ public synchronized void openDevTools(Point inspectAt) {
+ createDevToolsBrowser(client_, url_, request_context_, this, inspectAt).createImmediately();
}
@Override
- public synchronized CefBrowser getDevTools(Point inspectAt) {
- if (devTools_ == null) {
- devTools_ = createDevToolsBrowser(client_, url_, request_context_, this, inspectAt);
+ public synchronized CefDevToolsClient getDevToolsClient() {
+ if (!isPending_ || isClosing_ || isClosed_) {
+ return null;
+ }
+ if (devToolsClient_ == null || devToolsClient_.isClosed()) {
+ devToolsClient_ = new CefDevToolsClient(this);
}
- return devTools_;
+ return devToolsClient_;
+ }
+
+ CompletableFuture executeDevToolsMethod(String method, String parametersAsJson) {
+ CompletableFuture future = new CompletableFuture<>();
+ N_ExecuteDevToolsMethod(method, parametersAsJson, new IntCallback() {
+ @Override
+ public void onComplete(int generatedMessageId) {
+ if (generatedMessageId <= 0) {
+ future.completeExceptionally(new DevToolsException(
+ String.format("Failed to execute DevTools method %s", method)));
+ } else {
+ future.complete(generatedMessageId);
+ }
+ }
+ });
+ return future;
+ }
+
+ CefRegistration addDevToolsMessageObserver(CefDevToolsMessageObserver observer) {
+ return N_AddDevToolsMessageObserver(observer);
}
protected abstract CefBrowser_N createDevToolsBrowser(CefClient client, String url,
@@ -155,8 +192,8 @@ protected void createBrowser(CefClientHandler clientHandler, long windowHandle,
boolean osr, boolean transparent, Component canvas, CefRequestContext context) {
if (getNativeRef("CefBrowser") == 0 && !isPending_) {
try {
- N_CreateBrowser(
- clientHandler, windowHandle, url, osr, transparent, canvas, context);
+ N_CreateBrowser(clientHandler, windowHandle, url, osr, transparent, canvas, context,
+ settings_);
} catch (UnsatisfiedLinkError err) {
err.printStackTrace();
}
@@ -310,9 +347,9 @@ public CefFrame getFocusedFrame() {
}
@Override
- public CefFrame getFrame(long identifier) {
+ public CefFrame getFrameByIdentifier(String identifier) {
try {
- return N_GetFrame(identifier);
+ return N_GetFrameByIdentifier(identifier);
} catch (UnsatisfiedLinkError ule) {
ule.printStackTrace();
return null;
@@ -320,9 +357,9 @@ public CefFrame getFrame(long identifier) {
}
@Override
- public CefFrame getFrame(String name) {
+ public CefFrame getFrameByName(String name) {
try {
- return N_GetFrame2(name);
+ return N_GetFrameByName(name);
} catch (UnsatisfiedLinkError ule) {
ule.printStackTrace();
return null;
@@ -330,7 +367,7 @@ public CefFrame getFrame(String name) {
}
@Override
- public Vector getFrameIdentifiers() {
+ public Vector getFrameIdentifiers() {
try {
return N_GetFrameIdentifiers();
} catch (UnsatisfiedLinkError ule) {
@@ -379,6 +416,7 @@ public boolean hasDocument() {
return false;
}
+ @Override
public void viewSource() {
try {
N_ViewSource();
@@ -387,6 +425,7 @@ public void viewSource() {
}
}
+ @Override
public void getSource(CefStringVisitor visitor) {
try {
N_GetSource(visitor);
@@ -395,6 +434,7 @@ public void getSource(CefStringVisitor visitor) {
}
}
+ @Override
public void getText(CefStringVisitor visitor) {
try {
N_GetText(visitor);
@@ -550,7 +590,8 @@ public void stopFinding(boolean clearSelection) {
}
}
- protected final void closeDevTools() {
+ @Override
+ public void closeDevTools() {
try {
N_CloseDevTools();
} catch (UnsatisfiedLinkError ule) {
@@ -751,11 +792,38 @@ protected final void notifyMoveOrResizeStarted() {
}
}
+ public void setWindowlessFrameRate(int frameRate) {
+ try {
+ N_SetWindowlessFrameRate(frameRate);
+ } catch (UnsatisfiedLinkError ule) {
+ ule.printStackTrace();
+ }
+ }
+
+ public CompletableFuture getWindowlessFrameRate() {
+ final CompletableFuture future = new CompletableFuture<>();
+ try {
+ N_GetWindowlessFrameRate(future::complete);
+ } catch (UnsatisfiedLinkError ule) {
+ ule.printStackTrace();
+ future.complete(0);
+ }
+ return future;
+ }
+
+ private interface IntCallback {
+ void onComplete(int value);
+ }
+
private final native boolean N_CreateBrowser(CefClientHandler clientHandler, long windowHandle,
String url, boolean osr, boolean transparent, Component canvas,
- CefRequestContext context);
+ CefRequestContext context, CefBrowserSettings settings);
private final native boolean N_CreateDevTools(CefBrowser parent, CefClientHandler clientHandler,
long windowHandle, boolean osr, boolean transparent, Component canvas, Point inspectAt);
+ private final native void N_ExecuteDevToolsMethod(
+ String method, String parametersAsJson, IntCallback callback);
+ private final native CefRegistration N_AddDevToolsMessageObserver(
+ CefDevToolsMessageObserver observer);
private final native long N_GetWindowHandle(long surfaceHandle);
private final native boolean N_CanGoBack();
private final native void N_GoBack();
@@ -768,9 +836,9 @@ private final native boolean N_CreateDevTools(CefBrowser parent, CefClientHandle
private final native int N_GetIdentifier();
private final native CefFrame N_GetMainFrame();
private final native CefFrame N_GetFocusedFrame();
- private final native CefFrame N_GetFrame(long identifier);
- private final native CefFrame N_GetFrame2(String name);
- private final native Vector N_GetFrameIdentifiers();
+ private final native CefFrame N_GetFrameByIdentifier(String identifier);
+ private final native CefFrame N_GetFrameByName(String name);
+ private final native Vector N_GetFrameIdentifiers();
private final native Vector N_GetFrameNames();
private final native int N_GetFrameCount();
private final native boolean N_IsPopup();
@@ -814,4 +882,6 @@ private final native void N_DragTargetDragEnter(
private final native void N_UpdateUI(Rectangle contentRect, Rectangle browserRect);
private final native void N_SetParent(long windowHandle, Component canvas);
private final native void N_NotifyMoveOrResizeStarted();
+ private final native void N_SetWindowlessFrameRate(int frameRate);
+ private final native void N_GetWindowlessFrameRate(IntCallback frameRateCallback);
}
diff --git a/java/org/cef/browser/CefDevToolsClient.java b/java/org/cef/browser/CefDevToolsClient.java
new file mode 100644
index 00000000..ee119469
--- /dev/null
+++ b/java/org/cef/browser/CefDevToolsClient.java
@@ -0,0 +1,165 @@
+// Copyright (c) 2024 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 org.cef.browser;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+
+public class CefDevToolsClient implements AutoCloseable {
+ private final Map> queuedCommands_ =
+ Collections.synchronizedMap(new HashMap<>());
+ private final Set eventListeners_ =
+ Collections.synchronizedSet(new LinkedHashSet<>());
+ private CefRegistration registration_;
+ private final CefBrowser_N browser_;
+
+ /**
+ * Use {@link CefBrowser#getDevToolsClient()} to get an instance of this class.
+ */
+ CefDevToolsClient(CefBrowser_N browser) {
+ this.browser_ = browser;
+
+ registration_ = browser.addDevToolsMessageObserver(new CefDevToolsMessageObserver() {
+ @Override
+ public void onDevToolsMethodResult(
+ CefBrowser browser, int messageId, boolean success, String result) {
+ CompletableFuture future = getQueuedCommand(messageId);
+ if (success) {
+ future.complete(result);
+ } else {
+ future.completeExceptionally(
+ new DevToolsException("DevTools method failed", result));
+ }
+ }
+
+ @Override
+ public void onDevToolsEvent(CefBrowser browser, String method, String parameters) {
+ for (EventListener eventListener : eventListeners_) {
+ eventListener.onEvent(method, parameters);
+ }
+ }
+ });
+ }
+
+ @Override
+ public void close() {
+ queuedCommands_.clear();
+ eventListeners_.clear();
+ registration_ = null;
+ }
+
+ public boolean isClosed() {
+ return registration_ == null;
+ }
+
+ private CompletableFuture getQueuedCommand(Integer messageId) {
+ return queuedCommands_.computeIfAbsent(messageId, key -> new CompletableFuture<>());
+ }
+
+ /**
+ * Execute a method call over the DevTools protocol. See the DevTools protocol documentation
+ * for details of supported methods and the expected syntax for parameters.
+ *
+ *
If an error occurs the returned future is completed exceptionally, otherwise its value is
+ * asynchronously set to the method result.
+ *
+ *
Call {@link #addEventListener(String, EventListener)} to subscribe to events.
+ *
+ * @param method the method name
+ * @return return a future with the method result if the method was executed successfully
+ */
+ public CompletableFuture executeDevToolsMethod(String method) {
+ return executeDevToolsMethod(method, null);
+ }
+
+ /**
+ * Execute a method call over the DevTools protocol. See the DevTools protocol documentation
+ * for details of supported methods and the expected syntax for parameters.
+ *
+ *
If an error occurs the returned future is completed exceptionally, otherwise its value is
+ * asynchronously set to the method result.
+ *
+ *
Call {@link #addEventListener(String, EventListener)} to subscribe to events.
+ *
+ * @param method the method name
+ * @param parametersAsJson JSON object with parameters, or null if no parameters are needed
+ * @return return a future with the method result if the method was executed successfully
+ */
+ public CompletableFuture executeDevToolsMethod(String method, String parametersAsJson) {
+ if (isClosed()) {
+ CompletableFuture future = new CompletableFuture<>();
+ future.completeExceptionally(new DevToolsException("Client is closed"));
+ return future;
+ }
+
+ return browser_.executeDevToolsMethod(method, parametersAsJson)
+ .thenCompose(this::getQueuedCommand);
+ }
+
+ /**
+ * Add an event listener for DevTools protocol events. Events by default are disabled
+ * and need to be enabled on a per domain basis, e.g. by sending Network.enable to enable
+ * network related events.
+ *
+ * @param eventListener the listener to add
+ */
+ public void addEventListener(EventListener eventListener) {
+ eventListeners_.add(eventListener);
+ }
+
+ /**
+ * Remove an event listener for DevTools protocol events.
+ *
+ * @param eventListener the listener to remove
+ */
+ public void removeEventListener(EventListener eventListener) {
+ eventListeners_.remove(eventListener);
+ }
+
+ public interface EventListener {
+ /**
+ * Method that will be called on receipt of an event.
+ * @param eventName the event name
+ * @param messageAsJson JSON object with the event message
+ */
+ void onEvent(String eventName, String messageAsJson);
+ }
+
+ public static final class DevToolsException extends Exception {
+ private static final long serialVersionUID = 3952948449841375372L;
+
+ private final String json_;
+
+ public DevToolsException(String message) {
+ this(message, null);
+ }
+
+ public DevToolsException(String message, String json) {
+ super(message);
+ this.json_ = json;
+ }
+
+ @Override
+ public String getMessage() {
+ String message = super.getMessage();
+ if (json_ != null) message += ": " + json_;
+ return message;
+ }
+
+ /**
+ * JSON object with the error details that were passed back by the DevTools
+ * host, or null if no further details are available.
+ */
+ public String getJson() {
+ return json_;
+ }
+ }
+}
diff --git a/java/org/cef/browser/CefDevToolsMessageObserver.java b/java/org/cef/browser/CefDevToolsMessageObserver.java
new file mode 100644
index 00000000..3a851356
--- /dev/null
+++ b/java/org/cef/browser/CefDevToolsMessageObserver.java
@@ -0,0 +1,34 @@
+// Copyright (c) 2024 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 org.cef.browser;
+
+/**
+ * Used internally by {@link CefDevToolsClient}.
+ *
+ * Callback interface for {@link CefBrowser#addDevToolsMessageObserver(CefDevToolsMessageObserver)}.
+ * The methods of this class will be called on the CEF UI thread.
+ */
+interface CefDevToolsMessageObserver {
+ /**
+ * Method that will be called after attempted execution of a DevTools protocol method.
+ *
+ * @param browser the originating browser instance
+ * @param messageId the ID that identifies the originating method call
+ * @param success if the method succeeded, |success| will be true and |result| will be a JSON
+ * object containing the method call result. If the method call failed, |success| will
+ * be false and |result| will be a JSON object describing the error.
+ * @param result method call result or an error
+ */
+ void onDevToolsMethodResult(CefBrowser browser, int messageId, boolean success, String result);
+
+ /**
+ * Method that will be called on receipt of a DevTools protocol event.
+ *
+ * @param browser the originating browser instance
+ * @param method the method name
+ * @param parameters the event data
+ */
+ void onDevToolsEvent(CefBrowser browser, String method, String parameters);
+}
diff --git a/java/org/cef/browser/CefFrame.java b/java/org/cef/browser/CefFrame.java
index 3a2393fb..a64b4ed9 100644
--- a/java/org/cef/browser/CefFrame.java
+++ b/java/org/cef/browser/CefFrame.java
@@ -14,11 +14,11 @@ public interface CefFrame {
void dispose();
/**
- * Returns the globally unique identifier for this frame or < 0 if the
+ * Returns the globally unique identifier for this frame or an empty string if the
* underlying frame does not yet exist.
* @return The frame identifier
*/
- long getIdentifier();
+ String getIdentifier();
/**
* Emits the URL currently loaded in this frame.
@@ -98,4 +98,9 @@ public interface CefFrame {
* Execute paste in this frame.
*/
public void paste();
-}
\ No newline at end of file
+
+ /**
+ * Execute selectAll in this frame.
+ */
+ public void selectAll();
+}
diff --git a/java/org/cef/browser/CefFrame_N.java b/java/org/cef/browser/CefFrame_N.java
index 8e129f1a..0bd1c6af 100644
--- a/java/org/cef/browser/CefFrame_N.java
+++ b/java/org/cef/browser/CefFrame_N.java
@@ -30,12 +30,12 @@ public void dispose() {
}
@Override
- public long getIdentifier() {
+ public String getIdentifier() {
try {
return N_GetIdentifier(getNativeRef(null));
} catch (UnsatisfiedLinkError ule) {
ule.printStackTrace();
- return -1;
+ return null;
}
}
@@ -148,8 +148,16 @@ public void paste() {
}
}
+ public void selectAll() {
+ try {
+ N_SelectAll(getNativeRef(null));
+ } catch (UnsatisfiedLinkError ule) {
+ ule.printStackTrace();
+ }
+ }
+
private final native void N_Dispose(long self);
- private final native long N_GetIdentifier(long self);
+ private final native String N_GetIdentifier(long self);
private final native String N_GetURL(long self);
private final native String N_GetName(long self);
private final native boolean N_IsMain(long self);
@@ -162,4 +170,5 @@ public void paste() {
private final native void N_Cut(long self);
private final native void N_Copy(long self);
private final native void N_Paste(long self);
+ private final native void N_SelectAll(long self);
}
diff --git a/java/org/cef/browser/CefPaintEvent.java b/java/org/cef/browser/CefPaintEvent.java
new file mode 100644
index 00000000..aed9af31
--- /dev/null
+++ b/java/org/cef/browser/CefPaintEvent.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2024 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 org.cef.browser;
+
+import java.awt.*;
+import java.nio.ByteBuffer;
+
+public class CefPaintEvent {
+ private final CefBrowser browser;
+ private final boolean popup;
+ private final Rectangle[] dirtyRects;
+ private final ByteBuffer renderedFrame;
+ private final int width;
+ private final int height;
+
+ public CefPaintEvent(CefBrowser browser, boolean popup, Rectangle[] dirtyRects,
+ ByteBuffer renderedFrame, int width, int height) {
+ this.browser = browser;
+ this.popup = popup;
+ this.dirtyRects = dirtyRects;
+ this.renderedFrame = renderedFrame;
+ this.width = width;
+ this.height = height;
+ }
+
+ public CefBrowser getBrowser() {
+ return browser;
+ }
+
+ public boolean getPopup() {
+ return popup;
+ }
+
+ public Rectangle[] getDirtyRects() {
+ return dirtyRects;
+ }
+
+ public ByteBuffer getRenderedFrame() {
+ return renderedFrame;
+ }
+
+ public int getWidth() {
+ return width;
+ }
+
+ public int getHeight() {
+ return height;
+ }
+}
\ No newline at end of file
diff --git a/java/org/cef/browser/CefRegistration.java b/java/org/cef/browser/CefRegistration.java
new file mode 100644
index 00000000..11051404
--- /dev/null
+++ b/java/org/cef/browser/CefRegistration.java
@@ -0,0 +1,24 @@
+// Copyright (c) 2024 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 org.cef.browser;
+
+/**
+ * Used internally by {@link CefDevToolsClient}.
+ *
+ * Handle to observer registration, As long as this object is alive, the observer will stay
+ * registered.
+ */
+abstract class CefRegistration {
+ /**
+ * Removes the native reference from an unused object.
+ */
+ public abstract void dispose();
+
+ @Override
+ public void finalize() throws Throwable {
+ dispose();
+ super.finalize();
+ }
+}
diff --git a/java/org/cef/browser/CefRegistration_N.java b/java/org/cef/browser/CefRegistration_N.java
new file mode 100644
index 00000000..a7defd13
--- /dev/null
+++ b/java/org/cef/browser/CefRegistration_N.java
@@ -0,0 +1,33 @@
+// Copyright (c) 2024 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 org.cef.browser;
+
+import org.cef.callback.CefNative;
+
+class CefRegistration_N extends CefRegistration implements CefNative {
+ // Used internally to store a pointer to the CEF object.
+ private long N_CefHandle = 0;
+
+ @Override
+ public void setNativeRef(String identifier, long nativeRef) {
+ N_CefHandle = nativeRef;
+ }
+
+ @Override
+ public long getNativeRef(String identifier) {
+ return N_CefHandle;
+ }
+
+ @Override
+ public void dispose() {
+ try {
+ N_Dispose(N_CefHandle);
+ } catch (UnsatisfiedLinkError ule) {
+ ule.printStackTrace();
+ }
+ }
+
+ private final native void N_Dispose(long self);
+}
diff --git a/java/org/cef/browser/CefRequestContext.java b/java/org/cef/browser/CefRequestContext.java
index 26fa66aa..f6998eb1 100644
--- a/java/org/cef/browser/CefRequestContext.java
+++ b/java/org/cef/browser/CefRequestContext.java
@@ -6,6 +6,9 @@
import org.cef.handler.CefRequestContextHandler;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* A request context provides request handling for a set of related browser
* objects. A request context is specified when creating a new browser object
@@ -50,4 +53,48 @@ public static final CefRequestContext createContext(CefRequestContextHandler han
* Returns the handler for this context if any.
*/
public abstract CefRequestContextHandler getHandler();
+
+ /**
+ * Returns true if a preference with the specified |name| exists.
+ *
+ * This method must be called on the browser process UI thread, otherwise it will always return
+ * false. It is easiest to ensure the correct calling thread by using a callback method invoked
+ * by the browser process UI thread, such as CefLifeSpanHandler.onAfterCreated(CefBrowser), to
+ * configure the preferences.
+ */
+ public abstract boolean hasPreference(String name);
+
+ /**
+ * Returns the value for the preference with the specified |name|. Returns
+ * NULL if the preference does not exist.
+ * This method must be called on the browser process UI thread, otherwise it will always return
+ * null.
+ */
+ public abstract Object getPreference(String name);
+
+ /**
+ * Returns all preferences as a dictionary. If |includeDefaults| is true then
+ * preferences currently at their default value will be included. The returned
+ * object can be modified but modifications will not persist. This method must
+ * be called on the browser process UI thread, otherwise it will always return null.
+ */
+ public abstract Map getAllPreferences(boolean includeDefaults);
+
+ /**
+ * Returns true if the preference with the specified |name| can be modified
+ * using setPreference. As one example preferences set via the command-line
+ * usually cannot be modified. This method must be called on the browser
+ * process UI thread, otherwise it will always return false.
+ */
+ public abstract boolean canSetPreference(String name);
+
+ /**
+ * Set the |value| associated with preference |name|. Returns null if the
+ * value is set successfully, an error string otherwise. If |value| is NULL the
+ * preference will be restored to its default value. If setting the preference
+ * fails then a detailed description of the problem will be returned.
+ * This method must be called on the browser process UI thread, otherwise it will always return
+ * an error string.
+ */
+ public abstract String setPreference(String name, Object value);
}
diff --git a/java/org/cef/browser/CefRequestContext_N.java b/java/org/cef/browser/CefRequestContext_N.java
index 622a9ab5..eafdf013 100644
--- a/java/org/cef/browser/CefRequestContext_N.java
+++ b/java/org/cef/browser/CefRequestContext_N.java
@@ -6,6 +6,10 @@
import org.cef.callback.CefNative;
import org.cef.handler.CefRequestContextHandler;
+import org.cef.misc.StringRef;
+
+import java.util.HashMap;
+import java.util.Map;
class CefRequestContext_N extends CefRequestContext implements CefNative {
// Used internally to store a pointer to the CEF object.
@@ -73,6 +77,55 @@ public boolean isGlobal() {
return false;
}
+ @Override
+ public boolean hasPreference(String name) {
+ try {
+ return N_HasPreference(name);
+ } catch (UnsatisfiedLinkError ule) {
+ ule.printStackTrace();
+ }
+ return false;
+ }
+
+ @Override
+ public Object getPreference(String name) {
+ try {
+ return N_GetPreference(name);
+ } catch (UnsatisfiedLinkError ule) {
+ ule.printStackTrace();
+ }
+ return null;
+ }
+
+ @Override
+ public Map getAllPreferences(boolean includeDefaults) {
+ try {
+ return N_GetAllPreferences(includeDefaults);
+ } catch (UnsatisfiedLinkError ule) {
+ ule.printStackTrace();
+ }
+ return new HashMap();
+ }
+
+ @Override
+ public boolean canSetPreference(String name) {
+ try {
+ return N_CanSetPreference(name);
+ } catch (UnsatisfiedLinkError ule) {
+ ule.printStackTrace();
+ }
+ return false;
+ }
+
+ @Override
+ public String setPreference(String name, Object value) {
+ try {
+ return N_SetPreference(name, value);
+ } catch (UnsatisfiedLinkError ule) {
+ ule.printStackTrace();
+ return ule.getMessage();
+ }
+ }
@Override
public CefRequestContextHandler getHandler() {
return handler;
@@ -83,4 +136,13 @@ private final static native CefRequestContext_N N_CreateContext(
CefRequestContextHandler handler);
private final native boolean N_IsGlobal();
private final native void N_CefRequestContext_DTOR();
+
+ // -------------------------------------------------------------------------
+ // ADDED: Missing native declarations to fix compilation error
+ // -------------------------------------------------------------------------
+ private final native boolean N_HasPreference(String name);
+ private final native Object N_GetPreference(String name);
+ private final native Map N_GetAllPreferences(boolean includeDefaults);
+ private final native boolean N_CanSetPreference(String name);
+ private final native String N_SetPreference(String name, Object value);
}
diff --git a/java/org/cef/callback/CefDragData.java b/java/org/cef/callback/CefDragData.java
index 0d13029f..25a55471 100644
--- a/java/org/cef/callback/CefDragData.java
+++ b/java/org/cef/callback/CefDragData.java
@@ -127,6 +127,12 @@ public static final CefDragData create() {
*/
public abstract boolean getFileNames(Vector names);
+ /**
+ * Retrieve the list of file paths that are being dragged into the browser
+ * window.
+ */
+ public abstract boolean getFilePaths(Vector paths);
+
/**
* Set the link URL that is being dragged.
* @param url The link URL to be set.
diff --git a/java/org/cef/callback/CefDragData_N.java b/java/org/cef/callback/CefDragData_N.java
index 9f6e0fee..e56867d1 100644
--- a/java/org/cef/callback/CefDragData_N.java
+++ b/java/org/cef/callback/CefDragData_N.java
@@ -179,6 +179,16 @@ public boolean getFileNames(Vector names) {
return false;
}
+ @Override
+ public boolean getFilePaths(Vector paths) {
+ try {
+ return N_GetFilePaths(N_CefHandle, paths);
+ } catch (UnsatisfiedLinkError ule) {
+ ule.printStackTrace();
+ }
+ return false;
+ }
+
public void setLinkURL(String url) {
try {
N_SetLinkURL(N_CefHandle, url);
@@ -259,6 +269,7 @@ public void addFile(String path, String displayName) {
private final native int N_GetFileContents(long self, OutputStream writer);
private final native String N_GetFileName(long self);
private final native boolean N_GetFileNames(long self, Vector names);
+ private final native boolean N_GetFilePaths(long self, Vector paths);
private final native void N_SetLinkURL(long self, String url);
private final native void N_SetLinkTitle(long self, String title);
private final native void N_SetLinkMetadata(long self, String data);
diff --git a/java/org/cef/callback/CefFileDialogCallback.java b/java/org/cef/callback/CefFileDialogCallback.java
index 1bbb0b3c..edc06c30 100644
--- a/java/org/cef/callback/CefFileDialogCallback.java
+++ b/java/org/cef/callback/CefFileDialogCallback.java
@@ -15,11 +15,9 @@ public interface CefFileDialogCallback {
* a single value or a list of values depending on the dialog mode. An empty
* value is treated the same as calling Cancel().
*
- * @param selectedAcceptFilter 0-based index of the value selected from the
- * accept filters array passed to CefDialogHandler::OnFileDialog.
* @param filePaths list of selected file paths or an empty list.
*/
- public void Continue(int selectedAcceptFilter, Vector filePaths);
+ public void Continue(Vector filePaths);
/**
* Cancel the file selection.
diff --git a/java/org/cef/callback/CefFileDialogCallback_N.java b/java/org/cef/callback/CefFileDialogCallback_N.java
index de3d5410..770ed97b 100644
--- a/java/org/cef/callback/CefFileDialogCallback_N.java
+++ b/java/org/cef/callback/CefFileDialogCallback_N.java
@@ -16,9 +16,9 @@ protected void finalize() throws Throwable {
}
@Override
- public void Continue(int selectedAcceptFilter, Vector filePaths) {
+ public void Continue(Vector filePaths) {
try {
- N_Continue(getNativeRef(null), selectedAcceptFilter, filePaths);
+ N_Continue(getNativeRef(null), filePaths);
} catch (UnsatisfiedLinkError ule) {
ule.printStackTrace();
}
@@ -33,7 +33,6 @@ public void Cancel() {
}
}
- private final native void N_Continue(
- long self, int selectedAcceptFilter, Vector filePaths);
+ private final native void N_Continue(long self, Vector filePaths);
private final native void N_Cancel(long self);
}
diff --git a/java/org/cef/callback/CefPdfPrintCallback.java b/java/org/cef/callback/CefPdfPrintCallback.java
index 7bedd5c9..cd484042 100644
--- a/java/org/cef/callback/CefPdfPrintCallback.java
+++ b/java/org/cef/callback/CefPdfPrintCallback.java
@@ -9,7 +9,6 @@
* will be called on the browser process UI thread.
*/
public interface CefPdfPrintCallback {
-
/**
* Method that will be executed when the PDF printing has completed. |path|
* is the output path. |ok| will be true if the printing completed
@@ -18,5 +17,4 @@ public interface CefPdfPrintCallback {
* @param ok True if printing completed or false otherwise.
*/
public abstract void onPdfPrintFinished(String path, boolean ok);
-
}
diff --git a/java/org/cef/callback/CefResourceReadCallback.java b/java/org/cef/callback/CefResourceReadCallback.java
new file mode 100644
index 00000000..fb762430
--- /dev/null
+++ b/java/org/cef/callback/CefResourceReadCallback.java
@@ -0,0 +1,25 @@
+// Copyright (c) 2024 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 org.cef.callback;
+
+/**
+ * Callback interface used for asynchronous resource reading.
+ */
+public interface CefResourceReadCallback {
+ /**
+ * Callback for asynchronous continuation of Read(). If |bytes_read| == 0
+ * the response will be considered complete. If |bytes_read| > 0 then Read()
+ * will be called again until the request is complete (based on either the
+ * result or the expected content length). If |bytes_read| < 0 then the
+ * request will fail and the |bytes_read| value will be treated as the error
+ * code.
+ */
+ void Continue(int bytes_read);
+
+ /**
+ * Returns the byte buffer to write data into before calling #Continue(int).
+ */
+ public byte[] getBuffer();
+}
\ No newline at end of file
diff --git a/java/org/cef/callback/CefResourceReadCallback_N.java b/java/org/cef/callback/CefResourceReadCallback_N.java
new file mode 100644
index 00000000..1efaa8e4
--- /dev/null
+++ b/java/org/cef/callback/CefResourceReadCallback_N.java
@@ -0,0 +1,46 @@
+// Copyright (c) 2024 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 org.cef.callback;
+
+class CefResourceReadCallback_N extends CefNativeAdapter implements CefResourceReadCallback {
+ // The native buffer where to copy the data to.
+ private long N_NativeBufferRef;
+
+ // The Java buffer which the application is expected to fill with data.
+ private byte[] N_JavaBuffer;
+
+ CefResourceReadCallback_N() {}
+
+ @Override
+ protected void finalize() throws Throwable {
+ super.finalize();
+ }
+
+ public void setBufferRefs(long nativeBufferRef, byte[] javaBuffer) {
+ N_NativeBufferRef = nativeBufferRef;
+ N_JavaBuffer = javaBuffer;
+ }
+
+ @Override
+ public byte[] getBuffer() {
+ return N_JavaBuffer;
+ }
+
+ @Override
+ public void Continue(int bytes_read) {
+ try {
+ if (N_NativeBufferRef != 0 && N_JavaBuffer != null) {
+ N_Continue(getNativeRef(null), bytes_read, N_NativeBufferRef, N_JavaBuffer);
+ N_NativeBufferRef = 0;
+ N_JavaBuffer = null;
+ }
+ } catch (UnsatisfiedLinkError ule) {
+ ule.printStackTrace();
+ }
+ }
+
+ private final native void N_Continue(
+ long self, int bytes_read, long nativeBufferRef, byte[] javaBuffer);
+}
\ No newline at end of file
diff --git a/java/org/cef/callback/CefResourceSkipCallback.java b/java/org/cef/callback/CefResourceSkipCallback.java
new file mode 100644
index 00000000..420af6f2
--- /dev/null
+++ b/java/org/cef/callback/CefResourceSkipCallback.java
@@ -0,0 +1,18 @@
+// Copyright (c) 2024 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 org.cef.callback;
+
+/**
+ * Callback interface used for asynchronous resource skipping.
+ */
+public interface CefResourceSkipCallback {
+ /**
+ * Callback for asynchronous continuation of Skip(). If |bytes_skipped| > 0
+ * then either Skip() will be called again until the requested number of
+ * bytes have been skipped or the request will proceed. If |bytes_skipped|
+ * <= 0 the request will fail with ERR_REQUEST_RANGE_NOT_SATISFIABLE.
+ */
+ void Continue(long bytes_skipped);
+}
\ No newline at end of file
diff --git a/java/org/cef/callback/CefResourceSkipCallback_N.java b/java/org/cef/callback/CefResourceSkipCallback_N.java
new file mode 100644
index 00000000..19c84299
--- /dev/null
+++ b/java/org/cef/callback/CefResourceSkipCallback_N.java
@@ -0,0 +1,25 @@
+
+// reserved. Use of this source code is governed by a BSD-style license that
+// can be found in the LICENSE file.
+
+package org.cef.callback;
+
+class CefResourceSkipCallback_N extends CefNativeAdapter implements CefResourceSkipCallback {
+ CefResourceSkipCallback_N() {}
+
+ @Override
+ protected void finalize() throws Throwable {
+ super.finalize();
+ }
+
+ @Override
+ public void Continue(long bytes_skipped) {
+ try {
+ N_Continue(getNativeRef(null), bytes_skipped);
+ } catch (UnsatisfiedLinkError ule) {
+ ule.printStackTrace();
+ }
+ }
+
+ private final native void N_Continue(long self, long bytes_skipped);
+}
\ No newline at end of file
diff --git a/java/org/cef/callback/CefRunFileDialogCallback.java b/java/org/cef/callback/CefRunFileDialogCallback.java
index 21c96dac..9d7381a0 100644
--- a/java/org/cef/callback/CefRunFileDialogCallback.java
+++ b/java/org/cef/callback/CefRunFileDialogCallback.java
@@ -4,9 +4,10 @@
package org.cef.callback;
-import java.util.Vector;
import org.cef.browser.CefBrowser;
+import java.util.Vector;
+
/**
* Callback interface for CefBrowserHost::RunFileDialog. The methods of this
* class will be called on the browser process UI thread.
@@ -18,9 +19,7 @@ public interface CefRunFileDialogCallback {
* depending on the dialog mode. If the selection was cancelled filePaths
* will be empty.
*
- * @param selectedAcceptFilter 0-based index of the value selected from
- * the accept filters array passed to CefBrowserHost::RunFileDialog.
* @param filePaths list of file paths or empty list.
*/
- void onFileDialogDismissed(int selectedAcceptFilter, Vector filePaths);
+ void onFileDialogDismissed(Vector filePaths);
}
diff --git a/java/org/cef/callback/CefSchemeRegistrar.java b/java/org/cef/callback/CefSchemeRegistrar.java
index d4fcb4f2..f59263c3 100644
--- a/java/org/cef/callback/CefSchemeRegistrar.java
+++ b/java/org/cef/callback/CefSchemeRegistrar.java
@@ -62,7 +62,7 @@ public interface CefSchemeRegistrar {
* If |isCspBypassing| is true the scheme can bypass Content-Security-Policy
* (CSP) checks. This value should be false in most cases where |isStandard|
* is true.
- *
+ *
* If |is_fetch_enabled| is true the scheme can perform Fetch API requests.
*
* This function may be called on any thread. It should only be called once
diff --git a/java/org/cef/handler/CefAppHandler.java b/java/org/cef/handler/CefAppHandler.java
index 095e4747..b6ede710 100644
--- a/java/org/cef/handler/CefAppHandler.java
+++ b/java/org/cef/handler/CefAppHandler.java
@@ -72,4 +72,23 @@ public interface CefAppHandler {
* currently pending scheduled call should be cancelled.
*/
public void onScheduleMessagePumpWork(long delay_ms);
+
+ /**
+ * Implement this method to provide app-specific behavior when an already
+ * running app is relaunched with the same CefSettings.root_cache_path value.
+ * For example, activate an existing app window or create a new app window.
+ * |command_line| will be read-only. Do not keep a reference to
+ * |command_line| outside of this method. Return true if the relaunch is
+ * handled or false for default relaunch behavior. Default behavior will
+ * create a new default styled Chrome window.
+ *
+ * To avoid cache corruption only a single app instance is allowed to run for
+ * a given CefSettings.root_cache_path value. On relaunch the app checks a
+ * process singleton lock and then forwards the new launch arguments to the
+ * already running app process before exiting early. Client apps should
+ * therefore check the CefInitialize() return value for early exit before
+ * proceeding.
+ */
+ public boolean onAlreadyRunningAppRelaunch(
+ CefCommandLine command_line, String current_directory);
}
diff --git a/java/org/cef/handler/CefAppHandlerAdapter.java b/java/org/cef/handler/CefAppHandlerAdapter.java
index d74eee48..9947b74c 100644
--- a/java/org/cef/handler/CefAppHandlerAdapter.java
+++ b/java/org/cef/handler/CefAppHandlerAdapter.java
@@ -32,9 +32,10 @@ public void onBeforeCommandLineProcessing(String process_type, CefCommandLine co
continue;
}
// Arguments with '--', '-' and, on Windows, '/' prefixes are considered switches.
- int switchCnt = arg.startsWith("--")
- ? 2
- : arg.startsWith("/") ? 1 : arg.startsWith("-") ? 1 : 0;
+ int switchCnt = arg.startsWith("--") ? 2
+ : arg.startsWith("/") ? 1
+ : arg.startsWith("-") ? 1
+ : 0;
switch (switchCnt) {
case 2:
// An argument of "--" will terminate switch parsing with all subsequent
@@ -47,11 +48,13 @@ public void onBeforeCommandLineProcessing(String process_type, CefCommandLine co
case 1: {
// Switches can optionally have a value specified using the '=' delimiter
// (e.g. "-switch=value").
- String[] switchVals = arg.substring(switchCnt).split("=");
- if (switchVals.length == 2) {
- command_line.appendSwitchWithValue(switchVals[0], switchVals[1]);
+ String switchStr = arg.substring(switchCnt);
+ int index = switchStr.indexOf('=');
+ if (index > 0) {
+ command_line.appendSwitchWithValue(
+ switchStr.substring(0, index), switchStr.substring(index + 1));
} else {
- command_line.appendSwitch(switchVals[0]);
+ command_line.appendSwitch(switchStr);
}
break;
}
@@ -88,4 +91,11 @@ public void onContextInitialized() {
public void onScheduleMessagePumpWork(long delay_ms) {
CefApp.getInstance().doMessageLoopWork(delay_ms);
}
+
+ @Override
+ public boolean onAlreadyRunningAppRelaunch(
+ CefCommandLine command_line, String current_directory) {
+ // The default implementation does nothing
+ return false;
+ }
}
diff --git a/java/org/cef/handler/CefDialogHandler.java b/java/org/cef/handler/CefDialogHandler.java
index 4e9a9d65..dffc6b11 100644
--- a/java/org/cef/handler/CefDialogHandler.java
+++ b/java/org/cef/handler/CefDialogHandler.java
@@ -20,6 +20,7 @@ public interface CefDialogHandler {
enum FileDialogMode {
FILE_DIALOG_OPEN, //!< Requires that the file exists before allowing the user to pick it.
FILE_DIALOG_OPEN_MULTIPLE, //!< Like Open, but allows picking multiple files to open.
+ FILE_DIALOG_OPEN_FOLDER,
FILE_DIALOG_SAVE //!< Allows picking a nonexistent file, and prompts to overwrite if the
//! file already exists.
}
@@ -38,14 +39,17 @@ enum FileDialogMode {
* "image/*"), (b) individual file extensions (e.g. ".txt" or ".png"), or (c)
* combined description and file extension delimited using "|" and ";" (e.g.
* "Image Types|.png;.gif;.jpg").
- * @param selectedAcceptFilter is the 0-based index of the filter that should
- * be selected by default.
+ * @param acceptExtensions provides the semicolon-delimited expansion of MIME
+ * types to file extensions (if known, or empty string otherwise).
+ * @param acceptDescriptions provides the descriptions for MIME types (if known,
+ * or empty string otherwise). For example, the "image/*" mime type might
+ * have extensions ".png;.jpg;.bmp;..." and description "Image Files".
* @param callback is a callback handler for handling own file dialogs.
*
* @return To display a custom dialog return true and execute callback.
* To display the default dialog return false.
*/
public boolean onFileDialog(CefBrowser browser, FileDialogMode mode, String title,
- String defaultFilePath, Vector acceptFilters, int selectedAcceptFilter,
- CefFileDialogCallback callback);
+ String defaultFilePath, Vector acceptFilters, Vector acceptExtensions,
+ Vector acceptDescriptions, CefFileDialogCallback callback);
}
diff --git a/java/org/cef/handler/CefDisplayHandler.java b/java/org/cef/handler/CefDisplayHandler.java
index 0affefc5..f2a828eb 100644
--- a/java/org/cef/handler/CefDisplayHandler.java
+++ b/java/org/cef/handler/CefDisplayHandler.java
@@ -28,6 +28,13 @@ public interface CefDisplayHandler {
*/
public void onTitleChange(CefBrowser browser, String title);
+ /**
+ * Browser fullscreen mode changed.
+ * @param browser The browser generating the event.
+ * @param fullscreen True if fullscreen mode is on.
+ */
+ public void onFullscreenModeChange(CefBrowser browser, boolean fullscreen);
+
/**
* About to display a tooltip.
* @param browser The browser generating the event.
diff --git a/java/org/cef/handler/CefDisplayHandlerAdapter.java b/java/org/cef/handler/CefDisplayHandlerAdapter.java
index 80ab96b6..90d22d50 100644
--- a/java/org/cef/handler/CefDisplayHandlerAdapter.java
+++ b/java/org/cef/handler/CefDisplayHandlerAdapter.java
@@ -24,6 +24,11 @@ public void onTitleChange(CefBrowser browser, String title) {
return;
}
+ @Override
+ public void onFullscreenModeChange(CefBrowser browser, boolean fullscreen) {
+ return;
+ }
+
@Override
public boolean onTooltip(CefBrowser browser, String text) {
return false;
diff --git a/java/org/cef/handler/CefDownloadHandler.java b/java/org/cef/handler/CefDownloadHandler.java
index 66ea49a4..3f0ee6f2 100644
--- a/java/org/cef/handler/CefDownloadHandler.java
+++ b/java/org/cef/handler/CefDownloadHandler.java
@@ -15,9 +15,11 @@
*/
public interface CefDownloadHandler {
/**
- * Called before a download begins. By default the download will be canceled.
- * Execute callback either asynchronously or in this method to continue the download
- * if desired.
+ * Called before a download begins. Return true and execute |callback| either
+ * asynchronously or in this method to continue or cancel the download.
+ * Return false to proceed with default handling (cancel with Alloy style,
+ * download shelf with Chrome style). Do not keep a reference to
+ * downloadItem outside of this method.
*
* @param browser The desired browser.
* @param downloadItem The item to be downloaded. Do not keep a reference to it outside this
@@ -25,7 +27,7 @@ public interface CefDownloadHandler {
* @param suggestedName is the suggested name for the download file.
* @param callback start the download by calling the Continue method
*/
- public void onBeforeDownload(CefBrowser browser, CefDownloadItem downloadItem,
+ public boolean onBeforeDownload(CefBrowser browser, CefDownloadItem downloadItem,
String suggestedName, CefBeforeDownloadCallback callback);
/**
diff --git a/java/org/cef/handler/CefDownloadHandlerAdapter.java b/java/org/cef/handler/CefDownloadHandlerAdapter.java
index 8b1f46aa..f0311637 100644
--- a/java/org/cef/handler/CefDownloadHandlerAdapter.java
+++ b/java/org/cef/handler/CefDownloadHandlerAdapter.java
@@ -16,8 +16,10 @@
*/
public abstract class CefDownloadHandlerAdapter implements CefDownloadHandler {
@Override
- public void onBeforeDownload(CefBrowser browser, CefDownloadItem downloadItem,
- String suggestedName, CefBeforeDownloadCallback callback) {}
+ public boolean onBeforeDownload(CefBrowser browser, CefDownloadItem downloadItem,
+ String suggestedName, CefBeforeDownloadCallback callback) {
+ return false;
+ }
@Override
public void onDownloadUpdated(
diff --git a/java/org/cef/handler/CefLoadHandler.java b/java/org/cef/handler/CefLoadHandler.java
index ba7e5038..4f0bb831 100644
--- a/java/org/cef/handler/CefLoadHandler.java
+++ b/java/org/cef/handler/CefLoadHandler.java
@@ -40,7 +40,6 @@ enum ErrorCode {
ERR_NETWORK_CHANGED(-21),
ERR_BLOCKED_BY_ADMINISTRATOR(-22),
ERR_SOCKET_IS_CONNECTED(-23),
- ERR_BLOCKED_ENROLLMENT_CHECK_PENDING(-24),
ERR_UPLOAD_STREAM_REWIND_NOT_SUPPORTED(-25),
ERR_CONTEXT_SHUT_DOWN(-26),
ERR_BLOCKED_BY_RESPONSE(-27),
@@ -188,12 +187,8 @@ enum ErrorCode {
ERR_INVALID_HTTP_RESPONSE(-370),
ERR_CONTENT_DECODING_INIT_FAILED(-371),
ERR_HTTP2_RST_STREAM_NO_ERROR_RECEIVED(-372),
- ERR_HTTP2_PUSHED_STREAM_NOT_AVAILABLE(-373),
- ERR_HTTP2_CLAIMED_PUSHED_STREAM_RESET_BY_SERVER(-374),
ERR_TOO_MANY_RETRIES(-375),
ERR_HTTP2_STREAM_CLOSED(-376),
- ERR_HTTP2_CLIENT_REFUSED_STREAM(-377),
- ERR_HTTP2_PUSHED_RESPONSE_DOES_NOT_MATCH(-378),
ERR_HTTP_RESPONSE_CODE_FAILURE(-379),
ERR_QUIC_CERT_ROOT_NOT_KNOWN(-380),
ERR_QUIC_GOAWAY_REQUEST_CAN_BE_RETRIED(-381),
@@ -218,13 +213,6 @@ enum ErrorCode {
ERR_INVALID_WEB_BUNDLE(-505),
ERR_TRUST_TOKEN_OPERATION_FAILED(-506),
ERR_TRUST_TOKEN_OPERATION_SUCCESS_WITHOUT_SENDING_REQUEST(-507),
- ERR_FTP_FAILED(-601),
- ERR_FTP_SERVICE_UNAVAILABLE(-602),
- ERR_FTP_TRANSFER_ABORTED(-603),
- ERR_FTP_FILE_BUSY(-604),
- ERR_FTP_SYNTAX_ERROR(-605),
- ERR_FTP_COMMAND_NOT_SUPPORTED(-606),
- ERR_FTP_BAD_COMMAND_SEQUENCE(-607),
ERR_PKCS12_IMPORT_BAD_PASSWORD(-701),
ERR_PKCS12_IMPORT_FAILED(-702),
ERR_IMPORT_CA_CERT_NOT_CA(-703),
diff --git a/java/org/cef/handler/CefRenderHandler.java b/java/org/cef/handler/CefRenderHandler.java
index 0a94bb2f..258df884 100644
--- a/java/org/cef/handler/CefRenderHandler.java
+++ b/java/org/cef/handler/CefRenderHandler.java
@@ -5,11 +5,13 @@
package org.cef.handler;
import org.cef.browser.CefBrowser;
+import org.cef.browser.CefPaintEvent;
import org.cef.callback.CefDragData;
import java.awt.Point;
import java.awt.Rectangle;
import java.nio.ByteBuffer;
+import java.util.function.Consumer;
/**
* Implement this interface to handle events when window rendering is disabled.
@@ -65,6 +67,24 @@ public interface CefRenderHandler {
public void onPaint(CefBrowser browser, boolean popup, Rectangle[] dirtyRects,
ByteBuffer buffer, int width, int height);
+ /**
+ * Add provided listener.
+ * @param listener Code that gets executed after a frame was rendered.
+ */
+ public void addOnPaintListener(Consumer listener);
+
+ /**
+ * Remove existing listeners and replace with provided listener.
+ * @param listener Code that gets executed after a frame was rendered.
+ */
+ public void setOnPaintListener(Consumer listener);
+
+ /**
+ * Remove provided listener.
+ * @param listener Code that gets executed after a frame was rendered.
+ */
+ public void removeOnPaintListener(Consumer listener);
+
/**
* Handle cursor changes.
* @param browser The browser generating the event.
diff --git a/java/org/cef/handler/CefRequestHandler.java b/java/org/cef/handler/CefRequestHandler.java
index 8f5f26f9..22ba60dc 100644
--- a/java/org/cef/handler/CefRequestHandler.java
+++ b/java/org/cef/handler/CefRequestHandler.java
@@ -24,7 +24,10 @@ enum TerminationStatus {
TS_ABNORMAL_TERMINATION, //!< Non-zero exit status.
TS_PROCESS_WAS_KILLED, //!< SIGKILL or task manager kill.
TS_PROCESS_CRASHED, //!< Segmentation fault.
- TS_PROCESS_OOM //!< Out of memory.
+ TS_PROCESS_OOM, //!< Out of memory.
+ TS_LAUNCH_FAILED, //!< Failed to launch.
+ TS_INTEGRITY_FAILURE, //!< Integrity check failed.
+ TS_NUM_VALUES
}
/**
@@ -103,20 +106,6 @@ CefResourceRequestHandler getResourceRequestHandler(CefBrowser browser, CefFrame
boolean getAuthCredentials(CefBrowser browser, String origin_url, boolean isProxy, String host,
int port, String realm, String scheme, CefAuthCallback callback);
- /**
- * Called on the IO thread when JavaScript requests a specific storage quota size via the
- * webkitStorageInfo.requestQuota function.
- *
- * @param browser The corresponding browser.
- * @param origin_url Origin of the page making the request.
- * @param new_size Requested quota size in bytes.
- * @param callback Call CefCallback.Continue() either in this method or at a later time
- * to grant or deny the request.
- * @return True to handle the request (callback must be executed) or false to cancel.
- */
- boolean onQuotaRequest(
- CefBrowser browser, String origin_url, long new_size, CefCallback callback);
-
/**
* Called on the UI thread to handle requests for URLs with an invalid SSL certificate. If
* "ignore-certificate-errors" command-line switch is set all invalid certificates will be
@@ -137,6 +126,9 @@ boolean onCertificateError(CefBrowser browser, CefLoadHandler.ErrorCode cert_err
* Called on the browser process UI thread when the render process terminates unexpectedly.
* @param browser The corresponding browser.
* @param status Indicates how the process was terminated.
+ * @param error_code The process error code.
+ * @param error_string A string description of the error.
*/
- void onRenderProcessTerminated(CefBrowser browser, TerminationStatus status);
+ void onRenderProcessTerminated(
+ CefBrowser browser, TerminationStatus status, int error_code, String error_string);
}
diff --git a/java/org/cef/handler/CefRequestHandlerAdapter.java b/java/org/cef/handler/CefRequestHandlerAdapter.java
index 02736748..a6c04ef6 100644
--- a/java/org/cef/handler/CefRequestHandlerAdapter.java
+++ b/java/org/cef/handler/CefRequestHandlerAdapter.java
@@ -44,12 +44,6 @@ public boolean getAuthCredentials(CefBrowser browser, String origin_url, boolean
return false;
}
- @Override
- public boolean onQuotaRequest(
- CefBrowser browser, String origin_url, long new_size, CefCallback callback) {
- return false;
- }
-
@Override
public boolean onCertificateError(
CefBrowser browser, ErrorCode cert_error, String request_url, CefCallback callback) {
@@ -57,5 +51,6 @@ public boolean onCertificateError(
}
@Override
- public void onRenderProcessTerminated(CefBrowser browser, TerminationStatus status) {}
+ public void onRenderProcessTerminated(
+ CefBrowser browser, TerminationStatus status, int error_code, String error_string) {}
}
diff --git a/java/org/cef/handler/CefResourceHandler.java b/java/org/cef/handler/CefResourceHandler.java
index 72f9f30d..8574c700 100644
--- a/java/org/cef/handler/CefResourceHandler.java
+++ b/java/org/cef/handler/CefResourceHandler.java
@@ -5,15 +5,21 @@
package org.cef.handler;
import org.cef.callback.CefCallback;
+import org.cef.callback.CefResourceReadCallback;
+import org.cef.callback.CefResourceSkipCallback;
+import org.cef.misc.BoolRef;
import org.cef.misc.IntRef;
+import org.cef.misc.LongRef;
import org.cef.misc.StringRef;
import org.cef.network.CefCookie;
import org.cef.network.CefRequest;
import org.cef.network.CefResponse;
/**
- * Implement this interface to handle custom resource requests. The methods of
- * this class will always be called on the IO thread.
+ * Implement this interface to handle custom resource requests. This interface is a "new" API and an
+ * old API in one: the deprecated methods are part of the old API. The new API allows for parallel
+ * processing of requests, because it does not channel all reads through a dedicated IO thread, and
+ * it allows for skipping of bytes as part of handling Range requests.
*/
public interface CefResourceHandler {
/**
@@ -23,9 +29,22 @@ public interface CefResourceHandler {
* @param callback Callback to continue or cancel the request.
* @return True to handle the request and call CefCallback.Continue() once the response header
* information is available.
+ * * @deprecated Use open() instead
*/
boolean processRequest(CefRequest request, CefCallback callback);
+ /**
+ * Open the response stream. This and related (getResponseHeaders, read, skip) methods will be
+ * called in sequence but not from a dedicated thread.
For backwards compatibility set
+ * |handleRequest| to false and return false and the processRequest() method will be called.
+ * @param request The request itself. Cannot be modified in this callback. Instance only valid
+ * within the scope of this method.
+ * @param handleRequest Set to true to handle/cancel the request immediately
+ * @param callback Callback to continue or cancel the request at a later time
+ * @return True to handle the request
+ */
+ boolean open(CefRequest request, BoolRef handleRequest, CefCallback callback);
+
/**
* Retrieve response header information. If the response length is not known set
* |responseLength| to -1 and readResponse() will be called until it returns false. If the
@@ -49,9 +68,42 @@ public interface CefResourceHandler {
* @param bytesRead Number of bytes written to the buffer.
* @param callback Callback to execute if data will be available asynchronously.
* @return True if more data is or will be available.
+ * * @deprecated Use read() instead
*/
boolean readResponse(byte[] dataOut, int bytesToRead, IntRef bytesRead, CefCallback callback);
+ /**
+ * Read response data. If data is available immediately copy up to |bytesToRead| bytes into
+ * |dataOut|, set |bytesRead| to the number of bytes copied, and return true. To read the data
+ * at a later time store |dataOut|, set |bytesRead| to 0, return true and call the callback when
+ * the data is available. To indicate response completion set |bytesRead| to 0 and return false.
+ * To indicate failure set |bytesRead| to <0 (e.g. -2 for ERR_FAILED) and return false.
For
+ * backwards compatibility set |bytesRead| to -1 and return false and the readResponse() method
+ * will be called.
+ * @param dataOut Write data to this buffer. Buffer remains valid until either an immediate
+ * response is delivered (return true) or the callback is called later when data is
+ * available (return false).
+ * @param bytesToRead Size of the buffer.
+ * @param bytesRead Number of bytes written to the buffer.
+ * @param callback Callback to execute if data will be available asynchronously.
+ * @return True if more data is or will be available.
+ */
+ boolean read(
+ byte[] dataOut, int bytesToRead, IntRef bytesRead, CefResourceReadCallback callback);
+
+ /**
+ * Skip response data when requested by a Range header. Skip over and discard |bytesToSkip|
+ * bytes of response data. If data is available immediately set |bytesSkipped| to the number of
+ * bytes skipped and return true. To read the data at a later time set |bytesSkipped| to 0,
+ * return true and execute |callback| when the data is available. To indicate failure set
+ * |bytesSkipped| to < 0 (e.g. -2 for ERR_FAILED) and return false.
+ * @param bytesToSkip Number of bytes to skip.
+ * @param bytesSkipped Number of bytes skipped.
+ * @param callback Callback to execute if data will be skipped asynchronously.
+ */
+ boolean skip(long bytesToSkip, LongRef bytesSkipped, CefResourceSkipCallback callback);
+
+
/**
* Request processing has been canceled.
*/
diff --git a/java/org/cef/handler/CefResourceHandlerAdapter.java b/java/org/cef/handler/CefResourceHandlerAdapter.java
index 9458bb2b..8e6935e6 100644
--- a/java/org/cef/handler/CefResourceHandlerAdapter.java
+++ b/java/org/cef/handler/CefResourceHandlerAdapter.java
@@ -6,6 +6,10 @@
import org.cef.callback.CefCallback;
import org.cef.misc.IntRef;
+import org.cef.callback.CefResourceReadCallback;
+import org.cef.callback.CefResourceSkipCallback;
+import org.cef.misc.BoolRef;
+import org.cef.misc.LongRef;
import org.cef.misc.StringRef;
import org.cef.network.CefCookie;
import org.cef.network.CefRequest;
@@ -22,6 +26,13 @@ public boolean processRequest(CefRequest request, CefCallback callback) {
return false;
}
+ @Override
+ public boolean open(CefRequest request, BoolRef handleRequest, CefCallback callback) {
+ // Enables backwards compatibility by default by calling processRequest.
+ handleRequest.set(false);
+ return false;
+ }
+
@Override
public void getResponseHeaders(
CefResponse response, IntRef responseLength, StringRef redirectUrl) {}
@@ -32,6 +43,20 @@ public boolean readResponse(
return false;
}
+ @Override
+ public boolean read(
+ byte[] dataOut, int bytesToRead, IntRef bytesRead, CefResourceReadCallback callback) {
+ // Enables backwards compatibility by default by calling readResponse.
+ bytesRead.set(-1);
+ return false;
+ }
+
+ @Override
+ public boolean skip(long bytesToSkip, LongRef bytesSkipped, CefResourceSkipCallback callback) {
+ bytesSkipped.set(-2);
+ return false;
+ }
+
@Override
public void cancel() {}
}
diff --git a/java/org/cef/handler/CefWindowHandler.java b/java/org/cef/handler/CefWindowHandler.java
index eeda8dac..c0bc0f13 100644
--- a/java/org/cef/handler/CefWindowHandler.java
+++ b/java/org/cef/handler/CefWindowHandler.java
@@ -1,42 +1,42 @@
-// Copyright (c) 2015 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 org.cef.handler;
-
-import java.awt.Rectangle;
-
-import org.cef.browser.CefBrowser;
-
-/**
- * Implement this interface to handle events if window rendering is enabled.
- *
- */
-public interface CefWindowHandler {
- /**
- * Retrieve the view rectangle.
- * @param browser The browser generating the event.
- * @return The view rectangle.
- */
- public Rectangle getRect(CefBrowser browser);
-
- /**
- * Implement this method to handle mouse events on Windows.
- *
- * The method is called in case of the following events:
- * MOUSE_MOVED, MOUSE_PRESSED, MOUSE_RELEASED and MOUSE_WHEEL for a
- * horizontal wheel movement.
- *
- * @param browser The browser generating the event.
- * @param event A mouse event like MouseEvent.MOUSE_MOVED.
- * @param screenX The absolute X position on the screen.
- * @param screenY The absolute Y position on the screen.
- * @param modifier The modifier keys down during event (e.g. Shift, Ctrl).
- * @param button An integer indicating which mouse button state changed.
- * If parameter event is set to MouseEvent.MOUSE_WHEEL, the value of this
- * parameter specifies the rotation indicator (negative value for left scroll
- * and positive value for right scroll).
- */
- public void onMouseEvent(
- CefBrowser browser, int event, int screenX, int screenY, int modifier, int button);
-}
+// Copyright (c) 2015 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 org.cef.handler;
+
+import org.cef.browser.CefBrowser;
+
+import java.awt.Rectangle;
+
+/**
+ * Implement this interface to handle events if window rendering is enabled.
+ *
+ */
+public interface CefWindowHandler {
+ /**
+ * Retrieve the view rectangle.
+ * @param browser The browser generating the event.
+ * @return The view rectangle.
+ */
+ public Rectangle getRect(CefBrowser browser);
+
+ /**
+ * Implement this method to handle mouse events on Windows.
+ *
+ * The method is called in case of the following events:
+ * MOUSE_MOVED, MOUSE_PRESSED, MOUSE_RELEASED and MOUSE_WHEEL for a
+ * horizontal wheel movement.
+ *
+ * @param browser The browser generating the event.
+ * @param event A mouse event like MouseEvent.MOUSE_MOVED.
+ * @param screenX The absolute X position on the screen.
+ * @param screenY The absolute Y position on the screen.
+ * @param modifier The modifier keys down during event (e.g. Shift, Ctrl).
+ * @param button An integer indicating which mouse button state changed.
+ * If parameter event is set to MouseEvent.MOUSE_WHEEL, the value of this
+ * parameter specifies the rotation indicator (negative value for left scroll
+ * and positive value for right scroll).
+ */
+ public void onMouseEvent(
+ CefBrowser browser, int event, int screenX, int screenY, int modifier, int button);
+}
diff --git a/java/org/cef/handler/CefWindowHandlerAdapter.java b/java/org/cef/handler/CefWindowHandlerAdapter.java
index 1e6ad6bd..839c0c7d 100644
--- a/java/org/cef/handler/CefWindowHandlerAdapter.java
+++ b/java/org/cef/handler/CefWindowHandlerAdapter.java
@@ -1,25 +1,25 @@
-// Copyright (c) 2015 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 org.cef.handler;
-
-import java.awt.Rectangle;
-
-import org.cef.browser.CefBrowser;
-
-/**
- * An abstract adapter class for receiving windowed render events.
- * The methods in this class are empty.
- * This class exists as convenience for creating handler objects.
- */
-public abstract class CefWindowHandlerAdapter implements CefWindowHandler {
- @Override
- public Rectangle getRect(CefBrowser browser) {
- return new Rectangle(0, 0, 0, 0);
- }
-
- @Override
- public void onMouseEvent(
- CefBrowser browser, int event, int screenX, int screenY, int modifier, int button) {}
-}
+// Copyright (c) 2015 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 org.cef.handler;
+
+import org.cef.browser.CefBrowser;
+
+import java.awt.Rectangle;
+
+/**
+ * An abstract adapter class for receiving windowed render events.
+ * The methods in this class are empty.
+ * This class exists as convenience for creating handler objects.
+ */
+public abstract class CefWindowHandlerAdapter implements CefWindowHandler {
+ @Override
+ public Rectangle getRect(CefBrowser browser) {
+ return new Rectangle(0, 0, 0, 0);
+ }
+
+ @Override
+ public void onMouseEvent(
+ CefBrowser browser, int event, int screenX, int screenY, int modifier, int button) {}
+}
diff --git a/java/org/cef/misc/CefPdfPrintSettings.java b/java/org/cef/misc/CefPdfPrintSettings.java
index 554c2925..a014d81c 100644
--- a/java/org/cef/misc/CefPdfPrintSettings.java
+++ b/java/org/cef/misc/CefPdfPrintSettings.java
@@ -15,97 +15,128 @@ public enum MarginType {
// No margins
NONE,
- // Minimum margins.
- MINIMUM,
-
// Custom margins using the values from CefPdfPrintSettings
CUSTOM
}
/**
- * Set to true to print headers and footers or false to not print
- * headers and footers.
+ * Set to true for landscape mode or false for portrait mode.
*/
- public boolean header_footer_enabled;
+ public boolean landscape;
/**
- * Page title to display in the header. Only used if header_footer_enabled
- * is set to true.
+ * Set to true to print background graphics or false to not print
+ * background graphics.
*/
- public String header_footer_title;
+ public boolean print_background;
/**
- * URL to display in the footer. Only used if header_footer_enabled is set
- * to true.
+ * The percentage to scale the PDF by before printing (e.g. .5 is 50%).
+ * If this value is less than or equal to zero the default value of 1.0
+ * will be used.
*/
- public String header_footer_url;
+ public double scale;
/**
- * Set to true for landscape mode or false for portrait mode.
+ * Output paper size in inches. If either of these values is less than or
+ * equal to zero then the default paper size (letter, 8.5 x 11 inches) will
+ * be used.
*/
- public boolean landscape;
+ public double paper_width;
+ public double paper_height;
/**
- * Set to true to print background graphics or false to not print
- * background graphics.
+ * Set to true to prefer page size as defined by css. Defaults to false
+ * in which case the content will be scaled to fit the paper size.
*/
- public boolean backgrounds_enabled;
+ public boolean prefer_css_page_size;
/**
- * Output page size in microns (1 millimeter = 1000 microns). If either of these
- * values is less than or equal to zero then the default paper size will be
- * used as returned by the print_handler. A4 is 210 x 297 mm which would
- * be 210000 x 297000 microns. US Letter is 215.9 x 279.4 mm which would
- * be 215900 x 279400 microns.
+ * Margin type.
*/
- public int page_width;
- public int page_height;
+ public MarginType margin_type;
/**
- * Set to true to print the selection only or false to print all.
+ * Margins in inches. Only used if margin_type is set to CUSTOM.
*/
- public boolean selection_only;
+ public double margin_top;
+ public double margin_right;
+ public double margin_bottom;
+ public double margin_left;
/**
- * The percentage to scale the PDF by before printing (e.g. 50 is 50%).
- * If this value is less than or equal to zero the default value of 100
- * will be used.
+ * Paper ranges to print, one based, e.g., '1-5, 8, 11-13'. Pages are printed
+ * in the document order, not in the order specified, and no more than once.
+ * Defaults to empty string, which implies the entire document is printed.
+ * The page numbers are quietly capped to actual page count of the document,
+ * and ranges beyond the end of the document are ignored. If this results in
+ * no pages to print, an error is reported. It is an error to specify a range
+ * with start greater than end.
+ */
+ public String page_ranges;
+
+ /**
+ * Set to true to print headers and footers or false to not print
+ * headers and footers. Modify header_template and/or footer_template to
+ * customize the display.
*/
- public int scale_factor;
+ public boolean display_header_footer;
/**
- * Margins in points. Only used if |margin_type| is set to
- * PDF_PRINT_MARGIN_CUSTOM.
+ * HTML template for the print header. Only displayed if
+ * |display_header_footer| is true (1). Should be valid HTML markup with
+ * the following classes used to inject printing values into them:
+ *
+ * - date: formatted print date
+ * - title: document title
+ * - url: document location
+ * - pageNumber: current page number
+ * - totalPages: total pages in the document
+ *
+ * For example, "" would generate a span containing
+ * the title.
*/
- public int margin_top;
- public int margin_right;
- public int margin_bottom;
- public int margin_left;
+ public String header_template;
/**
- * Margin type.
+ * HTML template for the print footer. Only displayed if
+ * |display_header_footer| is true (1). Uses the same format as
+ * |header_template|.
*/
- public MarginType margin_type;
+ public String footer_template;
+
+ /**
+ * Whether or not to generate tagged (accessible) PDF.
+ */
+ public boolean generate_tagged_pdf;
+
+ /**
+ * Whether or not to embed the document outline into the PDF.
+ */
+ public boolean generate_document_outline;
public CefPdfPrintSettings() {}
@Override
public CefPdfPrintSettings clone() {
CefPdfPrintSettings tmp = new CefPdfPrintSettings();
- tmp.header_footer_enabled = this.header_footer_enabled;
- tmp.header_footer_title = this.header_footer_title;
- tmp.header_footer_url = this.header_footer_url;
tmp.landscape = this.landscape;
- tmp.backgrounds_enabled = this.backgrounds_enabled;
- tmp.page_width = this.page_width;
- tmp.page_height = this.page_height;
- tmp.selection_only = this.selection_only;
- tmp.scale_factor = this.scale_factor;
+ tmp.print_background = this.print_background;
+ tmp.scale = this.scale;
+ tmp.paper_width = this.paper_width;
+ tmp.paper_height = this.paper_height;
+ tmp.prefer_css_page_size = this.prefer_css_page_size;
+ tmp.margin_type = this.margin_type;
tmp.margin_top = this.margin_top;
- tmp.margin_right = this.margin_right;
tmp.margin_bottom = this.margin_bottom;
+ tmp.margin_right = this.margin_right;
tmp.margin_left = this.margin_left;
- tmp.margin_type = this.margin_type;
+ tmp.page_ranges = this.page_ranges;
+ tmp.display_header_footer = this.display_header_footer;
+ tmp.header_template = this.header_template;
+ tmp.footer_template = this.footer_template;
+ tmp.generate_tagged_pdf = this.generate_tagged_pdf;
+ tmp.generate_document_outline = this.generate_document_outline;
return tmp;
}
}
diff --git a/java/org/cef/misc/LongRef.java b/java/org/cef/misc/LongRef.java
new file mode 100644
index 00000000..02cd3ce9
--- /dev/null
+++ b/java/org/cef/misc/LongRef.java
@@ -0,0 +1,26 @@
+// Copyright (c) 2024 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 org.cef.misc;
+
+/**
+ * Helper class for passing long values by reference.
+ */
+public class LongRef {
+ private long value_;
+
+ public LongRef() {}
+
+ public LongRef(long value) {
+ value_ = value;
+ }
+
+ public void set(long value) {
+ value_ = value;
+ }
+
+ public long get() {
+ return value_;
+ }
+}
\ No newline at end of file
diff --git a/java/org/cef/network/CefPostDataElement.java b/java/org/cef/network/CefPostDataElement.java
index f8a209b3..576e940d 100644
--- a/java/org/cef/network/CefPostDataElement.java
+++ b/java/org/cef/network/CefPostDataElement.java
@@ -16,6 +16,7 @@ public static enum Type {
PDE_TYPE_EMPTY,
PDE_TYPE_BYTES,
PDE_TYPE_FILE,
+ PDE_TYPE_NUM_VALUES,
}
// This CTOR can't be called directly. Call method create() instead.
diff --git a/java/org/cef/network/CefRequest.java b/java/org/cef/network/CefRequest.java
index 47e38e92..5ce64451 100644
--- a/java/org/cef/network/CefRequest.java
+++ b/java/org/cef/network/CefRequest.java
@@ -41,6 +41,7 @@ public enum ResourceType {
RT_NAVIGATION_PRELOAD_MAIN_FRAME, //!< A main-frame service worker navigation preload
//!< request.
RT_NAVIGATION_PRELOAD_SUB_FRAME, //!< A sub-frame service worker navigation preload request.
+ RT_NUM_VALUES,
}
/**
@@ -317,7 +318,7 @@ public enum ReferrerPolicy {
/**
* Always the last value in this enumeration.
*/
- REFERRER_POLICY_LAST_VALUE
+ REFERRER_POLICY_NUM_VALUES
}
// This CTOR can't be called directly. Call method create() instead.
diff --git a/java/tests/detailed/BrowserFrame.java b/java/tests/detailed/BrowserFrame.java
index aa955f7f..dedcd1f8 100644
--- a/java/tests/detailed/BrowserFrame.java
+++ b/java/tests/detailed/BrowserFrame.java
@@ -4,15 +4,16 @@
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;
-import org.cef.CefApp;
-import org.cef.browser.CefBrowser;
-import org.cef.handler.CefLifeSpanHandlerAdapter;
-
public class BrowserFrame extends JFrame {
private volatile boolean isClosed_ = false;
private CefBrowser browser_ = null;
diff --git a/java/tests/detailed/MainFrame.java b/java/tests/detailed/MainFrame.java
index f13b321d..7377a2d1 100644
--- a/java/tests/detailed/MainFrame.java
+++ b/java/tests/detailed/MainFrame.java
@@ -6,6 +6,7 @@
import org.cef.CefApp;
import org.cef.CefApp.CefVersion;
+import org.cef.CefBrowserSettings;
import org.cef.CefClient;
import org.cef.CefSettings;
import org.cef.CefSettings.ColorType;
@@ -21,6 +22,8 @@
import org.cef.network.CefCookieManager;
import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.GraphicsConfiguration;
import java.awt.KeyboardFocusManager;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
@@ -29,6 +32,7 @@
import javax.swing.JFrame;
import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
import tests.detailed.dialog.DownloadDialog;
import tests.detailed.handler.AppHandler;
@@ -58,6 +62,7 @@ public static void main(String[] args) {
boolean osrEnabledArg = false;
boolean transparentPaintingEnabledArg = false;
boolean createImmediately = false;
+ int windowless_frame_rate = 0;
for (String arg : args) {
arg = arg.toLowerCase();
if (arg.equals("--off-screen-rendering-enabled")) {
@@ -66,6 +71,8 @@ public static void main(String[] args) {
transparentPaintingEnabledArg = true;
} else if (arg.equals("--create-immediately")) {
createImmediately = true;
+ } else if (arg.equals("--windowless-frame-rate-60")) {
+ windowless_frame_rate = 60;
}
}
@@ -73,10 +80,21 @@ public static void main(String[] args) {
// MainFrame keeps all the knowledge to display the embedded browser
// frame.
- final MainFrame frame = new MainFrame(
- osrEnabledArg, transparentPaintingEnabledArg, createImmediately, args);
+ final MainFrame frame = new MainFrame(osrEnabledArg, transparentPaintingEnabledArg,
+ createImmediately, windowless_frame_rate, args);
frame.setSize(800, 600);
frame.setVisible(true);
+
+ if (osrEnabledArg && windowless_frame_rate != 0) {
+ frame.getBrowser().getWindowlessFrameRate().thenAccept(
+ framerate -> System.out.println("Framerate is:" + framerate));
+
+ frame.getBrowser().setWindowlessFrameRate(2);
+ frame.getBrowser().getWindowlessFrameRate().thenAccept(
+ framerate -> System.out.println("Framerate is:" + framerate));
+
+ frame.getBrowser().setWindowlessFrameRate(windowless_frame_rate);
+ }
}
private final CefClient client_;
@@ -86,9 +104,11 @@ public static void main(String[] args) {
private boolean browserFocus_ = true;
private boolean osr_enabled_;
private boolean transparent_painting_enabled_;
+ private JPanel contentPanel_;
+ private JFrame fullscreenFrame_;
public MainFrame(boolean osrEnabled, boolean transparentPaintingEnabled,
- boolean createImmediately, String[] args) {
+ boolean createImmediately, int windowless_frame_rate, String[] args) {
this.osr_enabled_ = osrEnabled;
this.transparent_painting_enabled_ = transparentPaintingEnabled;
@@ -163,6 +183,10 @@ public void onTitleChange(CefBrowser browser, String title) {
public void onStatusMessage(CefBrowser browser, String value) {
status_panel_.setStatusText(value);
}
+ @Override
+ public void onFullscreenModeChange(CefBrowser browser, boolean fullscreen) {
+ setBrowserFullscreen(fullscreen);
+ }
});
// 2.2) To disable/enable navigation buttons and to display a prgress bar
@@ -175,19 +199,25 @@ public void onStatusMessage(CefBrowser browser, String value) {
@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_ = "";
- }
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ 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) {
+ if (errorCode != ErrorCode.ERR_NONE && errorCode != ErrorCode.ERR_ABORTED
+ && frame == browser.getMainFrame()) {
errorMsg_ = "
";
errorMsg_ += "Error while loading";
errorMsg_ += "";
@@ -200,14 +230,17 @@ public void onLoadError(CefBrowser browser, CefFrame frame, ErrorCode errorCode,
}
});
+ CefBrowserSettings browserSettings = new CefBrowserSettings();
+ browserSettings.windowless_frame_rate = windowless_frame_rate;
+
// Create the browser.
- CefBrowser browser = client_.createBrowser(
- "http://www.google.com", osrEnabled, transparentPaintingEnabled, null);
+ CefBrowser browser = client_.createBrowser("http://www.google.com", osrEnabled,
+ transparentPaintingEnabled, null, browserSettings);
setBrowser(browser);
// Set up the UI for this example implementation.
- JPanel contentPanel = createContentPanel();
- getContentPane().add(contentPanel, BorderLayout.CENTER);
+ contentPanel_ = createContentPanel();
+ getContentPane().add(contentPanel_, BorderLayout.CENTER);
// Clear focus from the browser when the address field gains focus.
control_pane_.getAddressField().addFocusListener(new FocusAdapter() {
@@ -239,7 +272,7 @@ public void onTakeFocus(CefBrowser browser, boolean next) {
if (createImmediately) browser.createImmediately();
// Add the browser to the UI.
- contentPanel.add(getBrowser().getUIComponent(), BorderLayout.CENTER);
+ contentPanel_.add(getBrowser().getUIComponent(), BorderLayout.CENTER);
MenuBar menuBar = new MenuBar(
this, browser, control_pane_, downloadDialog, CefCookieManager.getGlobalManager());
@@ -259,6 +292,8 @@ public void onTakeFocus(CefBrowser browser, boolean next) {
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.addBookmark("Fullscreen Test",
+ "https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_fullscreen2");
menuBar.addBookmarkSeparator();
menuBar.addBookmark(
"javachromiumembedded", "https://bitbucket.org/chromiumembedded/java-cef");
@@ -282,4 +317,33 @@ public boolean isOsrEnabled() {
public boolean isTransparentPaintingEnabled() {
return transparent_painting_enabled_;
}
+
+ public void setBrowserFullscreen(boolean fullscreen) {
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ Component browserUI = getBrowser().getUIComponent();
+ if (fullscreen) {
+ if (fullscreenFrame_ == null) {
+ fullscreenFrame_ = new JFrame();
+ fullscreenFrame_.setUndecorated(true);
+ fullscreenFrame_.setResizable(true);
+ }
+ GraphicsConfiguration gc = MainFrame.this.getGraphicsConfiguration();
+ fullscreenFrame_.setBounds(gc.getBounds());
+ gc.getDevice().setFullScreenWindow(fullscreenFrame_);
+
+ contentPanel_.remove(browserUI);
+ fullscreenFrame_.add(browserUI);
+ fullscreenFrame_.setVisible(true);
+ fullscreenFrame_.validate();
+ } else {
+ fullscreenFrame_.remove(browserUI);
+ fullscreenFrame_.setVisible(false);
+ contentPanel_.add(browserUI, BorderLayout.CENTER);
+ contentPanel_.validate();
+ }
+ }
+ });
+ }
}
diff --git a/java/tests/detailed/dialog/CookieManagerDialog.java b/java/tests/detailed/dialog/CookieManagerDialog.java
index 40d120e9..279ebbf2 100644
--- a/java/tests/detailed/dialog/CookieManagerDialog.java
+++ b/java/tests/detailed/dialog/CookieManagerDialog.java
@@ -1,148 +1,148 @@
-// 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 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;
-
-import org.cef.callback.CefCookieVisitor;
-import org.cef.misc.BoolRef;
-import org.cef.network.CefCookie;
-import org.cef.network.CefCookieManager;
-
-@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