CEF2 Development Status

Do not post support requests, bug reports or feature requests. Discuss CEF here. Non-CEF related discussion goes in General Discussion!

CEF2 Development Status

Postby magreenblatt » Tue Jun 01, 2010 12:28 pm

Hi All,

It's been 6 months since I announced CEF2. I appreciate the patience of those of you waiting for CEF2's release and I think it's time to give a progress report on where development stands. To review, there are two steps that I am seeking to complete before making CEF2 development public.

1. Implement something similar to http://codereview.chromium.org/10973/show for Chromium trunk that allows the hosting of Chromium windows in separate applications.


Step 1 is complete. The below screen shots show CEF2 embedding Chromium using a variety of different configurations controlled by command-line arguments. The ability to control Chromium behavior using command-line arguments is important and will be supported by the CEF2 API.

http://www.magpcss.com/pub/cef2_screen1.png
http://www.magpcss.com/pub/cef2_screen2.png
http://www.magpcss.com/pub/cef2_screen3.png

2. Implement a replacement for the existing CEF DLL that interfaces with 1 using an IPC layer and supports the basic CEF functionality. The existing CEF interfaces may be modified slightly to support the concept of multiple tabs.


Step 2 is about halfway complete. The implementation is internally composed of two parts: the CEF2 host layer which exists inside the libcef2 library and the CEF2 browser layer which is compiled as part of Chromium. These two layers communicate with each other via IPC, with CEF2 acting as the server and Chromium acting as the client.

The CEF2 host layer provides two main classes: CefThread (similar to Chromium's ChromeThread class) and CefNotificationService (similar to Chromium's NotificationService class). CefThread manages IO, PROCESS and UI threads. The IO thread is used for IPC communication, the PROCESS thread is used for launching Chromium sub-processes, and the UI thread is used for user interface integration. The UI thread can run separately or can be integrated with the main application message loop as with the current version of CEF. The CefNotificationService, which exists on a per-thread basis, allows consumers of certain event types to register and be notified when an event occurs.

The CEF2 browser layer running in Chromium associates the CEF2 IPC connection, the identifier for which is passed in as a command-line argument, with both the Chromium Profile and the Chromium Browser objects. It is possible for CEF2 to control multiple Chromium processes and browser windows, both embedded and framed, from a single client application. Chromium uses the user profile path to uniquely identify a browser process and so CEF2 follows the same approach. If two separate CEF2 client applications launch Chromium with the same user profile path then those applications will share a single Chromium browser process.

Internal implementation details have by necessity become more complex then with the current version of CEF. Consider, for instance, the CefHandler::HandleBeforeMenu() callback that is currently part of CEF. This method gives the application the option to substitute a custom context menu for the default Chromium context menu. With CEF2 the internal implementation of this callback will work as follows:

1. The CEF2 browser layer is notified by Chromium that the user wishes to show a context menu.
2. The CEF2 browser layer sends an IPC message to the CEF2 host layer which receives the message on the IO thread.
3. The IO thread IPC message handler proxies the message to the UI thread.
4. The UI thread broadcasts the context menu request using the notification service.
5. The CEF2 handler object, which is associated at one end with the client application's handler and at the other end with the source Chromium profile/window, receives the context menu notification and forwards it via the CEF2 API to the client application.
6. The client application performs the desired behavior and returns a response.
7. The CEF2 handler object proxies the response back to the IO thread.
8. The IO thread sends the response as an IPC message to the CEF2 browser layer.
9. The required action, if any, is executed by Chromium.

One driving principal of Chromium design is that all actions should be executed asynchronously if possible. Consequently the CEF2 implementation will make every effort to provide control capabilities in an asynchronous manner. For instance, methods like CefTab::CanGoBack() will be implemented internally by CEF2 as callbacks that are notified when the history state has changed. When the client calls CefTab::CanGoBack() they will be retrieving stored state information instead of initiating additional traffic over the IPC layer.

