FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cefpython/src/handlers/v8context_handler.pyx at cefpython54 · pythonthings/cefpython · GitHub
pythonthings
cefpython
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cefpython
/
src
/
handlers
/
v8context_handler.pyx
Copy path
More file actions
More file actions
Latest commit
History
History
History
66 lines (62 loc) · 2.81 KB
Breadcrumbs
cefpython
/
src
/
handlers
/
v8context_handler.pyx
Copy path
File metadata and controls
66 lines (62 loc) · 2.81 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
65
66
#
Copyright (c) 2012-2014 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.
include
"
../cefpython.pyx
"
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(
int
browserId,
int64 frameId
)
except
*
with
gil:
cdef PyBrowser pyBrowser
cdef PyFrame pyFrame
cdef
object
clientCallback
try
:
#
Due to multi-process architecture in CEF 3, this function won't
#
get called for the main frame in main browser. To send a message
#
from the renderer process a parent browser is used. If this was
#
a main frame then this would mean that the browser is being
#
destroyed, thus we can't send a process message using this browser.
#
There is no guarantee that this will get called for frames in the
#
main browser, if the browser is destroyed shortly after the frames
#
were released.
Debug(
"
V8ContextHandler_OnContextReleased()
"
)
pyBrowser
=
GetPyBrowserById(browserId)
pyFrame
=
GetPyFrameById(browserId, frameId)
if
pyBrowser
and
pyFrame:
clientCallback
=
pyBrowser.GetClientCallback(
"
OnContextReleased
"
)
if
clientCallback:
clientCallback(pyBrowser, pyFrame)
else
:
if
not
pyBrowser:
Debug(
"
V8ContextHandler_OnContextReleased() WARNING:
"
"
pyBrowser not found
"
)
if
not
pyFrame:
Debug(
"
V8ContextHandler_OnContextReleased() WARNING:
"
"
pyFrame not found
"
)
RemovePyFrame(browserId, frameId)
except
:
(exc_type, exc_value, exc_trace)
=
sys.exc_info()
sys.excepthook(exc_type, exc_value, exc_trace)
Back
|
FazBrowse Home
|
New Git URL