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

Feature/adpat new cef version #39

Merged
merged 3 commits into from
Sep 14, 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
35 changes: 23 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,29 @@ configure_file(
message(STATUS "Detecting CEF_SDK_VERSION: ${CEF_SDK_VERSION}")

if(NOT CEF_SDK_VERSION)
# "89.0.12+g2b76680+chromium-89.0.4389.90" # GOOD
# "91.1.23+g04c8d56+chromium-91.0.4472.164" # GOOD
# "95.7.12+g99c4ac0+chromium-95.0.4638.54" # GOOD
# "99.2.15+g71e9523+chromium-99.0.4844.84" # GOOD
# "102.0.10+gf249b2e+chromium-102.0.5005.115" # GOOD
# "104.4.18+g2587cf2+chromium-104.0.5112.81" # BAD # crash on macOS - debug mode
# "104.4.26+g4180781+chromium-104.0.5112.102" # BAD # crash on macOS - debug mode
# "105.3.25+g0ca6a9e+chromium-105.0.5195.54" # BAD # debugbreak - debug mode
# "105.3.28+g002805e+chromium-105.0.5195.54" # BAD # debugbreak - debug mode
# "107.1.9+g1f0a21a+chromium-107.0.5304.110" # BAD # debugbreak - debug mode
# "110.0.26+g732747f+chromium-110.0.5481.97" # BAD # TO-BE-FIXED
set(DEFAULT_CEF_SDK_VER "113.3.1+g525fa10+chromium-113.0.5672.128")
# set(DEFAULT_CEF_SDK_VER "89.0.12+g2b76680+chromium-89.0.4389.90") # GOOD
# set(DEFAULT_CEF_SDK_VER "91.1.23+g04c8d56+chromium-91.0.4472.164") # GOOD
# set(DEFAULT_CEF_SDK_VER "95.7.12+g99c4ac0+chromium-95.0.4638.54") # GOOD
# set(DEFAULT_CEF_SDK_VER "99.2.15+g71e9523+chromium-99.0.4844.84") # GOOD
# set(DEFAULT_CEF_SDK_VER "102.0.10+gf249b2e+chromium-102.0.5005.115") # GOOD
# set(DEFAULT_CEF_SDK_VER "104.4.18+g2587cf2+chromium-104.0.5112.81") # BAD # crash on macOS - debug mode
# set(DEFAULT_CEF_SDK_VER "104.4.26+g4180781+chromium-104.0.5112.102") # BAD # crash on macOS - debug mode
# set(DEFAULT_CEF_SDK_VER "105.3.25+g0ca6a9e+chromium-105.0.5195.54") # BAD # debugbreak - debug mode
# set(DEFAULT_CEF_SDK_VER "105.3.28+g002805e+chromium-105.0.5195.54") # BAD # debugbreak - debug mode
# set(DEFAULT_CEF_SDK_VER "107.1.9+g1f0a21a+chromium-107.0.5304.110") # BAD # debugbreak - debug mode
# set(DEFAULT_CEF_SDK_VER "110.0.26+g732747f+chromium-110.0.5481.97") # BAD # TO-BE-FIXED
# set(DEFAULT_CEF_SDK_VER "113.3.1+g525fa10+chromium-113.0.5672.128") # GOOD
# set(DEFAULT_CEF_SDK_VER "119.4.4+g5d1e039+chromium-119.0.6045.199") # GOOD
# set(DEFAULT_CEF_SDK_VER "120.1.6+gf08b1fd+chromium-120.0.6099.71") # GOOD
# set(DEFAULT_CEF_SDK_VER "121.3.15+g4d3b0b4+chromium-121.0.6167.184") # GOOD
# set(DEFAULT_CEF_SDK_VER "122.1.13+gde5b724+chromium-122.0.6261.130") # NOT-TEST
# set(DEFAULT_CEF_SDK_VER "123.0.13+gfc703fb+chromium-123.0.6312.124") # NOT-TEST
# set(DEFAULT_CEF_SDK_VER "124.3.9+g9bd638f+chromium-124.0.6367.207") # NOT-TEST
# set(DEFAULT_CEF_SDK_VER "125.0.22+gc410c95+chromium-125.0.6422.142") # NOT-TEST
# set(DEFAULT_CEF_SDK_VER "126.2.18+g3647d39+chromium-126.0.6478.183") # NOT-TEST
set(DEFAULT_CEF_SDK_VER "127.3.5+g114ea2a+chromium-127.0.6533.120") # GOOD

# set(DEFAULT_CEF_SDK_VER "128.4.9+g9840ad9+chromium-128.0.6613.120") # BAD # debugbreak - debug mode
message(STATUS
"CEF_SDK_VERSION is empty, use default version ${DEFAULT_CEF_SDK_VER}\n"
"You can change the version by adding -DCEF_SDK_VERSION=xxx to commandline for generation")
Expand Down
1 change: 1 addition & 0 deletions cmake/DownloadCef.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Generally, there is NO NEED to modify the following config
#
# Download CEF binary package
# https://cef-builds.spotifycdn.com/index.html
#
if(NOT CEF_SDK_VERSION)
message(FATAL_ERROR "CEF_SDK_VERSION is missing!")
Expand Down
60 changes: 51 additions & 9 deletions include/CefViewBrowserClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <include/wrapper/cef_resource_manager.h>
#pragma endregion cef_headers

#include <CefViewCoreGlobal.h>
#include <CefViewBrowserApp.h>
#include <CefViewBrowserClientDelegate.h>
#include <CefViewQueryHandler.h>
Expand Down Expand Up @@ -69,11 +70,12 @@ class CefViewBrowserClient
/// <summary>
///
/// </summary>
enum
{
MAIN_FRAME = (int64_t)0,
ALL_FRAMES = (int64_t)-1,
};
const static CefFrameId MAIN_FRAME;

/// <summary>
///
/// </summary>
const static CefFrameId ALL_FRAMES;

/// <summary>
///
Expand Down Expand Up @@ -118,7 +120,7 @@ class CefViewBrowserClient
const std::string& password,
int priority = 0);

