Repository navigation
Expand file tree
/
Copy pathload_handler_cef3.pyx
More file actions
110 lines (104 loc) · 4.26 KB
/
Copy pathload_handler_cef3.pyx
File metadata and controls
110 lines (104 loc) · 4.26 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# Copyright (c) 2012-2013 The CEF Python authors. All rights reserved.
# License: New BSD License.
# Website: http://code.google.com/p/cefpython/
# cef_termination_status_t
TS_ABNORMAL_TERMINATION = cef_types.TS_ABNORMAL_TERMINATION
TS_PROCESS_WAS_KILLED = cef_types.TS_PROCESS_WAS_KILLED
TS_PROCESS_CRASHED = cef_types.TS_PROCESS_CRASHED
cdef public void LoadHandler_OnLoadStart(
CefRefPtr[CefBrowser] cefBrowser,
CefRefPtr[CefFrame] cefFrame
) except * with gil:
cdef PyBrowser pyBrowser
cdef PyFrame pyFrame
cdef object clientCallback
try:
pyBrowser = GetPyBrowser(cefBrowser)
pyFrame = GetPyFrame(cefFrame)
clientCallback = pyBrowser.GetClientCallback("OnLoadStart")
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 LoadHandler_OnLoadEnd(
CefRefPtr[CefBrowser] cefBrowser,
CefRefPtr[CefFrame] cefFrame,
int httpStatusCode
) except * with gil:
cdef PyBrowser pyBrowser
cdef PyFrame pyFrame
cdef object clientCallback
try:
pyBrowser = GetPyBrowser(cefBrowser)
pyFrame = GetPyFrame(cefFrame)
clientCallback = pyBrowser.GetClientCallback("OnLoadEnd")
if clientCallback:
clientCallback(pyBrowser, pyFrame, httpStatusCode)
except:
(exc_type, exc_value, exc_trace) = sys.exc_info()
sys.excepthook(exc_type, exc_value, exc_trace)
cdef public void LoadHandler_OnLoadError(
CefRefPtr[CefBrowser] cefBrowser,
CefRefPtr[CefFrame] cefFrame,
cef_types.cef_errorcode_t cefErrorCode,
const CefString& cefErrorText,
const CefString& cefFailedUrl
) except * with gil:
cdef PyBrowser pyBrowser
cdef PyFrame pyFrame
cdef list errorTextOut
cdef object clientCallback
try:
pyBrowser = GetPyBrowser(cefBrowser)
pyFrame = GetPyFrame(cefFrame)
errorTextOut = [CefToPyString(cefErrorText)]
clientCallback = pyBrowser.GetClientCallback("OnLoadError")
if clientCallback:
clientCallback(
pyBrowser, pyFrame, cefErrorCode, errorTextOut,
CefToPyString(cefFailedUrl))
# Providing custom error messsage not yet supported in CEF 3.
# | PyToCefString(errorTextOut[0], cefErrorText)
except:
(exc_type, exc_value, exc_trace) = sys.exc_info()
sys.excepthook(exc_type, exc_value, exc_trace)
cdef public void LoadHandler_OnRendererProcessTerminated(
CefRefPtr[CefBrowser] cefBrowser,
cef_types.cef_termination_status_t cefStatus
) except * with gil:
# TODO: proccess may crash during browser creation. Let this callback
# to be set either through cefpython.SetGlobalClientCallback()
# or PyBrowser.SetClientCallback(). Modify the
# PyBrowser.GetClientCallback() implementation to return a global
# callback first if set.
cdef PyBrowser pyBrowser
cdef object clientCallback
try:
pyBrowser = GetPyBrowser(cefBrowser)
clientCallback = pyBrowser.GetClientCallback(
"OnRendererProcessTerminated")
if clientCallback:
clientCallback(pyBrowser, cefStatus)
except:
(exc_type, exc_value, exc_trace) = sys.exc_info()
sys.excepthook(exc_type, exc_value, exc_trace)
cdef public void LoadHandler_OnPluginCrashed(
CefRefPtr[CefBrowser] cefBrowser,
const CefString& cefPluginPath
) except * with gil:
# TODO: plugin may crash during browser creation. Let this callback
# to be set either through cefpython.SetGlobalClientCallback()
# or PyBrowser.SetClientCallback(). Modify the
# PyBrowser.GetClientCallback() implementation to return a global
# callback first if set.
cdef PyBrowser pyBrowser
cdef object clientCallback
try:
pyBrowser = GetPyBrowser(cefBrowser)
clientCallback = pyBrowser.GetClientCallback("OnPluginCrashed")
if clientCallback:
clientCallback(pyBrowser, CefToPyString(cefPluginPath))
except:
(exc_type, exc_value, exc_trace) = sys.exc_info()
sys.excepthook(exc_type, exc_value, exc_trace)