-
Notifications
You must be signed in to change notification settings - Fork 23
/
process.go
40 lines (34 loc) · 1.14 KB
/
process.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//----------------------------------------
//
// Copyright © yanghy. All Rights Reserved.
//
// Licensed under Apache License Version 2.0, January 2004
//
// https://www.apache.org/licenses/LICENSE-2.0
//
//----------------------------------------
package cef
import (
"fmt"
"github.com/energye/energy/v2/consts"
)
// process
const (
internalProcess = "process"
internalProcessBrowserId = "browserId"
internalProcessFrameId = "frameId"
)
var _processObject *ICefV8Value
// makeProcess 进程扩展变量
func makeProcess(browser *ICefBrowser, frame *ICefFrame, context *ICefV8Context) {
if _processObject != nil {
// 刷新时释放掉
_processObject.Free()
}
// process
_processObject = V8ValueRef.NewObject(nil)
_processObject.setValueByKey(internalProcessBrowserId, V8ValueRef.NewInt(browser.Identifier()), consts.V8_PROPERTY_ATTRIBUTE_READONLY)
_processObject.setValueByKey(internalProcessFrameId, V8ValueRef.NewString(fmt.Sprintf("%d", frame.Identifier())), consts.V8_PROPERTY_ATTRIBUTE_READONLY)
// process key to v8 global
context.Global().setValueByKey(internalProcess, _processObject, consts.V8_PROPERTY_ATTRIBUTE_READONLY)
}