bool TriggerEvent(CefRefPtr<CefBrowser> browser, const int64_t frame_id, const CefRefPtr<CefProcessMessage> msg);
bool TriggerEvent(CefRefPtr<CefBrowser> browser, const CefFrameId& frame_id, const CefRefPtr<CefProcessMessage> msg);

/// <summary>
///
Expand Down Expand Up @@ -193,15 +195,33 @@ class CefViewBrowserClient
// CefDialogHandler
#pragma region CefDialogHandler
virtual CefRefPtr<CefDialogHandler> GetDialogHandler() override;

#if CEF_VERSION_MAJOR < 102
virtual bool OnFileDialog(CefRefPtr<CefBrowser> browser,
FileDialogMode mode,
const CefString& title,
const CefString& default_file_path,
const std::vector<CefString>& accept_filters,
#if CEF_VERSION_MAJOR < 102
int selected_accept_filter,
#endif
CefRefPtr<CefFileDialogCallback> callback) override;
#elif CEF_VERSION_MAJOR < 126
virtual bool OnFileDialog(CefRefPtr<CefBrowser> browser,
FileDialogMode mode,
const CefString& title,
const CefString& default_file_path,
const std::vector<CefString>& accept_filters,
CefRefPtr<CefFileDialogCallback> callback) override;
#else
virtual bool OnFileDialog(CefRefPtr<CefBrowser> browser,
FileDialogMode mode,
const CefString& title,
const CefString& default_file_path,
const std::vector<CefString>& accept_filters,
const std::vector<CefString>& accept_extensions,
const std::vector<CefString>& accept_descriptions,
CefRefPtr<CefFileDialogCallback> callback) override;
#endif

#pragma endregion

