Initial commit

This commit is contained in:
2026-06-12 23:18:12 +08:00
commit 424bde1b02
249 changed files with 40338 additions and 0 deletions
+72
View File
@@ -0,0 +1,72 @@
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "CommonV8Handler.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma comment(lib, "CEF4DelphiVCLRTL")
//---------------------------------------------------------------------------
TV8Handler* u_pV8handler = NULL;
bool __fastcall TV8Handler::Execute(const ustring name, const _di_ICefv8Value obj,
const TCefv8ValueArray arguments, _di_ICefv8Value &retval, ustring &exception)
{
if( arguments.Length>0 ){
_di_ICefProcessMessage msg = TCefProcessMessageRef::New(name);
for( int i=0; i<arguments.Length; i++ ){
// if( arguments[i]->IsString() )
if( arguments[i]->IsInt() )
msg->ArgumentList->SetString(i, IntToStr(arguments[i]->GetIntValue()) );
else if( arguments[i]->IsDouble() )
msg->ArgumentList->SetString(i, FloatToStr(arguments[i]->GetDoubleValue()) );
else
msg->ArgumentList->SetString(i, arguments[i]->GetStringValue() );
}
TCefv8ContextRef::Current()->Browser->MainFrame->SendProcessMessage(PID_BROWSER, msg);
return true;
}
return false;
}
////////////////////////////////////////////////////////////////////////////////
void __fastcall TWebKitInitializeEvent::Invoke()
{
String app_code =
"var cefApp;"
"if(!cefApp)"
"cefApp={};"
"(function(){"
"cefApp.ReturnJQValue = function(){"
"native function ReturnJQValue();"
"return ReturnJQValue.apply(null,arguments);"
"};"
"cefApp.GetUserInfo=function(){"
"native function GetUserInfo();"
"return GetUserInfo.apply(null,arguments);"
"};"
"cefApp.GetRegInfo=function(){"
"native function GetRegInfo();"
"return GetRegInfo.apply(null,arguments);"
"};"
"cefApp.GetPageCode=function(){"
"native function GetPageCode();"
"return GetPageCode.apply(null,arguments);"
"};"
"cefApp.OnJSMessage = function(){"
"native function OnJSMessage();"
"return OnJSMessage.apply(null,arguments);"
"};"
"})();";
if( !u_pV8handler )
u_pV8handler = new TV8Handler;
CefRegisterExtension("v8/cefApp", app_code, *u_pV8handler);
}
////////////////////////////////////////////////////////////////////////////////