Skip to content

Commit 7e0ef9d

Browse files
S1artiemagreenblatt
authored andcommitted
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.
1 parent 8b4225a commit 7e0ef9d

File tree

8 files changed

+52
-59
lines changed

8 files changed

+52
-59
lines changed

CMakeLists.txt

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

131131
# Specify the CEF distribution version.
132132
if(NOT DEFINED CEF_VERSION)
133-
set(CEF_VERSION "127.3.1+g6cbb30e+chromium-127.0.6533.100")
133+
set(CEF_VERSION "130.1.9+gfc42567+chromium-130.0.6723.70")
134134
endif()
135135

136136
# Determine the platform.

java/org/cef/CefSettings.java

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

213-
/**
214-
* Set to true to disable loading of pack files for resources and locales.
215-
* A resource bundle handler must be provided for the browser and render
216-
* processes via CefApp::GetResourceBundleHandler() if loading of pack files
217-
* is disabled. Also configurable using the "disable-pack-loading" command-
218-
* line switch.
219-
*/
220-
public boolean pack_loading_disabled = false;
221-
222213
/**
223214
* Set to a value between 1024 and 65535 to enable remote debugging on the
224215
* specified port. For example, if 8080 is specified the remote debugging URL
@@ -278,7 +269,6 @@ public CefSettings clone() {
278269
tmp.javascript_flags = javascript_flags;
279270
tmp.resources_dir_path = resources_dir_path;
280271
tmp.locales_dir_path = locales_dir_path;
281-
tmp.pack_loading_disabled = pack_loading_disabled;
282272
tmp.remote_debugging_port = remote_debugging_port;
283273
tmp.uncaught_exception_stack_size = uncaught_exception_stack_size;
284274
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
@@ -337,18 +337,21 @@ public void runFileDialog(FileDialogMode mode, String title, String defaultFileP
337337
public void stopFinding(boolean clearSelection);
338338

339339
/**
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.
340+
* Get an instance of the DevTools to be displayed in its own window.
342341
*/
343-
public CefBrowser getDevTools();
342+
public void openDevTools();
344343

345344
/**
346-
* Get an instance of the DevTools to be displayed in its own window or to be
347-
* embedded within your UI. Only one instance per browser is available.
345+
* Open an instance of the DevTools to be displayed in its own window.
348346
*
349347
* @param inspectAt a position in the UI which should be inspected.
350348
*/
351-
public CefBrowser getDevTools(Point inspectAt);
349+
public void openDevTools(Point inspectAt);
350+
351+
/**
352+
* Close the DevTools.
353+
*/
354+
public void closeDevTools();
352355

