energy/cef/cef-chromium-config.go

73 lines
2.2 KiB
Go
Raw Normal View History

2022-10-04 13:21:05 +08:00
//----------------------------------------
//
// Copyright © yanghy. All Rights Reserved.
//
// 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 00:20:01 +08:00
// Chromium的配置
2022-10-04 13:21:05 +08:00
package cef
import "github.com/energye/golcl/lcl/api"
// tCefChromiumConfig Chromium的基础配置
2022-10-04 13:21:05 +08:00
type tCefChromiumConfig struct {
enableMenu uintptr //bool 启用右键菜单
enableViewSource uintptr //bool 启用查看源代码
enableDevTools uintptr //bool 启用开发者工具
enableWindowPopup uintptr //bool 启用弹出新窗口
enableOpenUrlTab uintptr //bool 启用tab签打开新窗口(需自定义实现)
enabledJavascript uintptr //bool 启用Javascript
}
2023-02-20 00:20:01 +08:00
// NewChromiumConfig 创建默认禁用相关功能
2022-10-04 13:21:05 +08:00
func NewChromiumConfig() *tCefChromiumConfig {
return &tCefChromiumConfig{
enableMenu: api.PascalBool(true),
enableViewSource: api.PascalBool(true),
enableDevTools: api.PascalBool(true),
enableWindowPopup: api.PascalBool(true),
2022-12-03 21:56:51 +08:00
enableOpenUrlTab: api.PascalBool(false),
enabledJavascript: api.PascalBool(false),
2022-10-04 13:21:05 +08:00
}
}
2023-02-20 00:20:01 +08:00
// SetEnableMenu 设置启用右键菜单
2022-10-04 13:21:05 +08:00
func (m *tCefChromiumConfig) SetEnableMenu(value bool) *tCefChromiumConfig {
2022-12-03 21:56:51 +08:00
m.enableMenu = api.PascalBool(value)
2022-10-04 13:21:05 +08:00
return m
}
2023-02-20 00:20:01 +08:00
// SetEnableViewSource 设置启用查询源文件
2022-10-04 13:21:05 +08:00
func (m *tCefChromiumConfig) SetEnableViewSource(value bool) *tCefChromiumConfig {
2022-12-03 21:56:51 +08:00
m.enableViewSource = api.PascalBool(value)
2022-10-04 13:21:05 +08:00
return m
}
2023-02-20 00:20:01 +08:00
// SetEnableDevTools 设置启用开发者工具
2022-10-04 13:21:05 +08:00
func (m *tCefChromiumConfig) SetEnableDevTools(value bool) *tCefChromiumConfig {
2022-12-03 21:56:51 +08:00
m.enableDevTools = api.PascalBool(value)
2022-10-04 13:21:05 +08:00
return m
}
2023-02-20 00:20:01 +08:00
// SetEnableWindowPopup 设置启用打开链接弹出新窗口
2022-10-04 13:21:05 +08:00
func (m *tCefChromiumConfig) SetEnableWindowPopup(value bool) *tCefChromiumConfig {
2022-12-03 21:56:51 +08:00
m.enableWindowPopup = api.PascalBool(value)
2022-10-04 13:21:05 +08:00
return m
}
2023-02-20 00:20:01 +08:00
// SetEnableOpenUrlTab 设置启用打开链接打开新tab
2022-10-04 13:21:05 +08:00
func (m *tCefChromiumConfig) SetEnableOpenUrlTab(value bool) *tCefChromiumConfig {
2022-12-03 21:56:51 +08:00
m.enableOpenUrlTab = api.PascalBool(value)
2022-10-04 13:21:05 +08:00
return m
}
2023-02-20 00:20:01 +08:00
// SetEnabledJavascript 设置启用Javascript
2022-10-04 13:21:05 +08:00
func (m *tCefChromiumConfig) SetEnabledJavascript(value bool) *tCefChromiumConfig {
2022-12-03 21:56:51 +08:00
m.enabledJavascript = api.PascalBool(value)
2022-10-04 13:21:05 +08:00
return m
}