Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: JCEF w/ CEF 122.1.10+gc902316+chromium-122.0.6261.112 #1

Merged
merged 13 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions .github/workflows/build-jcef.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
matrix:
platform: [amd64, arm64]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install deps and build
run: |
sudo apt update
Expand Down Expand Up @@ -40,7 +40,7 @@ jobs:
matrix:
platform: [amd64, arm64]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ilammy/msvc-dev-cmd@v1
- name: Build
run: |
Expand All @@ -61,3 +61,35 @@ jobs:
jcef_build/windows_${{ matrix.platform }}.tar.gz
jcef_build/windows_${{ matrix.platform }}.tar.gz.sha256
if-no-files-found: error

java-cef-macos:
runs-on: [macos-12]
strategy:
matrix:
platform: [amd64, arm64]
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.9'
- run: |
brew install ninja
brew install python
brew install coreutils
sudo xcode-select --switch /Applications/Xcode_13.1.app
mkdir jcef_build && cd jcef_build
cmake -G "Ninja" -DPROJECT_ARCH=${{ matrix.platform }} -DCMAKE_BUILD_TYPE=Release ..
ninja -j4
mv native/Release macos_${{ matrix.platform }}
tar -czf macos_${{ matrix.platform }}.tar.gz macos_${{ matrix.platform }}
sha256sum macos_${{ matrix.platform }}.tar.gz > macos_${{ matrix.platform }}.tar.gz.sha256

- uses: actions/upload-artifact@v3
if: ${{ github.ref == 'refs/heads/master' }}
with:
name: 'macos_${{ matrix.platform }}'
path: |
jcef_build/macos_${{ matrix.platform }}.tar.gz
jcef_build/macos_${{ matrix.platform }}.tar.gz.sha256
if-no-files-found: error
9 changes: 2 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,9 @@ set_property(GLOBAL PROPERTY OS_FOLDERS ON)
# CEF configuration.
#

# Specify the CEF branch
if(NOT DEFINED CEF_BRANCH)
set(CEF_BRANCH "5845")
endif()

# Specify the CEF distribution version.
if(NOT DEFINED CEF_VERSION)
set(CEF_VERSION "116.0.27+gd8c85ac+chromium-116.0.5845.190")
set(CEF_VERSION "122.1.10+gc902316+chromium-122.0.6261.112")
endif()

# Determine the platform.
Expand Down Expand Up @@ -172,7 +167,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

# Download and extract the CEF binary distribution (executes DownloadCEF.cmake).
include(DownloadCEF)
DownloadCEF("${CEF_PLATFORM}" "${CEF_BRANCH}" "${CEF_VERSION}" "${CMAKE_SOURCE_DIR}/third_party/cef")
DownloadCEF("${CEF_PLATFORM}" "${CEF_VERSION}" "${CMAKE_SOURCE_DIR}/third_party/cef")

# Add the CEF binary distribution's cmake/ directory to the module path.
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CEF_ROOT}/cmake")
Expand Down
7 changes: 0 additions & 7 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
<compilerarg value="-XDignore.symbol.file"/>
<classpath location="${jdk7.path}/jre/lib/rt.jar" />
<classpath refid="class.path"/>
<src path="java/tests/"/>
<src path="java/org/cef/"/>
</javac>
<copy todir="${out.path}">
Expand All @@ -47,11 +46,6 @@
<include name="org/cef/**"/>
</fileset>
</jar>
<jar destfile="${out.path}/jcef-tests.jar" index="true" update="false">
<fileset dir="${out.path}">
<include name="tests/**"/>
</fileset>
</jar>
</target>

<target name="bundle" depends="jar">
Expand All @@ -64,7 +58,6 @@
icon="third_party/cef/res/CefIcon.icns">
<classpath dir="${out.path}">
<include name="jcef.jar"/>
<include name="jcef-tests.jar"/>
</classpath>
<classpath dir="third_party/jogamp/jar/">
<include name="gluegen-rt.jar"/>
Expand Down
12 changes: 6 additions & 6 deletions cmake/DownloadCEF.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Visit https://cef-builds.spotifycdn.com/index.html for the list of
# supported platforms and versions.