// CefDisplayHandler methods
Expand Down Expand Up @@ -229,10 +249,17 @@ class CefViewBrowserClient
// CefDownloadHandler
#pragma region CefDownloadHandler
virtual CefRefPtr<CefDownloadHandler> GetDownloadHandler() override;
void OnBeforeDownload(CefRefPtr<CefBrowser> browser,
#if CEF_VERSION_MAJOR < 125
virtual void OnBeforeDownload(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDownloadItem> download_item,
const CefString& suggested_name,
CefRefPtr<CefBeforeDownloadCallback> callback) override;
#else
virtual bool OnBeforeDownload(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDownloadItem> download_item,
const CefString& suggested_name,
CefRefPtr<CefBeforeDownloadCallback> callback) override;
#endif

void OnDownloadUpdated(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDownloadItem> download_item,
Expand Down Expand Up @@ -341,10 +368,17 @@ class CefViewBrowserClient
const void* buffer,
int width,
int height) override;
#if CEF_VERSION_MAJOR < 124
virtual void OnAcceleratedPaint(CefRefPtr<CefBrowser> browser,
PaintElementType type,
const RectList& dirtyRects,
void* shared_handle) override;
#else
virtual void OnAcceleratedPaint(CefRefPtr<CefBrowser> browser,
PaintElementType type,
const RectList& dirtyRects,
const CefAcceleratedPaintInfo& info) override;
#endif
virtual bool StartDragging(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDragData> drag_data,
CefRenderHandler::DragOperationsMask allowed_ops,
Expand Down Expand Up @@ -382,7 +416,15 @@ class CefViewBrowserClient
CefRefPtr<CefCallback> callback) override;
#endif

#if CEF_VERSION_MAJOR < 124
virtual void OnRenderProcessTerminated(CefRefPtr<CefBrowser> browser, TerminationStatus status) override;
#else
virtual void OnRenderProcessTerminated(CefRefPtr<CefBrowser> browser,
TerminationStatus status,
int error_code,
const CefString& error_string) override;
#endif

#pragma endregion

// CefResourceRequestHandler
Expand Down
23 changes: 17 additions & 6 deletions include/CefViewBrowserClientDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include <include/cef_version.h>
#include <include/cef_client.h>

#include <CefViewCoreGlobal.h>

/// <summary>
///
/// </summary>
Expand All @@ -29,21 +31,21 @@ class CefViewBrowserClientDelegateInterface
virtual void processUrlRequest(const std::string& url) = 0;

virtual void processQueryRequest(CefRefPtr<CefBrowser>& browser,
int64_t frameId,
const CefFrameId& frameId,
const std::string& query,
const int64_t query_id) = 0;

virtual void focusedEditableNodeChanged(CefRefPtr<CefBrowser>& browser,
int64_t frameId,
const CefFrameId& frameId,
bool focusOnEditableNode) = 0;

virtual void invokeMethodNotify(CefRefPtr<CefBrowser>& browser,
int64_t frameId,
const CefFrameId& frameId,
const std::string& method,
const CefRefPtr<CefListValue>& arguments) = 0;

virtual void reportJSResult(CefRefPtr<CefBrowser>& browser,
int64_t frameId,
const CefFrameId& frameId,
const std::string& context,
const CefRefPtr<CefValue>& result) = 0;

Expand Down Expand Up @@ -84,7 +86,7 @@ class CefViewBrowserClientDelegateInterface

// display handler
#pragma region DisplayHandler
virtual void addressChanged(CefRefPtr<CefBrowser>& browser, int64_t frameId, const std::string& url) = 0;
virtual void addressChanged(CefRefPtr<CefBrowser>& browser, const CefFrameId& frameId, const std::string& url) = 0;

virtual void titleChanged(CefRefPtr<CefBrowser>& browser, const std::string& title) = 0;

Expand Down Expand Up @@ -134,7 +136,7 @@ class CefViewBrowserClientDelegateInterface
// life span handler
#pragma region LifeSpanHandler
virtual bool onBeforePopup(CefRefPtr<CefBrowser>& browser,
int64_t frameId,
const CefFrameId& frameId,
const std::string& targetUrl,
const std::string& targetFrameName,
CefLifeSpanHandler::WindowOpenDisposition targetDisposition,
Expand Down Expand Up @@ -207,12 +209,21 @@ class CefViewBrowserClientDelegateInterface
int height)
{
}
#if CEF_VERSION_MAJOR < 124
virtual void onAcceleratedPaint(CefRefPtr<CefBrowser> browser,
CefRenderHandler::PaintElementType type,
const CefRenderHandler::RectList& dirtyRects,
void* shared_handle)
{
}
#else
virtual void onAcceleratedPaint(CefRefPtr<CefBrowser> browser,
CefRenderHandler::PaintElementType type,
const CefRenderHandler::RectList& dirtyRects,
const CefAcceleratedPaintInfo& info)
{
}
#endif
virtual bool startDragging(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDragData> drag_data,
CefRenderHandler::DragOperationsMask allowed_ops,
Expand Down
42 changes: 42 additions & 0 deletions include/CefViewCoreGlobal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* File: CefViewCoreGlobal.h
* Project: include
* Created: 30 May 2023
* Author: Sheen Tian
*/
#ifndef CefViewCoreGlobal_h
#define CefViewCoreGlobal_h
#pragma once

#pragma region cef_headers
#include <include/cef_app.h>
#include <include/cef_version.h>
#pragma endregion cef_headers

#if CEF_VERSION_MAJOR < 122
using CefFrameId = int64_t;
#else
using CefFrameId = CefString;

template<>
struct std::hash<CefFrameId>
{
std::size_t operator()(const CefFrameId& k) const
{
using std::hash;
using std::string;
return std::hash<std::string>()(k.ToString());
}
};

// namespace std {
// static std::string
// to_string(const CefFrameId& k)
//{
// return k.ToString();
// }
// } // namespace std

#endif

#endif
Empty file modified linux-arm-gen.sh
100644 → 100755
Empty file.
Empty file modified linux-arm64-gen.sh
100644 → 100755
Empty file.
Empty file modified linux-x86-gen.sh
100644 → 100755
Empty file.
Empty file modified linux-x86_64-gen.sh
100644 → 100755
Empty file.
Empty file modified mac-arm64-gen.sh
100644 → 100755
Empty file.
Empty file modified mac-x86_64-gen.sh
100644 → 100755
Empty file.
19 changes: 16 additions & 3 deletions src/CefView/CefBrowserApp/CefViewBrowserClient.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <CefViewBrowserClient.h>
#include <CefViewBrowserClient.h>

#pragma region std_headers
#include <sstream>
Expand All @@ -13,6 +13,14 @@
#include <CefViewCoreProtocol.h>
#include <Common/CefViewCoreLog.h>

#if CEF_VERSION_MAJOR < 122
const CefFrameId CefViewBrowserClient::MAIN_FRAME = 0;
const CefFrameId CefViewBrowserClient::ALL_FRAMES = -1;
#else
const CefFrameId CefViewBrowserClient::MAIN_FRAME = "0";
const CefFrameId CefViewBrowserClient::ALL_FRAMES = "-1";
#endif

CefViewBrowserClient::CefViewBrowserClient(CefRefPtr<CefViewBrowserApp> app,
CefViewBrowserClientDelegateInterface::RefPtr delegate)
: is_closing_(false)
Expand Down Expand Up @@ -80,14 +88,14 @@ CefViewBrowserClient::AddArchiveResourceProvider(const std::string& archive_path

bool
CefViewBrowserClient::TriggerEvent(CefRefPtr<CefBrowser> browser,
const int64_t frame_id,
const CefFrameId& frame_id,
const CefRefPtr<CefProcessMessage> msg)
{
if (msg->GetName().empty())
return false;

if (browser) {
std::vector<int64_t> frameIds;
std::vector<CefFrameId> frameIds;
if (MAIN_FRAME == frame_id) {
frameIds.push_back(browser->GetMainFrame()->GetIdentifier());
} else if (ALL_FRAMES == frame_id) {
Expand All @@ -98,7 +106,12 @@ CefViewBrowserClient::TriggerEvent(CefRefPtr<CefBrowser> browser,

for (auto id : frameIds) {
auto m = msg->Copy();
#if CEF_VERSION_MAJOR > 121
auto frame = browser->GetFrameByIdentifier(id);
#else
auto frame = browser->GetFrame(id);
#endif

frame->SendProcessMessage(PID_RENDERER, m);
}

Expand Down
32 changes: 25 additions & 7 deletions src/CefView/CefBrowserApp/CefViewBrowserClient_DialogHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,34 @@ CefViewBrowserClient::GetDialogHandler()
return this;
}

#if CEF_VERSION_MAJOR < 102
bool
CefViewBrowserClient::OnFileDialog(CefRefPtr<CefBrowser> browser,
FileDialogMode mode,
const CefString& title,
const CefString& default_file_path,
const std::vector<CefString>& accept_filters,
#if CEF_VERSION_MAJOR < 102
int selected_accept_filter,
FileDialogMode mode,
const CefString& title,
const CefString& default_file_path,
const std::vector<CefString>& accept_filters,
int selected_accept_filter,
CefRefPtr<CefFileDialogCallback> callback)
#elif CEF_VERSION_MAJOR < 126
bool
CefViewBrowserClient::OnFileDialog(CefRefPtr<CefBrowser> browser,
FileDialogMode mode,
const CefString& title,
const CefString& default_file_path,
const std::vector<CefString>& accept_filters,
CefRefPtr<CefFileDialogCallback> callback)
#else
bool
CefViewBrowserClient::OnFileDialog(CefRefPtr<CefBrowser> browser,
FileDialogMode mode,
const CefString& title,
const CefString& default_file_path,
const std::vector<CefString>& accept_filters,
const std::vector<CefString>& accept_extensions,
const std::vector<CefString>& accept_descriptions,
CefRefPtr<CefFileDialogCallback> callback)
#endif
CefRefPtr<CefFileDialogCallback> callback)
{
auto delegate = client_delegate_.lock();
if (delegate)
Expand Down
Loading
Loading