353356
/**
354357
* 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
@@ -45,7 +45,6 @@ abstract class CefBrowser_N extends CefNativeAdapter implements CefBrowser {
4545
private final CefRequestContext request_context_;
4646
private volatile CefBrowser_N parent_ = null;
4747
private volatile Point inspectAt_ = null;
48-
private volatile CefBrowser_N devTools_ = null;
4948
private volatile CefDevToolsClient devToolsClient_ = null;
5049
private boolean closeAllowed_ = false;
5150
private volatile boolean isClosed_ = false;
@@ -134,7 +133,6 @@ public synchronized void onBeforeClose() {
134133
if (request_context_ != null) request_context_.dispose();
135134
if (parent_ != null) {
136135
parent_.closeDevTools();
137-
parent_.devTools_ = null;
138136
parent_ = null;
139137
}
140138
if (devToolsClient_ != null) {
@@ -143,16 +141,13 @@ public synchronized void onBeforeClose() {
143141
}
144142

145143
@Override
146-
public CefBrowser getDevTools() {
147-
return getDevTools(null);
144+
public void openDevTools() {
145+
openDevTools(null);
148146
}
149147

150148
@Override
151-
public synchronized CefBrowser getDevTools(Point inspectAt) {
152-
if (devTools_ == null) {
153-
devTools_ = createDevToolsBrowser(client_, url_, request_context_, this, inspectAt);
154-
}
155-
return devTools_;
149+
public synchronized void openDevTools(Point inspectAt) {
150+
createDevToolsBrowser(client_, url_, request_context_, this, inspectAt).createImmediately();
156151
}
157152

158153
@Override
@@ -594,7 +589,8 @@ public void stopFinding(boolean clearSelection) {
594589
}
595590
}
596591

597-
protected final void closeDevTools() {
592+
@Override
593+
public void closeDevTools() {
598594
try {
599595
N_CloseDevTools();
600596
} catch (UnsatisfiedLinkError ule) {

java/tests/detailed/dialog/DevToolsDialog.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@
1616

1717
@SuppressWarnings("serial")
1818
public class DevToolsDialog extends JDialog {
19-
private final CefBrowser devTools_;
19+
private final CefBrowser browser_;
2020
public DevToolsDialog(Frame owner, String title, CefBrowser browser) {
2121
this(owner, title, browser, null);
2222
}
2323

2424
public DevToolsDialog(Frame owner, String title, CefBrowser browser, Point inspectAt) {
2525
super(owner, title, false);
26+
browser_ = browser;
2627

2728
setLayout(new BorderLayout());
2829
setSize(800, 600);
2930
setLocation(owner.getLocation().x + 20, owner.getLocation().y + 20);
3031

31-
devTools_ = browser.getDevTools(inspectAt);
32-
add(devTools_.getUIComponent());
32+
browser.openDevTools(inspectAt);
3333

3434
addComponentListener(new ComponentAdapter() {
3535
@Override
@@ -41,7 +41,7 @@ public void componentHidden(ComponentEvent e) {
4141

4242
@Override
4343
public void dispose() {
44-
devTools_.close(true);
44+
browser_.closeDevTools();
4545
super.dispose();
4646
}
4747
}

native/CefBrowser_N.cpp

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,29 @@ void create(std::shared_ptr<JNIObjectsForCreate> objs,
940940
if (!lifeSpanHandler.get())
941941
return;
942942

943+
CefRefPtr<CefBrowser> parentBrowser =
944+
GetCefFromJNIObject<CefBrowser>(env, objs->jparentBrowser, "CefBrowser");
945+
943946
CefWindowInfo windowInfo;
947+
CefBrowserSettings settings;
948+
949+
// If parentBrowser is set, we want to show the DEV-Tools for that browser.
950+
// Since that cannot be an Alloy-style window, it cannot be integrated into
951+
// Java UI but must be opened as a pop-up.
952+
if (parentBrowser.get() != nullptr) {
953+
CefPoint inspectAt;
954+
if (objs->jinspectAt != nullptr) {
955+
int x, y;
956+
GetJNIPoint(env, objs->jinspectAt, &x, &y);
957+
inspectAt.Set(x, y);
958+
}
959+
960+
parentBrowser->GetHost()->ShowDevTools(windowInfo, clientHandler.get(),
961+
settings, inspectAt);
962+
JNI_CALL_VOID_METHOD(env, objs->jbrowser, "notifyBrowserCreated", "()V");
963+
return;
964+
}
965+
944966
if (osr == JNI_FALSE) {
945967
CefRect rect;
946968
CefRefPtr<WindowHandler> windowHandler =
@@ -978,8 +1000,6 @@ void create(std::shared_ptr<JNIObjectsForCreate> objs,
9781000
windowInfo.SetAsWindowless((CefWindowHandle)windowHandle);
9791001
}
9801002

981-
CefBrowserSettings settings;
982-
9831003
if (transparent == JNI_FALSE) {
9841004
// Specify an opaque background color (white) to disable transparency.
9851005
settings.background_color = CefColorSetARGB(255, 255, 255, 255);
@@ -998,27 +1018,10 @@ void create(std::shared_ptr<JNIObjectsForCreate> objs,
9981018
CefRefPtr<CefRequestContext> context = GetCefFromJNIObject<CefRequestContext>(
9991019
env, objs->jcontext, "CefRequestContext");
10001020

1001-
CefRefPtr<CefBrowser> parentBrowser =
1002-
GetCefFromJNIObject<CefBrowser>(env, objs->jparentBrowser, "CefBrowser");
1003-
10041021
// Add a global ref that will be released in LifeSpanHandler::OnAfterCreated.
10051022
jobject globalRef = env->NewGlobalRef(objs->jbrowser);
10061023
lifeSpanHandler->registerJBrowser(globalRef);
10071024

1008-
// If parentBrowser is set, we want to show the DEV-Tools for that browser
1009-
if (parentBrowser.get() != nullptr) {
1010-
CefPoint inspectAt;
1011-
if (objs->jinspectAt != nullptr) {
1012-
int x, y;
1013-
GetJNIPoint(env, objs->jinspectAt, &x, &y);
1014-
inspectAt.Set(x, y);
1015-
}
1016-
parentBrowser->GetHost()->ShowDevTools(windowInfo, clientHandler.get(),
1017-
settings, inspectAt);
1018-
JNI_CALL_VOID_METHOD(env, objs->jbrowser, "notifyBrowserCreated", "()V");
1019-
return;
1020-
}
1021-
10221025
CefRefPtr<CefDictionaryValue> extra_info;
10231026
auto router_configs = BrowserProcessHandler::GetMessageRouterConfigs();
10241027
if (router_configs) {
@@ -1027,6 +1030,10 @@ void create(std::shared_ptr<JNIObjectsForCreate> objs,
10271030
extra_info->SetList("router_configs", router_configs);
10281031
}
10291032

1033+
// JCEF requires Alloy runtime style for "normal" browsers in order for them
1034+
// to be integratable into Java UI.
1035+
windowInfo.runtime_style = CEF_RUNTIME_STYLE_ALLOY;
1036+
10301037
bool result = CefBrowserHost::CreateBrowser(
10311038
windowInfo, clientHandler.get(), strUrl, settings, extra_info, context);
10321039
if (!result) {
@@ -1524,7 +1531,6 @@ Java_org_cef_browser_CefBrowser_1N_N_1SetWindowVisibility(JNIEnv* env,
15241531
}
15251532
#endif
15261533
}
1527-
15281534
JNIEXPORT jdouble JNICALL
15291535
Java_org_cef_browser_CefBrowser_1N_N_1GetZoomLevel(JNIEnv* env, jobject obj) {
15301536
CefRefPtr<CefBrowser> browser = JNI_GET_BROWSER_OR_RETURN(env, obj, 0.0);

native/context.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ CefSettings GetJNISettings(JNIEnv* env, jobject obj) {
107107
CefString(&settings.locales_dir_path) = tmp;
108108
tmp.clear();
109109
}
110-
GetJNIFieldBoolean(env, cls, obj, "pack_loading_disabled",
111-
&settings.pack_loading_disabled);
112110
GetJNIFieldInt(env, cls, obj, "remote_debugging_port",
113111
&settings.remote_debugging_port);
114112
GetJNIFieldInt(env, cls, obj, "uncaught_exception_stack_size",

native/request_handler.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,10 @@ void RequestHandler::OnRenderProcessTerminated(CefRefPtr<CefBrowser> browser,
207207

208208
ScopedJNIString jerrorString(env, error_string);
209209

210-
JNI_CALL_VOID_METHOD(
211-
env, handle_, "onRenderProcessTerminated",
212-
"(Lorg/cef/browser/CefBrowser;"
213-
"Lorg/cef/handler/CefRequestHandler$TerminationStatus;"
214-
"ILjava/lang/String;)V",
215-
jbrowser.get(), jstatus.get(), error_code, jerrorString.get());
210+
JNI_CALL_VOID_METHOD(env, handle_, "onRenderProcessTerminated",
211+
"(Lorg/cef/browser/CefBrowser;"
212+
"Lorg/cef/handler/CefRequestHandler$TerminationStatus;"
213+
"ILjava/lang/String;)V",
214+
jbrowser.get(), jstatus.get(), error_code,
215+
jerrorString.get());
216216
}

0 commit comments

Comments
 (0)