#include "ClientHandler.h" #include "include/cef_task.h" void ClientHandler::OnAfterCreated(CefRefPtr new_browser) { if (!browser.get()) { // We need to keep the main child window, but not popup windows browser = new_browser; } } void ClientHandler::OnAddressChange(CefRefPtr browser, CefRefPtr frame, const CefString& url) { PostCallback(callback1(WhenUrlChange, url.ToString())); } bool ClientHandler::OnConsoleMessage(CefRefPtr browser, const CefString& message, const CefString& source, int line) { ASSERT(CefCurrentlyOn(TID_UI)); PostCallback(callback3(WhenConsoleMessage, source.ToString(), line, message.ToString())); return true; } bool ClientHandler::OnBeforePopup(CefRefPtr browser, CefRefPtr frame, const CefString& target_url, const CefString& target_frame_name, const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo, CefRefPtr& client, CefBrowserSettings& settings, bool* no_javascript_access) { RLOG(Upp::Format("Popup canceled, frame name: '%s', url '%s'", target_frame_name.ToString().c_str(), target_url.ToString().c_str())); // Cancel popups return true; } void ClientHandler::OnLoadError(CefRefPtr browser, CefRefPtr frame, ErrorCode errorCode, const CefString& errorText, const CefString& failedUrl) { frame->LoadString("

Page not found

", failedUrl); } bool ClientHandler::OnProcessMessageReceived(CefRefPtr browser, CefProcessId source_process, CefRefPtr message) { if (message->GetName().ToString() == "show_keyboard"){ PostCallback(callback1(WhenKeyboard, true)); }else if (message->GetName().ToString() == "hide_keyboard"){ PostCallback(callback1(WhenKeyboard, false)); }else{ PostCallback(callback1(WhenMessage, message->GetName().ToString())); } return true; } void ClientHandler::OnTakeFocus(CefRefPtr browser, bool next ) { PostCallback(WhenTakeFocus); } void ClientHandler::OnBeforeContextMenu(CefRefPtr browser, CefRefPtr frame, CefRefPtr params, CefRefPtr model) { //Empty context menu model->Clear(); } bool ClientHandler::OnJSDialog(CefRefPtr browser, const CefString& origin_url, const CefString& accept_lang, JSDialogType dialog_type, const CefString& message_text, const CefString& default_prompt_text, CefRefPtr callback, bool& suppress_message) { RLOG(message_text.ToString().c_str()); return false; }