2012-08-30 20:11:01 +04:00
|
|
|
#ifndef ATOM_CEF_CLIENT_H_
|
|
|
|
#define ATOM_CEF_CLIENT_H_
|
2012-08-10 23:32:19 +04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <set>
|
|
|
|
#include <string>
|
|
|
|
#include "include/cef_client.h"
|
|
|
|
|
2012-08-25 21:17:47 +04:00
|
|
|
class AtomCefClient : public CefClient,
|
2012-08-10 23:32:19 +04:00
|
|
|
public CefContextMenuHandler,
|
|
|
|
public CefDisplayHandler,
|
2012-08-28 19:01:00 +04:00
|
|
|
public CefJSDialogHandler,
|
2012-08-10 23:32:19 +04:00
|
|
|
public CefKeyboardHandler,
|
|
|
|
public CefLifeSpanHandler,
|
|
|
|
public CefLoadHandler,
|
|
|
|
public CefRequestHandler {
|
|
|
|
public:
|
2012-08-25 21:17:47 +04:00
|
|
|
AtomCefClient();
|
2012-10-29 21:44:56 +04:00
|
|
|
AtomCefClient(bool handlePasteboardCommands);
|
2012-08-25 21:17:47 +04:00
|
|
|
virtual ~AtomCefClient();
|
2012-08-10 23:32:19 +04:00
|
|
|
|
2012-08-22 04:22:43 +04:00
|
|
|
CefRefPtr<CefBrowser> GetBrowser() { return m_Browser; }
|
2012-08-28 20:58:24 +04:00
|
|
|
|
|
|
|
virtual CefRefPtr<CefContextMenuHandler> GetContextMenuHandler() OVERRIDE {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() OVERRIDE {
|
|
|
|
return this;
|
|
|
|
}
|
2012-08-28 19:01:00 +04:00
|
|
|
virtual CefRefPtr<CefJSDialogHandler> GetJSDialogHandler() {
|
|
|
|
return this;
|
|
|
|
}
|
2012-08-28 20:58:24 +04:00
|
|
|
virtual CefRefPtr<CefKeyboardHandler> GetKeyboardHandler() OVERRIDE {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
virtual CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() OVERRIDE {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
virtual CefRefPtr<CefLoadHandler> GetLoadHandler() OVERRIDE {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
virtual CefRefPtr<CefRequestHandler> GetRequestHandler() OVERRIDE {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2012-08-28 20:08:50 +04:00
|
|
|
virtual bool OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefProcessId source_process,
|
|
|
|
CefRefPtr<CefProcessMessage> message) OVERRIDE;
|
|
|
|
|
2012-08-28 20:58:24 +04:00
|
|
|
|
2012-08-10 23:32:19 +04:00
|
|
|
// CefContextMenuHandler methods
|
2012-08-28 20:58:24 +04:00
|
|
|
virtual void OnBeforeContextMenu(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame,
|
|
|
|
CefRefPtr<CefContextMenuParams> params,
|
|
|
|
CefRefPtr<CefMenuModel> model) OVERRIDE;
|
|
|
|
|
2012-08-10 23:32:19 +04:00
|
|
|
virtual bool OnContextMenuCommand(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame,
|
|
|
|
CefRefPtr<CefContextMenuParams> params,
|
|
|
|
int command_id,
|
|
|
|
EventFlags event_flags) OVERRIDE;
|
|
|
|
|
|
|
|
// CefDisplayHandler methods
|
|
|
|
virtual bool OnConsoleMessage(CefRefPtr<CefBrowser> browser,
|
|
|
|
const CefString& message,
|
|
|
|
const CefString& source,
|
|
|
|
int line) OVERRIDE;
|
|
|
|
|
2012-08-31 03:42:53 +04:00
|
|
|
virtual void OnTitleChange(CefRefPtr<CefBrowser> browser,
|
|
|
|
const CefString& title) OVERRIDE;
|
2012-08-10 23:32:19 +04:00
|
|
|
|
2012-08-28 19:01:00 +04:00
|
|
|
// CefJsDialogHandlerMethods
|
|
|
|
virtual bool OnBeforeUnloadDialog(CefRefPtr<CefBrowser> browser,
|
|
|
|
const CefString& message_text,
|
|
|
|
bool is_reload,
|
|
|
|
CefRefPtr<CefJSDialogCallback> callback) {
|
|
|
|
callback->Continue(true, "");
|
|
|
|
return true;
|
|
|
|
}
|
2012-08-28 20:58:24 +04:00
|
|
|
|
2012-08-28 03:39:12 +04:00
|
|
|
// CefKeyboardHandler methods
|
|
|
|
virtual bool OnKeyEvent(CefRefPtr<CefBrowser> browser,
|
|
|
|
const CefKeyEvent& event,
|
|
|
|
CefEventHandle os_event) OVERRIDE;
|
2012-08-28 20:58:24 +04:00
|
|
|
|
2012-08-10 23:32:19 +04:00
|
|
|
// CefLifeSpanHandler methods
|
2012-08-29 01:05:00 +04:00
|
|
|
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
2012-08-10 23:32:19 +04:00
|
|
|
virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
2012-08-30 03:31:49 +04:00
|
|
|
|
2012-08-10 23:32:19 +04:00
|
|
|
|
|
|
|
// CefLoadHandler methods
|
|
|
|
virtual void OnLoadError(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame,
|
|
|
|
ErrorCode errorCode,
|
|
|
|
const CefString& errorText,
|
|
|
|
const CefString& failedUrl) OVERRIDE;
|
|
|
|
|
2012-10-31 21:39:58 +04:00
|
|
|
void BeginTracing();
|
|
|
|
void EndTracing();
|
|
|
|
|
|
|
|
bool Save(const std::string& path, const std::string& data);
|
|
|
|
|
2012-08-10 23:32:19 +04:00
|
|
|
protected:
|
2012-08-28 20:58:24 +04:00
|
|
|
CefRefPtr<CefBrowser> m_Browser;
|
2012-10-29 21:44:56 +04:00
|
|
|
bool m_HandlePasteboardCommands = false;
|
2012-08-28 20:58:24 +04:00
|
|
|
|
2012-09-25 02:27:42 +04:00
|
|
|
void FocusNextWindow();
|
2012-08-28 20:08:50 +04:00
|
|
|
void Open(std::string path);
|
2012-08-28 22:54:44 +04:00
|
|
|
void Open();
|
2012-11-09 21:17:52 +04:00
|
|
|
void OpenUnstable(std::string path);
|
|
|
|
|
|
|
|
void OpenUnstable();
|
2012-08-29 04:04:56 +04:00
|
|
|
void NewWindow();
|
2012-08-30 21:24:01 +04:00
|
|
|
void ToggleDevTools(CefRefPtr<CefBrowser> browser);
|
|
|
|
void ShowDevTools(CefRefPtr<CefBrowser> browser);
|
2012-08-30 03:31:49 +04:00
|
|
|
void Confirm(int replyId,
|
|
|
|
std::string message,
|
|
|
|
std::string detailedMessage,
|
|
|
|
std::vector<std::string> buttonLabels,
|
|
|
|
CefRefPtr<CefBrowser> browser);
|
2012-08-30 20:52:35 +04:00
|
|
|
void ShowSaveDialog(int replyId, CefRefPtr<CefBrowser> browser);
|
|
|
|
CefRefPtr<CefListValue> CreateReplyDescriptor(int replyId, int callbackIndex);
|
2012-08-31 20:15:12 +04:00
|
|
|
void Exit(int status);
|
2012-09-21 02:26:26 +04:00
|
|
|
void Log(const char *message);
|
2012-08-28 20:58:24 +04:00
|
|
|
|
2012-08-25 21:17:47 +04:00
|
|
|
IMPLEMENT_REFCOUNTING(AtomCefClient);
|
|
|
|
IMPLEMENT_LOCKING(AtomCefClient);
|
2012-08-10 23:32:19 +04:00
|
|
|
};
|
|
|
|
|
2012-08-30 20:11:01 +04:00
|
|
|
#endif
|