1

How can one defines a custom scheme handler for CEF in Python using CEFPython?

I've found this thread that explains how to define a CefSchemeHandlerFactory and CefSchemeHandler in C++. But I can't find out how should I employ CefBase as a base type to implement these classes in Python and where is the documentation for equivalent classes in Python.

Kaveh Shahbazian
  • 13,088
  • 13
  • 80
  • 139

1 Answers1

1

Custom scheme support is not yet implemented in CEF Python, see Issue 50 "Add custom scheme support":

https://code.google.com/p/cefpython/issues/detail?id=50

You could probably accomplish the same thing using OnBeforeResourceLoad() and/or GetResourceHandler(). See the RequestHandler wiki page:

https://code.google.com/p/cefpython/wiki/RequestHandler

There is the wxpython-response.py example that uses GetResourceHandler to intercept all resources being loaded:

https://code.google.com/p/cefpython/source/browse/cefpython/cef3/linux/binaries_64bit/wxpython-response.py?r=dfff7897665f

See also Issue 49 "Implement OnBeforeResourceLoad" (CEF Python 1), some comments might give you insight on how things are:

https://code.google.com/p/cefpython/issues/detail?id=49

Czarek Tomczak
  • 20,079
  • 5
  • 49
  • 56
  • Thanks; How to feed a html, png or mp3 file to the request (beside things like setting headers)? One should use CEFStream for that, but I could not find CEFStream in CEFPython. – Kaveh Shahbazian Feb 22 '14 at 20:27
  • @KavehShahbazian In CEF Python 1 there is StreamReader passed to OnBeforeResourceLoad(): https://code.google.com/p/cefpython/wiki/RequestHandler#CEF_1 . And you can call reader.SetData() on it. In CEF 3 API has changed and these additional parameters are not available anymore. But you can use GetResourceHandler in CEF 3 and do the things you want. See the wxpython-response.py example. You don't have to use the WebRequestClient in ResourceHandler, you can have your own implementation. Feed it with data in ResourceHandler.ReadResponse(). – Czarek Tomczak Feb 22 '14 at 20:48
  • @KavehShahbazian ResourceHandler in CEF 3 is the best option, because you can feed it in chunks. With OnBeforeResourceLoad in CEF 1 using StreamReader you have to feed it with all data in one step. – Czarek Tomczak Feb 22 '14 at 20:50
  • This is an amazing project and I hope it reaches a level of maturity that can officially represent the UI for Python ecosystem. And custom schemes are really handy. – Kaveh Shahbazian Feb 22 '14 at 21:06
  • At the moment cef python is dead. No update since march.@czarek can you confirm that? – Phyo Arkar Lwin Jun 26 '14 at 05:29
  • @V3ss0n Three months is not that much time, I think that's an exaggerated conclusion. The forum and support are alive. Also it's an open source project, anyone can contribute if he feels like to. – Czarek Tomczak Jul 19 '14 at 12:28
  • @CzarekTomczak as you are the owner of the project , other competing implementations are way ahead now, with support for blink : https://github.com/rogerwang/node-webkit so it is not an exaggerated conclusion. I know it is very hard and time consuming to Maintain compatibility with very activly developing target like chromium. I am pythonist and i am all for increased adoptation of cross platform HTML5 UI Framework for Python so i may help maintain it. How much C knowlege is needed as my C skills are rusty since long. – Phyo Arkar Lwin Jul 19 '14 at 16:20
  • @V3ss0n You are comparing apples to oranges. This discussion is way off-topic here. – Czarek Tomczak Jul 19 '14 at 17:27