2022-10-04 13:21:05 +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
|
2022-10-04 13:21:05 +08:00
|
|
|
|
//
|
|
|
|
|
//----------------------------------------
|
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
|
// CEF 事件函数定义
|
2022-10-04 13:21:05 +08:00
|
|
|
|
package cef
|
|
|
|
|
|
|
|
|
|
import (
|
2022-12-28 22:08:44 +08:00
|
|
|
|
"github.com/energye/energy/consts"
|
2022-12-14 11:11:33 +08:00
|
|
|
|
t "github.com/energye/energy/types"
|
2022-10-04 13:21:05 +08:00
|
|
|
|
"github.com/energye/golcl/lcl"
|
|
|
|
|
"github.com/energye/golcl/lcl/types"
|
|
|
|
|
)
|
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
|
// ChromiumEvent 通用Result bool
|
2022-10-04 13:21:05 +08:00
|
|
|
|
type ChromiumEventOnResult func(sender lcl.IObject, aResultOK bool)
|
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
|
// ChromiumEvent 通用Result float
|
2022-10-04 13:21:05 +08:00
|
|
|
|
type ChromiumEventOnResultFloat func(sender lcl.IObject, result float64)
|
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
|
// ChromiumEvent Beforebrowser - 主进程执行每创建一个新的浏览器进程都会调用
|
2022-10-04 13:21:05 +08:00
|
|
|
|
type ChromiumEventOnBeforeBrowser func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame) bool
|
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
|
// ChromiumEvent 地址改变事件
|
2022-10-25 12:38:06 +08:00
|
|
|
|
type ChromiumEventOnAddressChange func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, url string)
|
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
|
// ChromiumEvent browser TitleChange
|
2022-10-04 13:21:05 +08:00
|
|
|
|
type ChromiumEventOnTitleChange func(sender lcl.IObject, browser *ICefBrowser, title string)
|
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
|
// ChromiumEvent Render Process Terminated
|
2022-12-28 22:08:44 +08:00
|
|
|
|
type ChromiumEventOnRenderProcessTerminated func(sender lcl.IObject, browser *ICefBrowser, status consts.TCefTerminationStatus)
|
2023-01-08 17:04:39 +08:00
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
|
// ChromiumEvent Windows Comp Message
|
2023-01-14 23:26:37 +08:00
|
|
|
|
type ChromiumEventOnCompMsg func(sender lcl.IObject, message *types.TMessage, lResult *types.LRESULT, aHandled *bool)
|
2022-10-04 13:21:05 +08:00
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
|
// ChromiumEvent CefBrowser
|
2022-10-04 13:21:05 +08:00
|
|
|
|
type ChromiumEventOnCefBrowser func(sender lcl.IObject, browser *ICefBrowser)
|
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
|
// ChromiumEvent ChromiumMain Create & close
|
2022-10-04 13:21:05 +08:00
|
|
|
|
type ChromiumEventOnAfterCreated ChromiumEventOnCefBrowser
|
|
|
|
|
type ChromiumEventOnBeforeClose ChromiumEventOnCefBrowser
|
|
|
|
|
type ChromiumEventOnClose func(sender lcl.IObject, browser *ICefBrowser, aAction *TCefCloseBrowsesAction)
|
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
|
// ChromiumEvent ScrollOffsetChanged
|
2022-10-04 13:21:05 +08:00
|
|
|
|
type ChromiumEventOnScrollOffsetChanged func(sender lcl.IObject, browser *ICefBrowser, x, y float64)
|
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
|
// ChromiumEvent Load
|
2023-02-26 19:14:49 +08:00
|
|
|
|
type ChromiumEventOnLoadStart func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, transitionType consts.TCefTransitionType)
|
2022-10-04 13:21:05 +08:00
|
|
|
|
type ChromiumEventOnLoadingStateChange func(sender lcl.IObject, browser *ICefBrowser, isLoading, canGoBack, canGoForward bool)
|
|
|
|
|
type ChromiumEventOnLoadingProgressChange func(sender lcl.IObject, browser *ICefBrowser, progress float64)
|
2022-12-28 22:08:44 +08:00
|
|
|
|
type ChromiumEventOnLoadError func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, errorCode consts.CEF_NET_ERROR, errorText, failedUrl string)
|
2022-10-04 13:21:05 +08:00
|
|
|
|
type ChromiumEventOnLoadEnd func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, httpStatusCode int32)
|
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
|
// ChromiumEvent Cookie
|
2022-10-04 13:21:05 +08:00
|
|
|
|
type ChromiumEventOnCookieSet func(sender lcl.IObject, success bool, ID int32)
|
|
|
|
|
type ChromiumEventOnCookiesDeleted func(sender lcl.IObject, numDeleted int32)
|
|
|
|
|
type ChromiumEventOnCookiesFlushed func(sender lcl.IObject)
|
|
|
|
|
type ChromiumEventOnCookiesVisited func(sender lcl.IObject, cookie *ICefCookie)
|
|
|
|
|
type ChromiumEventOnCookieVisitorDestroyed func(sender lcl.IObject, ID int32)
|
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
|
// ChromiumEvent context menu
|
2022-10-04 13:21:05 +08:00
|
|
|
|
type ChromiumEventOnBeforeContextMenu func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, params *ICefContextMenuParams, model *ICefMenuModel)
|
2022-12-28 22:08:44 +08:00
|
|
|
|
type ChromiumEventOnContextMenuCommand func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, params *ICefContextMenuParams, commandId consts.MenuId, eventFlags uint32, result *bool)
|
2022-10-04 13:21:05 +08:00
|
|
|
|
type ChromiumEventOnContextMenuDismissed func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame)
|
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
|
// ChromiumEvent 全屏模式改变
|
2022-10-04 13:21:05 +08:00
|
|
|
|
type ChromiumEventOnFullScreenModeChange func(sender lcl.IObject, browser *ICefBrowser, fullscreen bool)
|
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
|
// ChromiumEvent 下载
|
2023-02-28 09:55:20 +08:00
|
|
|
|
type ChromiumEventOnBeforeDownload func(sender lcl.IObject, browser *ICefBrowser, downloadItem *ICefDownloadItem, suggestedName string, callback *ICefBeforeDownloadCallback)
|
|
|
|
|
type ChromiumEventOnDownloadUpdated func(sender lcl.IObject, browser *ICefBrowser, downloadItem *ICefDownloadItem, callback *ICefDownloadItemCallback)
|
2022-10-04 13:21:05 +08:00
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
|
// ChromiumEvent 键盘
|
2022-10-04 13:21:05 +08:00
|
|
|
|
type ChromiumEventOnKeyEvent func(sender lcl.IObject, browser *ICefBrowser, event *TCefKeyEvent, result *bool)
|
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
|
// ChromiumEvent 资源加载
|
2022-12-28 22:08:44 +08:00
|
|
|
|
type ChromiumEventOnBeforeResourceLoad func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, request *ICefRequest, callback *ICefCallback, result *consts.TCefReturnValue)
|
2022-10-04 13:21:05 +08:00
|
|
|
|
type ChromiumEventOnResourceResponse func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, request *ICefRequest, response *ICefResponse, result *bool)
|
2022-12-14 11:11:33 +08:00
|
|
|
|
type ChromiumEventOnResourceRedirect func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, request *ICefRequest, response *ICefResponse, newUrl *t.TString)
|
2022-12-28 22:08:44 +08:00
|
|
|
|
type ChromiumEventOnResourceLoadComplete func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, request *ICefRequest, response *ICefResponse, status consts.TCefUrlRequestStatus, receivedContentLength int64)
|
2022-10-04 13:21:05 +08:00
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
|
// GlobalCEFAppEvent
|
2022-10-04 13:21:05 +08:00
|
|
|
|
type GlobalCEFAppEventOnContextCreated func(browser *ICefBrowser, frame *ICefFrame, context *ICefV8Context) bool
|
|
|
|
|
type GlobalCEFAppEventOnWebKitInitialized func()
|
2022-12-15 23:13:27 +08:00
|
|
|
|
type GlobalCEFAppEventOnContextInitialized func()
|
2022-10-04 13:21:05 +08:00
|
|
|
|
type GlobalCEFAppEventOnBeforeChildProcessLaunch func(commandLine *TCefCommandLine)
|
|
|
|
|
type GlobalCEFAppEventOnBrowserDestroyed func(browser *ICefBrowser)
|
2022-12-28 22:08:44 +08:00
|
|
|
|
type GlobalCEFAppEventOnRenderLoadStart func(browser *ICefBrowser, frame *ICefFrame, transitionType consts.TCefTransitionType)
|
2022-10-04 13:21:05 +08:00
|
|
|
|
type GlobalCEFAppEventOnRenderLoadEnd func(browser *ICefBrowser, frame *ICefFrame, httpStatusCode int32)
|
2022-12-28 22:08:44 +08:00
|
|
|
|
type GlobalCEFAppEventOnRenderLoadError func(browser *ICefBrowser, frame *ICefFrame, errorCode consts.TCefErrorCode, errorText, failedUrl string)
|
2022-10-04 13:21:05 +08:00
|
|
|
|
type GlobalCEFAppEventOnRenderLoadingStateChange func(browser *ICefBrowser, frame *ICefFrame, isLoading, canGoBack, canGoForward bool)
|
2022-12-12 17:34:57 +08:00
|
|
|
|
type GlobalCEFAppEventOnGetDefaultClient func(client *ICefClient)
|
2022-10-04 13:21:05 +08:00
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
|
// Browser & Rneder 进程消息接收
|
2023-02-26 21:17:28 +08:00
|
|
|
|
type RenderProcessMessageReceived func(browser *ICefBrowser, frame *ICefFrame, sourceProcess consts.CefProcessId, message *ICefProcessMessage) bool
|
|
|
|
|
type BrowseProcessMessageReceived func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, sourceProcess consts.CefProcessId, message *ICefProcessMessage) bool
|
2023-02-20 14:42:17 +08:00
|
|
|
|
|
|
|
|
|
// ChromiumEvent FindResult
|
2022-10-04 13:21:05 +08:00
|
|
|
|
type ChromiumEventOnFindResult func(sender lcl.IObject, browser *ICefBrowser, identifier, count int32, selectionRect *TCefRect, activeMatchOrdinal int32, finalUpdate bool)
|
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
|
// ChromiumEvent Frame
|
2022-10-04 13:21:05 +08:00
|
|
|
|
type ChromiumEventOnFrameAttached func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, reattached bool)
|
|
|
|
|
type ChromiumEventOnFrameCreated func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame)
|
|
|
|
|
type ChromiumEventOnFrameDetached func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame)
|
|
|
|
|
type ChromiumEventOnMainFrameChanged func(sender lcl.IObject, browser *ICefBrowser, oldFrame *ICefFrame, newFrame *ICefFrame)
|
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
|
// ChromiumEvent BeforePopup
|
2022-12-15 23:13:27 +08:00
|
|
|
|
type ChromiumEventOnBeforePopup func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, beforePopupInfo *BeforePopupInfo, client *ICefClient, noJavascriptAccess *bool) bool
|
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
|
// ChromiumEvent BeforePopupForWindowInfo
|
2023-01-06 17:42:34 +08:00
|
|
|
|
type ChromiumEventOnBeforePopupForWindowInfo func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, beforePopupInfo *BeforePopupInfo, popupWindow IBrowserWindow, noJavascriptAccess *bool) bool
|
2022-10-04 13:21:05 +08:00
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
|
// ChromiumEvent OpenUrlFromTab
|
2022-10-04 13:21:05 +08:00
|
|
|
|
type ChromiumEventOnOpenUrlFromTab func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame)
|
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
|
// ChromiumEvent DragEnter
|
2023-01-08 17:04:39 +08:00
|
|
|
|
type ChromiumEventOnDragEnter func(sender lcl.IObject, browser *ICefBrowser, dragData *ICefDragData, mask consts.TCefDragOperations, result *bool)
|
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
|
// ChromiumEvent DraggableRegionsChanged , web css: [-webkit-app-region: drag/no-drag]
|
2023-01-08 18:05:03 +08:00
|
|
|
|
type ChromiumEventOnDraggableRegionsChanged func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, regions *TCefDraggableRegions)
|
2023-01-08 17:04:39 +08:00
|
|
|
|
|
2023-02-20 14:42:17 +08:00
|
|
|
|
// LCL Window event
|
2022-10-04 13:21:05 +08:00
|
|
|
|
type TCloseEvent func(sender lcl.IObject, action *types.TCloseAction) bool
|
|
|
|
|
type TNotifyEvent func(sender lcl.IObject) bool
|
|
|
|
|
type TCloseQueryEvent func(sender lcl.IObject, canClose *bool) bool
|
2022-12-13 11:49:32 +08:00
|
|
|
|
|
2023-02-19 23:21:47 +08:00
|
|
|
|
// TCEFWindowComponent
|
2022-12-13 11:49:32 +08:00
|
|
|
|
type WindowComponentOnWindowCreated func(sender lcl.IObject, window *ICefWindow)
|
|
|
|
|
type WindowComponentOnWindowDestroyed func(sender lcl.IObject, window *ICefWindow)
|
|
|
|
|
type WindowComponentOnWindowActivationChanged func(sender lcl.IObject, window *ICefWindow, active bool)
|
|
|
|
|
type WindowComponentOnGetParentWindow func(sender lcl.IObject, window *ICefWindow, isMenu, canActivateMenu *bool, aResult *ICefWindow)
|
|
|
|
|
type WindowComponentOnGetInitialBounds func(sender lcl.IObject, window *ICefWindow, aResult *TCefRect)
|
2022-12-28 22:08:44 +08:00
|
|
|
|
type WindowComponentOnGetInitialShowState func(sender lcl.IObject, window *ICefWindow, aResult *consts.TCefShowState)
|
2022-12-13 11:49:32 +08:00
|
|
|
|
type WindowComponentOnIsFrameless func(sender lcl.IObject, window *ICefWindow, aResult *bool)
|
|
|
|
|
type WindowComponentOnCanResize func(sender lcl.IObject, window *ICefWindow, aResult *bool)
|
|
|
|
|
type WindowComponentOnCanMaximize func(sender lcl.IObject, window *ICefWindow, aResult *bool)
|
|
|
|
|
type WindowComponentOnCanMinimize func(sender lcl.IObject, window *ICefWindow, aResult *bool)
|
|
|
|
|
type WindowComponentOnCanClose func(sender lcl.IObject, window *ICefWindow, aResult *bool)
|
|
|
|
|
type WindowComponentOnAccelerator func(sender lcl.IObject, window *ICefWindow, commandId int32, aResult *bool)
|
|
|
|
|
type WindowComponentOnKeyEvent func(sender lcl.IObject, window *ICefWindow, event *TCefKeyEvent, aResult *bool)
|
2022-12-14 19:18:11 +08:00
|
|
|
|
|
2023-02-19 23:21:47 +08:00
|
|
|
|
// TCEFBrowserViewComponent
|
2022-12-14 19:18:11 +08:00
|
|
|
|
type BrowserViewComponentOnBrowserCreated func(sender lcl.IObject, browserView *ICefBrowserView, browser *ICefBrowser)
|
|
|
|
|
type BrowserViewComponentOnBrowserDestroyed func(sender lcl.IObject, browserView *ICefBrowserView, browser *ICefBrowser)
|
|
|
|
|
type BrowserViewComponentOnGetDelegateForPopupBrowserView func(sender lcl.IObject, browserView *ICefBrowserView, browserSettings *TCefBrowserSettings, client *ICefClient, isDevtools bool, aResult *ICefBrowserViewDelegate)
|
|
|
|
|
type BrowserViewComponentOnPopupBrowserViewCreated func(sender lcl.IObject, browserView, popupBrowserView *ICefBrowserView, isDevtools bool, aResult *bool)
|
2022-12-28 22:08:44 +08:00
|
|
|
|
type BrowserViewComponentOnGetChromeToolbarType func(sender lcl.IObject, aResult *consts.TCefChromeToolbarType)
|