Repository navigation
Expand file tree
/
Copy pathv8context_handler_cef3.pyx
More file actions
48 lines (45 loc) · 1.91 KB
/
Copy pathv8context_handler_cef3.pyx
File metadata and controls
48 lines (45 loc) · 1.91 KB
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
# Copyright (c) 2012-2013 The CEF Python authors. All rights reserved.
# License: New BSD License.
# Website: http://code.google.com/p/cefpython/
# In CEF 3 there is no V8ContextHandler, the methods OnContextCreated(),
# OnContextReleased(), OnUncaughtException() are in CefRenderProcessHandler
# and are called in the Renderer process, we use process messaging to
# recreate these events in the Browser process, but the timing will be
# a bit delayed due to asynchronous way this is being done.
cdef public void V8ContextHandler_OnContextCreated(
CefRefPtr[CefBrowser] cefBrowser,
CefRefPtr[CefFrame] cefFrame
) except * with gil:
cdef PyBrowser pyBrowser
cdef PyFrame pyFrame
cdef object clientCallback
try:
Debug("V8ContextHandler_OnContextCreated()")
pyBrowser = GetPyBrowser(cefBrowser)
pyBrowser.SetUserData("__v8ContextCreated", True)
pyFrame = GetPyFrame(cefFrame)
# User defined callback.
clientCallback = pyBrowser.GetClientCallback("OnContextCreated")
if clientCallback:
clientCallback(pyBrowser, pyFrame)
except:
(exc_type, exc_value, exc_trace) = sys.exc_info()
sys.excepthook(exc_type, exc_value, exc_trace)
cdef public void V8ContextHandler_OnContextReleased(
CefRefPtr[CefBrowser] cefBrowser,
CefRefPtr[CefFrame] cefFrame
) except * with gil:
cdef PyBrowser pyBrowser
cdef PyFrame pyFrame
cdef object clientCallback
try:
Debug("V8ContextHandler_OnContextReleased()")
pyBrowser = GetPyBrowser(cefBrowser)
pyFrame = GetPyFrame(cefFrame)
# User defined callback.
clientCallback = pyBrowser.GetClientCallback("OnContextReleased")
if clientCallback:
clientCallback(pyBrowser, pyFrame)
except:
(exc_type, exc_value, exc_trace) = sys.exc_info()
sys.excepthook(exc_type, exc_value, exc_trace)