function(DownloadCEF platform branch version download_dir)
function(DownloadCEF platform version download_dir)
# Specify the binary distribution type and download directory.
set(CEF_DISTRIBUTION "cef_binary_${version}_${platform}")
set(CEF_DOWNLOAD_DIR "${download_dir}")
Expand All @@ -21,19 +21,19 @@ function(DownloadCEF platform branch version download_dir)
set(CEF_DOWNLOAD_FILENAME "${CEF_DISTRIBUTION}.tar.bz2")
set(CEF_DOWNLOAD_PATH "${CEF_DOWNLOAD_DIR}/${CEF_DOWNLOAD_FILENAME}")
if(NOT EXISTS "${CEF_DOWNLOAD_PATH}")
set(CEF_DOWNLOAD_URL "https://mcef-download.cinemamod.com/cef-builds/${branch}/${CEF_DOWNLOAD_FILENAME}")
set(CEF_DOWNLOAD_URL "https://cef-builds.spotifycdn.com/${CEF_DOWNLOAD_FILENAME}")
string(REPLACE "+" "%2B" CEF_DOWNLOAD_URL_ESCAPED ${CEF_DOWNLOAD_URL})

# Download the SHA1 hash for the binary distribution.
# message(STATUS "Downloading ${CEF_DOWNLOAD_PATH}.sha1 from ${CEF_DOWNLOAD_URL_ESCAPED}...")
# file(DOWNLOAD "${CEF_DOWNLOAD_URL_ESCAPED}.sha1" "${CEF_DOWNLOAD_PATH}.sha1")
# file(READ "${CEF_DOWNLOAD_PATH}.sha1" CEF_SHA1)
message(STATUS "Downloading ${CEF_DOWNLOAD_PATH}.sha1 from ${CEF_DOWNLOAD_URL_ESCAPED}...")
file(DOWNLOAD "${CEF_DOWNLOAD_URL_ESCAPED}.sha1" "${CEF_DOWNLOAD_PATH}.sha1")
file(READ "${CEF_DOWNLOAD_PATH}.sha1" CEF_SHA1)

