#ifndef _ClinetHandler_h #define _ClinetHandler_h #include #undef LOG #undef DLOG #undef CHECK #undef LOG_INFO #undef LOG_WARNING #undef ITEM #include "include/cef_client.h" #include "include/cef_version.h" #ifndef CHROME_VERSION_BUILD #error "Unknown CEF version" #endif class ClientHandler : public CefClient, public CefLifeSpanHandler, public CefDisplayHandler, public CefLoadHandler, public CefFocusHandler, public CefContextMenuHandler, public CefJSDialogHandler { public: ClientHandler( Upp::Callback1 & wuc, Upp::Callback2 > > & wm, Upp::Callback & tf, Upp::Callback1 & wk, Upp::Callback3 & wcm): browser(NULL), WhenUrlChange(wuc), WhenMessage(wm), WhenTakeFocus(tf), WhenKeyboard(wk), WhenConsoleMessage(wcm) { } ~ClientHandler() { } Upp::Callback1 & WhenUrlChange; Upp::Callback2 > > & WhenMessage; Upp::Callback & WhenTakeFocus; Upp::Callback1 & WhenKeyboard; Upp::Callback3 & WhenConsoleMessage; virtual CefRefPtr GetLifeSpanHandler() OVERRIDE { return this; } virtual CefRefPtr GetDisplayHandler() OVERRIDE { return this; } virtual CefRefPtr GetFocusHandler() OVERRIDE { return this; } // virtual CefRefPtr GetLoadHandler() OVERRIDE { return this; } virtual CefRefPtr GetContextMenuHandler() OVERRIDE { return this; } virtual CefRefPtr GetJSDialogHandler() OVERRIDE { return this; } #if (CHROME_VERSION_BUILD >= 2357) virtual bool OnBeforePopup(CefRefPtr browser, CefRefPtr frame, const CefString& target_url, const CefString& target_frame_name, WindowOpenDisposition target_disposition, bool user_gesture, const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo, CefRefPtr& client, CefBrowserSettings& settings, bool* no_javascript_access) OVERRIDE; #else virtual bool OnBeforePopup(CefRefPtr browser, CefRefPtr frame, const CefString& target_url, const CefString& target_frame_name, const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo, CefRefPtr& client, CefBrowserSettings& settings, bool* no_javascript_access) OVERRIDE; #endif virtual void OnLoadError(CefRefPtr browser, CefRefPtr frame, ErrorCode errorCode, const CefString& errorText, const CefString& failedUrl) OVERRIDE; virtual void OnAfterCreated(CefRefPtr browser) OVERRIDE; virtual void OnAddressChange(CefRefPtr browser, CefRefPtr frame, const CefString& url) OVERRIDE; virtual bool OnConsoleMessage(CefRefPtr browser, const CefString& message, const CefString& source, int line) OVERRIDE; virtual bool OnProcessMessageReceived(CefRefPtr browser, CefProcessId source_process, CefRefPtr message) OVERRIDE; virtual void OnTakeFocus( CefRefPtr browser, bool next ) OVERRIDE; virtual void OnBeforeContextMenu(CefRefPtr browser, CefRefPtr frame, CefRefPtr params, CefRefPtr model) OVERRIDE; virtual bool OnJSDialog(CefRefPtr browser, const CefString& origin_url, const CefString& accept_lang, JSDialogType dialog_type, const CefString& message_text, const CefString& default_prompt_text, CefRefPtr callback, bool& suppress_message) OVERRIDE; CefRefPtr GetBrowser() { return browser; } protected: // The child browser window CefRefPtr browser; // 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! IMPLEMENT_REFCOUNTING(ClientHandler); }; #endif