#ifndef CLIENT_HANDLER_H_ #define CLIENT_HANDLER_H_ #pragma once #include #include #include "include/cef_client.h" #include "util.h" #include "native_handler.h" // ClientHandler implementation. class ClientHandler: public CefClient, public CefLifeSpanHandler, public CefLoadHandler, public CefDisplayHandler, public CefFocusHandler, public CefKeyboardHandler, public CefPrintHandler, public CefV8ContextHandler, public CefDragHandler { public: ClientHandler(); virtual ~ClientHandler(); // CefClient methods virtual CefRefPtr GetLifeSpanHandler() OVERRIDE { return this; } virtual CefRefPtr GetLoadHandler() OVERRIDE { return this; } virtual CefRefPtr GetDisplayHandler() OVERRIDE { return this; } virtual CefRefPtr GetFocusHandler() OVERRIDE { return this; } virtual CefRefPtr GetKeyboardHandler() OVERRIDE { return this; } virtual CefRefPtr GetPrintHandler() OVERRIDE { return this; } virtual CefRefPtr GetV8ContextHandler() OVERRIDE { return this; } virtual CefRefPtr GetDragHandler() OVERRIDE { return this; } // CefLifeSpanHandler methods virtual bool OnBeforePopup(CefRefPtr parentBrowser, const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo, const CefString& url, CefRefPtr& client, CefBrowserSettings& settings) OVERRIDE; virtual void OnAfterCreated(CefRefPtr browser) OVERRIDE; virtual bool DoClose(CefRefPtr browser) OVERRIDE; virtual void OnBeforeClose(CefRefPtr browser) OVERRIDE; // CefLoadHandler methods virtual void OnLoadStart(CefRefPtr browser, CefRefPtr frame) OVERRIDE; virtual void OnLoadEnd(CefRefPtr browser, CefRefPtr frame, int httpStatusCode) OVERRIDE; virtual bool OnLoadError(CefRefPtr browser, CefRefPtr frame, ErrorCode errorCode, const CefString& failedUrl, CefString& errorText) OVERRIDE; // CefDisplayHandler methods virtual void OnNavStateChange(CefRefPtr browser, bool canGoBack, bool canGoForward) OVERRIDE; virtual void OnAddressChange(CefRefPtr browser, CefRefPtr frame, const CefString& url) OVERRIDE; virtual void OnTitleChange(CefRefPtr browser, const CefString& title) OVERRIDE; virtual bool OnConsoleMessage(CefRefPtr browser, const CefString& message, const CefString& source, int line) OVERRIDE; // CefFocusHandler methods. virtual void OnFocusedNodeChanged(CefRefPtr browser, CefRefPtr frame, CefRefPtr node) OVERRIDE; // CefKeyboardHandler methods. virtual bool OnKeyEvent(CefRefPtr browser, KeyEventType type, int code, int modifiers, bool isSystemKey, bool isAfterJavaScript) OVERRIDE; // CefPrintHandler methods. virtual bool GetPrintHeaderFooter(CefRefPtr browser, CefRefPtr frame, const CefPrintInfo& printInfo, const CefString& url, const CefString& title, int currentPage, int maxPages, CefString& topLeft, CefString& topCenter, CefString& topRight, CefString& bottomLeft, CefString& bottomCenter, CefString& bottomRight) OVERRIDE; // CefV8ContextHandler methods virtual void OnContextCreated(CefRefPtr browser, CefRefPtr frame, CefRefPtr context) OVERRIDE; // CefDragHandler methods. virtual bool OnDragStart(CefRefPtr browser, CefRefPtr dragData, DragOperationsMask mask) OVERRIDE; virtual bool OnDragEnter(CefRefPtr browser, CefRefPtr dragData, DragOperationsMask mask) OVERRIDE; void SetWindow(GtkWidget* window); void SetMainHwnd(CefWindowHandle hwnd); CefWindowHandle GetMainHwnd() { return m_MainHwnd; } void SetEditHwnd(CefWindowHandle hwnd); CefRefPtr GetBrowser() { return m_Browser; } CefWindowHandle GetBrowserHwnd() { return m_BrowserHwnd; } enum NotificationType { NOTIFY_CONSOLE_MESSAGE }; void SendNotification(NotificationType type); void CloseMainWindow(); protected: GtkWidget* window; CefRefPtr m_nativeHandler; // The child browser window CefRefPtr m_Browser; // The main frame window handle CefWindowHandle m_MainHwnd; // The child browser window handle CefWindowHandle m_BrowserHwnd; // The edit window handle CefWindowHandle m_EditHwnd; // Support for logging. std::string m_LogFile; // Include the default reference counting implementation. IMPLEMENT_REFCOUNTING(ClientHandler) ; // Include the default locking implementation. IMPLEMENT_LOCKING(ClientHandler) ; }; #endif