Sunday, August 18, 2013

Chromium Embedded Framework 3 - Bare Bones

The CefClient

Your application's implementation of the CefClient class is a hook into a number of the lower level functions you need for the browser to interact with the display and for you to interact with the browser. It enables you to provide your own implementations for many things, such as a way to handle context menus, a way to handle Javascript dialogs, geolocation and others. Each "subsystem" (as I guess you'd call them) has its own handler that you can implement (such as CefGeolocationHandler for geolocation). Take a look at the ClientHandler class in the cefclient code that comes with the CEF source to see all your different options, as well as how to implement them. You don't need to provide an implementation of them by default, though. As long as you have a class that inherits from CefClient that implements CEF's handy reference counting (CefRefPtr) you're good to go. There's a default implementation built-in for many of the systems and the ones that don't have one aren't required for a minimal implementation.

Instead of explaining the bare bones implementation of the CefClient line by line, here's the full implementation since it's so basic:


#include "include/cef_client.h"

class BareBonesHandler : public CefClient {

  BareBonesHandler() { }
  ~BareBonesHandler() { }

  // Note that any of the IMPLEMENT_WHATEVER
  // macros that come with CEF can (and do) set
  // access modifiers, so you'll want them after
  // everything else in your class or you may be
  // in for a surprise when the access of a member
  // isn't what you expect it to be!