forked from cztomczak/cef2go
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcefApp.go
66 lines (51 loc) · 1.62 KB
/
cefApp.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright (c) 2014 The cef2go authors. All rights reserved.
// License: BSD 3-clause.
// Website: https://github.com/CzarekTomczak/cef2go
// Website: https://github.com/fromkeith/cef2go
package cef2go
/*
#include "include/capi/cef_app_capi.h"
extern void initialize_app_handler(cef_app_t* app);
*/
import "C"
import "unsafe"
var (
knownAppHandlers = make(map[unsafe.Pointer]AppHandler)
)
// create the underlying C structure for an App Handler.
func NewAppHandlerT(handler AppHandler) AppHandlerT {
var a AppHandlerT
a.CStruct = (*C.cef_app_t)(
C.calloc(1, C.sizeof_cef_app_t))
C.initialize_app_handler(a.CStruct)
Logger.Infof("_AppHandler: %x", unsafe.Pointer(a.CStruct))
knownAppHandlers[unsafe.Pointer(a.CStruct)] = handler
return a
}
//export goDebugLog
func goDebugLog(toLog *C.char) {
ll := C.GoString(toLog)
Logger.Infof(ll)
}
//export go_GetBrowserProcessHandler
func go_GetBrowserProcessHandler(self *C.cef_app_t) *C.struct__cef_browser_process_handler_t {
if handler, ok := knownAppHandlers[unsafe.Pointer(self)]; ok {
bph := handler.GetBrowserProcessHandler()
if bph != nil {
return bph.GetBrowserProcessHandlerT().CStruct
}
}
return nil
}
type AppHandler interface {
OnBeforeCommandLineProcessing(processType string, commandLine CommandLineT)
OnRegisterCustomSchemes()
GetResourceBundleHandler()
GetBrowserProcessHandler() BrowserProcessHandler
GetRenderProcessHandler()
// called to get the underlying c struct.
GetAppHandlerT() AppHandlerT
}
type AppHandlerT struct {
CStruct *C.cef_app_t
}