#ifndef ATOM_CEF_CLIENT_H_ #define ATOM_CEF_CLIENT_H_ #pragma once #include #include #include "include/cef_client.h" class AtomCefClient : public CefClient, public CefContextMenuHandler, public CefDisplayHandler, public CefJSDialogHandler, public CefKeyboardHandler, public CefLifeSpanHandler, public CefLoadHandler, public CefRequestHandler { public: AtomCefClient(); virtual ~AtomCefClient(); CefRefPtr GetBrowser() { return m_Browser; } virtual CefRefPtr GetContextMenuHandler() OVERRIDE { return this; } virtual CefRefPtr GetDisplayHandler() OVERRIDE { return this; } virtual CefRefPtr GetJSDialogHandler() { return this; } virtual CefRefPtr GetKeyboardHandler() OVERRIDE { return this; } virtual CefRefPtr GetLifeSpanHandler() OVERRIDE { return this; } virtual CefRefPtr GetLoadHandler() OVERRIDE { return this; } virtual CefRefPtr GetRequestHandler() OVERRIDE { return this; } virtual bool OnProcessMessageReceived(CefRefPtr browser, CefProcessId source_process, CefRefPtr message) OVERRIDE; // CefContextMenuHandler methods virtual void OnBeforeContextMenu(CefRefPtr browser, CefRefPtr frame, CefRefPtr params, CefRefPtr model) OVERRIDE; virtual bool OnContextMenuCommand(CefRefPtr browser, CefRefPtr frame, CefRefPtr params, int command_id, EventFlags event_flags) OVERRIDE; // CefDisplayHandler methods virtual bool OnConsoleMessage(CefRefPtr browser, const CefString& message, const CefString& source, int line) OVERRIDE; virtual void OnTitleChange(CefRefPtr browser, const CefString& title) OVERRIDE; // CefJsDialogHandlerMethods virtual bool OnBeforeUnloadDialog(CefRefPtr browser, const CefString& message_text, bool is_reload, CefRefPtr callback) { callback->Continue(true, ""); return true; } // CefKeyboardHandler methods virtual bool OnKeyEvent(CefRefPtr browser, const CefKeyEvent& event, CefEventHandle os_event) OVERRIDE; // CefLifeSpanHandler methods virtual void OnAfterCreated(CefRefPtr browser) OVERRIDE; virtual void OnBeforeClose(CefRefPtr browser) OVERRIDE; // CefLoadHandler methods virtual void OnLoadError(CefRefPtr browser, CefRefPtr frame, ErrorCode errorCode, const CefString& errorText, const CefString& failedUrl) OVERRIDE; protected: CefRefPtr m_Browser; void FocusNextWindow(); void Open(std::string path); void Open(); void NewWindow(); void ToggleDevTools(CefRefPtr browser); void ShowDevTools(CefRefPtr browser); void Confirm(int replyId, std::string message, std::string detailedMessage, std::vector buttonLabels, CefRefPtr browser); void ShowSaveDialog(int replyId, CefRefPtr browser); CefRefPtr CreateReplyDescriptor(int replyId, int callbackIndex); void Exit(int status); void Log(const char *message); IMPLEMENT_REFCOUNTING(AtomCefClient); IMPLEMENT_LOCKING(AtomCefClient); }; #endif