Commit 3cfcb534 authored by Callum Linden's avatar Callum Linden

Source drop of Dullahan 1.3.x that is compatible with CEF 76 and supports the...

Source drop of Dullahan 1.3.x that is compatible with CEF 76 and supports the new builds of Chromium/CEF with media codecs

--HG--
branch : vendor
parent 4ea3754d
......@@ -6,6 +6,10 @@
build/
build64/
# CEF builds folder
./cef/*
!cef/README.md
glob:*.wwdb
# misc files
......
......@@ -123,8 +123,6 @@ add_library(
src/dullahan_browser_client.h
src/dullahan_callback_manager.cpp
src/dullahan_callback_manager.h
src/dullahan_context_handler.cpp
src/dullahan_context_handler.h
src/dullahan_debug.h
src/dullahan_impl.cpp
src/dullahan_impl.h
......@@ -150,16 +148,27 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
endif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
################################################################################
## parse CEF version header and process into dullahan header
FILE(STRINGS ${CEF_INCLUDE_DIR}/cef_version.h CEF_VERSION_STR REGEX "\#define CEF_VERSION ")
FILE(STRINGS ${CEF_INCLUDE_DIR}/cef_version.h CHROME_VERSION_MAJOR_STR REGEX "\#define CHROME_VERSION_MAJOR ")
FILE(STRINGS ${CEF_INCLUDE_DIR}/cef_version.h CHROME_VERSION_MINOR_STR REGEX "\#define CHROME_VERSION_MINOR ")
FILE(STRINGS ${CEF_INCLUDE_DIR}/cef_version.h CHROME_VERSION_BUILD_STR REGEX "\#define CHROME_VERSION_BUILD ")
FILE(STRINGS ${CEF_INCLUDE_DIR}/cef_version.h CHROME_VERSION_PATCH_STR REGEX "\#define CHROME_VERSION_PATCH ")
CONFIGURE_FILE (
"${PROJECT_SOURCE_DIR}/src/dullahan_version.h.in"
"${PROJECT_SOURCE_DIR}/src/dullahan_version.h"
)
## Parse CEF version header and process into dullahan header.
## Only do this if it's a clean build (try to keep version/build number
## the same for the same set of source files)
if (NOT EXISTS "${PROJECT_SOURCE_DIR}/src/dullahan_version.h")
# Extract CEF/Chrome version info from CEF header
FILE(STRINGS ${CEF_INCLUDE_DIR}/cef_version.h CEF_VERSION_STR REGEX "\#define CEF_VERSION ")
FILE(STRINGS ${CEF_INCLUDE_DIR}/cef_version.h CHROME_VERSION_MAJOR_STR REGEX "\#define CHROME_VERSION_MAJOR ")
FILE(STRINGS ${CEF_INCLUDE_DIR}/cef_version.h CHROME_VERSION_MINOR_STR REGEX "\#define CHROME_VERSION_MINOR ")
FILE(STRINGS ${CEF_INCLUDE_DIR}/cef_version.h CHROME_VERSION_BUILD_STR REGEX "\#define CHROME_VERSION_BUILD ")
FILE(STRINGS ${CEF_INCLUDE_DIR}/cef_version.h CHROME_VERSION_PATCH_STR REGEX "\#define CHROME_VERSION_PATCH ")
# Create a build number based on the actual build date/time
string(TIMESTAMP BUILDNUMBER "#define DULLAHAN_VERSION_BUILD %Y%m%d%H%M")
# Parse the version input file into the Dullahan version header
CONFIGURE_FILE (
"${PROJECT_SOURCE_DIR}/src/dullahan_version.h.in"
"${PROJECT_SOURCE_DIR}/src/dullahan_version.h"
)
endif ()
################################################################################
## dullahan host executable
......@@ -219,6 +228,12 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set_target_properties(dullahan_host PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:WINDOWS")
set_target_properties(dullahan_host PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS")
set_target_properties(dullahan_host PROPERTIES LINK_FLAGS "/ignore:4099")
add_custom_command(
TARGET dullahan_host POST_BUILD
COMMAND "mt.exe" -manifest \"$(ProjectDir)..\\src\\win\\compatibility.manifest\" -outputresource:"$(TargetDir)$(TargetFileName)"\;\#1
COMMENT "Adding custom manifest...")
endif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
# Windows commands to copy CEF 'bin', 'resources' folders to executable dir (needed at runtime)
......@@ -291,6 +306,11 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
endif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
endif()
add_custom_command(
TARGET webcube POST_BUILD
COMMAND "mt.exe" -manifest \"$(ProjectDir)..\\src\\win\\compatibility.manifest\" -outputresource:"$(TargetDir)$(TargetFileName)"\;\#1
COMMENT "Adding custom manifest...")
################################################################################
## simplegl example application using FreeGLUT
......@@ -339,6 +359,11 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set_target_properties(simplegl PROPERTIES LINK_FLAGS "/ignore:4099")
endif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
add_custom_command(
TARGET simplegl POST_BUILD
COMMAND "mt.exe" -manifest \"$(ProjectDir)..\\src\\win\\compatibility.manifest\" -outputresource:"$(TargetDir)$(TargetFileName)"\;\#1
COMMENT "Adding custom manifest...")
################################################################################
## console example application
......@@ -368,6 +393,11 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set_target_properties(console PROPERTIES LINK_FLAGS "/ignore:4099")
endif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
add_custom_command(
TARGET console POST_BUILD
COMMAND "mt.exe" -manifest \"$(ProjectDir)..\\src\\win\\compatibility.manifest\" -outputresource:"$(TargetDir)$(TargetFileName)"\;\#1
COMMENT "Adding custom manifest...")
################################################################################
## minimal CEF console example (doesn't use Dullahan)
......@@ -400,6 +430,11 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set_target_properties(cef_minimal PROPERTIES LINK_FLAGS "/ignore:4099")
endif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
add_custom_command(
TARGET cef_minimal POST_BUILD
COMMAND "mt.exe" -manifest \"$(ProjectDir)..\\src\\win\\compatibility.manifest\" -outputresource:"$(TargetDir)$(TargetFileName)"\;\#1
COMMENT "Adding custom manifest...")
elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
################################################################################
......@@ -447,7 +482,6 @@ endif()
################################################################################
# generic commands that have to go after everything else
###### set only a Release configuration
if(CMAKE_CONFIGURATION_TYPES)
set(CMAKE_CONFIGURATION_TYPES "Debug;Release")
endif()
......@@ -7,6 +7,9 @@ A headless browser SDK that uses the [Chromium Embedded Framework](https://en.wi
#### **Important note**:
This is a __very__ early release - more than alpha quality but less than beta. I have high hopes this will develop into something useful but there is still a lot of work to do first.
#### **Documentation needs updating**:
The parts of this document that relate to building CEF are outdated as of 2019-09-11 and need to be updated. Once I have all the scripts working again on both Windows and macOS, I will update this document accordingly.
## What could I use it for?
It might be useful in a number of situations - for example:
......
This is a good place to put your CEF builds and refer to them here when using tools\build_win.bat.
This folder (except this file) is ignored by Mercurial (via .hgignore) so it makes commands like `hg status` less confusing when checking which files you have added or modified.
......@@ -222,7 +222,6 @@ int main(int argc, char* argv[])
settings.background_color = 0x80ffffff;
settings.cache_enabled = true;
settings.cache_path = ".\\cache";
settings.cookie_store_path = ".\\cookies";
settings.cookies_enabled = true;
settings.disable_gpu = false;
settings.disable_web_security = false;
......
......@@ -69,6 +69,7 @@ app::app()
mTextureWidth = 1024;
mTextureHeight = 1024;
mAllFinished = false;
// empty string means go load the page of test URLs
// may be overridden by command line arg --homepage="URL"
......@@ -113,6 +114,8 @@ void app::init_dullahan()
mDullahan->setOnRequestExitCallback(std::bind(&app::onRequestExitCallback, this));
mDullahan->setOnStatusMessageCallback(std::bind(&app::onStatusMessage, this, std::placeholders::_1));
mDullahan->setOnTitleChangeCallback(std::bind(&app::onTitleChange, this, std::placeholders::_1));
mDullahan->setOnJSDialogCallback(std::bind(&app::onJSDialogCallback, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
mDullahan->setOnTooltipCallback(std::bind(&app::onTooltip, this, std::placeholders::_1));
std::vector<std::string> custom_schemes(1, "secondlife");
mDullahan->setCustomSchemes(custom_schemes);
......@@ -121,8 +124,8 @@ void app::init_dullahan()
settings.accept_language_list = "en-US";
settings.background_color = 0xff666666;
settings.cache_enabled = true;
settings.locales_dir_path = "";
settings.cache_path = ".\\webcube_cache";
settings.cookie_store_path = ".\\webcube_cookies";
settings.cookies_enabled = true;
settings.disable_gpu = false;
settings.disable_web_security = false;
......@@ -752,6 +755,19 @@ void app::onPageChangedCallback(const unsigned char* pixels, int x, int y,
}
}
/////////////////////////////////////////////////////////////////////////////////
//
bool app::onJSDialogCallback(const std::string origin_url, const std::string message_text, const std::string default_prompt_text)
{
std::cout << "JavaScript dialog triggered:" << std::endl;
std::cout << " URL: " << origin_url << std::endl;
std::cout << " message: " << message_text << std::endl;
std::cout << " prompt: " << default_prompt_text << std::endl;
// cancel the dialog automatically
return true;
}
/////////////////////////////////////////////////////////////////////////////////
//
void app::onPdfPrintFinished(const std::string path, bool ok)
......@@ -771,6 +787,11 @@ void app::onPdfPrintFinished(const std::string path, bool ok)
//
void app::onRequestExitCallback()
{
mAllFinished = true;
// posted a quit message no longer works as of CEF 74. Not sure why - I
// think it swallows the message before the app (like this one) gets to
// see it. Now we need to use an explicit flag
PostQuitMessage(0);
}
......@@ -788,6 +809,13 @@ void app::onTitleChange(const std::string title)
std::cout << "onTitleChange: " << title << std::endl;
}
/////////////////////////////////////////////////////////////////////////////////
//
void app::onTooltip(const std::string tooltip)
{
std::cout << "onTooltip: " << tooltip << std::endl;
}
/////////////////////////////////////////////////////////////////////////////////
//
void app::on_left_mouse_down(int x, int y, int face)
......@@ -812,9 +840,9 @@ void app::on_mouse_move(int x, int y, int face, bool left_button_down)
/////////////////////////////////////////////////////////////////////////////////
//
void app::on_mouse_wheel(int delta_x, int delta_y)
void app::on_mouse_wheel(int x, int y, int delta_x, int delta_y)
{
mDullahan->mouseWheel(delta_x, delta_y);
mDullahan->mouseWheel(x, y, delta_x, delta_y);
}
/////////////////////////////////////////////////////////////////////////////////
......@@ -1060,9 +1088,18 @@ LRESULT CALLBACK window_proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
else
{
// location of mouse cursor when wheel was moved
int mouse_x = LOWORD(lParam);
int mouse_y = HIWORD(lParam);
// use the mouse position to get the position on a face in texture
int texture_x, texture_y, texture_face;
gApp->windowPosToTexturePos(mouse_x, mouse_y, texture_x, texture_y, texture_face);
// synthesize a virtual mouse wheel event (clamp X delta for now)
int delta_x = 0;
int delta_y = GET_WHEEL_DELTA_WPARAM(wParam);
gApp->on_mouse_wheel(delta_x, delta_y);
gApp->on_mouse_wheel(texture_x, texture_y, delta_x, delta_y);
}
return 0;
};
......@@ -1120,6 +1157,13 @@ void app::closeConsole()
FreeConsole();
}
/////////////////////////////////////////////////////////////////////////////////
//
bool app::isAllFinished()
{
return mAllFinished;
}
/////////////////////////////////////////////////////////////////////////////////
//
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
......@@ -1222,7 +1266,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
SwapBuffers(hDC);
}
}
while (msg.message != WM_QUIT);
while (gApp->isAllFinished() == false);
wglMakeCurrent(nullptr, nullptr);
wglDeleteContext(hRC);
......
......@@ -78,7 +78,7 @@ class app
void on_left_mouse_down(int x, int y, int face);
void on_left_mouse_up(int x, int y, int face);
void on_mouse_move(int x, int y, int face, bool left_button_down);
void on_mouse_wheel(int delta_x, int delta_y);
void on_mouse_wheel(int x, int y, int delta_x, int delta_y);
void native_keyboard_event(uint32_t msg, uint64_t wparam, uint64_t lparam);
public:
......@@ -106,6 +106,7 @@ class app
const std::string get_title();
void set_homepage_url(std::string url);
bool isAllFinished();
private:
FILE* mConsole;
......@@ -122,6 +123,7 @@ class app
std::string mHomePageURL;
dullahan* mDullahan;
const std::string getHomePageURL();
bool mAllFinished;
void init_dullahan();
......@@ -132,6 +134,7 @@ class app
const std::vector<std::string> onFileDialog(dullahan::EFileDialogType dialog_type, const std::string dialog_title, const std::string default_file, const std::string dialog_accept_filter, bool& use_default);
void onFileDownloadProgress(int percent, bool complete);
bool onHTTPAuth(const std::string host, const std::string realm, std::string& username, std::string& password);
bool onJSDialogCallback(const std::string origin_url, const std::string message_text, const std::string default_prompt_text);
void onLoadEnd(int status, const std::string url);
void onLoadError(int status, const std::string error_text);
void onLoadStart();
......@@ -141,6 +144,7 @@ class app
void onRequestExitCallback();
void onStatusMessage(const std::string message);
void onTitleChange(const std::string title);
void onTooltip(const std::string title);
};
#endif // _WEBCUBE_EXAMPLE
......@@ -152,9 +152,9 @@ void dullahan::mouseButton(EMouseButton mouse_button,
mImpl->mouseButton(mouse_button, mouse_event, x, y);
}
void dullahan::mouseWheel(int delta_x, int delta_y)
void dullahan::mouseWheel(int x, int y, int delta_x, int delta_y)
{
mImpl->mouseWheel(delta_x, delta_y);
mImpl->mouseWheel(x, y, delta_x, delta_y);
}
void dullahan::nativeKeyboardEventWin(uint32_t msg,
......@@ -359,6 +359,11 @@ void dullahan::setOnTitleChangeCallback(std::function<void(const std::string tit
mImpl->getCallbackManager()->setOnTitleChangeCallback(callback);
}
void dullahan::setOnTooltipCallback(std::function<void(const std::string text)> callback)
{
mImpl->getCallbackManager()->setOnTooltipCallback(callback);
}
void dullahan::setOnPdfPrintFinishedCallback(std::function<void(const std::string path, bool ok)> callback)
{
mImpl->getCallbackManager()->setOnPdfPrintFinishedCallback(callback);
......@@ -373,3 +378,9 @@ void dullahan::setOnFileDialogCallback(std::function<const std::vector<std::stri
{
mImpl->getCallbackManager()->setOnFileDialogCallback(callback);
}
void dullahan::setOnJSDialogCallback(std::function<bool(const std::string origin_url, const std::string message_text, const std::string default_prompt_text)> callback)
{
mImpl->getCallbackManager()->setOnJSDialogCallback(callback);
}
......@@ -162,11 +162,11 @@ class dullahan
bool plugins_enabled = true; // all plugins
bool webgl_enabled = true; // webgl
// path to browser cache
std::string cache_path = "";
// explicitly set the path to the locales folder since defaults no longer work on some systems
std::string locales_dir_path = "";
// path to cookie store
std::string cookie_store_path = "";
// path to browser cache - cookies (if enabled) are also stored here as of Chrome 75
std::string cache_path = "";
// list of language locale codes used to configure the Accept-Language HTTP header value
// and change the default language of the browser
......@@ -244,7 +244,7 @@ class dullahan
EMouseEvent mouse_event,
int x, int y);
void mouseMove(int x, int y);
void mouseWheel(int delta_x, int delta_y);
void mouseWheel(int x, int y, int delta_x, int delta_y);
// keyboard input
void nativeKeyboardEventWin(uint32_t msg, uint32_t wparam, uint64_t lparam);
......@@ -346,6 +346,8 @@ class dullahan
// page title changes
void setOnTitleChangeCallback(std::function<void(const std::string title)> callback);
void setOnTooltipCallback(std::function<void(const std::string text)> callback);
// a call to printToPDF completed
void setOnPdfPrintFinishedCallback(std::function<void(const std::string path, bool ok)> callback);
......@@ -355,6 +357,11 @@ class dullahan
// file picker shown
void setOnFileDialogCallback(std::function<const std::vector<std::string>(dullahan::EFileDialogType dialog_type, const std::string dialog_title, const std::string default_file, const std::string dialog_accept_filter, bool& use_default)> callback);
// JS dialog shown (alert)
void setOnJSDialogCallback(std::function<bool(const std::string origin_url,
const std::string message_text,
const std::string default_prompt_text)> callback);
private:
std::unique_ptr <dullahan_impl> mImpl;
};
......
......@@ -55,11 +55,16 @@ CefRefPtr<CefRenderHandler> dullahan_browser_client::GetRenderHandler()
// CefLifeSpanHandler override
bool dullahan_browser_client::OnBeforePopup(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const CefString& target_url, const CefString& target_frame_name,
const CefString& target_url,
const CefString& target_frame_name,
CefLifeSpanHandler::WindowOpenDisposition target_disposition,
bool user_gesture, const CefPopupFeatures& popupFeatures,
CefWindowInfo& windowInfo, CefRefPtr<CefClient>& client,
CefBrowserSettings& settings, bool* no_javascript_access)
bool user_gesture,
const CefPopupFeatures& popupFeatures,
CefWindowInfo& windowInfo,
CefRefPtr<CefClient>& client,
CefBrowserSettings& settings,
CefRefPtr<CefDictionaryValue>& extra_info,
bool* no_javascript_access)
{
CEF_REQUIRE_UI_THREAD();
......@@ -177,6 +182,16 @@ void dullahan_browser_client::OnTitleChange(CefRefPtr<CefBrowser> browser,
mParent->getCallbackManager()->onTitleChange(std::string(title));
}
// CefDisplayhandler overrides
bool dullahan_browser_client::OnTooltip(CefRefPtr<CefBrowser> browser,
CefString& text)
{
CEF_REQUIRE_UI_THREAD();
mParent->getCallbackManager()->OnTooltip(std::string(text));
return false;
}
// CefLoadHandler override
void dullahan_browser_client::OnLoadingStateChange(CefRefPtr<CefBrowser> browser,
bool isLoading, bool canGoBack, bool canGoForward)
......@@ -245,7 +260,10 @@ bool dullahan_browser_client::OnBeforeBrowse(CefRefPtr<CefBrowser> browser,
std::string url = request->GetURL();
// for conmparison
std::transform(url.begin(), url.end(), url.begin(), ::tolower);
std::transform(url.begin(), url.end(), url.begin(), [](char c)
{
return static_cast<char>(tolower(c));
});
std::vector<std::string>::iterator iter = mParent->getCustomSchemes().begin();
while (iter != mParent->getCustomSchemes().end())
......@@ -267,9 +285,8 @@ bool dullahan_browser_client::OnBeforeBrowse(CefRefPtr<CefBrowser> browser,
}
// CefRequestHandler override
bool dullahan_browser_client::GetAuthCredentials(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
bool isProxy, const CefString& host, int port, const CefString& realm,
bool dullahan_browser_client::GetAuthCredentials(CefRefPtr<CefBrowser> browser, const CefString& origin_url, bool isProxy,
const CefString& host, int port, const CefString& realm,
const CefString& scheme, CefRefPtr<CefAuthCallback> callback)
{
CEF_REQUIRE_IO_THREAD();
......@@ -309,18 +326,6 @@ bool dullahan_browser_client::OnQuotaRequest(CefRefPtr<CefBrowser> browser,
return true;
}
// CefRequestHandler override
CefRequestHandler::ReturnValue dullahan_browser_client::OnBeforeResourceLoad(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
CefRefPtr<CefRequestCallback> callback)
{
CEF_REQUIRE_IO_THREAD();
return RV_CONTINUE;
}
// CefDownloadHandler overrides
void dullahan_browser_client::OnBeforeDownload(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDownloadItem> download_item,
......@@ -415,3 +420,19 @@ bool dullahan_browser_client::OnFileDialog(CefRefPtr<CefBrowser> browser,
return true;
}
// CefJSDialogHandler overrides
bool dullahan_browser_client::OnJSDialog(CefRefPtr<CefBrowser> browser,
const CefString& origin_url,
JSDialogType dialog_type,
const CefString& message_text,
const CefString& default_prompt_text,
CefRefPtr<CefJSDialogCallback> callback,
bool& suppress_message)
{
suppress_message = mParent->getCallbackManager()->onJSDialogCallback(std::string(origin_url),
std::string(message_text),
std::string(default_prompt_text));
return false;
}
......@@ -41,7 +41,8 @@ class dullahan_browser_client :
public CefLoadHandler,
public CefRequestHandler,
public CefDownloadHandler,
public CefDialogHandler
public CefDialogHandler,
public CefJSDialogHandler
{
public:
dullahan_browser_client(dullahan_impl* parent,
......@@ -56,12 +57,18 @@ class dullahan_browser_client :
{
return this;
}
bool OnBeforePopup(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
const CefString& target_url, const CefString& target_frame_name,
bool OnBeforePopup(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const CefString& target_url,
const CefString& target_frame_name,
CefLifeSpanHandler::WindowOpenDisposition target_disposition,
bool user_gesture, const CefPopupFeatures& popupFeatures,
CefWindowInfo& windowInfo, CefRefPtr<CefClient>& client,
CefBrowserSettings& settings, bool* no_javascript_access) override;
bool user_gesture,
const CefPopupFeatures& popupFeatures,
CefWindowInfo& windowInfo,
CefRefPtr<CefClient>& client,
CefBrowserSettings& settings,
CefRefPtr<CefDictionaryValue>& extra_info,
bool* no_javascript_access) override;
void OnAfterCreated(CefRefPtr<CefBrowser> browser) override;
void OnBeforeClose(CefRefPtr<CefBrowser> browser) override;
bool DoClose(CefRefPtr<CefBrowser> browser) override;
......@@ -79,6 +86,8 @@ class dullahan_browser_client :
const CefString& value) override;
void OnTitleChange(CefRefPtr<CefBrowser> browser,
const CefString& title) override;
bool OnTooltip(CefRefPtr<CefBrowser> browser,
CefString& text) override;
// CefLoadHandler overrides
CefRefPtr<CefLoadHandler> GetLoadHandler() override
......@@ -103,18 +112,14 @@ class dullahan_browser_client :
}
bool OnBeforeBrowse(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request, bool user_gesture, bool isRedirect) override;
bool GetAuthCredentials(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
bool isProxy, const CefString& host, int port, const CefString& realm,
bool GetAuthCredentials(CefRefPtr<CefBrowser> browser, const CefString& origin_url, bool isProxy,
const CefString& host, int port, const CefString& realm,
const CefString& scheme, CefRefPtr<CefAuthCallback> callback) override;
bool OnQuotaRequest(CefRefPtr<CefBrowser> browser,
const CefString& origin_url,
int64 new_size,
CefRefPtr<CefRequestCallback> callback) override;
CefRequestHandler::ReturnValue OnBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
CefRefPtr<CefRequestCallback> callback) override;
// CefDownloadHandler overrides
CefRefPtr<CefDownloadHandler> GetDownloadHandler() override
......@@ -138,6 +143,19 @@ class dullahan_browser_client :
const CefString& default_file_path, const std::vector<CefString>& accept_filters, int selected_accept_filter,
CefRefPtr<CefFileDialogCallback> callback) override;
// CefJSDialogHandler overrides
CefRefPtr<CefJSDialogHandler> GetJSDialogHandler() override
{
return this;
}
bool OnJSDialog(CefRefPtr<CefBrowser> browser,
const CefString& origin_url,
JSDialogType dialog_type,
const CefString& message_text,
const CefString& default_prompt_text,
CefRefPtr<CefJSDialogCallback> callback,
bool& suppress_message) override;
private:
dullahan_impl* mParent;
CefRefPtr<CefRenderHandler> mRenderHandler;
......
......@@ -204,6 +204,19 @@ void dullahan_callback_manager::onTitleChange(const std::string title)
}
}
void dullahan_callback_manager::setOnTooltipCallback(std::function<void(const std::string text)> callback)
{
mOnTooltipCallbackFunc = callback;
}
void dullahan_callback_manager::OnTooltip(const std::string text)
{
if (mOnTooltipCallbackFunc)
{
mOnTooltipCallbackFunc(text);
}
}
void dullahan_callback_manager::setOnPdfPrintFinishedCallback(std::function<void(const std::string path, bool ok)> callback)
{
mOnPdfPrintFinishedCallbackFunc = callback;
......@@ -244,3 +257,21 @@ const std::vector<std::string> dullahan_callback_manager::onFileDialog(dullahan:
return std::vector<std::string>();
}
void dullahan_callback_manager::setOnJSDialogCallback(
std::function<bool(const std::string origin_url, const std::string message_text, const std::string default_prompt_text)> callback)
{
mOnJSDialogCallbackFunc = callback;
}
bool dullahan_callback_manager::onJSDialogCallback(const std::string origin_url, const std::string message_text, const std::string default_prompt_text)
{
if (mOnJSDialogCallbackFunc)
{
return mOnJSDialogCallbackFunc(origin_url, message_text, default_prompt_text);
}
// default to cancel request if no callback set up
return false;
}
......@@ -73,6 +73,9 @@ class dullahan_callback_manager
void setOnTitleChangeCallback(std::function<void(const std::string title)> callback);
void onTitleChange(const std::string title);
void setOnTooltipCallback(std::function<void(const std::string text)> callback);
void OnTooltip(const std::string text);
void setOnPdfPrintFinishedCallback(std::function<void(const std::string path, bool ok)> callback);
void onPdfPrintFinished(const std::string path, bool ok);
......@@ -82,6 +85,9 @@ class dullahan_callback_manager
void setOnFileDialogCallback(std::function<const std::vector<std::string>(