pulsar/native/atom_cef_client.h

108 lines
3.7 KiB
C
Raw Normal View History

2012-08-10 23:32:19 +04:00
// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#ifndef CEF_TESTS_CEFCLIENT_CLIENT_HANDLER_H_
#define CEF_TESTS_CEFCLIENT_CLIENT_HANDLER_H_
#pragma once
#include <set>
#include <string>
#include "include/cef_client.h"
2012-08-28 00:21:59 +04:00
#include "native/util.h"
2012-08-10 23:32:19 +04:00
// AtomCefClient implementation.
class AtomCefClient : public CefClient,
2012-08-10 23:32:19 +04:00
public CefContextMenuHandler,
public CefDisplayHandler,
public CefJSDialogHandler,
2012-08-10 23:32:19 +04:00
public CefKeyboardHandler,
public CefLifeSpanHandler,
public CefLoadHandler,
public CefRequestHandler {
public:
AtomCefClient();
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-23 02:29:39 +04:00
virtual CefRefPtr<CefContextMenuHandler> GetContextMenuHandler() OVERRIDE {
return this;
}
virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() OVERRIDE {
return this;
}
virtual CefRefPtr<CefJSDialogHandler> GetJSDialogHandler() {
return this;
}
2012-08-23 02:29:39 +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-10 23:32:19 +04:00
// CefContextMenuHandler methods
2012-08-22 04:22:43 +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;
// CefJsDialogHandlerMethods
virtual bool OnBeforeUnloadDialog(CefRefPtr<CefBrowser> browser,
const CefString& message_text,
bool is_reload,
CefRefPtr<CefJSDialogCallback> callback) {
callback->Continue(true, "");
return true;
}
// CefKeyboardHandler methods
virtual bool OnKeyEvent(CefRefPtr<CefBrowser> browser,
const CefKeyEvent& event,
CefEventHandle os_event) OVERRIDE;
2012-08-10 23:32:19 +04:00
// CefLifeSpanHandler methods
virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
// CefLoadHandler methods
2012-08-22 04:22:43 +04:00
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
2012-08-10 23:32:19 +04:00
virtual void OnLoadError(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
ErrorCode errorCode,
const CefString& errorText,
const CefString& failedUrl) OVERRIDE;
protected:
2012-08-22 04:22:43 +04:00
CefRefPtr<CefBrowser> m_Browser;
2012-08-10 23:32:19 +04:00
2012-08-22 04:22:43 +04:00
void ShowDevTools(CefRefPtr<CefBrowser> browser);
IMPLEMENT_REFCOUNTING(AtomCefClient);
IMPLEMENT_LOCKING(AtomCefClient);
2012-08-10 23:32:19 +04:00
};
#endif // CEF_TESTS_CEFCLIENT_CLIENT_HANDLER_H_