Initial commit

This commit is contained in:
2025-12-17 16:47:48 +00:00
commit 13813f3363
4964 changed files with 1079753 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
add_executable(CefSubprocess src/main.cpp)
if(AYA_OS_WINDOWS)
target_sources(CefSubprocess PRIVATE
resources/winrc.h
resources/script.rc
)
set_target_properties(CefSubprocess PROPERTIES WIN32_EXECUTABLE TRUE)
endif()
target_include_directories(CefSubprocess PRIVATE src resources)
set_target_properties(CefSubprocess PROPERTIES OUTPUT_NAME "${AYA_PROJECT_NAME}.CefSubprocess")
target_link_libraries(CefSubprocess PRIVATE ${CEF_LIBRARIES})

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 KiB

View File

@@ -0,0 +1,49 @@
#include "winrc.h"
#if defined(__MINGW64__) || defined(__MINGW32__)
// MinGW-w64, MinGW
#if defined(__has_include) && __has_include(<winres.h>)
#include <winres.h>
#else
#include <afxres.h>
#include <winresrc.h>
#endif
#else
// MSVC, Windows SDK
#include <winres.h>
#endif
IDI_ICON1 ICON APP_ICON
LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
VS_VERSION_INFO VERSIONINFO
FILEVERSION VERSION_RESOURCE
PRODUCTVERSION VERSION_RESOURCE
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", APP_ORGANIZATION
VALUE "FileDescription", APP_DESCRIPTION
VALUE "FileVersion", VERSION_RESOURCE_STR
VALUE "LegalCopyright", APP_COPYRIGHT
VALUE "ProductName", APP_NAME
VALUE "ProductVersion", VERSION_RESOURCE_STR
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", PRODUCT_LANGUAGE, PRODUCT_CHARSET
END
END

View File

@@ -0,0 +1,24 @@
#pragma once
#define VERSION_MAJOR_MINOR_STR AYA_VERSION_MAJOR_STR "." AYA_VERSION_MINOR_STR
#define VERSION_MAJOR_MINOR_PATCH_STR VERSION_MAJOR_MINOR_STR "." AYA_VERSION_PATCH_STR
#ifdef AYA_VERSION_TYPE
#define VERSION_FULL_STR VERSION_MAJOR_MINOR_PATCH_STR "-" AYA_VERSION_TYPE
#else
#define VERSION_FULL_STR VERSION_MAJOR_MINOR_PATCH_STR
#endif
#define VERSION_RESOURCE AYA_VERSION_MAJOR, AYA_VERSION_MINOR, AYA_VERSION_PATCH, 0
#define VERSION_RESOURCE_STR VERSION_FULL_STR "\0"
/*
* These properties are part of VarFileInfo.
* For more information, please see: https://learn.microsoft.com/en-us/windows/win32/menurc/varfileinfo-block
*/
#define PRODUCT_LANGUAGE 0x0409 // en-US
#define PRODUCT_CHARSET 1200 // Unicode
#define APP_ICON "icon.ico"
#define APP_NAME AYA_PROJECT_NAME "\0"
#define APP_DESCRIPTION AYA_PROJECT_NAME " CEF Subprocess\0"
#define APP_ORGANIZATION AYA_PROJECT_NAME "\0"
#define APP_COPYRIGHT AYA_PROJECT_NAME " License\0"

View File

@@ -0,0 +1,75 @@
#include <include/base/cef_bind.h>
#include <include/cef_app.h>
#include <include/cef_base.h>
#include <include/cef_browser.h>
#include <include/cef_client.h>
#include <include/cef_frame_handler.h>
#include <include/cef_render_process_handler.h>
#include <include/wrapper/cef_closure_task.h>
class AyaCefApp : public CefApp
{
public:
AyaCefApp() {};
private:
IMPLEMENT_REFCOUNTING(AyaCefApp);
};
class AyaCefSubprocess
: public AyaCefApp
, public CefRenderProcessHandler
, public CefV8Handler
{
public:
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() override
{
return this;
}
void OnContextCreated(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context) override
{
CefRefPtr<CefV8Value> global = context->GetGlobal();
CefRefPtr<CefV8Value> func = CefV8Value::CreateFunction("sendResultToEngine", this);
global->SetValue("sendResultToEngine", func, V8_PROPERTY_ATTRIBUTE_NONE);
}
bool Execute(const CefString& name, CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
CefString& exception) override
{
if (name == "sendResultToEngine" && arguments.size() == 1)
{
CefRefPtr<CefProcessMessage> msg = CefProcessMessage::Create("resultMessage");
CefRefPtr<CefListValue> args = msg->GetArgumentList();
args->SetString(0, arguments[0]->GetStringValue());
CefRefPtr<CefBrowser> browser = CefV8Context::GetCurrentContext()->GetBrowser();
CefRefPtr<CefFrame> frame = browser->GetMainFrame();
frame->SendProcessMessage(PID_BROWSER, msg);
return true;
}
return false;
}
private:
IMPLEMENT_REFCOUNTING(AyaCefSubprocess);
};
#ifdef WIN32
int CALLBACK WinMain(_In_ HINSTANCE hInstance, _In_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nCmdShow)
{
CefMainArgs args(hInstance);
return CefExecuteProcess(args, new AyaCefSubprocess(), nullptr);
}
#else
int main(int argc, char* argv[])
{
CefMainArgs args(argc, argv);
return CefExecuteProcess(args, new AyaCefSubprocess(), nullptr);
}
#endif