How do I properly embed Chromium?

711 views
Skip to first unread message

Kevin Ingwersen

unread,
Apr 8, 2014, 2:07:50 PM4/8/14
to chromium-dev
Hey.

I am trying to wrap my head around how to embed Chromium into a project. From what I have learned from all the very well writtne docs, I know that I have to use a multi-process archivecture, of a Browser process and several render processes.

But what I do not understand is: When do I extend a class, and when do I just use an existing one? And, why are almost all methods „virtual“?

I am also searching for the classes that I need to use. So far, the only real starting point that I found was:

- BrowserMainParts
- content::ContentMain

I want to do the following things:

- Add a custom scheme to allow loading contents of an archive.
I.e.: app://appname/assets.zip/style.css
- Running a v8 thread from the browser’s process and make renderer v8 processes capable of speaking to this one (probably thru IPC, i guess)
- Catching URL requests on a custom scheme. if the extension matches a pattern (like „.os“), I wish to pre-process the file first with an embedded scripting language and then output the result in the browser.
- Use FLTK for the browser; so I need to know where and when I have to tell the browser window „where it belongs to“.
I.e.: myBrowserInstance->setWindow(…)
- Adding some v8 extensions into the renderer’s context (some other things to the global object).

To me, this sounds pretty basic. But these Chromium derived frameworks - CEF for example - don’t offer all the things I wish, especially the raw accessing of v8 instances.

Can somebody point me to where I have to look for? I am keeping my eyes wide open within the contents/public/ folder, as the documentation stated that everything relevant is here.

Kind regards, Ingwie.

Nico Weber

unread,
Apr 8, 2014, 2:10:00 PM4/8/14
to Ingwie Phoenix, chromium-dev
We don't support embedding chromium. Have you looked at https://code.google.com/p/chromiumembedded/ ?


On Tue, Apr 8, 2014 at 11:07 AM, Kevin Ingwersen <ingwi...@googlemail.com> wrote:
Hey.

I am trying to wrap my head around how to embed Chromium into a project. From what I have learned from all the very well writtne docs, I know that I have to use a multi-process archivecture, of a Browser process and several render processes.

But what I do not understand is: When do I extend a class, and when do I just use an existing one? And, why are almost all methods "virtual"?

I am also searching for the classes that I need to use. So far, the only real starting point that I found was:

- BrowserMainParts
- content::ContentMain

I want to do the following things:

- Add a custom scheme to allow loading contents of an archive.
        I.e.: app://appname/assets.zip/style.css
- Running a v8 thread from the browser's process and make renderer v8 processes capable of speaking to this one (probably thru IPC, i guess)
- Catching URL requests on a custom scheme. if the extension matches a pattern (like ".os"), I wish to pre-process the file first with an embedded scripting language and then output the result in the browser.
- Use FLTK for the browser; so I need to know where and when I have to tell the browser window "where it belongs to".
        I.e.: myBrowserInstance->setWindow(...)

- Adding some v8 extensions into the renderer's context (some other things to the global object).

To me, this sounds pretty basic. But these Chromium derived frameworks - CEF for example - don't offer all the things I wish, especially the raw accessing of v8 instances.

Can somebody point me to where I have to look for? I am keeping my eyes wide open within the contents/public/ folder, as the documentation stated that everything relevant is here.

Kind regards, Ingwie.

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
    http://groups.google.com/a/chromium.org/group/chromium-dev

Kevin Ingwersen

unread,
Apr 8, 2014, 2:27:00 PM4/8/14
to Nico Weber, chromium-dev
I did. But It does not satisfy what I need.
In the end I want to implement a patched version of nodejs, which will require actual v8 access. CEF abstracts this, which means I would have to re-write nodejs entirely…which is not exactly what I wanted.
Thus, I can’t launch a new „script thread“ with CEF. Sure, for anything else, such as the url handles and th elike, its exactly what I need. But for anything else, it’s not. Therefore I wanted to create my own layer ontop, similar to the Brightray project, and the Atom Framework, that do essentially something similar. But Brightray won’t build on mac, and Atom…well, its closed source.

Jeremy Roman

unread,
Apr 8, 2014, 2:53:42 PM4/8/14
to ingwi...@googlemail.com, Nico Weber, chromium-dev
You might also look at https://github.com/rogerwang/node-webkit. (Despite the name, I believe it is currently based on Chromium/Blink and not WebKit.)


Kevin Ingwersen

