FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cefpython/src/subprocess/v8function_handler.cpp at cefpython51 · cleverphp/cefpython · GitHub
cleverphp
cefpython
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
cefpython
/
src
/
subprocess
/
v8function_handler.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
64 lines (62 loc) · 2.9 KB
Breadcrumbs
cefpython
/
src
/
subprocess
/
v8function_handler.cpp
Copy path
File metadata and controls
64 lines (62 loc) · 2.9 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
//
Copyright (c) 2012-2014 The CEF Python authors. All rights reserved.
//
License: New BSD License.
//
Website: http://code.google.com/p/cefpython/
#
include
"
cefpython_app.h
"
#
include
"
v8utils.h
"
#
include
"
DebugLog.h
"
bool
V8FunctionHandler::Execute
(
const
CefString& functionName,
CefRefPtr<CefV8Value> thisObject,
const
CefV8ValueList& v8Arguments,
CefRefPtr<CefV8Value>& returnValue,
CefString& exception) {
if
(!
CefV8Context::InContext
()) {
//
CefV8Context::GetCurrentContext may not be called when
//
not in a V8 context.
DebugLog
(
"
Renderer: V8FunctionHandler::Execute() FAILED:
"
\
"
not inside a V8 context
"
);
return
false
;
}
CefRefPtr<CefV8Context> context =
CefV8Context::GetCurrentContext
();
CefRefPtr<CefBrowser> browser = context.
get
()->
GetBrowser
();
CefRefPtr<CefFrame> frame = context.
get
()->
GetFrame
();
if
(pythonCallbackId_) {
DebugLog
(
"
Renderer: V8FunctionHandler::Execute(): python callback
"
);
CefRefPtr<CefListValue> functionArguments =
V8ValueListToCefListValue
(
v8Arguments);
CefRefPtr<CefProcessMessage> processMessage = \
CefProcessMessage::Create
(
"
ExecutePythonCallback
"
);
CefRefPtr<CefListValue> messageArguments = \
processMessage->
GetArgumentList
();
messageArguments->
SetInt
(
0
, pythonCallbackId_);
messageArguments->
SetList
(
1
, functionArguments);
browser->
SendProcessMessage
(
PID_BROWSER
, processMessage);
returnValue =
CefV8Value::CreateNull
();
return
true
;
}
else
{
DebugLog
(
"
Renderer: V8FunctionHandler::Execute(): js binding
"
);
if
(!(cefPythonApp_.
get
() \
&& cefPythonApp_->
BindedFunctionExists
( \
browser, functionName))) {
exception =
std::string
(
"
[CEF Python]
"
\
"
V8FunctionHandler::Execute() FAILED:
"
\
"
function does not exist:
"
).
append
(functionName) \
.
append
(
"
()
"
);
//
Must return true for the exception to be thrown.
return
true
;
}
CefRefPtr<CefListValue> functionArguments =
V8ValueListToCefListValue
(
v8Arguments);
//
TODO: losing int64 precision here.
int
frameId = (
int
)frame->
GetIdentifier
();
CefRefPtr<CefProcessMessage> processMessage = \
CefProcessMessage::Create
(
"
V8FunctionHandler::Execute
"
);
CefRefPtr<CefListValue> messageArguments = \
processMessage->
GetArgumentList
();
messageArguments->
SetInt
(
0
, frameId);
messageArguments->
SetString
(
1
, functionName);
messageArguments->
SetList
(
2
, functionArguments);
browser->
SendProcessMessage
(
PID_BROWSER
, processMessage);
returnValue =
CefV8Value::CreateNull
();
return
true
;
}
}
Back
|
FazBrowse Home
|
New Git URL