The API structure for CEF2 is still under consideration, but current development indicates that it will look something like this:

  • Call CefInitialize and CefShutdown to initialize and shutdown CEF2, respectively. Calling CefShutdown will reset all state information such that calling CefInitialize again will behave as expected.
  • The top-level API class for CEF2 will be CefProfile. CefProfile objects represent a single instance of the Chromium browser process. CefProfile will provide one or more methods for creating a new CefBrowser based on a combination of window placement and command-line information.
  • CefBrowser objects will support multiple CefTab objects if the browser is created in standard mode, or a single CefTab object if the browser is created in app mode. CefTab objects can be created and destroyed using methods provided by the parent CefBrowser object.
  • CefTab objects will support multiple CefFrame objects.

Instead of continuing the existing CEF approach of providing a single CefHandler class implementation for each CefBrowser it may make more sense to extend the notification service concept for use by the client application. For instance, staying with the CefHandler::HandleBeforeMenu() example, CEF2 might instead implement special handling behavior with an approach like the following:

1. The CEF2 API defines a handler interface:

Code: Select all
class CefHandlerBeforeMenu
{
public:
  virtual RetVal HandleBeforeMenu(CefRefPtr<CefBrowser> browser,
                                  const MenuInfo& menuInfo) =0;
};


2. The CEF2 client implements one or more interfaces in a class:

Code: Select all
class MyHandlerBeforeMenu : public CefHandlerBeforeMenu
{
  virtual RetVal HandleBeforeMenu(CefRefPtr<CefBrowser> browser,
                                  const MenuInfo& menuInfo) {
    // Do something here
    return RV_HANDLED;
  }
};


3. The CEF2 client registers their handler with the CefBrowser object that they want to control.

Code: Select all
browser->AddHandlerBeforeMenu(new MyHandlerBeforeMenu);


This approach has a number of advantages over the existing single-handler-class approach.

1. The client only needs to implement the handlers they're interested in, and only the interested handlers are actually called.
2. Multiple handlers for each event type can be supported.
3. Handlers can potentially be registered at different granularity levels (register at the CefProfile level to handle events for all CefBrowser objects owned by that profile, register at the CefBrowser level to handle events for all CefTab objects owned by that browser, etc).

Regards,
Marshall
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: CEF2 Development Status

Postby lodle » Thu Jun 03, 2010 2:45 am

Looking good. Will we still be able to extend v8?
lodle
Techie
 
Posts: 32
Joined: Tue Jun 01, 2010 4:36 am

Re: CEF2 Development Status

Postby magreenblatt » Thu Jun 03, 2010 11:48 am

Will we still be able to extend v8?

Yes, but the architectural differences between CEF2 and CEF1 will necessitate a slightly different approach to V8 extension writing. Recall that a V8 extension is currently composed of two parts -- a text-based JavaScript portion that defines the extension API, and native methods that are implemented by the CEF client. With Chromium's multi-process architecture V8 extensions run within the WebKit renderer process. Existing Chromium V8 extensions such as chrome.bookmarks provide fixed JavaScript API bindings that support limited communication between the renderer process and the browser process. CEF2 will likely follow a similar approach by exposing a fixed JavaScript API that provides a limited communication capability between scripts running in the renderer process and the CEF2 client. The CEF2 client would then implement the text-based JavaScript portion that defines their custom extension API as a wrapper around the fixed CEF2 JavaScript API.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: CEF2 Development Status

Postby heshiming » Sat Jun 05, 2010 1:09 am

Hi Marshall, Thanks for the work, it's looking real good. I've got couple questions:

1. How much modification is done to chromium itself? Ideally, the CEF2 host and browser layer runs without modifications to chromium at all, is this possible?
2. Is CEF2 still going to support things like a custom scheme handler? This should require modification to chromium right?
3. Will it be possible for CEF2 to spawn existing installation of Google Chrome on user's computer?

I've seen the "Gmail App" in "Google Packs". It's a pretty small app using the existing installation of Google Chrome. I'm wondering how this is done. It seems to me that Chrome already has this framework for reusing.
heshiming
Techie
 
Posts: 29
Joined: Fri Jul 31, 2009 1:59 am

Re: CEF2 Development Status

Postby magreenblatt » Sun Jun 06, 2010 1:56 pm

