2023-01-10 09:40:03 +08:00
|
|
|
|
//----------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Copyright © yanghy. All Rights Reserved.
|
|
|
|
|
//
|
2023-02-19 23:21:47 +08:00
|
|
|
|
// Licensed under Apache License Version 2.0, January 2004
|
|
|
|
|
//
|
|
|
|
|
// https://www.apache.org/licenses/LICENSE-2.0
|
2023-01-10 09:40:03 +08:00
|
|
|
|
//
|
|
|
|
|
//----------------------------------------
|
|
|
|
|
|
2023-05-31 17:41:14 +08:00
|
|
|
|
// energy 全局窗口管理, 窗口初始化、事件注册、属性配置
|
|
|
|
|
|
2023-01-10 09:40:03 +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/process"
|
|
|
|
|
. "github.com/energye/energy/v2/consts"
|
2023-01-10 09:40:03 +08:00
|
|
|
|
"github.com/energye/golcl/lcl"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// 浏览器包装结构体
|
2023-03-04 11:19:45 +08:00
|
|
|
|
type browserWindow struct {
|
|
|
|
|
mainBrowserWindow *lclBrowserWindow //LCL 主浏览器窗口
|
2023-01-10 09:40:03 +08:00
|
|
|
|
mainVFBrowserWindow *ViewsFrameworkBrowserWindow //Views Frameworks 主浏览器窗口
|
|
|
|
|
popupWindow IBrowserWindow //弹出的子窗口
|
2023-07-23 00:04:20 +08:00
|
|
|
|
browserEvent *BrowserEvent //浏览器全局事件, 已默认实现事件
|
2023-01-10 09:40:03 +08:00
|
|
|
|
Config *browserConfig //浏览器和窗口配置
|
|
|
|
|
windowInfo map[int32]IBrowserWindow //窗口信息集合
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-31 17:41:14 +08:00
|
|
|
|
// BrowserEvent 浏览器全局事件监听-已被默认实现事件
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// 该结构中的对象属性, 是已被默认实现的
|
2023-01-10 09:40:03 +08:00
|
|
|
|
type BrowserEvent struct {
|
2023-06-13 12:12:21 +08:00
|
|
|
|
chromium IChromiumEvent //chromium event
|
|
|
|
|
onBeforePopup chromiumEventOnBeforePopupEx //default
|
|
|
|
|
onDragEnter chromiumEventOnDragEnterEx //default
|
|
|
|
|
onDraggableRegionsChanged chromiumEventOnDraggableRegionsChangedEx //default
|
|
|
|
|
onLoadEnd chromiumEventOnLoadEnd //default
|
2023-07-23 00:04:20 +08:00
|
|
|
|
onAfterCreated chromiumEventOnAfterCreatedEx //default
|
2023-06-13 12:12:21 +08:00
|
|
|
|
onBeforeBrowser chromiumEventOnBeforeBrowserEx //default
|
|
|
|
|
onBeforeClose chromiumEventOnBeforeCloseEx //default
|
|
|
|
|
onClose chromiumEventOnCloseEx //default
|
|
|
|
|
onMainFrameChanged chromiumEventOnMainFrameChangedEx //default
|
|
|
|
|
onBeforeDownload chromiumEventOnBeforeDownload //default can cover
|
|
|
|
|
onKeyEvent chromiumEventOnKeyEventEx //default can cover
|
|
|
|
|
onProcessMessageReceived BrowseProcessMessageReceived //default
|
|
|
|
|
onTitleChange chromiumEventOnTitleChangeEx //default
|
|
|
|
|
onContextMenuCommand chromiumEventOnContextMenuCommand //default can cover
|
2023-07-23 00:04:20 +08:00
|
|
|
|
onBeforeContextMenu chromiumEventOnBeforeContextMenuEx //default can cover
|
2023-06-13 12:12:21 +08:00
|
|
|
|
onBeforeResourceLoad chromiumEventOnBeforeResourceLoad //default
|
|
|
|
|
onRenderCompMsg chromiumEventOnCompMsg //default windows
|
2023-01-10 09:40:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-19 23:21:47 +08:00
|
|
|
|
// LCLBrowserWindow
|
2023-03-04 11:19:45 +08:00
|
|
|
|
type lclBrowserWindow struct {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
LCLBrowserWindow
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-19 23:21:47 +08:00
|
|
|
|
// OnFormCreate LCL窗口组件窗口创建回调
|
2023-03-04 11:19:45 +08:00
|
|
|
|
func (m *lclBrowserWindow) OnFormCreate(sender lcl.IObject) {
|
2023-01-23 10:52:40 +08:00
|
|
|
|
m.windowProperty = &BrowserWindow.Config.WindowProperty
|
2023-01-10 09:40:03 +08:00
|
|
|
|
m.SetWindowType(WT_MAIN_BROWSER)
|
|
|
|
|
m.FormCreate()
|
|
|
|
|
m.defaultWindowEvent()
|
|
|
|
|
m.defaultWindowCloseEvent()
|
|
|
|
|
m.ChromiumCreate(BrowserWindow.Config.ChromiumConfig(), BrowserWindow.Config.Url)
|
|
|
|
|
m.defaultChromiumEvent()
|
2023-05-31 17:41:14 +08:00
|
|
|
|
m.setProperty()
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if BrowserWindow.Config.browserWindowOnEventCallback != nil {
|
2023-05-31 17:41:14 +08:00
|
|
|
|
BrowserWindow.browserEvent.chromium = m.Chromium()
|
2023-07-07 15:27:26 +08:00
|
|
|
|
BrowserWindow.Config.browserWindowOnEventCallback(BrowserWindow.browserEvent, m)
|
2023-05-31 17:41:14 +08:00
|
|
|
|
m.setProperty() //再次设置可能修改属性
|
2023-01-10 09:40:03 +08:00
|
|
|
|
}
|
2023-01-18 13:50:54 +08:00
|
|
|
|
//browserWindowOnEventCallback 执行完后,注册CompMsgEvent
|
2023-01-12 10:07:10 +08:00
|
|
|
|
m.registerWindowsCompMsgEvent()
|
2023-01-10 09:40:03 +08:00
|
|
|
|
|
2023-05-31 17:41:14 +08:00
|
|
|
|
//自定义窗口标题栏
|
2023-01-24 12:23:03 +08:00
|
|
|
|
m.cwcap = &customWindowCaption{
|
|
|
|
|
bw: &m.LCLBrowserWindow,
|
|
|
|
|
}
|
2023-05-31 17:41:14 +08:00
|
|
|
|
//设置 CEF Chromium IPC
|
|
|
|
|
ipc.SetProcessMessage(m.Chromium().(*TCEFChromium))
|
2023-06-14 17:30:45 +08:00
|
|
|
|
// 如果开启了开发者工具,需要在这里初始化开发者工具窗口
|
2023-06-19 12:41:52 +08:00
|
|
|
|
if m.Chromium().Config().EnableDevTools() {
|
2023-06-14 17:30:45 +08:00
|
|
|
|
m.createAuxTools()
|
2023-06-15 18:29:23 +08:00
|
|
|
|
m.GetAuxTools().SetDevTools(createDevtoolsWindow(&m.LCLBrowserWindow))
|
2023-06-14 17:30:45 +08:00
|
|
|
|
}
|
2023-01-10 09:40:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-05-31 17:41:14 +08:00
|
|
|
|
// MainWindow 获取主浏窗口
|
|
|
|
|
// 返回LCL或VF窗口组件实例
|
|
|
|
|
// Window和MacOS平台LCL窗口组件
|
|
|
|
|
// Linux平台VF窗口组件
|
2023-03-04 11:19:45 +08:00
|
|
|
|
func (m *browserWindow) MainWindow() IBrowserWindow {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if m.mainVFBrowserWindow != nil {
|
|
|
|
|
return m.mainVFBrowserWindow
|
|
|
|
|
} else if m.mainBrowserWindow != nil {
|
|
|
|
|
return m.mainBrowserWindow
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-31 17:41:14 +08:00
|
|
|
|
// SetBrowserInit 主窗口初始化时回调
|
|
|
|
|
// LCL: 可以对主窗体属性设置、创建各种LCL子组件
|
|
|
|
|
// VF : 有很大限制不能使用LCL的组件
|
|
|
|
|
// event : 浏览器事件
|
|
|
|
|
// window : 窗口信息对象
|
2023-03-04 11:19:45 +08:00
|
|
|
|
func (m *browserWindow) SetBrowserInit(fn browserWindowOnEventCallback) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
m.Config.setBrowserWindowInitOnEvent(fn)
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-31 17:41:14 +08:00
|
|
|
|
// createNextLCLPopupWindow 预创建下一个弹出的子窗口
|
|
|
|
|
func (m *browserWindow) createNextLCLPopupWindow() {
|
|
|
|
|
if m.popupWindow == nil {
|
2023-07-20 10:00:08 +08:00
|
|
|
|
if mw := m.MainWindow(); mw != nil {
|
|
|
|
|
m.popupWindow = NewLCLWindow(m.Config.WindowProperty, mw.AsLCLBrowserWindow().BrowserWindow())
|
|
|
|
|
}
|
2023-01-10 09:40:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-31 17:41:14 +08:00
|
|
|
|
// getNextLCLPopupWindow 拿到预创建的下一个弹出的子窗口
|
|
|
|
|
func (m *browserWindow) getNextLCLPopupWindow() IBrowserWindow {
|
|
|
|
|
bw := m.popupWindow
|
|
|
|
|
m.popupWindow = nil
|
|
|
|
|
return bw
|
2023-01-10 09:40:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-19 23:21:47 +08:00
|
|
|
|
// GetWindowInfo 根据浏览器窗口ID获取窗口信息
|
2023-03-04 11:19:45 +08:00
|
|
|
|
func (m *browserWindow) GetWindowInfo(browserId int32) IBrowserWindow {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if winInfo, ok := m.windowInfo[browserId]; ok {
|
|
|
|
|
return winInfo
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-19 23:21:47 +08:00
|
|
|
|
// GetWindowInfos 获得所有窗口信息
|
2023-03-04 11:19:45 +08:00
|
|
|
|
func (m *browserWindow) GetWindowInfos() map[int32]IBrowserWindow {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
return m.windowInfo
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-19 23:21:47 +08:00
|
|
|
|
// putWindowInfo 创建一个窗口这后会添加到windowInfo中
|
2023-03-04 11:19:45 +08:00
|
|
|
|
func (m *browserWindow) putWindowInfo(browserId int32, windowInfo IBrowserWindow) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
m.windowInfo[browserId] = windowInfo
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-19 23:21:47 +08:00
|
|
|
|
// removeWindowInfo 窗口关闭会从windowInfo移除
|
2023-03-04 11:19:45 +08:00
|
|
|
|
func (m *browserWindow) removeWindowInfo(browseId int32) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
delete(m.windowInfo, browseId)
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-19 23:21:47 +08:00
|
|
|
|
// GetBrowser 获取窗口Browser
|
2023-03-04 11:19:45 +08:00
|
|
|
|
func (m *browserWindow) GetBrowser(browseId int32) *ICefBrowser {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if winInfo, ok := m.windowInfo[browseId]; ok {
|
|
|
|
|
return winInfo.Browser()
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnAfterCreated
|
2023-07-23 00:04:20 +08:00
|
|
|
|
func (m *BrowserEvent) SetOnAfterCreated(event chromiumEventOnAfterCreatedEx) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.onAfterCreated = event
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnBeforeBrowser
|
|
|
|
|
func (m *BrowserEvent) SetOnBeforeBrowser(event chromiumEventOnBeforeBrowserEx) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.onBeforeBrowser = event
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnAddressChange
|
2023-05-31 17:41:14 +08:00
|
|
|
|
func (m *BrowserEvent) SetOnAddressChange(event chromiumEventOnAddressChange) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.chromium.SetOnAddressChange(event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnBeforeClose
|
|
|
|
|
func (m *BrowserEvent) SetOnBeforeClose(event chromiumEventOnBeforeCloseEx) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.onBeforeClose = event
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnClose
|
|
|
|
|
func (m *BrowserEvent) SetOnClose(event chromiumEventOnCloseEx) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.onClose = event
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnPdfPrintFinished
|
2023-05-31 17:41:14 +08:00
|
|
|
|
func (m *BrowserEvent) SetOnPdfPrintFinished(event chromiumEventOnPdfPrintFinished) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.chromium.SetOnPdfPrintFinished(event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnZoomPctAvailable
|
2023-05-31 17:41:14 +08:00
|
|
|
|
func (m *BrowserEvent) SetOnZoomPctAvailable(event chromiumEventOnResultFloat) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.chromium.SetOnZoomPctAvailable(event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnLoadStart
|
2023-05-31 17:41:14 +08:00
|
|
|
|
func (m *BrowserEvent) SetOnLoadStart(event chromiumEventOnLoadStart) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.chromium.SetOnLoadStart(event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnLoadingStateChange
|
2023-05-31 17:41:14 +08:00
|
|
|
|
func (m *BrowserEvent) SetOnLoadingStateChange(event chromiumEventOnLoadingStateChange) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.chromium.SetOnLoadingStateChange(event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnLoadingProgressChange
|
2023-05-31 17:41:14 +08:00
|
|
|
|
func (m *BrowserEvent) SetOnLoadingProgressChange(event chromiumEventOnLoadingProgressChange) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.chromium.SetOnLoadingProgressChange(event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnLoadError
|
2023-05-31 17:41:14 +08:00
|
|
|
|
func (m *BrowserEvent) SetOnLoadError(event chromiumEventOnLoadError) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.chromium.SetOnLoadError(event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnLoadEnd
|
2023-05-31 17:41:14 +08:00
|
|
|
|
func (m *BrowserEvent) SetOnLoadEnd(event chromiumEventOnLoadEnd) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.onLoadEnd = event
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnBeforeDownload
|
2023-05-31 17:41:14 +08:00
|
|
|
|
func (m *BrowserEvent) SetOnBeforeDownload(event chromiumEventOnBeforeDownload) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.onBeforeDownload = event
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnDownloadUpdated
|
2023-05-31 17:41:14 +08:00
|
|
|
|
func (m *BrowserEvent) SetOnDownloadUpdated(event chromiumEventOnDownloadUpdated) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.chromium.SetOnDownloadUpdated(event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnFullScreenModeChange
|
2023-05-31 17:41:14 +08:00
|
|
|
|
func (m *BrowserEvent) SetOnFullScreenModeChange(event chromiumEventOnFullScreenModeChange) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.chromium.SetOnFullScreenModeChange(event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnKeyEvent
|
|
|
|
|
func (m *BrowserEvent) SetOnKeyEvent(event chromiumEventOnKeyEventEx) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.onKeyEvent = event
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnTitleChange
|
|
|
|
|
func (m *BrowserEvent) SetOnTitleChange(event chromiumEventOnTitleChangeEx) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.onTitleChange = event
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnRenderCompMsg windows
|
2023-05-31 17:41:14 +08:00
|
|
|
|
func (m *BrowserEvent) SetOnRenderCompMsg(event chromiumEventOnCompMsg) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
2023-01-12 10:07:10 +08:00
|
|
|
|
m.onRenderCompMsg = event
|
2023-01-10 09:40:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-02 12:53:38 +08:00
|
|
|
|
func (m *BrowserEvent) ChromiumEvent() IChromiumEvent {
|
|
|
|
|
return m.chromium
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnWidgetCompMsg windows
|
2023-05-31 17:41:14 +08:00
|
|
|
|
func (m *BrowserEvent) SetOnWidgetCompMsg(event chromiumEventOnCompMsg) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
2023-01-14 23:26:37 +08:00
|
|
|
|
m.chromium.SetOnWidgetCompMsg(event)
|
2023-01-10 09:40:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnBrowserCompMsg windows
|
2023-05-31 17:41:14 +08:00
|
|
|
|
func (m *BrowserEvent) SetOnBrowserCompMsg(event chromiumEventOnCompMsg) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.chromium.SetOnBrowserCompMsg(event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnRenderProcessTerminated
|
2023-05-31 17:41:14 +08:00
|
|
|
|
func (m *BrowserEvent) SetOnRenderProcessTerminated(event chromiumEventOnRenderProcessTerminated) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.chromium.SetOnRenderProcessTerminated(event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnRenderViewReady
|
2023-05-31 17:41:14 +08:00
|
|
|
|
func (m *BrowserEvent) SetOnRenderViewReady(event chromiumEventOnRenderViewReady) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.chromium.SetOnRenderViewReady(event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnScrollOffsetChanged
|
2023-05-31 17:41:14 +08:00
|
|
|
|
func (m *BrowserEvent) SetOnScrollOffsetChanged(event chromiumEventOnScrollOffsetChanged) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.chromium.SetOnScrollOffsetChanged(event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnBrowseProcessMessageReceived
|
2023-01-10 09:40:03 +08:00
|
|
|
|
func (m *BrowserEvent) SetOnBrowseProcessMessageReceived(event BrowseProcessMessageReceived) {
|
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.onProcessMessageReceived = event
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnBeforeResourceLoad
|
2023-05-31 17:41:14 +08:00
|
|
|
|
func (m *BrowserEvent) SetOnBeforeResourceLoad(event chromiumEventOnBeforeResourceLoad) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.onBeforeResourceLoad = event
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnResourceResponse
|
2023-05-31 17:41:14 +08:00
|
|
|
|
func (m *BrowserEvent) SetOnResourceResponse(event chromiumEventOnResourceResponse) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.chromium.SetOnResourceResponse(event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnResourceRedirect
|
2023-05-31 17:41:14 +08:00
|
|
|
|
func (m *BrowserEvent) SetOnResourceRedirect(event chromiumEventOnResourceRedirect) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.chromium.SetOnResourceRedirect(event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnResourceLoadComplete
|
2023-05-31 17:41:14 +08:00
|
|
|
|
func (m *BrowserEvent) SetOnResourceLoadComplete(event chromiumEventOnResourceLoadComplete) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.chromium.SetOnResourceLoadComplete(event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnCookieSet
|
2023-05-31 17:41:14 +08:00
|
|
|
|
func (m *BrowserEvent) SetOnCookieSet(event chromiumEventOnCookieSet) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.chromium.SetOnCookieSet(event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnCookiesDeleted
|
2023-05-31 17:41:14 +08:00
|
|
|
|
func (m *BrowserEvent) SetOnCookiesDeleted(event chromiumEventOnCookiesDeleted) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.chromium.SetOnCookiesDeleted(event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnCookiesFlushed
|
2023-05-31 17:41:14 +08:00
|
|
|
|
func (m *BrowserEvent) SetOnCookiesFlushed(event chromiumEventOnCookiesFlushed) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.chromium.SetOnCookiesFlushed(event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnCookiesVisited
|
2023-05-31 17:41:14 +08:00
|
|
|
|
func (m *BrowserEvent) SetOnCookiesVisited(event chromiumEventOnCookiesVisited) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.chromium.SetOnCookiesVisited(event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnCookieVisitorDestroyed
|
2023-05-31 17:41:14 +08:00
|
|
|
|
func (m *BrowserEvent) SetOnCookieVisitorDestroyed(event chromiumEventOnCookieVisitorDestroyed) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.chromium.SetOnCookieVisitorDestroyed(event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnBeforeContextMenu
|
2023-07-23 00:04:20 +08:00
|
|
|
|
func (m *BrowserEvent) SetOnBeforeContextMenu(event chromiumEventOnBeforeContextMenuEx) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.onBeforeContextMenu = event
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnContextMenuCommand
|
2023-05-31 17:41:14 +08:00
|
|
|
|
func (m *BrowserEvent) SetOnContextMenuCommand(event chromiumEventOnContextMenuCommand) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.onContextMenuCommand = event
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnContextMenuDismissed
|
2023-05-31 17:41:14 +08:00
|
|
|
|
func (m *BrowserEvent) SetOnContextMenuDismissed(event chromiumEventOnContextMenuDismissed) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.chromium.SetOnContextMenuDismissed(event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnFrameAttached
|
2023-05-31 17:41:14 +08:00
|
|
|
|
func (m *BrowserEvent) SetOnFrameAttached(event chromiumEventOnFrameAttached) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.chromium.SetOnFrameAttached(event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnMainFrameChanged
|
|
|
|
|
func (m *BrowserEvent) SetOnMainFrameChanged(event chromiumEventOnMainFrameChangedEx) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.onMainFrameChanged = event
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnBeforePopup
|
|
|
|
|
// 弹出窗口, 已被默认实现的函数
|
|
|
|
|
// 函数返回值
|
|
|
|
|
// false: 窗口会以默认行为管理
|
|
|
|
|
// true: 需要你自己管理窗口行为
|
|
|
|
|
func (m *BrowserEvent) SetOnBeforePopup(event chromiumEventOnBeforePopupEx) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.onBeforePopup = event
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnOpenUrlFromTab
|
2023-05-31 17:41:14 +08:00
|
|
|
|
//func (m *BrowserEvent) SetOnOpenUrlFromTab(event chromiumEventOnOpenUrlFromTab) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
// if Args.IsMain() {
|
|
|
|
|
// m.chromium.SetOnOpenUrlFromTab(event)
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnFindResult
|
2023-05-31 17:41:14 +08:00
|
|
|
|
func (m *BrowserEvent) SetOnFindResult(event chromiumEventOnFindResult) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.chromium.SetOnFindResult(event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnDragEnter
|
|
|
|
|
func (m *BrowserEvent) SetOnDragEnter(event chromiumEventOnDragEnterEx) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.onDragEnter = event
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 12:12:21 +08:00
|
|
|
|
// SetOnDraggableRegionsChanged
|
|
|
|
|
func (m *BrowserEvent) SetOnDraggableRegionsChanged(event chromiumEventOnDraggableRegionsChangedEx) {
|
2023-01-10 09:40:03 +08:00
|
|
|
|
if Args.IsMain() {
|
|
|
|
|
m.onDraggableRegionsChanged = event
|
|
|
|
|
}
|
|
|
|
|
}
|