energy/cef/application-callback.go

58 lines
2.3 KiB
Go
Raw Normal View History

2023-03-01 18:01:34 +08:00
//----------------------------------------
//
// Copyright © yanghy. All Rights Reserved.
//
// Licensed under Apache License Version 2.0, January 2004
//
// https://www.apache.org/licenses/LICENSE-2.0
//
//----------------------------------------
// application event 默认事件实现
2023-05-31 17:41:14 +08:00
2023-03-01 18:01:34 +08:00
package cef
import (
2023-05-31 18:00:34 +08:00
"github.com/energye/energy/v2/cef/internal/ipc"
"github.com/energye/energy/v2/cef/internal/process"
"github.com/energye/energy/v2/consts"
2023-03-02 18:47:39 +08:00
)
2023-03-01 18:01:34 +08:00
// appOnContextCreated 创建应用上下文 - 默认实现
2023-03-02 18:47:39 +08:00
func appOnContextCreated(browser *ICefBrowser, frame *ICefFrame, context *ICefV8Context) {
2023-05-31 17:41:14 +08:00
process.Current.SetBrowserId(browser.Identifier()) // 当前进程 browserID
process.Current.SetFrameId(frame.Identifier()) // 当前进程 frameId
ipc.RenderChan().SetRealityChannel(browser.Identifier(), frame.Identifier()) // 设置并更新真实的通道ID
ipcRender.registerGoSyncReplayEvent() // render ipc
2023-06-02 14:49:23 +08:00
ipcRender.makeIPC(context) // render ipc make
makeProcess(browser, frame, context) // process make
2023-03-03 12:52:00 +08:00
}
2023-03-03 17:08:06 +08:00
// appMainRunCallback 应用运行 - 默认实现
func appMainRunCallback() {
2023-05-31 17:41:14 +08:00
ipcBrowser.registerEvent() // browser ipc
2023-03-03 17:08:06 +08:00
}
2023-03-24 14:31:40 +08:00
// appWebKitInitialized - webkit - 默认实现
2023-03-23 21:34:56 +08:00
func appWebKitInitialized() {
//dragExtensionHandler() // drag extension handler TODO free
2023-03-23 21:34:56 +08:00
}
2023-03-13 17:30:13 +08:00
// renderProcessMessageReceived 渲染进程消息 - 默认实现
func renderProcessMessageReceived(browser *ICefBrowser, frame *ICefFrame, sourceProcess consts.CefProcessId, message *ICefProcessMessage) (result bool) {
2023-03-20 10:09:54 +08:00
if message.Name() == internalIPCJSExecuteGoEventReplay {
2023-03-14 17:41:30 +08:00
result = ipcRender.ipcJSExecuteGoEventMessageReply(browser, frame, sourceProcess, message)
2023-03-21 16:17:29 +08:00
} else if message.Name() == internalIPCGoExecuteJSEvent {
2023-03-14 17:41:30 +08:00
result = ipcRender.ipcGoExecuteJSEvent(browser, frame, sourceProcess, message)
2023-03-13 16:48:40 +08:00
}
return
}
2023-03-13 17:30:13 +08:00
// browserProcessMessageReceived 主进程消息 - 默认实现
2023-03-21 13:18:44 +08:00
func browserProcessMessageReceived(browser *ICefBrowser, frame *ICefFrame, message *ICefProcessMessage) (result bool) {
2023-03-20 10:09:54 +08:00
if message.Name() == internalIPCJSExecuteGoEvent {
2023-03-21 13:18:44 +08:00
result = ipcBrowser.jsExecuteGoMethodMessage(browser, frame, message)
2023-03-02 22:08:10 +08:00
}
2023-03-04 17:12:22 +08:00
return
2023-03-02 21:08:51 +08:00
}