unread,
Apr 8, 2014, 2:57:56 PM4/8/14
to Jeremy Roman, Nico Weber, chromium-dev
I have seen node-webkit before, but it does not allow me to intercept requests and implement things such as custom routers from what I have seen at the times that I tried it. Besides, compiling it is kind of weird anyway o.o
Don’t worry, I have seen a bunch of alternatives, but the API that I am looking for seems to be highly unavailable :/

Awesomium - closed source, no way of creating a separate script thread
Berklium - Discontinued
node-webkit - No custom routing for schemes and file handling
CEF - explained in previous post

I have tried to integrate Gecko before, but its ultimatively harder to build than Chromium, or rather the library libchromiumcontent, found on github. Its much easier using a pre-compiled libchromiumcontent library and just build a layer ontop, than requiring a user to build a patched version of node-webkit, for example.

That is why I was asking for some advice on how I would integrate Chromium directly o.o

John Abd-El-Malek

unread,
Apr 8, 2014, 3:28:29 PM4/8/14
to ingwi...@googlemail.com, Jeremy Roman, Nico Weber, chromium-dev
You can look into embedding the content module, which is what CEF and other projects are built on. The code samples to look at would be content/shell, which is a simple embedder of the code (aside: also mixed in with layout tests, so just ignore the testrunner subdirectories). Once you have that basic part working, you can look at content/public to see how to get at the objects that you need, and also see how src/chrome does similar things by inspecting their usage of the API.

As Nico hints at, we only officially support Chrome's usage of the Content API. We make no guarantees about API stability, and in fact they're always changing. External projects like CEF provide a more stable API.


Kevin Ingwersen

unread,
Apr 8, 2014, 3:37:14 PM4/8/14
to John Abd-El-Malek, Jeremy Roman, Nico Weber, chromium-dev
Yeah, I was looking to learn more about the Content module, as it was stated in the public docs that this is a good point for embedding - and as stated in my first email, I have been lurking in contents/public/ for a while, but didn’t find a starting point - like, the parts that I needed to bring up a basic-basic browser.
Going to look into the content_shell to see how this works, for now.

bTW, is this here the right list to ask about things such as the Content API?

Kind regards, Ingwie

Kevin Ingwersen

unread,
Apr 8, 2014, 7:08:51 PM4/8/14
to John Abd-El-Malek, Jeremy Roman, Nico Weber, chromium-dev
There is a bunch of overrides like:

WebRTCPeerConnectionHandler*
ShellContentRendererClient::OverrideCreateWebRTCPeerConnectionHandler(…)

The contents pick up WebTestInterfaces. Other functions pick up similar things. Can I savely ignore them? I wish to use WebRTC in my project, so I am not sure if I have to override this method, or not?

Kind regards, Ingwie.
Am Di. Apr. 08 2014 21:28:29 schrieb John Abd-El-Malek:

John Abd-El-Malek

unread,
Apr 8, 2014, 8:24:45 PM4/8/14
to Kevin Ingwersen, Jeremy Roman, Nico Weber, chromium-dev
Yes, usually the overrides in content/shell are for test-specific behavior for layout tests. The intent with the content API is that all features work without the embedder having to do extra work.

Kevin Ingwersen

unread,
Apr 8, 2014, 8:41:47 PM4/8/14
to John Abd-El-Malek, Jeremy Roman, Nico Weber, chromium-dev
I just finished „studdying“ the source of Content Shell…and I must say, the Content API is very easy, once one has wrapped their head around it! I am just now filtering out which classes i very especially need to take care of, such as for v8 specific stuff, or for catching and modifying requests. And, I have to poke the GUI part a bit more, as the part at which the WebContents get feeded into a window got kind of lost for me x). But other than that, I am good to go.

Thanks for pointing out the Content Shell’s source! ^-^

Kevin Ingwersen

unread,
Apr 8, 2014, 8:46:38 PM4/8/14
to John Abd-El-Malek, Jeremy Roman, Nico Weber, chromium-dev
Found the part, but cant seem to find the coresponding parts:

  registrar_.Add(this, NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED,
      Source<WebContents>(web_contents));

What is that Source? o.o
Am Mi. Apr. 09 2014 02:24:45 schrieb John Abd-El-Malek:

Lei Zhang

unread,
Apr 8, 2014, 8:51:29 PM4/8/14
to Ingwie Phoenix, chromium-dev
Search for it on cs.chromium.org and you will quickly find the one
place that sends this particular notification.

On Tue, Apr 8, 2014 at 5:46 PM, Kevin Ingwersen
Reply all
Reply to author
Forward
0 new messages