Skip to content

Commit fb606da

Browse files
1zun4VladRassokhinOLSanderS1artieRigner
authored
feat: JCEF w/ CEF 130.1.9+gfc42567+chromium-130.0.6723.70 (#9)
* 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>
1 parent 8ad0e87 commit fb606da

28 files changed

Lines changed: 162 additions & 185 deletions

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ set_property(GLOBAL PROPERTY OS_FOLDERS ON)
132132

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

138138
# Determine the platform.

java/org/cef/CefClient.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,11 @@ public void removeDialogHandler() {
212212

213213
@Override
214214
public boolean onFileDialog(CefBrowser browser, FileDialogMode mode, String title,
215-
String defaultFilePath, Vector<String> acceptFilters, CefFileDialogCallback callback) {
215+
String defaultFilePath, Vector<String> acceptFilters, Vector<String> acceptExtensions,
216+
Vector<String> acceptDescriptions, CefFileDialogCallback callback) {
216217
if (dialogHandler_ != null && browser != null) {
217-
return dialogHandler_.onFileDialog(
218-
browser, mode, title, defaultFilePath, acceptFilters, callback);
218+
return dialogHandler_.onFileDialog(browser, mode, title, defaultFilePath, acceptFilters,
219+
acceptExtensions, acceptDescriptions, callback);
219220
}
220221
return false;
221222
}
@@ -244,9 +245,9 @@ public void onTitleChange(CefBrowser browser, String title) {
244245
}
245246

246247
@Override
247-
public void OnFullscreenModeChange(CefBrowser browser, boolean fullscreen) {
248+
public void onFullscreenModeChange(CefBrowser browser, boolean fullscreen) {
248249
if (displayHandler_ != null && browser != null)
249-
displayHandler_.OnFullscreenModeChange(browser, fullscreen);
250+
displayHandler_.onFullscreenModeChange(browser, fullscreen);
250251
}
251252

252253
@Override
@@ -303,10 +304,12 @@ public void removeDownloadHandler() {
303304
}
304305

305306
@Override
306-
public void onBeforeDownload(CefBrowser browser, CefDownloadItem downloadItem,
307-
String suggestedName, CefBeforeDownloadCallback callback) {
307+
public boolean onBeforeDownload(CefBrowser browser, CefDownloadItem downloadItem,
308+
String suggestedName, CefBeforeDownloadCallback callback) {
308309
if (downloadHandler_ != null && browser != null)
309-
downloadHandler_.onBeforeDownload(browser, downloadItem, suggestedName, callback);
310+
return downloadHandler_.onBeforeDownload(
311+
browser, downloadItem, suggestedName, callback);
312+
return false;
310313
}
311314

312315
@Override
@@ -757,8 +760,10 @@ public boolean onCertificateError(
757760
}
758761

759762
@Override
760-
public void onRenderProcessTerminated(CefBrowser browser, TerminationStatus status) {
761-
if (requestHandler_ != null) requestHandler_.onRenderProcessTerminated(browser, status);
763+
public void onRenderProcessTerminated(
764+
CefBrowser browser, TerminationStatus status, int error_code, String error_string) {
765+
if (requestHandler_ != null)
766+
requestHandler_.onRenderProcessTerminated(browser, status, error_code, error_string);
762767
}
763768

764769
// CefWindowHandler

java/org/cef/CefSettings.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -214,15 +214,6 @@ public ColorType clone() {
214214
*/
215215
public String locales_dir_path = null;
216216

217-
/**
218-
* Set to true to disable loading of pack files for resources and locales.
219-
* A resource bundle handler must be provided for the browser and render
220-
* processes via CefApp::GetResourceBundleHandler() if loading of pack files
221-
* is disabled. Also configurable using the "disable-pack-loading" command-
222-
* line switch.
223-
*/
224-
public boolean pack_loading_disabled = false;
225-
226217
/**
227218
* Set to a value between 1024 and 65535 to enable remote debugging on the
228219
* specified port. For example, if 8080 is specified the remote debugging URL
@@ -284,7 +275,6 @@ public CefSettings clone() {
284275
tmp.javascript_flags = javascript_flags;
285276
tmp.resources_dir_path = resources_dir_path;
286277
tmp.locales_dir_path = locales_dir_path;
287-
tmp.pack_loading_disabled = pack_loading_disabled;
288278
tmp.remote_debugging_port = remote_debugging_port;
289279
tmp.uncaught_exception_stack_size = uncaught_exception_stack_size;
290280
if (background_color != null) tmp.background_color = background_color.clone();

java/org/cef/browser/CefBrowser.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,18 +331,21 @@ public void runFileDialog(FileDialogMode mode, String title, String defaultFileP
331331
public void stopFinding(boolean clearSelection);
332332

333333
/**
334-
* Get an instance of the DevTools to be displayed in its own window or to be
335-
* embedded within your UI. Only one instance per browser is available.
334+
* Get an instance of the DevTools to be displayed in its own window.
336335
*/
337-
public CefBrowser getDevTools();
336+
public void openDevTools();
338337

339338
/**
340-
* Get an instance of the DevTools to be displayed in its own window or to be
341-
* embedded within your UI. Only one instance per browser is available.
339+
* Open an instance of the DevTools to be displayed in its own window.
342340
*
343341
* @param inspectAt a position in the UI which should be inspected.
344342
*/
345-
public CefBrowser getDevTools(Point inspectAt);
343+
public void openDevTools(Point inspectAt);
344+
345+
/**
346+
* Close the DevTools.
347+
*/
348+
public void closeDevTools();
346349

347350
/**
348351
* Get an instance of a client that can be used to leverage the DevTools

java/org/cef/browser/CefBrowser_N.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public abstract class CefBrowser_N extends CefNativeAdapter implements CefBrowse
3535
private final CefRequestContext request_context_;
3636
private volatile CefBrowser_N parent_ = null;
3737
private volatile Point inspectAt_ = null;
38-
private volatile CefBrowser_N devTools_ = null;
3938
private volatile CefDevToolsClient devToolsClient_ = null;
4039
private boolean closeAllowed_ = false;
4140
private volatile boolean isClosed_ = false;
@@ -112,7 +111,6 @@ public synchronized void onBeforeClose() {
112111
if (request_context_ != null) request_context_.dispose();
113112
if (parent_ != null) {
114113
parent_.closeDevTools();
115-
parent_.devTools_ = null;
116114
parent_ = null;
117115
}
118116
if (devToolsClient_ != null) {
@@ -121,16 +119,13 @@ public synchronized void onBeforeClose() {
121119
}
122120

123121
@Override
124-
public CefBrowser getDevTools() {
125-
return getDevTools(null);
122+
public void openDevTools() {
123+
openDevTools(null);
126124
}
127125

128126
@Override
129-
public synchronized CefBrowser getDevTools(Point inspectAt) {
130-
if (devTools_ == null) {
131-
devTools_ = createDevToolsBrowser(client_, url_, request_context_, this, inspectAt);
132-
}
133-
return devTools_;
127+
public synchronized void openDevTools(Point inspectAt) {
128+
createDevToolsBrowser(client_, url_, request_context_, this, inspectAt).createImmediately();
134129
}
135130

136131
@Override
@@ -572,7 +567,8 @@ public void stopFinding(boolean clearSelection) {
572567
}
573568
}
574569

575-
protected final void closeDevTools() {
570+
@Override
571+
public void closeDevTools() {
576572
try {
577573
N_CloseDevTools();
578574
} catch (UnsatisfiedLinkError ule) {

java/org/cef/handler/CefAppHandlerAdapter.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ public void onBeforeCommandLineProcessing(String process_type, CefCommandLine co
4848
case 1: {
4949
// Switches can optionally have a value specified using the '=' delimiter
5050
// (e.g. "-switch=value").
51-
String[] switchVals = arg.substring(switchCnt).split("=");
52-
if (switchVals.length == 2) {
53-
command_line.appendSwitchWithValue(switchVals[0], switchVals[1]);
51+
String switchStr = arg.substring(switchCnt);
52+
int index = switchStr.indexOf('=');
53+
if (index > 0) {
54+
command_line.appendSwitchWithValue(
55+
switchStr.substring(0, index), switchStr.substring(index + 1));
5456
} else {
55-
command_line.appendSwitch(switchVals[0]);
57+
command_line.appendSwitch(switchStr);
5658
}
5759
break;
5860
}

java/org/cef/handler/CefDialogHandler.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,17 @@ enum FileDialogMode {
3838
* "image/*"), (b) individual file extensions (e.g. ".txt" or ".png"), or (c)
3939
* combined description and file extension delimited using "|" and ";" (e.g.
4040
* "Image Types|.png;.gif;.jpg").
41+
* @param acceptExtensions provides the semicolon-delimited expansion of MIME
42+
* types to file extensions (if known, or empty string otherwise).
43+
* @param acceptDescriptions provides the descriptions for MIME types (if known,
44+
* or empty string otherwise). For example, the "image/*" mime type might
45+
* have extensions ".png;.jpg;.bmp;..." and description "Image Files".
4146
* @param callback is a callback handler for handling own file dialogs.
4247
*
4348
* @return To display a custom dialog return true and execute callback.
4449
* To display the default dialog return false.
4550
*/
4651
public boolean onFileDialog(CefBrowser browser, FileDialogMode mode, String title,
47-
String defaultFilePath, Vector<String> acceptFilters, CefFileDialogCallback callback);
52+
String defaultFilePath, Vector<String> acceptFilters, Vector<String> acceptExtensions,
53+
Vector<String> acceptDescriptions, CefFileDialogCallback callback);
4854
}

java/org/cef/handler/CefDisplayHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public interface CefDisplayHandler {
3333
* @param browser The browser generating the event.
3434
* @param fullscreen True if fullscreen mode is on.
3535
*/
36-
public void OnFullscreenModeChange(CefBrowser browser, boolean fullscreen);
36+
public void onFullscreenModeChange(CefBrowser browser, boolean fullscreen);
3737

3838
/**
3939
* About to display a tooltip.

java/org/cef/handler/CefDisplayHandlerAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void onTitleChange(CefBrowser browser, String title) {
2525
}
2626

2727
@Override
28-
public void OnFullscreenModeChange(CefBrowser browser, boolean fullscreen) {
28+
public void onFullscreenModeChange(CefBrowser browser, boolean fullscreen) {
2929
return;
3030
}
3131

java/org/cef/handler/CefDownloadHandler.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,19 @@
1515
*/
1616
public interface CefDownloadHandler {
1717
/**
18-
* Called before a download begins. By default the download will be canceled.
19-
* Execute callback either asynchronously or in this method to continue the download
20-
* if desired.
18+
* Called before a download begins. Return true and execute |callback| either
19+
* asynchronously or in this method to continue or cancel the download.
20+
* Return false to proceed with default handling (cancel with Alloy style,
21+
* download shelf with Chrome style). Do not keep a reference to
22+
* downloadItem outside of this method.
2123
*
2224
* @param browser The desired browser.
2325
* @param downloadItem The item to be downloaded. Do not keep a reference to it outside this
2426
* method.
2527
* @param suggestedName is the suggested name for the download file.
2628
* @param callback start the download by calling the Continue method
2729
*/
28-
public void onBeforeDownload(CefBrowser browser, CefDownloadItem downloadItem,
30+
public boolean onBeforeDownload(CefBrowser browser, CefDownloadItem downloadItem,
2931
String suggestedName, CefBeforeDownloadCallback callback);
3032

3133
/**

0 commit comments

Comments
 (0)