Ideally, the CEF2 host and browser layer runs without modifications to chromium at all, is this possible?


It will not be possible to use CEF2 with an unmodified distribution of Chromium. However, it will be possible to use the default Chromium installer and then substitute modified versions of chrome.dll and chrome.exe that have CEF2 support enabled -- this will likely be the approach used for the CEF2 binary distribution.

Is CEF2 still going to support things like a custom scheme handler?


Custom scheme handlers will eventually be supported. All network requests are currently handled by the Chromium browser process so forwarding those requests to the CEF2 client should be relatively straight forward.

How much modification is done to chromium itself?


So far, the modifications to Chromium source code have been relatively small (about 50kb in patches). As the amount of CEF2 functionality increases the extent of the Chromium source code modifications is also likely to increase. At a basic level, the modifications to Chromium fall into two general categories.

1. Support for creating the Chromium browser window as a child of another window. This category requires minor changes to browser window creation and UI layout and rendering. For example, on Windows systems supporting the Aero desktop, Chromium applies transparency behind the tab strip. This behavior is not desirable with child browser windows.

2. Support for reporting and controlling Chromium behavior. This category involves integration of CEF2 with the user profile object for IPC support, and the introduction of CEF2 notification observers and/or callback hooks. This functionality needs to be linked into chrome.dll, but much of it, including support for custom scheme handlers, can likely be accomplished without further modifications to the Chromium source code.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: CEF2 Development Status

Postby magreenblatt » Sun Jun 06, 2010 2:43 pm

I've seen the "Gmail App" in "Google Packs". It's a pretty small app using the existing installation of Google Chrome. I'm wondering how this is done. It seems to me that Chrome already has this framework for reusing.

I haven't tried it myself, but if it uses the existing Google Chrome installation then it likely runs in app mode and utilizes HTML5 and/or extension capabilities. App (and kiosk) modes are effectively the same as running Chrome normally but without the standard browser UI controls. Chrome Frame supports embedding Chrome in other native applications but it's aimed primarily at other browsers, the interface for native applications is complex, and it exposes only very basic navigational controls to the hosting application. CEF2 will support all of the normal Chrome capabilities and, in addition, integrate closely with the native hosting application.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: CEF2 Development Status

Postby magreenblatt » Fri Jul 09, 2010 9:23 pm

The initial version of CEF2 is now available from SVN. It's currently based on Chromium rev 46337.

To build CEF2:

1. Set up your build environment as described in the "Source Distributions" section of the CEF project summary page.
2. Download the branches/cef2 directory from SVN.
3. Run the cef2_create_projects.bat script. This will integrate CEF2 with the Chromium build environment.
4. Open the chrome/chrome.sln solution file in Visual Studio.
5. Right-click on the "chrome" project and select "Build" to build the Chromium component of CEF2.
6. Right-click on the "cefclient" project and select "Build" to build the libcef2 and cefclient components of CEF2.
7. Run the cefclient application.

The API for CEF2 can be viewed here:
http://chromiumembedded.googlecode.com/ ... ude/cef2.h

Regards,
Marshall
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: CEF2 Development Status

Postby lodle » Sun Jul 11, 2010 10:32 pm

Are you sure its version 46337? As the patching process all ways fails for me.
lodle
Techie
 
Posts: 32
Joined: Tue Jun 01, 2010 4:36 am

Re: CEF2 Development Status

Postby magreenblatt » Mon Jul 12, 2010 8:38 am

Are you sure its version 46337? As the patching process all ways fails for me.

If you look in the patch files you'll see that they say "revision 46337" :-). Try running gclient sync again just in case it didn't succeed the first time.

Code: Select all
gclient sync --revision src@46337 --force

It could also potentially be a problem with the patch script. Have you tried applying the patches yourself using a merge program?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: CEF2 Development Status

Postby lodle » Mon Jul 12, 2010 8:53 am

I did a svn revert and tried again and still no go. I manually tried to make the changes but some are to different for it to work.
lodle
Techie
 
Posts: 32
Joined: Tue Jun 01, 2010 4:36 am

Next

Return to CEF Discussion

Who is online

Users browsing this forum: No registered users and 153 guests