energy/cef/cef-application-callback.go

48 lines
1.7 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 默认事件实现
package cef
import (
2023-03-02 18:47:39 +08:00
"github.com/energye/energy/consts"
)
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-03-23 11:46:34 +08:00
ipcRender.ipcChannelRender(browser, frame)
2023-03-22 13:27:25 +08:00
ipcRender.makeIPC(browser, frame, context)
2023-03-03 12:52:00 +08:00
}
2023-03-03 17:08:06 +08:00
// appMainRunCallback 应用运行 - 默认实现
func appMainRunCallback() {
2023-03-23 11:46:34 +08:00
ipcBrowser.ipcChannelBrowser()
2023-03-03 17:08:06 +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-21 16:53:02 +08:00
} else if message.Name() == internalIPCGoExecuteJSEventReplay {
result = ipcBrowser.ipcGoExecuteMethodMessageReply(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
}