-
Notifications
You must be signed in to change notification settings - Fork 1
/
JSManager.h
48 lines (33 loc) · 970 Bytes
/
JSManager.h
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
#ifndef _JS_MGR_H_
#define _JS_MGR_H_
#include <functional>
#define JS_FUNC(name) void name(CefRefPtr<CefV8Value>& retVal, const CefV8ValueList& args, CefRefPtr<CefBrowser> browser)
typedef struct jsf
{
enum
{
FUNC_GLOBAL,
FUNC_CONFIG
};
std::function<void(CefRefPtr<CefV8Value>&,
const CefV8ValueList&,
CefRefPtr<CefBrowser>)> function;
int type;
} TJSfunction;
typedef std::map<std::string, TJSfunction> func_container;
class JSManager : public CefV8Handler
{
public:
JSManager();
void Initialize(CefRefPtr<CefBrowser> browser, CefRefPtr<CefV8Context> context);
// handle javascript calls
virtual bool Execute(const CefString& name,
CefRefPtr<CefV8Value> object,
const CefV8ValueList& arguments,
CefRefPtr<CefV8Value>& retval,
CefString& exception) OVERRIDE;
private:
static func_container functions;
IMPLEMENT_REFCOUNTING(JSManager);
};
#endif