Skip to content

Commit

Permalink
feat: JCEF w/ CEF 130.1.9+gfc42567+chromium-130.0.6723.70 (#9)
Browse files Browse the repository at this point in the history
* Fix CefDisplayHandler.onFullscreenModeChange name (see chromiumembedded#239)

Method names should follow Java naming conventions.

* Add two flags to CefPdfPrintSettings

* CefApp.getInstance: Support switch values containing '=' (fixes chromiumembedded#470)

* Update to CEF 126.2.0+g5c56e98+chromium-126.0.6478.62

* Update to CEF 127.3.1+g6cbb30e+chromium-127.0.6533.100

Disabled signal handlers on POSIX systems and removed the previous signal
handler fix.

* Fix Java signature for CefRequestHandler#onRenderProcessTerminated method

* Update to CEF 130.1.9+gfc42567+chromium-130.0.6723.70

This adapts JCEF to a significant change in CEF: the removal of the Alloy Bootstrap. It makes JCEF use the Alloy Runtime mode for "normal" browser windows (because Chrome-style windows can't be integrated into existing native parents, which is how JCEF integrates browsers into Java UI) and changes the DevTools handling to open the DevTools in a separate pop-up window. The latter is necessary because DevTools are unsupported in an Alloy-style window by CEF at the moment, thus it's no longer possible to integrate the DevTools into Java windows.

* fix: pack_loading_disabled on context

* fix: no AWT OSR

---------

Co-authored-by: Vladislav Rassokhin <vladrassokhin@gmail.com>
Co-authored-by: Sander van den Berg <svandenberg@uplandsoftware.com>
Co-authored-by: Rene Schneider <slartie@posteo.de>
Co-authored-by: Loïc Frasse-Mathon <scooby-lolo97@hotmail.fr>
Co-authored-by: David Cernoch <dcernoch@uplandsoftware.com>
  • Loading branch information
6 people authored Jan 23, 2025
1 parent 8ad0e87 commit fb606da
Show file tree
Hide file tree
Showing 28 changed files with 162 additions and 185 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ set_property(GLOBAL PROPERTY OS_FOLDERS ON)

# Specify the CEF distribution version.
if(NOT DEFINED CEF_VERSION)
set(CEF_VERSION "122.1.10+gc902316+chromium-122.0.6261.112")
set(CEF_VERSION "130.1.9+gfc42567+chromium-130.0.6723.70")
endif()

# Determine the platform.
Expand Down
25 changes: 15 additions & 10 deletions java/org/cef/CefClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,11 @@ public void removeDialogHandler() {

@Override
public boolean onFileDialog(CefBrowser browser, FileDialogMode mode, String title,
String defaultFilePath, Vector<String> acceptFilters, CefFileDialogCallback callback) {
String defaultFilePath, Vector<String> acceptFilters, Vector<String> acceptExtensions,
Vector<String> acceptDescriptions, CefFileDialogCallback callback) {
if (dialogHandler_ != null && browser != null) {
return dialogHandler_.onFileDialog(
browser, mode, title, defaultFilePath, acceptFilters, callback);
return dialogHandler_.onFileDialog(browser, mode, title, defaultFilePath, acceptFilters,
acceptExtensions, acceptDescriptions, callback);
}
return false;
}
Expand Down Expand Up @@ -244,9 +245,9 @@ public void onTitleChange(CefBrowser browser, String title) {
}

@Override
public void OnFullscreenModeChange(CefBrowser browser, boolean fullscreen) {
public void onFullscreenModeChange(CefBrowser browser, boolean fullscreen) {
if (displayHandler_ != null && browser != null)
displayHandler_.OnFullscreenModeChange(browser, fullscreen);
displayHandler_.onFullscreenModeChange(browser, fullscreen);
}

@Override
Expand Down Expand Up @@ -303,10 +304,12 @@ public void removeDownloadHandler() {
}

@Override
public void onBeforeDownload(CefBrowser browser, CefDownloadItem downloadItem,
String suggestedName, CefBeforeDownloadCallback callback) {
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
Expand Down Expand Up @@ -757,8 +760,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
Expand Down
10 changes: 0 additions & 10 deletions java/org/cef/CefSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,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
Expand Down Expand Up @@ -284,7 +275,6 @@ 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.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();
Expand Down
15 changes: 9 additions & 6 deletions java/org/cef/browser/CefBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -331,18 +331,21 @@ public void runFileDialog(FileDialogMode mode, String title, String defaultFileP
public void stopFinding(boolean clearSelection);

/**
* Get an instance of the DevTools 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 DevTools 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
Expand Down
16 changes: 6 additions & 10 deletions java/org/cef/browser/CefBrowser_N.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public abstract class CefBrowser_N extends CefNativeAdapter implements CefBrowse
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;
Expand Down Expand Up @@ -112,7 +111,6 @@ public synchronized void onBeforeClose() {
if (request_context_ != null) request_context_.dispose();
if (parent_ != null) {
parent_.closeDevTools();
parent_.devTools_ = null;
parent_ = null;
}
if (devToolsClient_ != null) {
Expand All @@ -121,16 +119,13 @@ public synchronized void onBeforeClose() {
}

@Override
public CefBrowser getDevTools() {
return getDevTools(null);
public void openDevTools() {
openDevTools(null);
}

@Override
public synchronized CefBrowser getDevTools(Point inspectAt) {
if (devTools_ == null) {
devTools_ = createDevToolsBrowser(client_, url_, request_context_, this, inspectAt);
}
return devTools_;
public synchronized void openDevTools(Point inspectAt) {
createDevToolsBrowser(client_, url_, request_context_, this, inspectAt).createImmediately();
}

@Override
Expand Down Expand Up @@ -572,7 +567,8 @@ public void stopFinding(boolean clearSelection) {
}
}

protected final void closeDevTools() {
@Override
public void closeDevTools() {
try {
N_CloseDevTools();
} catch (UnsatisfiedLinkError ule) {
Expand Down
10 changes: 6 additions & 4 deletions java/org/cef/handler/CefAppHandlerAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,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;
}
Expand Down
8 changes: 7 additions & 1 deletion java/org/cef/handler/CefDialogHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,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 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<String> acceptFilters, CefFileDialogCallback callback);
String defaultFilePath, Vector<String> acceptFilters, Vector<String> acceptExtensions,
Vector<String> acceptDescriptions, CefFileDialogCallback callback);
}
2 changes: 1 addition & 1 deletion java/org/cef/handler/CefDisplayHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public interface CefDisplayHandler {
* @param browser The browser generating the event.
* @param fullscreen True if fullscreen mode is on.
*/
public void OnFullscreenModeChange(CefBrowser browser, boolean fullscreen);
public void onFullscreenModeChange(CefBrowser browser, boolean fullscreen);

/**
* About to display a tooltip.
Expand Down
2 changes: 1 addition & 1 deletion java/org/cef/handler/CefDisplayHandlerAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void onTitleChange(CefBrowser browser, String title) {
}

@Override
public void OnFullscreenModeChange(CefBrowser browser, boolean fullscreen) {
public void onFullscreenModeChange(CefBrowser browser, boolean fullscreen) {
return;
}

Expand Down
10 changes: 6 additions & 4 deletions java/org/cef/handler/CefDownloadHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@
*/
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
* method.
* @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);

/**
Expand Down
6 changes: 4 additions & 2 deletions java/org/cef/handler/CefDownloadHandlerAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
7 changes: 0 additions & 7 deletions java/org/cef/handler/CefLoadHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,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),
Expand Down
9 changes: 7 additions & 2 deletions java/org/cef/handler/CefRequestHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ 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.
}

/**
Expand Down Expand Up @@ -123,6 +125,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);
}
3 changes: 2 additions & 1 deletion java/org/cef/handler/CefRequestHandlerAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,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) {}
}
12 changes: 12 additions & 0 deletions java/org/cef/misc/CefPdfPrintSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ public enum MarginType {
*/
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
Expand All @@ -125,6 +135,8 @@ public CefPdfPrintSettings clone() {
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;
}
}
4 changes: 0 additions & 4 deletions native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,13 @@ set(JCEF_SRCS
set(JCEF_SRCS_LINUX
critical_wait_posix.cpp
jni_util_linux.cpp
signal_restore_posix.cpp
signal_restore_posix.h
temp_window_x11.cc
temp_window_x11.h
util_linux.cpp
util_posix.cpp
)
set(JCEF_SRCS_MAC
critical_wait_posix.cpp
signal_restore_posix.cpp
signal_restore_posix.h
temp_window_mac.h
temp_window_mac.mm
util_mac.h
Expand Down
Loading

0 comments on commit fb606da

Please sign in to comment.