# Download the binary distribution and verify the hash.
message(STATUS "Downloading ${CEF_DOWNLOAD_PATH}...")
file(
DOWNLOAD "${CEF_DOWNLOAD_URL_ESCAPED}" "${CEF_DOWNLOAD_PATH}"
# EXPECTED_HASH SHA1=${CEF_SHA1}
EXPECTED_HASH SHA1=${CEF_SHA1}
SHOW_PROGRESS
)
endif()
Expand Down
14 changes: 12 additions & 2 deletions java/org/cef/CefApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public final class CefVersion {
public final int CHROME_VERSION_PATCH;

private CefVersion(int jcefCommitNo, int cefMajor, int cefMinor, int cefPatch,
int cefCommitNo, int chrMajor, int chrMin, int chrBuild, int chrPatch) {
int cefCommitNo, int chrMajor, int chrMin, int chrBuild, int chrPatch) {
JCEF_COMMIT_NUMBER = jcefCommitNo;

CEF_VERSION_MAJOR = cefMajor;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -384,7 +390,11 @@ private final void initialize() {
settings.locales_dir_path = localesPath.normalize().toAbsolutePath().toString();
}

if (N_Initialize(appHandler_, settings)) setState(CefAppState.INITIALIZED);
if (N_Initialize(appHandler_, settings)) {
setState(CefAppState.INITIALIZED);
} else {
setState(CefAppState.INITIALIZATION_FAILED);
}
}

/**
Expand Down
31 changes: 31 additions & 0 deletions java/org/cef/CefBrowserSettings.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
82 changes: 39 additions & 43 deletions java/org/cef/CefClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,21 @@

package org.cef;

import org.cef.browser.CefBrowser;
import org.cef.browser.CefBrowserFactory;
import org.cef.browser.CefFrame;
import org.cef.browser.CefMessageRouter;
import org.cef.browser.CefRequestContext;
import org.cef.callback.CefAuthCallback;
import org.cef.callback.CefBeforeDownloadCallback;
import org.cef.callback.CefCallback;
import org.cef.callback.CefContextMenuParams;
import org.cef.callback.CefDownloadItem;
import org.cef.callback.CefDownloadItemCallback;
import org.cef.callback.CefDragData;
import org.cef.callback.CefFileDialogCallback;
import org.cef.callback.CefJSDialogCallback;
import org.cef.callback.CefMenuModel;
import org.cef.callback.CefPrintDialogCallback;
import org.cef.callback.CefPrintJobCallback;
import org.cef.browser.*;
import org.cef.callback.*;
import org.cef.handler.*;
import org.cef.misc.BoolRef;
import org.cef.misc.CefAudioParameters;
import org.cef.misc.CefPrintSettings;
import org.cef.misc.StringRef;
import org.cef.network.CefRequest;
import org.cef.network.CefRequest.TransitionType;
import org.cef.network.CefResponse;
import org.cef.network.CefURLRequest;

import java.awt.Dimension;
import java.awt.Point;
import java.awt.Rectangle;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

import java.awt.*;
import java.nio.ByteBuffer;
import java.util.Collection;
import java.util.HashMap;
import java.util.Vector;

import javax.swing.SwingUtilities;
import java.util.function.Consumer;

/**
* Client that owns a browser and renderer.
Expand Down Expand Up @@ -85,16 +62,20 @@ public void dispose() {

// CefClientHandler

public CefBrowser createBrowser(
String url, boolean isTransparent) {
return createBrowser(url, isTransparent, null);
public CefBrowser createBrowser(String url, boolean isOffscreenRendered, boolean isTransparent,
CefRequestContext context) {
if (isDisposed_)
throw new IllegalStateException("Can't create browser. CefClient is disposed");
return CefBrowserFactory.create(
this, url, isOffscreenRendered, isTransparent, context, null);
}

public CefBrowser createBrowser(String url, boolean isTransparent,
CefRequestContext context) {
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, isTransparent, context);
return CefBrowserFactory.create(
this, url, isOffscreenRendered, isTransparent, context, settings);
}

@Override
Expand Down Expand Up @@ -125,7 +106,7 @@ protected CefDialogHandler getDialogHandler() {
protected CefDisplayHandler getDisplayHandler() {
return this;
}

@Override
protected CefAudioHandler getAudioHandler() {
return this;
Expand Down Expand Up @@ -263,6 +244,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) {
Expand Down Expand Up @@ -687,6 +674,15 @@ public void onPaint(CefBrowser browser, boolean popup, Rectangle[] dirtyRects,
realHandler.onPaint(browser, popup, dirtyRects, buffer, width, height);
}

@Override
public void addOnPaintListener(Consumer<CefPaintEvent> listener) {}

@Override
public void setOnPaintListener(Consumer<CefPaintEvent> listener) {}

@Override
public void removeOnPaintListener(Consumer<CefPaintEvent> listener) {}

@Override
public boolean startDragging(CefBrowser browser, CefDragData dragData, int mask, int x, int y) {
if (browser == null) return false;
Expand Down Expand Up @@ -791,39 +787,39 @@ public void onMouseEvent(
public boolean getScreenInfo(CefBrowser arg0, CefScreenInfo arg1) {
return false;
}

// CefAudioHandler

public CefClient addAudioHandler(CefAudioHandler handler) {
if (audioHandler_ == null) audioHandler_ = handler;
return this;
}

public void removeAudioHandler() {
audioHandler_ = null;
}

@Override
public boolean getAudioParameters(CefBrowser browser, CefAudioParameters params) {
if (audioHandler_ != null) return audioHandler_.getAudioParameters(browser, params);
return false;
}

@Override
public void onAudioStreamStarted(CefBrowser browser, CefAudioParameters params, int channels) {
if (audioHandler_ != null) audioHandler_.onAudioStreamStarted(browser, params, channels);
}

@Override
public void onAudioStreamPacket(CefBrowser browser, float[] data, int frames, long pts) {
if (audioHandler_ != null) audioHandler_.onAudioStreamPacket(browser, data, frames, pts);
}

@Override
public void onAudioStreamStopped(CefBrowser browser) {
if (audioHandler_ != null) audioHandler_.onAudioStreamStopped(browser);
}

@Override
public void onAudioStreamError(CefBrowser browser, String text) {
if (audioHandler_ != null) audioHandler_.onAudioStreamError(browser, text);
Expand Down
Loading
Loading