init lserp cs 5.0
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Cef3.Interop;
|
||||
|
||||
public abstract unsafe partial class CefApp
|
||||
{
|
||||
private void on_before_command_line_processing(cef_app_t* self, cef_string_t* process_type, cef_command_line_t* command_line)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var processType = cef_string_t.ToString(process_type);
|
||||
var m_commandLine = CefCommandLine.FromNative(command_line);
|
||||
|
||||
OnBeforeCommandLineProcessing(processType, m_commandLine);
|
||||
|
||||
m_commandLine.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides an opportunity to view and/or modify command-line arguments before
|
||||
/// processing by CEF and Chromium. The |process_type| value will be empty for
|
||||
/// the browser process. Do not keep a reference to the CefCommandLine object
|
||||
/// passed to this method. The CefSettings.command_line_args_disabled value
|
||||
/// can be used to start with an empty command-line object. Any values
|
||||
/// specified in CefSettings that equate to command-line arguments will be set
|
||||
/// before this method is called. Be cautious when using this method to modify
|
||||
/// command-line arguments for non-browser processes as this may result in
|
||||
/// undefined behavior including crashes.
|
||||
/// </summary>
|
||||
protected virtual void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private void on_register_custom_schemes(cef_app_t* self, cef_scheme_registrar_t* registrar)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_registrar = CefSchemeRegistrar.FromNative(registrar);
|
||||
|
||||
OnRegisterCustomSchemes(m_registrar);
|
||||
|
||||
m_registrar.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides an opportunity to register custom schemes. Do not keep a reference
|
||||
/// to the |registrar| object. This method is called on the main thread for
|
||||
/// each process and the registered schemes should be the same across all
|
||||
/// processes.
|
||||
/// </summary>
|
||||
protected virtual void OnRegisterCustomSchemes(CefSchemeRegistrar registrar)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private cef_resource_bundle_handler_t* get_resource_bundle_handler(cef_app_t* self)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var result = GetResourceBundleHandler();
|
||||
|
||||
return result != null ? result.ToNative() : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the handler for resource bundle events. If
|
||||
/// CefSettings.pack_loading_disabled is true a handler must be returned. If no
|
||||
/// handler is returned resources will be loaded from pack files. This method
|
||||
/// is called by the browser and renderer processes on multiple threads.
|
||||
/// </summary>
|
||||
protected virtual CefResourceBundleHandler GetResourceBundleHandler()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private cef_browser_process_handler_t* get_browser_process_handler(cef_app_t* self)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var result = GetBrowserProcessHandler();
|
||||
|
||||
return result != null ? result.ToNative() : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the handler for functionality specific to the browser process. This
|
||||
/// method is called on multiple threads in the browser process.
|
||||
/// </summary>
|
||||
protected virtual CefBrowserProcessHandler GetBrowserProcessHandler()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private cef_render_process_handler_t* get_render_process_handler(cef_app_t* self)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var result = GetRenderProcessHandler();
|
||||
|
||||
return result != null ? result.ToNative() : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the handler for render process events. This method is called by the
|
||||
/// render process main thread.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected virtual CefRenderProcessHandler GetRenderProcessHandler()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class used to implement browser process callbacks. The methods of this class
|
||||
/// will be called on the browser process main thread unless otherwise indicated.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefBrowserProcessHandler
|
||||
{
|
||||
private void on_context_initialized(cef_browser_process_handler_t* self)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
OnContextInitialized();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on the browser process UI thread immediately after the CEF context
|
||||
/// has been initialized.
|
||||
/// </summary>
|
||||
protected virtual void OnContextInitialized()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private void on_before_child_process_launch(cef_browser_process_handler_t* self, cef_command_line_t* command_line)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_commandLine = CefCommandLine.FromNative(command_line);
|
||||
OnBeforeChildProcessLaunch(m_commandLine);
|
||||
m_commandLine.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called before a child process is launched. Will be called on the browser
|
||||
/// process UI thread when launching a render process and on the browser
|
||||
/// process IO thread when launching a GPU or plugin process. Provides an
|
||||
/// opportunity to modify the child process command line. Do not keep a
|
||||
/// reference to |command_line| outside of this method.
|
||||
/// </summary>
|
||||
protected virtual void OnBeforeChildProcessLaunch(CefCommandLine commandLine)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private void on_render_process_thread_created(cef_browser_process_handler_t* self, cef_list_value_t* extra_info)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var mExtraInfo = CefListValue.FromNative(extra_info);
|
||||
OnRenderProcessThreadCreated(mExtraInfo);
|
||||
mExtraInfo.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on the browser process IO thread after the main thread has been
|
||||
/// created for a new render process. Provides an opportunity to specify extra
|
||||
/// information that will be passed to
|
||||
/// CefRenderProcessHandler::OnRenderThreadCreated() in the render process. Do
|
||||
/// not keep a reference to |extra_info| outside of this method.
|
||||
/// </summary>
|
||||
protected virtual void OnRenderProcessThreadCreated(CefListValue extraInfo)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private cef_print_handler_t* get_print_handler(cef_browser_process_handler_t* self)
|
||||
{
|
||||
CheckSelf(self);
|
||||
var result = GetPrintHandler();
|
||||
return result != null ? result.ToNative() : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the handler for printing on Linux. If a print handler is not
|
||||
/// provided then printing will not be supported on the Linux platform.
|
||||
/// </summary>
|
||||
protected virtual CefPrintHandler GetPrintHandler()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,277 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
public abstract unsafe partial class CefClient
|
||||
{
|
||||
private cef_context_menu_handler_t* get_context_menu_handler(cef_client_t* self)
|
||||
{
|
||||
CheckSelf(self);
|
||||
var result = GetContextMenuHandler();
|
||||
return result != null ? result.ToNative() : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the handler for context menus. If no handler is provided the default
|
||||
/// implementation will be used.
|
||||
/// </summary>
|
||||
protected virtual CefContextMenuHandler GetContextMenuHandler()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private cef_dialog_handler_t* get_dialog_handler(cef_client_t* self)
|
||||
{
|
||||
CheckSelf(self);
|
||||
var result = GetDialogHandler();
|
||||
return result != null ? result.ToNative() : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the handler for dialogs. If no handler is provided the default
|
||||
/// implementation will be used.
|
||||
/// </summary>
|
||||
protected virtual CefDialogHandler GetDialogHandler()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private cef_display_handler_t* get_display_handler(cef_client_t* self)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var result = GetDisplayHandler();
|
||||
return result != null ? result.ToNative() : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the handler for browser display state events.
|
||||
/// </summary>
|
||||
protected virtual CefDisplayHandler GetDisplayHandler()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private cef_download_handler_t* get_download_handler(cef_client_t* self)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var result = GetDownloadHandler();
|
||||
return result != null ? result.ToNative() : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the handler for download events. If no handler is returned downloads
|
||||
/// will not be allowed.
|
||||
/// </summary>
|
||||
protected virtual CefDownloadHandler GetDownloadHandler()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private cef_drag_handler_t* get_drag_handler(cef_client_t* self)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var result = GetDragHandler();
|
||||
return result != null ? result.ToNative() : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the handler for drag events.
|
||||
/// </summary>
|
||||
protected virtual CefDragHandler GetDragHandler()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private cef_find_handler_t* get_find_handler(cef_client_t* self)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var result = GetFindHandler();
|
||||
return result != null ? result.ToNative() : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the handler for find result events.
|
||||
/// </summary>
|
||||
protected virtual CefFindHandler GetFindHandler()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private cef_focus_handler_t* get_focus_handler(cef_client_t* self)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var result = GetFocusHandler();
|
||||
return result != null ? result.ToNative() : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the handler for focus events.
|
||||
/// </summary>
|
||||
protected virtual CefFocusHandler GetFocusHandler()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private cef_geolocation_handler_t* get_geolocation_handler(cef_client_t* self)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var result = GetGeolocationHandler();
|
||||
return result != null ? result.ToNative() : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the handler for geolocation permissions requests. If no handler is
|
||||
/// provided geolocation access will be denied by default.
|
||||
/// </summary>
|
||||
protected virtual CefGeolocationHandler GetGeolocationHandler()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private cef_jsdialog_handler_t* get_jsdialog_handler(cef_client_t* self)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var result = GetJSDialogHandler();
|
||||
return result != null ? result.ToNative() : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the handler for JavaScript dialogs. If no handler is provided the
|
||||
/// default implementation will be used.
|
||||
/// </summary>
|
||||
protected virtual CefJSDialogHandler GetJSDialogHandler()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private cef_keyboard_handler_t* get_keyboard_handler(cef_client_t* self)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var result = GetKeyboardHandler();
|
||||
return result != null ? result.ToNative() : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the handler for keyboard events.
|
||||
/// </summary>
|
||||
protected virtual CefKeyboardHandler GetKeyboardHandler()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private cef_life_span_handler_t* get_life_span_handler(cef_client_t* self)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var result = GetLifeSpanHandler();
|
||||
return result != null ? result.ToNative() : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the handler for browser life span events.
|
||||
/// </summary>
|
||||
protected virtual CefLifeSpanHandler GetLifeSpanHandler()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private cef_load_handler_t* get_load_handler(cef_client_t* self)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var result = GetLoadHandler();
|
||||
return result != null ? result.ToNative() : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the handler for browser load status events.
|
||||
/// </summary>
|
||||
protected virtual CefLoadHandler GetLoadHandler()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private cef_render_handler_t* get_render_handler(cef_client_t* self)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var result = GetRenderHandler();
|
||||
return result != null ? result.ToNative() : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the handler for off-screen rendering events.
|
||||
/// </summary>
|
||||
protected virtual CefRenderHandler GetRenderHandler()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private cef_request_handler_t* get_request_handler(cef_client_t* self)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var result = GetRequestHandler();
|
||||
return result != null ? result.ToNative() : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the handler for browser request events.
|
||||
/// </summary>
|
||||
protected virtual CefRequestHandler GetRequestHandler()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private int on_process_message_received(cef_client_t* self, cef_browser_t* browser, CefProcessId source_process, cef_process_message_t* message)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_message = CefProcessMessage.FromNative(message);
|
||||
|
||||
var result = OnProcessMessageReceived(m_browser, source_process, m_message);
|
||||
|
||||
// m_browser.Dispose();
|
||||
m_message.Dispose();
|
||||
|
||||
return result ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when a new message is received from a different process. Return true
|
||||
/// if the message was handled or false otherwise. Do not keep a reference to
|
||||
/// or attempt to access the message outside of this callback.
|
||||
/// </summary>
|
||||
protected virtual bool OnProcessMessageReceived(CefBrowser browser, CefProcessId sourceProcess, CefProcessMessage message)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Generic callback interface used for asynchronous completion.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefCompletionCallback
|
||||
{
|
||||
private void on_complete(cef_completion_callback_t* self)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
OnComplete();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method that will be called once the task is complete.
|
||||
/// </summary>
|
||||
protected abstract void OnComplete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Implement this interface to handle context menu events. The methods of this
|
||||
/// class will be called on the UI thread.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefContextMenuHandler
|
||||
{
|
||||
private void on_before_context_menu(cef_context_menu_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, cef_context_menu_params_t* @params, cef_menu_model_t* model)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var mBrowser = CefBrowser.FromNative(browser);
|
||||
var mFrame = CefFrame.FromNative(frame);
|
||||
var mState = CefContextMenuParams.FromNative(@params);
|
||||
var mModel = CefMenuModel.FromNative(model);
|
||||
|
||||
OnBeforeContextMenu(mBrowser, mFrame, mState, mModel);
|
||||
|
||||
mState.Dispose();
|
||||
mModel.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called before a context menu is displayed. |params| provides information
|
||||
/// about the context menu state. |model| initially contains the default
|
||||
/// context menu. The |model| can be cleared to show no context menu or
|
||||
/// modified to show a custom menu. Do not keep references to |params| or
|
||||
/// |model| outside of this callback.
|
||||
/// </summary>
|
||||
protected virtual void OnBeforeContextMenu(CefBrowser browser, CefFrame frame, CefContextMenuParams state, CefMenuModel model)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private int on_context_menu_command(cef_context_menu_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, cef_context_menu_params_t* @params, int command_id, CefEventFlags event_flags)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var mBrowser = CefBrowser.FromNative(browser);
|
||||
var mFrame = CefFrame.FromNative(frame);
|
||||
var mState = CefContextMenuParams.FromNative(@params);
|
||||
|
||||
var result = OnContextMenuCommand(mBrowser, mFrame, mState, command_id, event_flags);
|
||||
|
||||
mState.Dispose();
|
||||
|
||||
return result ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called to execute a command selected from the context menu. Return true if
|
||||
/// the command was handled or false for the default implementation. See
|
||||
/// cef_menu_id_t for the command ids that have default implementations. All
|
||||
/// user-defined command ids should be between MENU_ID_USER_FIRST and
|
||||
/// MENU_ID_USER_LAST. |params| will have the same values as what was passed to
|
||||
/// OnBeforeContextMenu(). Do not keep a reference to |params| outside of this
|
||||
/// callback.
|
||||
/// </summary>
|
||||
protected virtual bool OnContextMenuCommand(CefBrowser browser, CefFrame frame, CefContextMenuParams state, int commandId, CefEventFlags eventFlags)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void on_context_menu_dismissed(cef_context_menu_handler_t* self, cef_browser_t* browser, cef_frame_t* frame)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var mBrowser = CefBrowser.FromNative(browser);
|
||||
var mFrame = CefFrame.FromNative(frame);
|
||||
|
||||
OnContextMenuDismissed(mBrowser, mFrame);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the context menu is dismissed irregardless of whether the menu
|
||||
/// was empty or a command was selected.
|
||||
/// </summary>
|
||||
protected virtual void OnContextMenuDismissed(CefBrowser browser, CefFrame frame)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Interface to implement for visiting cookie values. The methods of this class
|
||||
/// will always be called on the IO thread.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefCookieVisitor
|
||||
{
|
||||
private int visit(cef_cookie_visitor_t* self, cef_cookie_t* cookie, int count, int total, int* deleteCookie)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var mCookie = CefCookie.FromNative(cookie);
|
||||
bool mDelete;
|
||||
|
||||
var result = Visit(mCookie, count, total, out mDelete);
|
||||
|
||||
*deleteCookie = mDelete ? 1 : 0;
|
||||
return result ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method that will be called once for each cookie. |count| is the 0-based
|
||||
/// index for the current cookie. |total| is the total number of cookies.
|
||||
/// Set |deleteCookie| to true to delete the cookie currently being visited.
|
||||
/// Return false to stop visiting cookies. This method may never be called if
|
||||
/// no cookies are found.
|
||||
/// </summary>
|
||||
protected abstract bool Visit(CefCookie cookie, int count, int total, out bool delete);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Interface to implement to be notified of asynchronous completion via
|
||||
/// CefCookieManager::DeleteCookies().
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefDeleteCookiesCallback
|
||||
{
|
||||
private void on_complete(cef_delete_cookies_callback_t* self, int num_deleted)
|
||||
{
|
||||
CheckSelf(self);
|
||||
OnComplete(num_deleted);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method that will be called upon completion. |num_deleted| will be the
|
||||
/// number of cookies that were deleted or -1 if unknown.
|
||||
/// </summary>
|
||||
protected abstract void OnComplete(int numDeleted);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Implement this interface to handle dialog events. The methods of this class
|
||||
/// will be called on the browser process UI thread.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefDialogHandler
|
||||
{
|
||||
private int on_file_dialog(cef_dialog_handler_t* self, cef_browser_t* browser, CefFileDialogMode mode, cef_string_t* title, cef_string_t* default_file_path, cef_string_list* accept_filters, int selected_accept_filter, cef_file_dialog_callback_t* callback)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var mBrowser = CefBrowser.FromNative(browser);
|
||||
var mTitle = cef_string_t.ToString(title);
|
||||
var mDefaultFilePath = cef_string_t.ToString(default_file_path);
|
||||
var mAcceptFilters = cef_string_list.ToArray(accept_filters);
|
||||
var mCallback = CefFileDialogCallback.FromNative(callback);
|
||||
|
||||
var result = OnFileDialog(mBrowser, mode, mTitle, mDefaultFilePath, mAcceptFilters, selected_accept_filter, mCallback);
|
||||
|
||||
return result ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called to run a file chooser dialog. |mode| represents the type of dialog
|
||||
/// to display. |title| to the title to be used for the dialog and may be empty
|
||||
/// to show the default title ("Open" or "Save" depending on the mode).
|
||||
/// |default_file_path| is the path with optional directory and/or file name
|
||||
/// component that should be initially selected in the dialog. |accept_filters|
|
||||
/// are used to restrict the selectable file types and may any combination of
|
||||
/// (a) valid lower-cased MIME types (e.g. "text/*" or "image/*"),
|
||||
/// (b) individual file extensions (e.g. ".txt" or ".png"), or (c) combined
|
||||
/// description and file extension delimited using "|" and ";" (e.g.
|
||||
/// "Image Types|.png;.gif;.jpg"). |selected_accept_filter| is the 0-based
|
||||
/// index of the filter that should be selected by default. To display a custom
|
||||
/// dialog return true and execute |callback| either inline or at a later time.
|
||||
/// To display the default dialog return false.
|
||||
/// </summary>
|
||||
protected virtual bool OnFileDialog(CefBrowser browser, CefFileDialogMode mode, string title, string defaultFilePath, string[] acceptFilters, int selectedAcceptFilter, CefFileDialogCallback callback)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Implement this interface to handle events related to browser display state.
|
||||
/// The methods of this class will be called on the UI thread.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefDisplayHandler
|
||||
{
|
||||
private void on_address_change(cef_display_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, cef_string_t* url)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var mBrowser = CefBrowser.FromNative(browser);
|
||||
var mFrame = CefFrame.FromNative(frame);
|
||||
var mUrl = cef_string_t.ToString(url);
|
||||
|
||||
OnAddressChange(mBrowser, mFrame, mUrl);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when a frame's address has changed.
|
||||
/// </summary>
|
||||
protected virtual void OnAddressChange(CefBrowser browser, CefFrame frame, string url)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private void on_title_change(cef_display_handler_t* self, cef_browser_t* browser, cef_string_t* title)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var mBrowser = CefBrowser.FromNative(browser);
|
||||
var mTitle = cef_string_t.ToString(title);
|
||||
|
||||
OnTitleChange(mBrowser, mTitle);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the page title changes.
|
||||
/// </summary>
|
||||
protected virtual void OnTitleChange(CefBrowser browser, string title)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private void on_favicon_urlchange(cef_display_handler_t* self, cef_browser_t* browser, cef_string_list* icon_urls)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var mBrowser = CefBrowser.FromNative(browser);
|
||||
var mIconUrls = cef_string_list.ToArray(icon_urls);
|
||||
|
||||
OnFaviconUrlChange(mBrowser, mIconUrls);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the page icon changes.
|
||||
/// </summary>
|
||||
protected virtual void OnFaviconUrlChange(CefBrowser browser, string[] iconUrls)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private void on_fullscreen_mode_change(cef_display_handler_t* self, cef_browser_t* browser, int fullscreen)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var mBrowser = CefBrowser.FromNative(browser);
|
||||
OnFullscreenModeChange(mBrowser, fullscreen != 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when web content in the page has toggled fullscreen mode. If
|
||||
/// |fullscreen| is true the content will automatically be sized to fill the
|
||||
/// browser content area. If |fullscreen| is false the content will
|
||||
/// automatically return to its original size and position. The client is
|
||||
/// responsible for resizing the browser if desired.
|
||||
/// </summary>
|
||||
protected virtual void OnFullscreenModeChange(CefBrowser browser, bool fullscreen) { }
|
||||
|
||||
|
||||
private int on_tooltip(cef_display_handler_t* self, cef_browser_t* browser, cef_string_t* text)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var mBrowser = CefBrowser.FromNative(browser);
|
||||
var mText = cef_string_t.ToString(text);
|
||||
|
||||
return OnTooltip(mBrowser, mText) ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the browser is about to display a tooltip. |text| contains the
|
||||
/// text that will be displayed in the tooltip. To handle the display of the
|
||||
/// tooltip yourself return true. Otherwise, you can optionally modify |text|
|
||||
/// and then return false to allow the browser to display the tooltip.
|
||||
/// When window rendering is disabled the application is responsible for
|
||||
/// drawing tooltips and the return value is ignored.
|
||||
/// </summary>
|
||||
protected virtual bool OnTooltip(CefBrowser browser, string text)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void on_status_message(cef_display_handler_t* self, cef_browser_t* browser, cef_string_t* value)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var mBrowser = CefBrowser.FromNative(browser);
|
||||
var mValue = cef_string_t.ToString(value);
|
||||
|
||||
OnStatusMessage(mBrowser, mValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the browser receives a status message. |value| contains the
|
||||
/// text that will be displayed in the status message.
|
||||
/// </summary>
|
||||
protected virtual void OnStatusMessage(CefBrowser browser, string value)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private int on_console_message(cef_display_handler_t* self, cef_browser_t* browser, cef_string_t* message, cef_string_t* source, int line)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var mBrowser = CefBrowser.FromNative(browser);
|
||||
var mMessage = cef_string_t.ToString(message);
|
||||
var mSource = cef_string_t.ToString(source);
|
||||
|
||||
return OnConsoleMessage(mBrowser, mMessage, mSource, line) ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called to display a console message. Return true to stop the message from
|
||||
/// being output to the console.
|
||||
/// </summary>
|
||||
protected virtual bool OnConsoleMessage(CefBrowser browser, string message, string source, int line)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Interface to implement for visiting the DOM. The methods of this class will
|
||||
/// be called on the render process main thread.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefDomVisitor
|
||||
{
|
||||
private void visit(cef_domvisitor_t* self, cef_domdocument_t* document)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_document = CefDomDocument.FromNative(document);
|
||||
|
||||
Visit(m_document);
|
||||
|
||||
m_document.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method executed for visiting the DOM. The document object passed to this
|
||||
/// method represents a snapshot of the DOM at the time this method is
|
||||
/// executed. DOM objects are only valid for the scope of this method. Do not
|
||||
/// keep references to or attempt to access any DOM objects outside the scope
|
||||
/// of this method.
|
||||
/// </summary>
|
||||
protected abstract void Visit(CefDomDocument document);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class used to handle file downloads. The methods of this class will called
|
||||
/// on the browser process UI thread.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefDownloadHandler
|
||||
{
|
||||
private void on_before_download(cef_download_handler_t* self, cef_browser_t* browser, cef_download_item_t* download_item, cef_string_t* suggested_name, cef_before_download_callback_t* callback)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_download_item = CefDownloadItem.FromNative(download_item);
|
||||
var m_suggested_name = cef_string_t.ToString(suggested_name);
|
||||
var m_callback = CefBeforeDownloadCallback.FromNative(callback);
|
||||
|
||||
OnBeforeDownload(m_browser, m_download_item, m_suggested_name, m_callback);
|
||||
|
||||
m_download_item.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called before a download begins. |suggested_name| is the suggested name for
|
||||
/// the download file. By default the download will be canceled. Execute
|
||||
/// |callback| either asynchronously or in this method to continue the download
|
||||
/// if desired. Do not keep a reference to |download_item| outside of this
|
||||
/// method.
|
||||
/// </summary>
|
||||
protected virtual void OnBeforeDownload(CefBrowser browser, CefDownloadItem downloadItem, string suggestedName, CefBeforeDownloadCallback callback)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private void on_download_updated(cef_download_handler_t* self, cef_browser_t* browser, cef_download_item_t* download_item, cef_download_item_callback_t* callback)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_download_item = CefDownloadItem.FromNative(download_item);
|
||||
var m_callback = CefDownloadItemCallback.FromNative(callback);
|
||||
|
||||
OnDownloadUpdated(m_browser, m_download_item, m_callback);
|
||||
|
||||
m_download_item.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when a download's status or progress information has been updated.
|
||||
/// This may be called multiple times before and after OnBeforeDownload().
|
||||
/// Execute |callback| either asynchronously or in this method to cancel the
|
||||
/// download if desired. Do not keep a reference to |download_item| outside of
|
||||
/// this method.
|
||||
/// </summary>
|
||||
protected virtual void OnDownloadUpdated(CefBrowser browser, CefDownloadItem downloadItem, CefDownloadItemCallback callback)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Implement this interface to handle events related to dragging. The methods of
|
||||
/// this class will be called on the UI thread.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefDragHandler
|
||||
{
|
||||
private int on_drag_enter(cef_drag_handler_t* self, cef_browser_t* browser, cef_drag_data_t* dragData, CefDragOperationsMask mask)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_dragData = CefDragData.FromNative(dragData);
|
||||
var m_result = OnDragEnter(m_browser, m_dragData, mask);
|
||||
|
||||
return m_result ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when an external drag event enters the browser window. |dragData|
|
||||
/// contains the drag event data and |mask| represents the type of drag
|
||||
/// operation. Return false for default drag handling behavior or true to
|
||||
/// cancel the drag event.
|
||||
/// </summary>
|
||||
protected abstract bool OnDragEnter(CefBrowser browser, CefDragData dragData, CefDragOperationsMask mask);
|
||||
|
||||
|
||||
private static readonly CefDraggableRegion[] EmptyDraggableRegion = new CefDraggableRegion[0];
|
||||
|
||||
private void on_draggable_regions_changed(cef_drag_handler_t* self, cef_browser_t* browser, UIntPtr regionsCount, cef_draggable_region_t* regions)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
CefDraggableRegion[] m_regions;
|
||||
var m_count = (int)regionsCount;
|
||||
if (m_count == 0) m_regions = EmptyDraggableRegion;
|
||||
else
|
||||
{
|
||||
m_regions = new CefDraggableRegion[m_count];
|
||||
for (var i = 0; i < m_count; i++)
|
||||
{
|
||||
m_regions[i] = CefDraggableRegion.FromNative(regions + i);
|
||||
}
|
||||
}
|
||||
|
||||
OnDraggableRegionsChanged(m_browser, m_regions);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called whenever draggable regions for the browser window change. These can
|
||||
/// be specified using the '-webkit-app-region: drag/no-drag' CSS-property. If
|
||||
/// draggable regions are never defined in a document this method will also
|
||||
/// never be called. If the last draggable region is removed from a document
|
||||
/// this method will be called with an empty vector.
|
||||
/// </summary>
|
||||
protected abstract void OnDraggableRegionsChanged(CefBrowser browser, CefDraggableRegion[] regions);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Implement this interface to receive notification when tracing has completed.
|
||||
/// The methods of this class will be called on the browser process UI thread.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefEndTracingCallback
|
||||
{
|
||||
private void on_end_tracing_complete(cef_end_tracing_callback_t* self, cef_string_t* tracing_file)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
OnEndTracingComplete(cef_string_t.ToString(tracing_file));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called after all processes have sent their trace data. |tracing_file| is
|
||||
/// the path at which tracing data was written. The client is responsible for
|
||||
/// deleting |tracing_file|.
|
||||
/// </summary>
|
||||
protected abstract void OnEndTracingComplete(string tracingFile);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Implement this interface to handle events related to find results. The
|
||||
/// methods of this class will be called on the UI thread.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefFindHandler
|
||||
{
|
||||
private void on_find_result(cef_find_handler_t* self, cef_browser_t* browser, int identifier, int count, cef_rect_t* selectionRect, int activeMatchOrdinal, int finalUpdate)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var mBrowser = CefBrowser.FromNative(browser);
|
||||
var mSelectionRect = new CefRectangle(selectionRect->x, selectionRect->y, selectionRect->width, selectionRect->height);
|
||||
|
||||
OnFindResult(mBrowser, identifier, count, mSelectionRect, activeMatchOrdinal, finalUpdate != 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called to report find results returned by CefBrowserHost::Find().
|
||||
/// |identifer| is the identifier passed to Find(), |count| is the number of
|
||||
/// matches currently identified, |selectionRect| is the location of where the
|
||||
/// match was found (in window coordinates), |activeMatchOrdinal| is the
|
||||
/// current position in the search results, and |finalUpdate| is true if this
|
||||
/// is the last find notification.
|
||||
/// </summary>
|
||||
protected abstract void OnFindResult(CefBrowser browser, int identifier, int count, CefRectangle selectionRect, int activeMatchOrdinal, bool finalUpdate);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Implement this interface to handle events related to focus. The methods of
|
||||
/// this class will be called on the UI thread.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefFocusHandler
|
||||
{
|
||||
private void on_take_focus(cef_focus_handler_t* self, cef_browser_t* browser, int next)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
|
||||
OnTakeFocus(m_browser, next != 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the browser component is about to loose focus. For instance, if
|
||||
/// focus was on the last HTML element and the user pressed the TAB key. |next|
|
||||
/// will be true if the browser is giving focus to the next component and false
|
||||
/// if the browser is giving focus to the previous component.
|
||||
/// </summary>
|
||||
protected virtual void OnTakeFocus(CefBrowser browser, bool next)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private int on_set_focus(cef_focus_handler_t* self, cef_browser_t* browser, CefFocusSource source)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
|
||||
return OnSetFocus(m_browser, source) ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the browser component is requesting focus. |source| indicates
|
||||
/// where the focus request is originating from. Return false to allow the
|
||||
/// focus to be set or true to cancel setting the focus.
|
||||
/// </summary>
|
||||
protected virtual bool OnSetFocus(CefBrowser browser, CefFocusSource source)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void on_got_focus(cef_focus_handler_t* self, cef_browser_t* browser)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
|
||||
OnGotFocus(m_browser);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the browser component has received focus.
|
||||
/// </summary>
|
||||
protected virtual void OnGotFocus(CefBrowser browser)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Implement this interface to handle events related to geolocation permission
|
||||
/// requests. The methods of this class will be called on the browser process UI
|
||||
/// thread.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefGeolocationHandler
|
||||
{
|
||||
private int on_request_geolocation_permission(cef_geolocation_handler_t* self, cef_browser_t* browser, cef_string_t* requesting_url, int request_id, cef_geolocation_callback_t* callback)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_requesting_url = cef_string_t.ToString(requesting_url);
|
||||
var m_callback = CefGeolocationCallback.FromNative(callback);
|
||||
|
||||
var m_result = OnRequestGeolocationPermission(m_browser, m_requesting_url, request_id, m_callback);
|
||||
|
||||
return m_result ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when a page requests permission to access geolocation information.
|
||||
/// |requesting_url| is the URL requesting permission and |request_id| is the
|
||||
/// unique ID for the permission request. Return true and call
|
||||
/// CefGeolocationCallback::Continue() either in this method or at a later
|
||||
/// time to continue or cancel the request. Return false to cancel the request
|
||||
/// immediately.
|
||||
/// </summary>
|
||||
protected abstract bool OnRequestGeolocationPermission(CefBrowser browser, string requestingUrl, int requestId, CefGeolocationCallback callback);
|
||||
|
||||
|
||||
private void on_cancel_geolocation_permission(cef_geolocation_handler_t* self, cef_browser_t* browser, cef_string_t* requesting_url, int request_id)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_requesting_url = cef_string_t.ToString(requesting_url);
|
||||
|
||||
OnCancelGeolocationPermission(m_browser, m_requesting_url, request_id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when a geolocation access request is canceled. |requesting_url| is
|
||||
/// the URL that originally requested permission and |request_id| is the unique
|
||||
/// ID for the permission request.
|
||||
/// </summary>
|
||||
protected abstract void OnCancelGeolocationPermission(CefBrowser browser, string requesting_url, int request_id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Implement this interface to receive geolocation updates. The methods of this
|
||||
/// class will be called on the browser process UI thread.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefGetGeolocationCallback
|
||||
{
|
||||
private void on_location_update(cef_get_geolocation_callback_t* self, cef_geoposition_t* position)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var mPosition = CefGeoposition.FromNative(position);
|
||||
|
||||
OnLocationUpdate(mPosition);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called with the 'best available' location information or, if the location
|
||||
/// update failed, with error information.
|
||||
/// </summary>
|
||||
protected abstract void OnLocationUpdate(CefGeoposition position);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Implement this interface to handle events related to JavaScript dialogs. The
|
||||
/// methods of this class will be called on the UI thread.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefJSDialogHandler
|
||||
{
|
||||
private int on_jsdialog(cef_jsdialog_handler_t* self, cef_browser_t* browser, cef_string_t* origin_url, cef_string_t* accept_lang, CefJSDialogType dialog_type, cef_string_t* message_text, cef_string_t* default_prompt_text, cef_jsdialog_callback_t* callback, int* suppress_message)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_origin_url = cef_string_t.ToString(origin_url);
|
||||
var m_accept_lang = cef_string_t.ToString(accept_lang);
|
||||
var m_message_text = cef_string_t.ToString(message_text);
|
||||
var m_default_prompt_text = cef_string_t.ToString(default_prompt_text);
|
||||
var m_callback = CefJSDialogCallback.FromNative(callback);
|
||||
bool m_suppress_message;
|
||||
|
||||
var result = OnJSDialog(m_browser, m_origin_url, m_accept_lang, dialog_type, m_message_text, m_default_prompt_text, m_callback, out m_suppress_message);
|
||||
|
||||
*suppress_message = m_suppress_message ? 1 : 0;
|
||||
return result ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called to run a JavaScript dialog. The |default_prompt_text| value will be
|
||||
/// specified for prompt dialogs only. Set |suppress_message| to true and
|
||||
/// return false to suppress the message (suppressing messages is preferable
|
||||
/// to immediately executing the callback as this is used to detect presumably
|
||||
/// malicious behavior like spamming alert messages in onbeforeunload). Set
|
||||
/// |suppress_message| to false and return false to use the default
|
||||
/// implementation (the default implementation will show one modal dialog at a
|
||||
/// time and suppress any additional dialog requests until the displayed dialog
|
||||
/// is dismissed). Return true if the application will use a custom dialog or
|
||||
/// if the callback has been executed immediately. Custom dialogs may be either
|
||||
/// modal or modeless. If a custom dialog is used the application must execute
|
||||
/// |callback| once the custom dialog is dismissed.
|
||||
/// </summary>
|
||||
protected abstract bool OnJSDialog(CefBrowser browser, string originUrl, string acceptLang, CefJSDialogType dialogType, string message_text, string default_prompt_text, CefJSDialogCallback callback, out bool suppress_message);
|
||||
|
||||
|
||||
private int on_before_unload_dialog(cef_jsdialog_handler_t* self, cef_browser_t* browser, cef_string_t* message_text, int is_reload, cef_jsdialog_callback_t* callback)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_message_text = cef_string_t.ToString(message_text);
|
||||
var m_callback = CefJSDialogCallback.FromNative(callback);
|
||||
|
||||
return OnBeforeUnloadDialog(m_browser, m_message_text, is_reload != 0, m_callback) ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called to run a dialog asking the user if they want to leave a page. Return
|
||||
/// false to use the default dialog implementation. Return true if the
|
||||
/// application will use a custom dialog or if the callback has been executed
|
||||
/// immediately. Custom dialogs may be either modal or modeless. If a custom
|
||||
/// dialog is used the application must execute |callback| once the custom
|
||||
/// dialog is dismissed.
|
||||
/// </summary>
|
||||
protected abstract bool OnBeforeUnloadDialog(CefBrowser browser, string messageText, bool isReload, CefJSDialogCallback callback);
|
||||
|
||||
|
||||
private void on_reset_dialog_state(cef_jsdialog_handler_t* self, cef_browser_t* browser)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
|
||||
OnResetDialogState(m_browser);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called to cancel any pending dialogs and reset any saved dialog state. Will
|
||||
/// be called due to events like page navigation irregardless of whether any
|
||||
/// dialogs are currently pending.
|
||||
/// </summary>
|
||||
protected abstract void OnResetDialogState(CefBrowser browser);
|
||||
|
||||
|
||||
private void on_dialog_closed(cef_jsdialog_handler_t* self, cef_browser_t* browser)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
|
||||
OnDialogClosed(m_browser);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the default implementation dialog is closed.
|
||||
/// </summary>
|
||||
protected abstract void OnDialogClosed(CefBrowser browser);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Implement this interface to handle events related to keyboard input. The
|
||||
/// methods of this class will be called on the UI thread.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefKeyboardHandler
|
||||
{
|
||||
private int on_pre_key_event(cef_keyboard_handler_t* self, cef_browser_t* browser, cef_key_event_t* @event, IntPtr os_event, int* is_keyboard_shortcut)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_event = CefKeyEvent.FromNative(@event);
|
||||
// TODO: wrap cef_event_handle_t (os_event)
|
||||
IntPtr m_os_event = IntPtr.Zero;
|
||||
if (os_event != IntPtr.Zero)
|
||||
{
|
||||
}
|
||||
|
||||
var m_is_keyboard_shortcut = *is_keyboard_shortcut != 0;
|
||||
|
||||
var result = OnPreKeyEvent(m_browser, m_event, m_os_event, out m_is_keyboard_shortcut);
|
||||
*is_keyboard_shortcut = m_is_keyboard_shortcut ? 1 : 0;
|
||||
|
||||
return result ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called before a keyboard event is sent to the renderer. |event| contains
|
||||
/// information about the keyboard event. |os_event| is the operating system
|
||||
/// event message, if any. Return true if the event was handled or false
|
||||
/// otherwise. If the event will be handled in OnKeyEvent() as a keyboard
|
||||
/// shortcut set |is_keyboard_shortcut| to true and return false.
|
||||
/// </summary>
|
||||
protected virtual bool OnPreKeyEvent(CefBrowser browser, CefKeyEvent keyEvent, IntPtr os_event, out bool isKeyboardShortcut)
|
||||
{
|
||||
isKeyboardShortcut = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private int on_key_event(cef_keyboard_handler_t* self, cef_browser_t* browser, cef_key_event_t* @event, IntPtr os_event)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_event = CefKeyEvent.FromNative(@event);
|
||||
// TODO: wrap cef_event_handle_t (os_event)
|
||||
IntPtr m_os_event = IntPtr.Zero;
|
||||
if (os_event != IntPtr.Zero)
|
||||
{
|
||||
}
|
||||
|
||||
var result = OnKeyEvent(m_browser, m_event, m_os_event);
|
||||
|
||||
return result ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called after the renderer and JavaScript in the page has had a chance to
|
||||
/// handle the event. |event| contains information about the keyboard event.
|
||||
/// |os_event| is the operating system event message, if any. Return true if
|
||||
/// the keyboard event was handled or false otherwise.
|
||||
/// </summary>
|
||||
protected virtual bool OnKeyEvent(CefBrowser browser, CefKeyEvent keyEvent, IntPtr osEvent)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Implement this interface to handle events related to browser life span. The
|
||||
/// methods of this class will be called on the UI thread unless otherwise
|
||||
/// indicated.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefLifeSpanHandler
|
||||
{
|
||||
private int on_before_popup(cef_life_span_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, cef_string_t* target_url, cef_string_t* target_frame_name, CefWindowOpenDisposition target_disposition, int user_gesture, cef_popup_features_t* popupFeatures, cef_window_info_t* windowInfo, cef_client_t** client, cef_browser_settings_t* settings, int* no_javascript_access)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_frame = CefFrame.FromNative(frame);
|
||||
var m_targetUrl = cef_string_t.ToString(target_url);
|
||||
var m_targetFrameName = cef_string_t.ToString(target_frame_name);
|
||||
var m_userGesture = user_gesture != 0;
|
||||
var m_popupFeatures = new CefPopupFeatures(popupFeatures);
|
||||
var m_windowInfo = CefWindowInfo.FromNative(windowInfo);
|
||||
var m_client = CefClient.FromNative(*client);
|
||||
var m_settings = new CefBrowserSettings(settings);
|
||||
var m_noJavascriptAccess = (*no_javascript_access) != 0;
|
||||
|
||||
var o_client = m_client;
|
||||
var result = OnBeforePopup(m_browser, m_frame, m_targetUrl, m_targetFrameName, target_disposition, m_userGesture, m_popupFeatures, m_windowInfo, ref m_client, m_settings, ref m_noJavascriptAccess);
|
||||
|
||||
if ((object)o_client != m_client && m_client != null)
|
||||
{
|
||||
*client = m_client.ToNative();
|
||||
}
|
||||
|
||||
*no_javascript_access = m_noJavascriptAccess ? 1 : 0;
|
||||
|
||||
m_popupFeatures.Dispose();
|
||||
m_windowInfo.Dispose();
|
||||
m_settings.Dispose();
|
||||
|
||||
return result ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on the IO thread before a new popup browser is created. The
|
||||
/// |browser| and |frame| values represent the source of the popup request. The
|
||||
/// |target_url| and |target_frame_name| values indicate where the popup
|
||||
/// browser should navigate and may be empty if not specified with the request.
|
||||
/// The |target_disposition| value indicates where the user intended to open
|
||||
/// the popup (e.g. current tab, new tab, etc). The |user_gesture| value will
|
||||
/// be true if the popup was opened via explicit user gesture (e.g. clicking a
|
||||
/// link) or false if the popup opened automatically (e.g. via the
|
||||
/// DomContentLoaded event). The |popupFeatures| structure contains additional
|
||||
/// information about the requested popup window. To allow creation of the
|
||||
/// popup browser optionally modify |windowInfo|, |client|, |settings| and
|
||||
/// |no_javascript_access| and return false. To cancel creation of the popup
|
||||
/// browser return true. The |client| and |settings| values will default to the
|
||||
/// source browser's values. If the |no_javascript_access| value is set to
|
||||
/// false the new browser will not be scriptable and may not be hosted in the
|
||||
/// same renderer process as the source browser.
|
||||
/// </summary>
|
||||
protected virtual bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefWindowOpenDisposition targetDisposition, bool userGesture, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref bool noJavascriptAccess)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void on_after_created(cef_life_span_handler_t* self, cef_browser_t* browser)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
|
||||
OnAfterCreated(m_browser);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called after a new browser is created.
|
||||
/// </summary>
|
||||
protected virtual void OnAfterCreated(CefBrowser browser)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private int run_modal(cef_life_span_handler_t* self, cef_browser_t* browser)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
|
||||
return RunModal(m_browser) ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when a modal window is about to display and the modal loop should
|
||||
/// begin running. Return false to use the default modal loop implementation or
|
||||
/// true to use a custom implementation.
|
||||
/// </summary>
|
||||
protected virtual bool RunModal(CefBrowser browser)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private int do_close(cef_life_span_handler_t* self, cef_browser_t* browser)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
|
||||
return DoClose(m_browser) ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when a browser has recieved a request to close. This may result
|
||||
/// directly from a call to CefBrowserHost::CloseBrowser() or indirectly if the
|
||||
/// browser is a top-level OS window created by CEF and the user attempts to
|
||||
/// close the window. This method will be called after the JavaScript
|
||||
/// 'onunload' event has been fired. It will not be called for browsers after
|
||||
/// the associated OS window has been destroyed (for those browsers it is no
|
||||
/// longer possible to cancel the close).
|
||||
/// If CEF created an OS window for the browser returning false will send an OS
|
||||
/// close notification to the browser window's top-level owner (e.g. WM_CLOSE
|
||||
/// on Windows, performClose: on OS-X and "delete_event" on Linux). If no OS
|
||||
/// window exists (window rendering disabled) returning false will cause the
|
||||
/// browser object to be destroyed immediately. Return true if the browser is
|
||||
/// parented to another window and that other window needs to receive close
|
||||
/// notification via some non-standard technique.
|
||||
/// If an application provides its own top-level window it should handle OS
|
||||
/// close notifications by calling CefBrowserHost::CloseBrowser(false) instead
|
||||
/// of immediately closing (see the example below). This gives CEF an
|
||||
/// opportunity to process the 'onbeforeunload' event and optionally cancel the
|
||||
/// close before DoClose() is called.
|
||||
/// The CefLifeSpanHandler::OnBeforeClose() method will be called immediately
|
||||
/// before the browser object is destroyed. The application should only exit
|
||||
/// after OnBeforeClose() has been called for all existing browsers.
|
||||
/// If the browser represents a modal window and a custom modal loop
|
||||
/// implementation was provided in CefLifeSpanHandler::RunModal() this callback
|
||||
/// should be used to restore the opener window to a usable state.
|
||||
/// By way of example consider what should happen during window close when the
|
||||
/// browser is parented to an application-provided top-level OS window.
|
||||
/// 1. User clicks the window close button which sends an OS close
|
||||
/// notification (e.g. WM_CLOSE on Windows, performClose: on OS-X and
|
||||
/// "delete_event" on Linux).
|
||||
/// 2. Application's top-level window receives the close notification and:
|
||||
/// A. Calls CefBrowserHost::CloseBrowser(false).
|
||||
/// B. Cancels the window close.
|
||||
/// 3. JavaScript 'onbeforeunload' handler executes and shows the close
|
||||
/// confirmation dialog (which can be overridden via
|
||||
/// CefJSDialogHandler::OnBeforeUnloadDialog()).
|
||||
/// 4. User approves the close.
|
||||
/// 5. JavaScript 'onunload' handler executes.
|
||||
/// 6. Application's DoClose() handler is called. Application will:
|
||||
/// A. Set a flag to indicate that the next close attempt will be allowed.
|
||||
/// B. Return false.
|
||||
/// 7. CEF sends an OS close notification.
|
||||
/// 8. Application's top-level window receives the OS close notification and
|
||||
/// allows the window to close based on the flag from #6B.
|
||||
/// 9. Browser OS window is destroyed.
|
||||
/// 10. Application's CefLifeSpanHandler::OnBeforeClose() handler is called and
|
||||
/// the browser object is destroyed.
|
||||
/// 11. Application exits by calling CefQuitMessageLoop() if no other browsers
|
||||
/// exist.
|
||||
/// </summary>
|
||||
protected virtual bool DoClose(CefBrowser browser)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void on_before_close(cef_life_span_handler_t* self, cef_browser_t* browser)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
|
||||
OnBeforeClose(m_browser);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called just before a browser is destroyed. Release all references to the
|
||||
/// browser object and do not attempt to execute any methods on the browser
|
||||
/// object after this callback returns. If this is a modal window and a custom
|
||||
/// modal loop implementation was provided in RunModal() this callback should
|
||||
/// be used to exit the custom modal loop. See DoClose() documentation for
|
||||
/// additional usage information.
|
||||
/// </summary>
|
||||
protected virtual void OnBeforeClose(CefBrowser browser)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Implement this interface to handle events related to browser load status. The
|
||||
/// methods of this class will be called on the browser process UI thread or
|
||||
/// render process main thread (TID_RENDERER).
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefLoadHandler
|
||||
{
|
||||
private void on_loading_state_change(cef_load_handler_t* self, cef_browser_t* browser, int isLoading, int canGoBack, int canGoForward)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var mBrowser = CefBrowser.FromNative(browser);
|
||||
|
||||
OnLoadingStateChange(mBrowser, isLoading != 0, canGoBack != 0, canGoForward != 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the loading state has changed. This callback will be executed
|
||||
/// twice -- once when loading is initiated either programmatically or by user
|
||||
/// action, and once when loading is terminated due to completion, cancellation
|
||||
/// of failure.
|
||||
/// </summary>
|
||||
protected virtual void OnLoadingStateChange(CefBrowser browser, bool isLoading, bool canGoBack, bool canGoForward)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private void on_load_start(cef_load_handler_t* self, cef_browser_t* browser, cef_frame_t* frame)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_frame = CefFrame.FromNative(frame);
|
||||
|
||||
OnLoadStart(m_browser, m_frame);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the browser begins loading a frame. The |frame| value will
|
||||
/// never be empty -- call the IsMain() method to check if this frame is the
|
||||
/// main frame. Multiple frames may be loading at the same time. Sub-frames may
|
||||
/// start or continue loading after the main frame load has ended. This method
|
||||
/// may not be called for a particular frame if the load request for that frame
|
||||
/// fails. For notification of overall browser load status use
|
||||
/// OnLoadingStateChange instead.
|
||||
/// </summary>
|
||||
protected virtual void OnLoadStart(CefBrowser browser, CefFrame frame)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private void on_load_end(cef_load_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, int httpStatusCode)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_frame = CefFrame.FromNative(frame);
|
||||
|
||||
OnLoadEnd(m_browser, m_frame, httpStatusCode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the browser is done loading a frame. The |frame| value will
|
||||
/// never be empty -- call the IsMain() method to check if this frame is the
|
||||
/// main frame. Multiple frames may be loading at the same time. Sub-frames may
|
||||
/// start or continue loading after the main frame load has ended. This method
|
||||
/// will always be called for all frames irrespective of whether the request
|
||||
/// completes successfully.
|
||||
/// </summary>
|
||||
protected virtual void OnLoadEnd(CefBrowser browser, CefFrame frame, int httpStatusCode)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private void on_load_error(cef_load_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, CefErrorCode errorCode, cef_string_t* errorText, cef_string_t* failedUrl)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_frame = CefFrame.FromNative(frame);
|
||||
var m_errorText = cef_string_t.ToString(errorText);
|
||||
var m_failedUrl = cef_string_t.ToString(failedUrl);
|
||||
|
||||
OnLoadError(m_browser, m_frame, errorCode, m_errorText, m_failedUrl);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the resource load for a navigation fails or is canceled.
|
||||
/// |errorCode| is the error code number, |errorText| is the error text and
|
||||
/// |failedUrl| is the URL that failed to load. See net\base\net_error_list.h
|
||||
/// for complete descriptions of the error codes.
|
||||
/// </summary>
|
||||
protected virtual void OnLoadError(CefBrowser browser, CefFrame frame, CefErrorCode errorCode, string errorText, string failedUrl)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Callback interface for CefBrowserHost::GetNavigationEntries. The methods of
|
||||
/// this class will be called on the browser process UI thread.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefNavigationEntryVisitor
|
||||
{
|
||||
private int visit(cef_navigation_entry_visitor_t* self, cef_navigation_entry_t* entry, int current, int index, int total)
|
||||
{
|
||||
CheckSelf(self);
|
||||
var m_entry = CefNavigationEntry.FromNative(entry);
|
||||
var m_result = Visit(m_entry, current != 0, index, total);
|
||||
m_entry.Dispose();
|
||||
return m_result ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method that will be executed. Do not keep a reference to |entry| outside of
|
||||
/// this callback. Return true to continue visiting entries or false to stop.
|
||||
/// |current| is true if this entry is the currently loaded navigation entry.
|
||||
/// |index| is the 0-based index of this entry and |total| is the total number
|
||||
/// of entries.
|
||||
/// </summary>
|
||||
protected abstract bool Visit(CefNavigationEntry entry, bool current, int index, int total);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Callback interface for CefBrowserHost::PrintToPDF. The methods of this class
|
||||
/// will be called on the browser process UI thread.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefPdfPrintCallback
|
||||
{
|
||||
private void on_pdf_print_finished(cef_pdf_print_callback_t* self, cef_string_t* path, int ok)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_path = cef_string_t.ToString(path);
|
||||
OnPdfPrintFinished(m_path, ok != 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method that will be executed when the PDF printing has completed. |path|
|
||||
/// is the output path. |ok| will be true if the printing completed
|
||||
/// successfully or false otherwise.
|
||||
/// </summary>
|
||||
protected abstract void OnPdfPrintFinished(string path, bool ok);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Implement this interface to handle printing on Linux. The methods of this
|
||||
/// class will be called on the browser process UI thread.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefPrintHandler
|
||||
{
|
||||
private void on_print_settings(cef_print_handler_t* self, cef_print_settings_t* settings, int get_defaults)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_settings = CefPrintSettings.FromNative(settings);
|
||||
OnPrintSettings(m_settings, get_defaults != 0);
|
||||
m_settings.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Synchronize |settings| with client state. If |get_defaults| is true then
|
||||
/// populate |settings| with the default print settings. Do not keep a
|
||||
/// reference to |settings| outside of this callback.
|
||||
/// </summary>
|
||||
protected abstract void OnPrintSettings(CefPrintSettings settings, bool getDefaults);
|
||||
|
||||
private int on_print_dialog(cef_print_handler_t* self, int has_selection, cef_print_dialog_callback_t* callback)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_callback = CefPrintDialogCallback.FromNative(callback);
|
||||
var m_result = OnPrintDialog(has_selection != 0, m_callback);
|
||||
return m_result ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show the print dialog. Execute |callback| once the dialog is dismissed.
|
||||
/// Return true if the dialog will be displayed or false to cancel the
|
||||
/// printing immediately.
|
||||
/// </summary>
|
||||
protected abstract bool OnPrintDialog(bool hasSelection, CefPrintDialogCallback callback);
|
||||
|
||||
private int on_print_job(cef_print_handler_t* self, cef_string_t* document_name, cef_string_t* pdf_file_path, cef_print_job_callback_t* callback)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_documentName = cef_string_t.ToString(document_name);
|
||||
var m_pdfFilePath = cef_string_t.ToString(pdf_file_path);
|
||||
var m_callback = CefPrintJobCallback.FromNative(callback);
|
||||
|
||||
var m_result = OnPrintJob(m_documentName, m_pdfFilePath, m_callback);
|
||||
|
||||
return m_result ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send the print job to the printer. Execute |callback| once the job is
|
||||
/// completed. Return true if the job will proceed or false to cancel the job
|
||||
/// immediately.
|
||||
/// </summary>
|
||||
protected abstract bool OnPrintJob(string documentName, string pdfFilePath, CefPrintJobCallback callback);
|
||||
|
||||
|
||||
private void on_print_reset(cef_print_handler_t* self)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
OnPrintReset();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reset client state related to printing.
|
||||
/// </summary>
|
||||
protected abstract void OnPrintReset();
|
||||
|
||||
|
||||
private cef_size_t get_pdf_paper_size(cef_print_handler_t* self, int device_units_per_inch)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_result = GetPdfPaperSize(device_units_per_inch);
|
||||
|
||||
var n_result = new cef_size_t
|
||||
{
|
||||
width = m_result.Width,
|
||||
height = m_result.Height,
|
||||
};
|
||||
|
||||
return n_result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the PDF paper size in device units. Used in combination with
|
||||
/// CefBrowserHost::PrintToPDF().
|
||||
/// </summary>
|
||||
protected abstract CefSize GetPdfPaperSize(int deviceUnitsPerInch);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Interface the client can implement to provide a custom stream reader. The
|
||||
/// methods of this class may be called on any thread.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefReadHandler
|
||||
{
|
||||
private UIntPtr read(cef_read_handler_t* self, void* ptr, UIntPtr size, UIntPtr n)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var length = (long)size * (long)n;
|
||||
using (var stream = new UnmanagedMemoryStream((byte*)ptr, length, length, FileAccess.Write))
|
||||
{
|
||||
return (UIntPtr)Read(stream, length);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read raw binary data.
|
||||
/// </summary>
|
||||
protected abstract long Read(Stream stream, long length);
|
||||
|
||||
|
||||
private int seek(cef_read_handler_t* self, long offset, int whence)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
return Seek(offset, (SeekOrigin)whence) ? 0 : -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Seek to the specified offset position. |whence| may be any one of
|
||||
/// SEEK_CUR, SEEK_END or SEEK_SET. Return zero on success and non-zero on
|
||||
/// failure.
|
||||
/// </summary>
|
||||
protected abstract bool Seek(long offset, SeekOrigin whence);
|
||||
|
||||
|
||||
private long tell(cef_read_handler_t* self)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
return Tell();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the current offset position.
|
||||
/// </summary>
|
||||
protected abstract long Tell();
|
||||
|
||||
|
||||
private int eof(cef_read_handler_t* self)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
return Eof() ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return non-zero if at end of file.
|
||||
/// </summary>
|
||||
protected abstract bool Eof();
|
||||
|
||||
|
||||
private int may_block(cef_read_handler_t* self)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
return MayBlock() ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return true if this handler performs work like accessing the file system
|
||||
/// which may block. Used as a hint for determining the thread to access the
|
||||
/// handler from.
|
||||
/// </summary>
|
||||
protected abstract bool MayBlock();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,288 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Implement this interface to handle events when window rendering is disabled.
|
||||
/// The methods of this class will be called on the UI thread.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefRenderHandler
|
||||
{
|
||||
private int get_root_screen_rect(cef_render_handler_t* self, cef_browser_t* browser, cef_rect_t* rect)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_rect = new CefRectangle();
|
||||
|
||||
var result = GetRootScreenRect(m_browser, ref m_rect);
|
||||
|
||||
if (result)
|
||||
{
|
||||
rect->x = m_rect.X;
|
||||
rect->y = m_rect.Y;
|
||||
rect->width = m_rect.Width;
|
||||
rect->height = m_rect.Height;
|
||||
return 1;
|
||||
}
|
||||
else return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called to retrieve the root window rectangle in screen coordinates. Return
|
||||
/// true if the rectangle was provided.
|
||||
/// </summary>
|
||||
protected virtual bool GetRootScreenRect(CefBrowser browser, ref CefRectangle rect)
|
||||
{
|
||||
// TODO: return CefRectangle? (Nullable<CefRectangle>) instead of returning bool?
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private int get_view_rect(cef_render_handler_t* self, cef_browser_t* browser, cef_rect_t* rect)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_rect = new CefRectangle();
|
||||
|
||||
var result = GetViewRect(m_browser, ref m_rect);
|
||||
|
||||
if (result)
|
||||
{
|
||||
rect->x = m_rect.X;
|
||||
rect->y = m_rect.Y;
|
||||
rect->width = m_rect.Width;
|
||||
rect->height = m_rect.Height;
|
||||
return 1;
|
||||
}
|
||||
else return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called to retrieve the view rectangle which is relative to screen
|
||||
/// coordinates. Return true if the rectangle was provided.
|
||||
/// </summary>
|
||||
protected virtual bool GetViewRect(CefBrowser browser, ref CefRectangle rect)
|
||||
{
|
||||
// TODO: return CefRectangle? (Nullable<CefRectangle>) instead of returning bool?
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private int get_screen_point(cef_render_handler_t* self, cef_browser_t* browser, int viewX, int viewY, int* screenX, int* screenY)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
|
||||
int m_screenX = 0;
|
||||
int m_screenY = 0;
|
||||
|
||||
var result = GetScreenPoint(m_browser, viewX, viewY, ref m_screenX, ref m_screenY);
|
||||
|
||||
if (result)
|
||||
{
|
||||
*screenX = m_screenX;
|
||||
*screenY = m_screenY;
|
||||
return 1;
|
||||
}
|
||||
else return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called to retrieve the translation from view coordinates to actual screen
|
||||
/// coordinates. Return true if the screen coordinates were provided.
|
||||
/// </summary>
|
||||
protected virtual bool GetScreenPoint(CefBrowser browser, int viewX, int viewY, ref int screenX, ref int screenY)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private int get_screen_info(cef_render_handler_t* self, cef_browser_t* browser, cef_screen_info_t* screen_info)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_screenInfo = new CefScreenInfo(screen_info);
|
||||
|
||||
var result = GetScreenInfo(m_browser, m_screenInfo);
|
||||
|
||||
m_screenInfo.Dispose();
|
||||
m_browser.Dispose();
|
||||
|
||||
return result ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called to allow the client to fill in the CefScreenInfo object with
|
||||
/// appropriate values. Return true if the |screen_info| structure has been
|
||||
/// modified.
|
||||
/// If the screen info rectangle is left empty the rectangle from GetViewRect
|
||||
/// will be used. If the rectangle is still empty or invalid popups may not be
|
||||
/// drawn correctly.
|
||||
/// </summary>
|
||||
protected abstract bool GetScreenInfo(CefBrowser browser, CefScreenInfo screenInfo);
|
||||
|
||||
|
||||
private void on_popup_show(cef_render_handler_t* self, cef_browser_t* browser, int show)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
|
||||
OnPopupShow(m_browser, show != 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the browser wants to show or hide the popup widget. The popup
|
||||
/// should be shown if |show| is true and hidden if |show| is false.
|
||||
/// </summary>
|
||||
protected virtual void OnPopupShow(CefBrowser browser, bool show)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private void on_popup_size(cef_render_handler_t* self, cef_browser_t* browser, cef_rect_t* rect)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_rect = new CefRectangle(rect->x, rect->y, rect->width, rect->height);
|
||||
|
||||
OnPopupSize(m_browser, m_rect);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the browser wants to move or resize the popup widget. |rect|
|
||||
/// contains the new location and size in view coordinates.
|
||||
/// </summary>
|
||||
protected abstract void OnPopupSize(CefBrowser browser, CefRectangle rect);
|
||||
|
||||
|
||||
private void on_paint(cef_render_handler_t* self, cef_browser_t* browser, CefPaintElementType type, UIntPtr dirtyRectsCount, cef_rect_t* dirtyRects, void* buffer, int width, int height)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
|
||||
// TODO: reuse arrays?
|
||||
var m_dirtyRects = new CefRectangle[(int)dirtyRectsCount];
|
||||
|
||||
var count = (int)dirtyRectsCount;
|
||||
var rect = dirtyRects;
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
m_dirtyRects[i].X = rect->x;
|
||||
m_dirtyRects[i].Y = rect->y;
|
||||
m_dirtyRects[i].Width = rect->width;
|
||||
m_dirtyRects[i].Height = rect->height;
|
||||
|
||||
rect++;
|
||||
}
|
||||
|
||||
OnPaint(m_browser, type, m_dirtyRects, (IntPtr)buffer, width, height);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when an element should be painted. Pixel values passed to this
|
||||
/// method are scaled relative to view coordinates based on the value of
|
||||
/// CefScreenInfo.device_scale_factor returned from GetScreenInfo. |type|
|
||||
/// indicates whether the element is the view or the popup widget. |buffer|
|
||||
/// contains the pixel data for the whole image. |dirtyRects| contains the set
|
||||
/// of rectangles in pixel coordinates that need to be repainted. |buffer| will
|
||||
/// be |width|*|height|*4 bytes in size and represents a BGRA image with an
|
||||
/// upper-left origin.
|
||||
/// </summary>
|
||||
protected abstract void OnPaint(CefBrowser browser, CefPaintElementType type, CefRectangle[] dirtyRects, IntPtr buffer, int width, int height);
|
||||
|
||||
|
||||
private void on_cursor_change(cef_render_handler_t* self, cef_browser_t* browser, IntPtr cursor, CefCursorType type, cef_cursor_info_t* custom_cursor_info)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_cefCursorInfo = type == CefCursorType.Custom ? new CefCursorInfo(custom_cursor_info) : null;
|
||||
|
||||
OnCursorChange(m_browser, cursor, type, m_cefCursorInfo);
|
||||
|
||||
if (m_cefCursorInfo != null) m_cefCursorInfo.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the browser's cursor has changed. If |type| is CT_CUSTOM then
|
||||
/// |custom_cursor_info| will be populated with the custom cursor information.
|
||||
/// </summary>
|
||||
protected abstract void OnCursorChange(CefBrowser browser, IntPtr cursorHandle, CefCursorType type, CefCursorInfo customCursorInfo);
|
||||
|
||||
|
||||
private int start_dragging(cef_render_handler_t* self, cef_browser_t* browser, cef_drag_data_t* drag_data, CefDragOperationsMask allowed_ops, int x, int y)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_dragData = CefDragData.FromNative(drag_data);
|
||||
|
||||
var m_result = StartDragging(m_browser, m_dragData, allowed_ops, x, y);
|
||||
|
||||
return m_result ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the user starts dragging content in the web view. Contextual
|
||||
/// information about the dragged content is supplied by |drag_data|.
|
||||
/// (|x|, |y|) is the drag start location in screen coordinates.
|
||||
/// OS APIs that run a system message loop may be used within the
|
||||
/// StartDragging call.
|
||||
/// Return false to abort the drag operation. Don't call any of
|
||||
/// CefBrowserHost::DragSource*Ended* methods after returning false.
|
||||
/// Return true to handle the drag operation. Call
|
||||
/// CefBrowserHost::DragSourceEndedAt and DragSourceSystemDragEnded either
|
||||
/// synchronously or asynchronously to inform the web view that the drag
|
||||
/// operation has ended.
|
||||
/// </summary>
|
||||
protected virtual bool StartDragging(CefBrowser browser, CefDragData dragData, CefDragOperationsMask allowedOps, int x, int y)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void update_drag_cursor(cef_render_handler_t* self, cef_browser_t* browser, CefDragOperationsMask operation)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
|
||||
UpdateDragCursor(m_browser, operation);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the web view wants to update the mouse cursor during a
|
||||
/// drag & drop operation. |operation| describes the allowed operation
|
||||
/// (none, move, copy, link).
|
||||
/// </summary>
|
||||
protected virtual void UpdateDragCursor(CefBrowser browser, CefDragOperationsMask operation)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private void on_scroll_offset_changed(cef_render_handler_t* self, cef_browser_t* browser, double x, double y)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
|
||||
OnScrollOffsetChanged(m_browser, x, y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the scroll offset has changed.
|
||||
/// </summary>
|
||||
protected abstract void OnScrollOffsetChanged(CefBrowser browser, double x, double y);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class used to implement render process callbacks. The methods of this class
|
||||
/// will be called on the render process main thread (TID_RENDERER) unless
|
||||
/// otherwise indicated.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefRenderProcessHandler
|
||||
{
|
||||
private void on_render_thread_created(cef_render_process_handler_t* self, cef_list_value_t* extra_info)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var mExtraInfo = CefListValue.FromNative(extra_info);
|
||||
OnRenderThreadCreated(mExtraInfo);
|
||||
mExtraInfo.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called after the render process main thread has been created.
|
||||
/// </summary>
|
||||
protected virtual void OnRenderThreadCreated(CefListValue extraInfo)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private void on_web_kit_initialized(cef_render_process_handler_t* self)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
OnWebKitInitialized();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called after WebKit has been initialized.
|
||||
/// </summary>
|
||||
protected virtual void OnWebKitInitialized()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private void on_browser_created(cef_render_process_handler_t* self, cef_browser_t* browser)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
|
||||
OnBrowserCreated(m_browser);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called after a browser has been created. When browsing cross-origin a new
|
||||
/// browser will be created before the old browser with the same identifier is
|
||||
/// destroyed.
|
||||
/// </summary>
|
||||
protected virtual void OnBrowserCreated(CefBrowser browser)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private void on_browser_destroyed(cef_render_process_handler_t* self, cef_browser_t* browser)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
|
||||
OnBrowserDestroyed(m_browser);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called before a browser is destroyed.
|
||||
/// </summary>
|
||||
protected virtual void OnBrowserDestroyed(CefBrowser browser)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private cef_load_handler_t* get_load_handler(cef_render_process_handler_t* self)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var result = GetLoadHandler();
|
||||
|
||||
return result != null ? result.ToNative() : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the handler for browser load status events.
|
||||
/// </summary>
|
||||
protected virtual CefLoadHandler GetLoadHandler()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private int on_before_navigation(cef_render_process_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, cef_request_t* request, CefNavigationType navigation_type, int is_redirect)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_frame = CefFrame.FromNative(frame);
|
||||
var m_request = CefRequest.FromNative(request);
|
||||
|
||||
var result = OnBeforeNavigation(m_browser, m_frame, m_request, navigation_type, is_redirect != 0);
|
||||
|
||||
return result ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called before browser navigation. Return true to cancel the navigation or
|
||||
/// false to allow the navigation to proceed. The |request| object cannot be
|
||||
/// modified in this callback.
|
||||
/// </summary>
|
||||
protected virtual bool OnBeforeNavigation(CefBrowser browser, CefFrame frame, CefRequest request, CefNavigationType navigation_type, bool isRedirect)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void on_context_created(cef_render_process_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, cef_v8context_t* context)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_frame = CefFrame.FromNative(frame);
|
||||
var m_context = CefV8Context.FromNative(context);
|
||||
|
||||
OnContextCreated(m_browser, m_frame, m_context);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called immediately after the V8 context for a frame has been created. To
|
||||
/// retrieve the JavaScript 'window' object use the CefV8Context::GetGlobal()
|
||||
/// method. V8 handles can only be accessed from the thread on which they are
|
||||
/// created. A task runner for posting tasks on the associated thread can be
|
||||
/// retrieved via the CefV8Context::GetTaskRunner() method.
|
||||
/// </summary>
|
||||
protected virtual void OnContextCreated(CefBrowser browser, CefFrame frame, CefV8Context context)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private void on_context_released(cef_render_process_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, cef_v8context_t* context)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_frame = CefFrame.FromNative(frame);
|
||||
var m_context = CefV8Context.FromNative(context);
|
||||
|
||||
OnContextReleased(m_browser, m_frame, m_context);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called immediately before the V8 context for a frame is released. No
|
||||
/// references to the context should be kept after this method is called.
|
||||
/// </summary>
|
||||
protected virtual void OnContextReleased(CefBrowser browser, CefFrame frame, CefV8Context context)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private void on_uncaught_exception(cef_render_process_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, cef_v8context_t* context, cef_v8exception_t* exception, cef_v8stack_trace_t* stackTrace)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var mBrowser = CefBrowser.FromNative(browser);
|
||||
var mFrame = CefFrame.FromNative(frame);
|
||||
var mContext = CefV8Context.FromNative(context);
|
||||
var mException = CefV8Exception.FromNative(exception);
|
||||
var mStackTrace = CefV8StackTrace.FromNative(stackTrace);
|
||||
|
||||
OnUncaughtException(mBrowser, mFrame, mContext, mException, mStackTrace);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called for global uncaught exceptions in a frame. Execution of this
|
||||
/// callback is disabled by default. To enable set
|
||||
/// CefSettings.uncaught_exception_stack_size > 0.
|
||||
/// </summary>
|
||||
protected virtual void OnUncaughtException(CefBrowser browser, CefFrame frame, CefV8Context context, CefV8Exception exception, CefV8StackTrace stackTrace)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private void on_focused_node_changed(cef_render_process_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, cef_domnode_t* node)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_frame = CefFrame.FromNative(frame);
|
||||
var m_node = CefDomNode.FromNativeOrNull(node);
|
||||
|
||||
OnFocusedNodeChanged(m_browser, m_frame, m_node);
|
||||
|
||||
if (m_node != null) m_node.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when a new node in the the browser gets focus. The |node| value may
|
||||
/// be empty if no specific node has gained focus. The node object passed to
|
||||
/// this method represents a snapshot of the DOM at the time this method is
|
||||
/// executed. DOM objects are only valid for the scope of this method. Do not
|
||||
/// keep references to or attempt to access any DOM objects outside the scope
|
||||
/// of this method.
|
||||
/// </summary>
|
||||
protected virtual void OnFocusedNodeChanged(CefBrowser browser, CefFrame frame, CefDomNode node)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private int on_process_message_received(cef_render_process_handler_t* self, cef_browser_t* browser, CefProcessId source_process, cef_process_message_t* message)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_message = CefProcessMessage.FromNative(message);
|
||||
|
||||
var result = OnProcessMessageReceived(m_browser, source_process, m_message);
|
||||
|
||||
m_message.Dispose();
|
||||
|
||||
return result ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when a new message is received from a different process. Return true
|
||||
/// if the message was handled or false otherwise. Do not keep a reference to
|
||||
/// or attempt to access the message outside of this callback.
|
||||
/// </summary>
|
||||
protected virtual bool OnProcessMessageReceived(CefBrowser browser, CefProcessId sourceProcess, CefProcessMessage message)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Implement this interface to provide handler implementations. The handler
|
||||
/// instance will not be released until all objects related to the context have
|
||||
/// been destroyed.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefRequestContextHandler
|
||||
{
|
||||
private cef_cookie_manager_t* get_cookie_manager(cef_request_context_handler_t* self)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var result = GetCookieManager();
|
||||
|
||||
return result != null ? result.ToNative() : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on the IO thread to retrieve the cookie manager. If this method
|
||||
/// returns NULL the default cookie manager retrievable via
|
||||
/// CefRequestContext::GetDefaultCookieManager() will be used.
|
||||
/// </summary>
|
||||
protected abstract CefCookieManager GetCookieManager();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,384 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Implement this interface to handle events related to browser requests. The
|
||||
/// methods of this class will be called on the thread indicated.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefRequestHandler
|
||||
{
|
||||
private int on_before_browse(cef_request_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, cef_request_t* request, int is_redirect)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_frame = CefFrame.FromNative(frame);
|
||||
var m_request = CefRequest.FromNative(request);
|
||||
var m_isRedirect = is_redirect != 0;
|
||||
|
||||
var result = OnBeforeBrowse(m_browser, m_frame, m_request, m_isRedirect);
|
||||
|
||||
return result ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on the UI thread before browser navigation. Return true to cancel
|
||||
/// the navigation or false to allow the navigation to proceed. The |request|
|
||||
/// object cannot be modified in this callback.
|
||||
/// CefLoadHandler::OnLoadingStateChange will be called twice in all cases.
|
||||
/// If the navigation is allowed CefLoadHandler::OnLoadStart and
|
||||
/// CefLoadHandler::OnLoadEnd will be called. If the navigation is canceled
|
||||
/// CefLoadHandler::OnLoadError will be called with an |errorCode| value of
|
||||
/// ERR_ABORTED.
|
||||
/// </summary>
|
||||
protected virtual bool OnBeforeBrowse(CefBrowser browser, CefFrame frame, CefRequest request, bool isRedirect)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private int on_open_urlfrom_tab(cef_request_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, cef_string_t* target_url, CefWindowOpenDisposition target_disposition, int user_gesture)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_frame = CefFrame.FromNative(frame);
|
||||
var m_targetUrl = cef_string_t.ToString(target_url);
|
||||
var m_userGesture = user_gesture != 0;
|
||||
|
||||
var m_result = OnOpenUrlFromTab(m_browser, m_frame, m_targetUrl, target_disposition, m_userGesture);
|
||||
|
||||
return m_result ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on the UI thread before OnBeforeBrowse in certain limited cases
|
||||
/// where navigating a new or different browser might be desirable. This
|
||||
/// includes user-initiated navigation that might open in a special way (e.g.
|
||||
/// links clicked via middle-click or ctrl + left-click) and certain types of
|
||||
/// cross-origin navigation initiated from the renderer process (e.g.
|
||||
/// navigating the top-level frame to/from a file URL). The |browser| and
|
||||
/// |frame| values represent the source of the navigation. The
|
||||
/// |target_disposition| value indicates where the user intended to navigate
|
||||
/// the browser based on standard Chromium behaviors (e.g. current tab,
|
||||
/// new tab, etc). The |user_gesture| value will be true if the browser
|
||||
/// navigated via explicit user gesture (e.g. clicking a link) or false if it
|
||||
/// navigated automatically (e.g. via the DomContentLoaded event). Return true
|
||||
/// to cancel the navigation or false to allow the navigation to proceed in the
|
||||
/// source browser's top-level frame.
|
||||
/// </summary>
|
||||
protected virtual bool OnOpenUrlFromTab(CefBrowser browser, CefFrame frame, string targetUrl, CefWindowOpenDisposition targetDisposition, bool userGesture)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private CefReturnValue on_before_resource_load(cef_request_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, cef_request_t* request, cef_request_callback_t* callback)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_frame = CefFrame.FromNative(frame);
|
||||
var m_request = CefRequest.FromNative(request);
|
||||
var m_callback = CefRequestCallback.FromNative(callback);
|
||||
|
||||
var result = OnBeforeResourceLoad(m_browser, m_frame, m_request, m_callback);
|
||||
|
||||
m_request.Dispose();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on the IO thread before a resource request is loaded. The |request|
|
||||
/// object may be modified. Return RV_CONTINUE to continue the request
|
||||
/// immediately. Return RV_CONTINUE_ASYNC and call CefRequestCallback::
|
||||
/// Continue() at a later time to continue or cancel the request
|
||||
/// asynchronously. Return RV_CANCEL to cancel the request immediately.
|
||||
/// </summary>
|
||||
protected virtual CefReturnValue OnBeforeResourceLoad(CefBrowser browser, CefFrame frame, CefRequest request, CefRequestCallback callback)
|
||||
{
|
||||
return CefReturnValue.Continue;
|
||||
}
|
||||
|
||||
|
||||
private cef_resource_handler_t* get_resource_handler(cef_request_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, cef_request_t* request)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_frame = CefFrame.FromNative(frame);
|
||||
var m_request = CefRequest.FromNative(request);
|
||||
|
||||
var handler = GetResourceHandler(m_browser, m_frame, m_request);
|
||||
|
||||
m_request.Dispose();
|
||||
|
||||
return handler != null ? handler.ToNative() : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on the IO thread before a resource is loaded. To allow the resource
|
||||
/// to load normally return NULL. To specify a handler for the resource return
|
||||
/// a CefResourceHandler object. The |request| object should not be modified in
|
||||
/// this callback.
|
||||
/// </summary>
|
||||
protected virtual CefResourceHandler GetResourceHandler(CefBrowser browser, CefFrame frame, CefRequest request)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private void on_resource_redirect(cef_request_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, cef_request_t* request, cef_string_t* new_url)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_frame = CefFrame.FromNative(frame);
|
||||
var m_request = CefRequest.FromNative(request);
|
||||
var m_newUrl = cef_string_t.ToString(new_url);
|
||||
|
||||
var o_newUrl = m_newUrl;
|
||||
OnResourceRedirect(m_browser, m_frame, m_request, ref m_newUrl);
|
||||
|
||||
if ((object)m_newUrl != (object)o_newUrl)
|
||||
{
|
||||
cef_string_t.Copy(m_newUrl, new_url);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on the IO thread when a resource load is redirected. The |request|
|
||||
/// parameter will contain the old URL and other request-related information.
|
||||
/// The |new_url| parameter will contain the new URL and can be changed if
|
||||
/// desired. The |request| object cannot be modified in this callback.
|
||||
/// </summary>
|
||||
protected virtual void OnResourceRedirect(CefBrowser browser, CefFrame frame, CefRequest request, ref string newUrl)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private int on_resource_response(cef_request_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, cef_request_t* request, cef_response_t* response)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_frame = CefFrame.FromNative(frame);
|
||||
var m_request = CefRequest.FromNative(request);
|
||||
var m_response = CefResponse.FromNative(response);
|
||||
|
||||
var m_result = OnResourceResponse(m_browser, m_frame, m_request, m_response);
|
||||
|
||||
return m_result ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on the IO thread when a resource response is received. To allow the
|
||||
/// resource to load normally return false. To redirect or retry the resource
|
||||
/// modify |request| (url, headers or post body) and return true. The
|
||||
/// |response| object cannot be modified in this callback.
|
||||
/// </summary>
|
||||
protected virtual bool OnResourceResponse(CefBrowser browser, CefFrame frame, CefRequest request, CefResponse response)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private int get_auth_credentials(cef_request_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, int isProxy, cef_string_t* host, int port, cef_string_t* realm, cef_string_t* scheme, cef_auth_callback_t* callback)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_frame = CefFrame.FromNative(frame);
|
||||
var m_host = cef_string_t.ToString(host);
|
||||
var m_realm = cef_string_t.ToString(realm);
|
||||
var m_scheme = cef_string_t.ToString(scheme);
|
||||
var m_callback = CefAuthCallback.FromNative(callback);
|
||||
|
||||
var result = GetAuthCredentials(m_browser, m_frame, isProxy != 0, m_host, port, m_realm, m_scheme, m_callback);
|
||||
|
||||
return result ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on the IO thread when the browser needs credentials from the user.
|
||||
/// |isProxy| indicates whether the host is a proxy server. |host| contains the
|
||||
/// hostname and |port| contains the port number. Return true to continue the
|
||||
/// request and call CefAuthCallback::Continue() either in this method or
|
||||
/// at a later time when the authentication information is available. Return
|
||||
/// false to cancel the request immediately.
|
||||
/// </summary>
|
||||
protected virtual bool GetAuthCredentials(CefBrowser browser, CefFrame frame, bool isProxy, string host, int port, string realm, string scheme, CefAuthCallback callback)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private int on_quota_request(cef_request_handler_t* self, cef_browser_t* browser, cef_string_t* origin_url, long new_size, cef_request_callback_t* callback)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_origin_url = cef_string_t.ToString(origin_url);
|
||||
var m_callback = CefRequestCallback.FromNative(callback);
|
||||
|
||||
var result = OnQuotaRequest(m_browser, m_origin_url, new_size, m_callback);
|
||||
|
||||
return result ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on the IO thread when JavaScript requests a specific storage quota
|
||||
/// size via the webkitStorageInfo.requestQuota function. |origin_url| is the
|
||||
/// origin of the page making the request. |new_size| is the requested quota
|
||||
/// size in bytes. Return true to continue the request and call
|
||||
/// CefRequestCallback::Continue() either in this method or at a later time to
|
||||
/// grant or deny the request. Return false to cancel the request immediately.
|
||||
/// </summary>
|
||||
protected virtual bool OnQuotaRequest(CefBrowser browser, string originUrl, long newSize, CefRequestCallback callback)
|
||||
{
|
||||
callback.Continue(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void on_protocol_execution(cef_request_handler_t* self, cef_browser_t* browser, cef_string_t* url, int* allow_os_execution)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_url = cef_string_t.ToString(url);
|
||||
bool m_allow_os_execution;
|
||||
|
||||
OnProtocolExecution(m_browser, m_url, out m_allow_os_execution);
|
||||
|
||||
*allow_os_execution = m_allow_os_execution ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on the UI thread to handle requests for URLs with an unknown
|
||||
/// protocol component. Set |allow_os_execution| to true to attempt execution
|
||||
/// via the registered OS protocol handler, if any.
|
||||
/// SECURITY WARNING: YOU SHOULD USE THIS METHOD TO ENFORCE RESTRICTIONS BASED
|
||||
/// ON SCHEME, HOST OR OTHER URL ANALYSIS BEFORE ALLOWING OS EXECUTION.
|
||||
/// </summary>
|
||||
protected virtual void OnProtocolExecution(CefBrowser browser, string url, out bool allowOSExecution)
|
||||
{
|
||||
allowOSExecution = true;
|
||||
}
|
||||
|
||||
|
||||
private int on_certificate_error(cef_request_handler_t* self, cef_browser_t* browser, CefErrorCode cert_error, cef_string_t* request_url, cef_sslinfo_t* ssl_info, cef_request_callback_t* callback)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_request_url = cef_string_t.ToString(request_url);
|
||||
var m_ssl_info = CefSslInfo.FromNative(ssl_info);
|
||||
var m_callback = CefRequestCallback.FromNativeOrNull(callback);
|
||||
|
||||
var result = OnCertificateError(m_browser, cert_error, m_request_url, m_ssl_info, m_callback);
|
||||
|
||||
return result ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on the UI thread to handle requests for URLs with an invalid
|
||||
/// SSL certificate. Return true and call CefRequestCallback::Continue() either
|
||||
/// in this method or at a later time to continue or cancel the request. Return
|
||||
/// false to cancel the request immediately. If |callback| is empty the error
|
||||
/// cannot be recovered from and the request will be canceled automatically.
|
||||
/// If CefSettings.ignore_certificate_errors is set all invalid certificates
|
||||
/// will be accepted without calling this method.
|
||||
/// </summary>
|
||||
protected virtual bool OnCertificateError(CefBrowser browser, CefErrorCode certError, string requestUrl, CefSslInfo sslInfo, CefRequestCallback callback)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private int on_before_plugin_load(cef_request_handler_t* self, cef_browser_t* browser, cef_string_t* url, cef_string_t* policy_url, cef_web_plugin_info_t* info)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_url = cef_string_t.ToString(url);
|
||||
var m_policy_url = cef_string_t.ToString(policy_url);
|
||||
var m_info = CefWebPluginInfo.FromNative(info);
|
||||
|
||||
var result = OnBeforePluginLoad(m_browser, m_url, m_policy_url, m_info);
|
||||
|
||||
return result ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on the browser process IO thread before a plugin is loaded. Return
|
||||
/// true to block loading of the plugin.
|
||||
/// </summary>
|
||||
protected virtual bool OnBeforePluginLoad(CefBrowser browser, string url, string policyUrl, CefWebPluginInfo info)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void on_plugin_crashed(cef_request_handler_t* self, cef_browser_t* browser, cef_string_t* plugin_path)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
var m_plugin_path = cef_string_t.ToString(plugin_path);
|
||||
|
||||
OnPluginCrashed(m_browser, m_plugin_path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on the browser process UI thread when a plugin has crashed.
|
||||
/// |plugin_path| is the path of the plugin that crashed.
|
||||
/// </summary>
|
||||
protected virtual void OnPluginCrashed(CefBrowser browser, string pluginPath)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private void on_render_view_ready(cef_request_handler_t* self, cef_browser_t* browser)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
OnRenderViewReady(m_browser);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on the browser process UI thread when the render view associated
|
||||
/// with |browser| is ready to receive/handle IPC messages in the render
|
||||
/// process.
|
||||
/// </summary>
|
||||
protected virtual void OnRenderViewReady(CefBrowser browser)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private void on_render_process_terminated(cef_request_handler_t* self, cef_browser_t* browser, CefTerminationStatus status)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNative(browser);
|
||||
|
||||
OnRenderProcessTerminated(m_browser, status);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on the browser process UI thread when the render process
|
||||
/// terminates unexpectedly. |status| indicates how the process
|
||||
/// terminated.
|
||||
/// </summary>
|
||||
protected virtual void OnRenderProcessTerminated(CefBrowser browser, CefTerminationStatus status)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class used to implement a custom resource bundle interface. The methods of
|
||||
/// this class may be called on multiple threads.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefResourceBundleHandler
|
||||
{
|
||||
private int get_localized_string(cef_resource_bundle_handler_t* self, int message_id, cef_string_t* @string)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var value = GetLocalizedString(message_id);
|
||||
|
||||
if (value != null)
|
||||
{
|
||||
cef_string_t.Copy(value, @string);
|
||||
return 1;
|
||||
}
|
||||
else return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called to retrieve a localized translation for the string specified by
|
||||
/// |message_id|. To provide the translation set |string| to the translation
|
||||
/// string and return true. To use the default translation return false.
|
||||
/// Supported message IDs are listed in cef_pack_strings.h.
|
||||
/// </summary>
|
||||
protected virtual string GetLocalizedString(int messageId)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private int get_data_resource(cef_resource_bundle_handler_t* self, int resource_id, void** data, UIntPtr* data_size)
|
||||
{
|
||||
CheckSelf(self);
|
||||
return 0; // TODO: CefResourceBundleHandler.GetDataResource
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called to retrieve data for the resource specified by |resource_id|. To
|
||||
/// provide the resource data set |data| and |data_size| to the data pointer
|
||||
/// and size respectively and return true. To use the default resource data
|
||||
/// return false. The resource data will not be copied and must remain resident
|
||||
/// in memory. Supported resource IDs are listed in cef_pack_resources.h.
|
||||
/// </summary>
|
||||
protected virtual bool GetDataResource(int resource_id, void** data, UIntPtr* data_size)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
using System.IO;
|
||||
|
||||
/// <summary>
|
||||
/// Class used to implement a custom request handler interface. The methods of
|
||||
/// this class will always be called on the IO thread.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefResourceHandler
|
||||
{
|
||||
private int process_request(cef_resource_handler_t* self, cef_request_t* request, cef_callback_t* callback)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_request = CefRequest.FromNative(request);
|
||||
var m_callback = CefCallback.FromNative(callback);
|
||||
|
||||
var result = ProcessRequest(m_request, m_callback);
|
||||
return result ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Begin processing the request. To handle the request return true and call
|
||||
/// CefCallback::Continue() once the response header information is available
|
||||
/// (CefCallback::Continue() can also be called from inside this method if
|
||||
/// header information is available immediately). To cancel the request return
|
||||
/// false.
|
||||
/// </summary>
|
||||
protected abstract bool ProcessRequest(CefRequest request, CefCallback callback);
|
||||
|
||||
|
||||
private void get_response_headers(cef_resource_handler_t* self, cef_response_t* response, long* response_length, cef_string_t* redirectUrl)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_response = CefResponse.FromNative(response);
|
||||
long m_responseLength;
|
||||
string m_redirectUrl;
|
||||
|
||||
GetResponseHeaders(m_response, out m_responseLength, out m_redirectUrl);
|
||||
|
||||
*response_length = m_responseLength;
|
||||
|
||||
if (!string.IsNullOrEmpty(m_redirectUrl))
|
||||
{
|
||||
cef_string_t.Copy(m_redirectUrl, redirectUrl);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve response header information. If the response length is not known
|
||||
/// set |response_length| to -1 and ReadResponse() will be called until it
|
||||
/// returns false. If the response length is known set |response_length|
|
||||
/// to a positive value and ReadResponse() will be called until it returns
|
||||
/// false or the specified number of bytes have been read. Use the |response|
|
||||
/// object to set the mime type, http status code and other optional header
|
||||
/// values. To redirect the request to a new URL set |redirectUrl| to the new
|
||||
/// URL.
|
||||
/// </summary>
|
||||
protected abstract void GetResponseHeaders(CefResponse response, out long responseLength, out string redirectUrl);
|
||||
|
||||
|
||||
private int read_response(cef_resource_handler_t* self, void* data_out, int bytes_to_read, int* bytes_read, cef_callback_t* callback)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_callback = CefCallback.FromNative(callback);
|
||||
|
||||
using (var m_stream = new UnmanagedMemoryStream((byte*)data_out, bytes_to_read, bytes_to_read, FileAccess.Write))
|
||||
{
|
||||
int m_bytesRead;
|
||||
var result = ReadResponse(m_stream, bytes_to_read, out m_bytesRead, m_callback);
|
||||
*bytes_read = m_bytesRead;
|
||||
return result ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read response data. If data is available immediately copy up to
|
||||
/// |bytes_to_read| bytes into |data_out|, set |bytes_read| to the number of
|
||||
/// bytes copied, and return true. To read the data at a later time set
|
||||
/// |bytes_read| to 0, return true and call CefCallback::Continue() when the
|
||||
/// data is available. To indicate response completion return false.
|
||||
/// </summary>
|
||||
protected abstract bool ReadResponse(Stream response, int bytesToRead, out int bytesRead, CefCallback callback);
|
||||
|
||||
|
||||
private int can_get_cookie(cef_resource_handler_t* self, cef_cookie_t* cookie)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_cookie = CefCookie.FromNative(cookie);
|
||||
|
||||
return CanGetCookie(m_cookie) ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return true if the specified cookie can be sent with the request or false
|
||||
/// otherwise. If false is returned for any cookie then no cookies will be sent
|
||||
/// with the request.
|
||||
/// </summary>
|
||||
protected abstract bool CanGetCookie(CefCookie cookie);
|
||||
|
||||
|
||||
private int can_set_cookie(cef_resource_handler_t* self, cef_cookie_t* cookie)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_cookie = CefCookie.FromNative(cookie);
|
||||
|
||||
return CanSetCookie(m_cookie) ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return true if the specified cookie returned with the response can be set
|
||||
/// or false otherwise.
|
||||
/// </summary>
|
||||
protected abstract bool CanSetCookie(CefCookie cookie);
|
||||
|
||||
|
||||
private void cancel(cef_resource_handler_t* self)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
Cancel();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Request processing has been canceled.
|
||||
/// </summary>
|
||||
protected abstract void Cancel();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Callback interface for CefBrowserHost::RunFileDialog. The methods of this
|
||||
/// class will be called on the browser process UI thread.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefRunFileDialogCallback
|
||||
{
|
||||
private void on_file_dialog_dismissed(cef_run_file_dialog_callback_t* self, int selected_accept_filter, cef_string_list* file_paths)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var mFilePaths = cef_string_list.ToArray(file_paths);
|
||||
|
||||
OnFileDialogDismissed(selected_accept_filter, mFilePaths);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called asynchronously after the file dialog is dismissed.
|
||||
/// |selected_accept_filter| is the 0-based index of the value selected from
|
||||
/// the accept filters array passed to CefBrowserHost::RunFileDialog.
|
||||
/// |file_paths| will be a single value or a list of values depending on the
|
||||
/// dialog mode. If the selection was cancelled |file_paths| will be empty.
|
||||
/// </summary>
|
||||
protected abstract void OnFileDialogDismissed(int selectedAcceptFilter, string[] filePaths);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class that creates CefResourceHandler instances for handling scheme requests.
|
||||
/// The methods of this class will always be called on the IO thread.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefSchemeHandlerFactory
|
||||
{
|
||||
private cef_resource_handler_t* create(cef_scheme_handler_factory_t* self, cef_browser_t* browser, cef_frame_t* frame, cef_string_t* scheme_name, cef_request_t* request)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_browser = CefBrowser.FromNativeOrNull(browser);
|
||||
var m_frame = CefFrame.FromNativeOrNull(frame);
|
||||
var m_schemeName = cef_string_t.ToString(scheme_name);
|
||||
var m_request = CefRequest.FromNative(request);
|
||||
|
||||
var handler = Create(m_browser, m_frame, m_schemeName, m_request);
|
||||
|
||||
// TODO: [ApiUsage] method can return null, only when schemeName is built-in scheme, in other cases it is incorrect.
|
||||
return handler != null ? handler.ToNative() : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a new resource handler instance to handle the request or an empty
|
||||
/// reference to allow default handling of the request. |browser| and |frame|
|
||||
/// will be the browser window and frame respectively that originated the
|
||||
/// request or NULL if the request did not originate from a browser window
|
||||
/// (for example, if the request came from CefURLRequest). The |request| object
|
||||
/// passed to this method will not contain cookie data.
|
||||
/// </summary>
|
||||
protected abstract CefResourceHandler Create(CefBrowser browser, CefFrame frame, string schemeName, CefRequest request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Interface to implement to be notified of asynchronous completion via
|
||||
/// CefCookieManager::SetCookie().
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefSetCookieCallback
|
||||
{
|
||||
private void on_complete(cef_set_cookie_callback_t* self, int success)
|
||||
{
|
||||
CheckSelf(self);
|
||||
OnComplete(success != 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method that will be called upon completion. |success| will be true if the
|
||||
/// cookie was set successfully.
|
||||
/// </summary>
|
||||
protected abstract void OnComplete(bool success);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Implement this interface to receive string values asynchronously.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefStringVisitor
|
||||
{
|
||||
private void visit(cef_string_visitor_t* self, cef_string_t* @string)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
Visit(cef_string_t.ToString(@string));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method that will be executed.
|
||||
/// </summary>
|
||||
protected abstract void Visit(string value);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Implement this interface for asynchronous task execution. If the task is
|
||||
/// posted successfully and if the associated message loop is still running then
|
||||
/// the Execute() method will be called on the target thread. If the task fails
|
||||
/// to post then the task object may be destroyed on the source thread instead of
|
||||
/// the target thread. For this reason be cautious when performing work in the
|
||||
/// task object destructor.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefTask
|
||||
{
|
||||
private void execute(cef_task_t* self)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
Execute();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method that will be executed on the target thread.
|
||||
/// </summary>
|
||||
protected abstract void Execute();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
using System.IO;
|
||||
|
||||
/// <summary>
|
||||
/// Interface that should be implemented by the CefURLRequest client. The
|
||||
/// methods of this class will be called on the same thread that created the
|
||||
/// request unless otherwise documented.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefUrlRequestClient
|
||||
{
|
||||
private void on_request_complete(cef_urlrequest_client_t* self, cef_urlrequest_t* request)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_request = CefUrlRequest.FromNative(request);
|
||||
|
||||
OnRequestComplete(m_request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notifies the client that the request has completed. Use the
|
||||
/// CefURLRequest::GetRequestStatus method to determine if the request was
|
||||
/// successful or not.
|
||||
/// </summary>
|
||||
protected abstract void OnRequestComplete(CefUrlRequest request);
|
||||
|
||||
|
||||
private void on_upload_progress(cef_urlrequest_client_t* self, cef_urlrequest_t* request, long current, long total)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_request = CefUrlRequest.FromNative(request);
|
||||
|
||||
OnUploadProgress(m_request, current, total);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notifies the client of upload progress. |current| denotes the number of
|
||||
/// bytes sent so far and |total| is the total size of uploading data (or -1 if
|
||||
/// chunked upload is enabled). This method will only be called if the
|
||||
/// UR_FLAG_REPORT_UPLOAD_PROGRESS flag is set on the request.
|
||||
/// </summary>
|
||||
protected abstract void OnUploadProgress(CefUrlRequest request, long current, long total);
|
||||
|
||||
|
||||
private void on_download_progress(cef_urlrequest_client_t* self, cef_urlrequest_t* request, long current, long total)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_request = CefUrlRequest.FromNative(request);
|
||||
|
||||
OnDownloadProgress(m_request, current, total);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notifies the client of download progress. |current| denotes the number of
|
||||
/// bytes received up to the call and |total| is the expected total size of the
|
||||
/// response (or -1 if not determined).
|
||||
/// </summary>
|
||||
protected abstract void OnDownloadProgress(CefUrlRequest request, long current, long total);
|
||||
|
||||
|
||||
private void on_download_data(cef_urlrequest_client_t* self, cef_urlrequest_t* request, void* data, UIntPtr data_length)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_request = CefUrlRequest.FromNative(request);
|
||||
|
||||
using (var stream = new UnmanagedMemoryStream((byte*)data, (long)data_length))
|
||||
{
|
||||
OnDownloadData(m_request, stream);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when some part of the response is read. |data| contains the current
|
||||
/// bytes received since the last call. This method will not be called if the
|
||||
/// UR_FLAG_NO_DOWNLOAD_DATA flag is set on the request.
|
||||
/// </summary>
|
||||
protected abstract void OnDownloadData(CefUrlRequest request, Stream data);
|
||||
|
||||
|
||||
private int get_auth_credentials(cef_urlrequest_client_t* self, int isProxy, cef_string_t* host, int port, cef_string_t* realm, cef_string_t* scheme, cef_auth_callback_t* callback)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_isProxy = isProxy != 0;
|
||||
var m_host = cef_string_t.ToString(host);
|
||||
var m_realm = cef_string_t.ToString(realm);
|
||||
var m_scheme = cef_string_t.ToString(scheme);
|
||||
var m_callback = CefAuthCallback.FromNative(callback);
|
||||
|
||||
var m_result = GetAuthCredentials(m_isProxy, m_host, port, m_realm, m_scheme, m_callback);
|
||||
|
||||
return m_result ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on the IO thread when the browser needs credentials from the user.
|
||||
/// |isProxy| indicates whether the host is a proxy server. |host| contains the
|
||||
/// hostname and |port| contains the port number. Return true to continue the
|
||||
/// request and call CefAuthCallback::Continue() when the authentication
|
||||
/// information is available. Return false to cancel the request. This method
|
||||
/// will only be called for requests initiated from the browser process.
|
||||
/// </summary>
|
||||
protected virtual bool GetAuthCredentials(bool isProxy, string host, int port, string realm, string scheme, CefAuthCallback callback)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Cef3.Interop;
|
||||
|
||||
public abstract unsafe partial class CefUserData
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Interface that should be implemented to handle V8 function calls. The methods
|
||||
/// of this class will be called on the thread associated with the V8 function.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefV8Accessor
|
||||
{
|
||||
private int get(cef_v8accessor_t* self, cef_string_t* name, cef_v8value_t* @object, cef_v8value_t** retval, cef_string_t* exception)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_name = cef_string_t.ToString(name);
|
||||
var m_obj = CefV8Value.FromNative(@object);
|
||||
CefV8Value m_returnValue;
|
||||
string mException;
|
||||
|
||||
var handled = Get(m_name, m_obj, out m_returnValue, out mException);
|
||||
|
||||
if (handled)
|
||||
{
|
||||
if (mException != null)
|
||||
{
|
||||
cef_string_t.Copy(mException, exception);
|
||||
}
|
||||
else if (m_returnValue != null)
|
||||
{
|
||||
*retval = m_returnValue.ToNative();
|
||||
}
|
||||
}
|
||||
|
||||
return handled ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle retrieval the accessor value identified by |name|. |object| is the
|
||||
/// receiver ('this' object) of the accessor. If retrieval succeeds set
|
||||
/// |retval| to the return value. If retrieval fails set |exception| to the
|
||||
/// exception that will be thrown. Return true if accessor retrieval was
|
||||
/// handled.
|
||||
/// </summary>
|
||||
protected abstract bool Get(string name, CefV8Value obj, out CefV8Value returnValue, out string exception);
|
||||
|
||||
|
||||
private int set(cef_v8accessor_t* self, cef_string_t* name, cef_v8value_t* @object, cef_v8value_t* value, cef_string_t* exception)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_name = cef_string_t.ToString(name);
|
||||
var m_obj = CefV8Value.FromNative(@object);
|
||||
var m_value = CefV8Value.FromNative(value);
|
||||
string mException;
|
||||
|
||||
var handled = this.Set(m_name, m_obj, m_value, out mException);
|
||||
|
||||
if (handled)
|
||||
{
|
||||
if (mException != null)
|
||||
{
|
||||
cef_string_t.Copy(mException, exception);
|
||||
}
|
||||
}
|
||||
|
||||
return handled ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle assignment of the accessor value identified by |name|. |object| is
|
||||
/// the receiver ('this' object) of the accessor. |value| is the new value
|
||||
/// being assigned to the accessor. If assignment fails set |exception| to the
|
||||
/// exception that will be thrown. Return true if accessor assignment was
|
||||
/// handled.
|
||||
/// </summary>
|
||||
protected abstract bool Set(string name, CefV8Value obj, CefV8Value value, out string exception);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Interface that should be implemented to handle V8 function calls. The methods
|
||||
/// of this class will always be called on the render process main thread.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefV8Handler
|
||||
{
|
||||
private static readonly CefV8Value[] emtpyArgs = new CefV8Value[0];
|
||||
|
||||
private int execute(cef_v8handler_t* self, cef_string_t* name, cef_v8value_t* @object, UIntPtr argumentsCount, cef_v8value_t** arguments, cef_v8value_t** retval, cef_string_t* exception)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_name = cef_string_t.ToString(name);
|
||||
var m_obj = CefV8Value.FromNative(@object);
|
||||
var argc = (int)argumentsCount;
|
||||
CefV8Value[] m_arguments;
|
||||
if (argc == 0) { m_arguments = emtpyArgs; }
|
||||
else
|
||||
{
|
||||
m_arguments = new CefV8Value[argc];
|
||||
for (var i = 0; i < argc; i++)
|
||||
{
|
||||
m_arguments[i] = CefV8Value.FromNative(arguments[i]);
|
||||
}
|
||||
}
|
||||
|
||||
CefV8Value m_returnValue;
|
||||
string m_exception;
|
||||
|
||||
var handled = Execute(m_name, m_obj, m_arguments, out m_returnValue, out m_exception);
|
||||
|
||||
if (handled)
|
||||
{
|
||||
if (m_exception != null)
|
||||
{
|
||||
cef_string_t.Copy(m_exception, exception);
|
||||
}
|
||||
else if (m_returnValue != null)
|
||||
{
|
||||
*retval = m_returnValue.ToNative();
|
||||
}
|
||||
}
|
||||
|
||||
return handled ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle execution of the function identified by |name|. |object| is the
|
||||
/// receiver ('this' object) of the function. |arguments| is the list of
|
||||
/// arguments passed to the function. If execution succeeds set |retval| to the
|
||||
/// function return value. If execution fails set |exception| to the exception
|
||||
/// that will be thrown. Return true if execution was handled.
|
||||
/// </summary>
|
||||
protected abstract bool Execute(string name, CefV8Value obj, CefV8Value[] arguments, out CefV8Value returnValue, out string exception);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Interface to implement for visiting web plugin information. The methods of
|
||||
/// this class will be called on the browser process UI thread.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefWebPluginInfoVisitor
|
||||
{
|
||||
private int visit(cef_web_plugin_info_visitor_t* self, cef_web_plugin_info_t* info, int count, int total)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_info = CefWebPluginInfo.FromNative(info);
|
||||
|
||||
var result = Visit(m_info, count, total);
|
||||
|
||||
return result ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method that will be called once for each plugin. |count| is the 0-based
|
||||
/// index for the current plugin. |total| is the total number of plugins.
|
||||
/// Return false to stop visiting plugins. This method may never be called if
|
||||
/// no plugins are found.
|
||||
/// </summary>
|
||||
protected abstract bool Visit(CefWebPluginInfo info, int count, int total);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Interface to implement for receiving unstable plugin information. The methods
|
||||
/// of this class will be called on the browser process IO thread.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefWebPluginUnstableCallback
|
||||
{
|
||||
private void is_unstable(cef_web_plugin_unstable_callback_t* self, cef_string_t* path, int unstable)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var m_path = cef_string_t.ToString(path);
|
||||
IsUnstable(m_path, unstable != 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method that will be called for the requested plugin. |unstable| will be
|
||||
/// true if the plugin has reached the crash count threshold of 3 times in 120
|
||||
/// seconds.
|
||||
/// </summary>
|
||||
protected abstract void IsUnstable(string path, bool unstable);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Interface the client can implement to provide a custom stream writer. The
|
||||
/// methods of this class may be called on any thread.
|
||||
/// </summary>
|
||||
public abstract unsafe partial class CefWriteHandler
|
||||
{
|
||||
private UIntPtr write(cef_write_handler_t* self, void* ptr, UIntPtr size, UIntPtr n)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
var length = (long)size * (long)n;
|
||||
using (var stream = new UnmanagedMemoryStream((byte*)ptr, length, length, FileAccess.Write))
|
||||
{
|
||||
return (UIntPtr)Write(stream, length);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write raw binary data.
|
||||
/// </summary>
|
||||
protected abstract long Write(Stream stream, long length);
|
||||
|
||||
|
||||
private int seek(cef_write_handler_t* self, long offset, int whence)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
return Seek(offset, (SeekOrigin)whence) ? 0 : -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Seek to the specified offset position. |whence| may be any one of
|
||||
/// SEEK_CUR, SEEK_END or SEEK_SET. Return zero on success and non-zero on
|
||||
/// failure.
|
||||
/// </summary>
|
||||
protected abstract bool Seek(long offset, SeekOrigin whence);
|
||||
|
||||
|
||||
private long tell(cef_write_handler_t* self)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
return Tell();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the current offset position.
|
||||
/// </summary>
|
||||
protected abstract long Tell();
|
||||
|
||||
|
||||
private int flush(cef_write_handler_t* self)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
return Flush() ? 0 : -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Flush the stream.
|
||||
/// </summary>
|
||||
protected abstract bool Flush();
|
||||
|
||||
|
||||
private int may_block(cef_write_handler_t* self)
|
||||
{
|
||||
CheckSelf(self);
|
||||
|
||||
return MayBlock() ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return true if this handler performs work like accessing the file system
|
||||
/// which may block. Used as a hint for determining the thread to access the
|
||||
/// handler from.
|
||||
/// </summary>
|
||||
protected abstract bool MayBlock();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user