44
55IF CEF_VERSION == 1 :
66 # In CEF 1 there are both KT_KEYDOWN and KEYEVENT_KEYDOWN, and
7- # these are different constants, making a bit of confusion.
7+ # these are different constants, making a bit of confusion.
88 # In CEF 1 KT_ is for SendKeyEvent, KEYEVENT_ is for OnKeyEvent().
99 # In CEF 3 there are only KEYEVENT_* constants.
1010 KEYTYPE_KEYDOWN = cef_types.KT_KEYDOWN
@@ -179,7 +179,7 @@ cdef class PyBrowser:
179179 # -------------------------------------------------------------------------
180180 # CEF 1
181181 # -------------------------------------------------------------------------
182- cpdef py_void SetClientCallback_CEF1(self ,
182+ cpdef py_void SetClientCallback_CEF1(self ,
183183 py_string name, object callback):
184184 if not self .allowedClientCallbacks:
185185 # CefLoadHandler.
@@ -196,7 +196,7 @@ cdef class PyBrowser:
196196 " OnResourceResponse" , " OnProtocolExecution" ,
197197 " GetDownloadHandler" , " GetAuthCredentials" ,
198198 " GetCookieManager" ]
199-
199+
200200 # CefDisplayHandler.
201201 self .allowedClientCallbacks += [" OnAddressChange" ,
202202 " OnConsoleMessage" , " OnContentsSizeChange" ,
@@ -219,7 +219,7 @@ cdef class PyBrowser:
219219 # -------------------------------------------------------------------------
220220 # CEF 3
221221 # -------------------------------------------------------------------------
222- cpdef py_void SetClientCallback_CEF3(self ,
222+ cpdef py_void SetClientCallback_CEF3(self ,
223223 py_string name, object callback):
224224 if not self .allowedClientCallbacks:
225225 # DisplayHandler
@@ -229,19 +229,19 @@ cdef class PyBrowser:
229229 # KeyboardHandler
230230 self .allowedClientCallbacks += [" OnPreKeyEvent" , " OnKeyEvent" ];
231231 # RequestHandler
232- # NOTE: OnCertificateError and OnBeforePluginLoad are not
233- # included as they must be set using
232+ # NOTE: OnCertificateError and OnBeforePluginLoad are not
233+ # included as they must be set using
234234 # cefpython.SetGlobalClientCallback().
235235 self .allowedClientCallbacks += [" OnBeforeResourceLoad" ,
236236 " OnResourceRedirect" , " GetAuthCredentials" ,
237- " OnQuotaRequest" , " OnProtocolExecution" ,
237+ " OnQuotaRequest" , " OnProtocolExecution" ,
238238 " GetResourceHandler" ,
239239 " OnBeforeBrowse" , " OnRendererProcessTerminated" ,
240240 " OnPluginCrashed" ]
241241 # RequestContextHandler
242242 self .allowedClientCallbacks += [" GetCookieManager" ]
243243 # LoadHandler
244- self .allowedClientCallbacks += [" OnLoadingStateChange" ,
244+ self .allowedClientCallbacks += [" OnLoadingStateChange" ,
245245 " OnLoadStart" , " OnLoadEnd" , " OnLoadError" ]
246246 # LifespanHandler
247247 # NOTE: OnAfterCreated not included as it must be set using
@@ -335,18 +335,25 @@ cdef class PyBrowser:
335335 if len (g_pyBrowsers) == 1 :
336336 # This is the last browser remaining.
337337 if g_sharedRequestContext.get():
338- # A similar release is done in Shutdown
338+ # A similar release is done in Shutdown
339339 # and RemovePyBrowser.
340340 Debug(" CloseBrowser: releasing shared request context" )
341341 g_sharedRequestContext.Assign(NULL )
342342 Debug(" CefBrowser::CloseBrowser(%s )" % forceClose)
343343 self .GetCefBrowserHost().get().CloseBrowser(bool (forceClose))
344-
344+
345345 IF CEF_VERSION == 1 :
346346
347347 cpdef py_void CloseDevTools(self ):
348348 self .GetCefBrowser().get().CloseDevTools()
349349
350+ def ExecuteFunction (self , *args ):
351+ self .GetMainFrame().ExecuteFunction(* args)
352+
353+ cpdef py_void ExecuteJavascript(self , py_string jsCode,
354+ py_string scriptUrl = " " , int startLine = 0 ):
355+ self .GetMainFrame().ExecuteJavascript(jsCode, scriptUrl, startLine)
356+
350357 cpdef py_void Find(self , int searchId, py_string searchText,
351358 py_bool forward, py_bool matchCase,
352359 py_bool findNext):
@@ -708,7 +715,7 @@ cdef class PyBrowser:
708715
709716 cpdef py_void SendCaptureLostEvent(self ):
710717 self .GetCefBrowser().get().SendCaptureLostEvent()
711-
718+
712719 ELIF CEF_VERSION == 3 :
713720 cpdef py_void SendKeyEvent(self , dict pyEvent):
714721 cdef CefKeyEvent cefEvent
@@ -731,7 +738,7 @@ cdef class PyBrowser:
731738 cefEvent.focus_on_editable_field = \
732739 bool (pyEvent[" focus_on_editable_field" ])
733740 self .GetCefBrowserHost().get().SendKeyEvent(cefEvent)
734-
741+
735742 cpdef py_void SendMouseClickEvent(self , x, y,
736743 cef_types.cef_mouse_button_type_t mouseButtonType,
737744 py_bool mouseUp, int clickCount):
@@ -779,7 +786,7 @@ cdef class PyBrowser:
779786 mouseEvent.modifiers = 0
780787 self .GetCefBrowserHost().get().SendMouseWheelEvent(mouseEvent,
781788 deltaX, deltaY)
782-
789+
783790 cpdef py_void SendFocusEvent(self , py_bool setFocus):
784791 self .GetCefBrowserHost().get().SendFocusEvent(bool (setFocus))
785792
@@ -812,7 +819,7 @@ cdef class PyBrowser:
812819 # virtual void HandleKeyEventBeforeTextInputClient(CefEventHandle keyEvent) =0;
813820 # virtual void HandleKeyEventAfterTextInputClient(CefEventHandle keyEvent) =0;
814821
815- cdef void SendProcessMessage(self , cef_process_id_t targetProcess,
822+ cdef void SendProcessMessage(self , cef_process_id_t targetProcess,
816823 object frameId, py_string messageName, list pyArguments
817824 ) except * :
818825 cdef CefRefPtr[CefProcessMessage] message = \
@@ -826,7 +833,7 @@ cdef class PyBrowser:
826833 PyListToExistingCefListValue(self .GetIdentifier(), frameId,
827834 pyArguments, messageArguments)
828835 Debug(" SendProcessMessage(): message=%s , arguments size=%d " % (
829- messageName,
836+ messageName,
830837 message.get().GetArgumentList().get().GetSize()))
831838 cdef cpp_bool success = \
832839 self .GetCefBrowser().get().SendProcessMessage(
0 commit comments