4

I'm investigating using CEF in a new desktop application in which I want to render the UI with HTML5/js. However, I don't want the model to be a typical web application that's just rendered in an embedded browser (i.e. fetching resources from a remote server like a web page). Basically I want to have a desktop app that comes prepackaged with all the HTML and scripts that are needed to render the UI, and function entirely offline.

My question is: Is CEF capable of doing this more or less out of the box? Or will I need to write a bunch of custom code for handling and rendering local resources, or embedding a local web server? A simple example would be building the UI buttons and output for a basic calculator app (although the planned application is much more complex). How would I begin to approach this?

I'm also looking at Electron as a possible solution. It seems like it is more geared towards what I want to do (render a UI with web technologies but without necessarily being connected to anything). However, we have some legacy c++ libraries that we need to integrate and I believe this would be easier with CEF than with Electron.

From looking around, it seems that CEF supports appcache for so-called "offline apps". However, I'm leery of using it because of the numerous problems it has. Also it seems like appcache is dying, so I'd rather not tie myself to that sinking ship anyways. Unfortunately service worker doesn't quite look ready for primetime either.

jtheis
  • 916
  • 3
  • 12
  • 28
  • It's possible. Either you can use a custom scheme factory and supply the resources yourself (basically map a some kind of rc://100 to a 100.html file), or load the HTMLs and supply them in-memory. – Cristian Amarie Oct 18 '16 at 21:54

1 Answers1

2

See the CEF General Usage guide under Request Handling for the two supported methods of dealing with custom requests.

https://bitbucket.org/chromiumembedded/cef/wiki/GeneralUsage.md#markdown-header-request-handling

What your looking for is indeed possible out of the box and relatively easy to implement. The cefclient example application has working examples.

https://bitbucket.org/chromiumembedded/cef/src/694b45717c971a0bb639f555b640d313fc15ccc8/tests/cefclient/?at=master

amaitland
  • 4,073
  • 3
  • 25
  • 63