From 667e23b91c409d3d2850afb3f9066f9fad9c89a6 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Mon, 2 Jun 2025 13:22:20 -0400 Subject: [PATCH] bootstrap: Support use with older API versions (see #3935) --- include/cef_version_info.h | 24 +++++++++++++++++-- .../wrapper/cef_scoped_library_loader_win.cc | 6 +++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/include/cef_version_info.h b/include/cef_version_info.h index 1b83dfea8..7d56fdec9 100644 --- a/include/cef_version_info.h +++ b/include/cef_version_info.h @@ -30,6 +30,8 @@ #ifndef CEF_INCLUDE_CEF_VERSION_INFO_H_ #define CEF_INCLUDE_CEF_VERSION_INFO_H_ +#include + #include "include/cef_api_hash.h" #include "include/internal/cef_export.h" @@ -82,6 +84,26 @@ typedef struct _cef_version_info_t { /// CEF_EXPORT void cef_version_info_all(cef_version_info_t* info); +#elif !defined(GENERATING_CEF_API_HASH) + +// Unversioned definition to support use of the bootstrap and +// CefScopedLibraryLoader with older API versions. +typedef struct _cef_version_info_t { + // Size of this structure. + size_t size; + + int cef_version_major; + int cef_version_minor; + int cef_version_patch; + int cef_commit_number; + int chrome_version_major; + int chrome_version_minor; + int chrome_version_build; + int chrome_version_patch; +} cef_version_info_t; + +#endif // !defined(GENERATING_CEF_API_HASH) + /// /// Populate CEF version information for the client library. /// @@ -96,8 +118,6 @@ CEF_EXPORT void cef_version_info_all(cef_version_info_t* info); (info)->chrome_version_build = CHROME_VERSION_BUILD; \ (info)->chrome_version_patch = CHROME_VERSION_PATCH -#endif // CEF_API_ADDED(CEF_NEXT) - #ifdef __cplusplus } #endif diff --git a/libcef_dll/wrapper/cef_scoped_library_loader_win.cc b/libcef_dll/wrapper/cef_scoped_library_loader_win.cc index dba340ad1..d230eaac5 100644 --- a/libcef_dll/wrapper/cef_scoped_library_loader_win.cc +++ b/libcef_dll/wrapper/cef_scoped_library_loader_win.cc @@ -59,7 +59,13 @@ HMODULE Load(const std::wstring& dll_path, // which non-matching versions are compatible. cef_version_info_t dll_info = {}; dll_info.size = sizeof(cef_version_info_t); +#if CEF_API_ADDED(CEF_NEXT) cef_version_info_all(&dll_info); +#else + // Only populating the members that are used below. + dll_info.chrome_version_major = cef_version_info(4); + dll_info.chrome_version_patch = cef_version_info(7); +#endif if (dll_info.chrome_version_major != version_info->chrome_version_major || dll_info.chrome_version_patch != version_info->chrome_version_patch) { LOG(FATAL) << "Failed libcef.dll version check; expected "