init lserp cs 5.0
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Callback interface used for asynchronous continuation of authentication
|
||||
/// requests.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefAuthCallback
|
||||
{
|
||||
/// <summary>
|
||||
/// Continue the authentication request.
|
||||
/// </summary>
|
||||
public void Continue(string username, string password)
|
||||
{
|
||||
if (username == null) throw new ArgumentNullException("username");
|
||||
if (password == null) throw new ArgumentNullException("password");
|
||||
|
||||
fixed (char* username_str = username)
|
||||
fixed (char* password_str = password)
|
||||
{
|
||||
var n_username = new cef_string_t(username_str, username.Length);
|
||||
var n_password = new cef_string_t(password_str, password.Length);
|
||||
|
||||
cef_auth_callback_t.cont(_self, &n_username, &n_password);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancel the authentication request.
|
||||
/// </summary>
|
||||
public void Cancel()
|
||||
{
|
||||
cef_auth_callback_t.cancel(_self);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Callback interface used to asynchronously continue a download.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefBeforeDownloadCallback
|
||||
{
|
||||
/// <summary>
|
||||
/// Call to continue the download. Set |download_path| to the full file path
|
||||
/// for the download including the file name or leave blank to use the
|
||||
/// suggested name and the default temp directory. Set |show_dialog| to true
|
||||
/// if you do wish to show the default "Save As" dialog.
|
||||
/// </summary>
|
||||
public void Continue(string downloadPath, bool showDialog)
|
||||
{
|
||||
fixed (char* downloadPath_ptr = downloadPath)
|
||||
{
|
||||
var n_downloadPath = new cef_string_t(downloadPath_ptr, downloadPath != null ? downloadPath.Length : 0);
|
||||
cef_before_download_callback_t.cont(_self, &n_downloadPath, showDialog ? 1 : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
// TODO: use intptr-sized implementations ?
|
||||
|
||||
/// <summary>
|
||||
/// Class representing a binary value. Can be used on any process and thread.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefBinaryValue
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new object that is not owned by any other object. The specified
|
||||
/// |data| will be copied.
|
||||
/// </summary>
|
||||
public static CefBinaryValue Create(byte[] data)
|
||||
{
|
||||
if (data == null) throw new ArgumentNullException("data");
|
||||
|
||||
fixed (byte* data_ptr = data)
|
||||
{
|
||||
var value = cef_binary_value_t.create(data_ptr, (UIntPtr)data.LongLength);
|
||||
return CefBinaryValue.FromNative(value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this object is valid. This object may become invalid if
|
||||
/// the underlying data is owned by another object (e.g. list or dictionary)
|
||||
/// and that other object is then modified or destroyed. Do not call any other
|
||||
/// methods if this method returns false.
|
||||
/// </summary>
|
||||
public bool IsValid
|
||||
{
|
||||
get { return cef_binary_value_t.is_valid(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this object is currently owned by another object.
|
||||
/// </summary>
|
||||
public bool IsOwned
|
||||
{
|
||||
get { return cef_binary_value_t.is_owned(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this object and |that| object have the same underlying
|
||||
/// data.
|
||||
/// </summary>
|
||||
public bool IsSame(CefBinaryValue that)
|
||||
{
|
||||
return cef_binary_value_t.is_same(_self, that.ToNative()) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this object and |that| object have an equivalent underlying
|
||||
/// value but are not necessarily the same object.
|
||||
/// </summary>
|
||||
public bool IsEqual(CefBinaryValue that)
|
||||
{
|
||||
return cef_binary_value_t.is_equal(_self, that.ToNative()) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a copy of this object. The data in this object will also be copied.
|
||||
/// </summary>
|
||||
public CefBinaryValue Copy()
|
||||
{
|
||||
var value = cef_binary_value_t.copy(_self);
|
||||
return CefBinaryValue.FromNative(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the data size.
|
||||
/// </summary>
|
||||
public long Size
|
||||
{
|
||||
get { return (long)cef_binary_value_t.get_size(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read up to |buffer_size| number of bytes into |buffer|. Reading begins at
|
||||
/// the specified byte |data_offset|. Returns the number of bytes read.
|
||||
/// </summary>
|
||||
public long GetData(byte[] buffer, long bufferSize, long dataOffset)
|
||||
{
|
||||
if (buffer.LongLength < dataOffset + bufferSize) throw new ArgumentOutOfRangeException("dataOffset");
|
||||
|
||||
fixed (byte* buffer_ptr = buffer)
|
||||
{
|
||||
return (long)cef_binary_value_t.get_data(_self, buffer_ptr, (UIntPtr)bufferSize, (UIntPtr)dataOffset);
|
||||
}
|
||||
|
||||
// FIXME: CefBinaryValue.GetData - allow work with buffer / etc
|
||||
}
|
||||
|
||||
public byte[] ToArray()
|
||||
{
|
||||
var value = new byte[Size];
|
||||
var readed = GetData(value, value.Length, 0);
|
||||
if (readed != value.Length) throw new InvalidOperationException();
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class used to represent a browser window. When used in the browser process
|
||||
/// the methods of this class may be called on any thread unless otherwise
|
||||
/// indicated in the comments. When used in the render process the methods of
|
||||
/// this class may only be called on the main thread.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefBrowser
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the browser host object. This method can only be called in the
|
||||
/// browser process.
|
||||
/// </summary>
|
||||
public CefBrowserHost GetHost()
|
||||
{
|
||||
return CefBrowserHost.FromNative(
|
||||
cef_browser_t.get_host(_self)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the browser can navigate backwards.
|
||||
/// </summary>
|
||||
public bool CanGoBack
|
||||
{
|
||||
get { return cef_browser_t.can_go_back(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Navigate backwards.
|
||||
/// </summary>
|
||||
public void GoBack()
|
||||
{
|
||||
cef_browser_t.go_back(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the browser can navigate forwards.
|
||||
/// </summary>
|
||||
public bool CanGoForward
|
||||
{
|
||||
get { return cef_browser_t.can_go_forward(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Navigate forwards.
|
||||
/// </summary>
|
||||
public void GoForward()
|
||||
{
|
||||
cef_browser_t.go_forward(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the browser is currently loading.
|
||||
/// </summary>
|
||||
public bool IsLoading
|
||||
{
|
||||
get { return cef_browser_t.is_loading(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reload the current page.
|
||||
/// </summary>
|
||||
public void Reload()
|
||||
{
|
||||
cef_browser_t.reload(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reload the current page ignoring any cached data.
|
||||
/// </summary>
|
||||
public void ReloadIgnoreCache()
|
||||
{
|
||||
cef_browser_t.reload_ignore_cache(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stop loading the page.
|
||||
/// </summary>
|
||||
public void StopLoad()
|
||||
{
|
||||
cef_browser_t.stop_load(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the globally unique identifier for this browser.
|
||||
/// </summary>
|
||||
public int Identifier
|
||||
{
|
||||
get { return cef_browser_t.get_identifier(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this object is pointing to the same handle as |that|
|
||||
/// object.
|
||||
/// </summary>
|
||||
public bool IsSame(CefBrowser that)
|
||||
{
|
||||
if (that == null) return false;
|
||||
return cef_browser_t.is_same(_self, that.ToNative()) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the window is a popup window.
|
||||
/// </summary>
|
||||
public bool IsPopup
|
||||
{
|
||||
get { return cef_browser_t.is_popup(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if a document has been loaded in the browser.
|
||||
/// </summary>
|
||||
public bool HasDocument
|
||||
{
|
||||
get { return cef_browser_t.has_document(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the main (top-level) frame for the browser window.
|
||||
/// </summary>
|
||||
public CefFrame GetMainFrame()
|
||||
{
|
||||
return CefFrame.FromNative(
|
||||
cef_browser_t.get_main_frame(_self)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the focused frame for the browser window.
|
||||
/// </summary>
|
||||
public CefFrame GetFocusedFrame()
|
||||
{
|
||||
return CefFrame.FromNative(
|
||||
cef_browser_t.get_focused_frame(_self)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the frame with the specified identifier, or NULL if not found.
|
||||
/// </summary>
|
||||
public CefFrame GetFrame(long identifier)
|
||||
{
|
||||
return CefFrame.FromNativeOrNull(
|
||||
cef_browser_t.get_frame_byident(_self, identifier)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the frame with the specified name, or NULL if not found.
|
||||
/// </summary>
|
||||
public CefFrame GetFrame(string name)
|
||||
{
|
||||
fixed (char* name_str = name)
|
||||
{
|
||||
var n_name = new cef_string_t(name_str, name.Length);
|
||||
|
||||
return CefFrame.FromNativeOrNull(
|
||||
cef_browser_t.get_frame(_self, &n_name)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the number of frames that currently exist.
|
||||
/// </summary>
|
||||
public int FrameCount
|
||||
{
|
||||
get { return (int)cef_browser_t.get_frame_count(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the identifiers of all existing frames.
|
||||
/// </summary>
|
||||
public long[] GetFrameIdentifiers()
|
||||
{
|
||||
var frameCount = FrameCount;
|
||||
var identifiers = new long[frameCount];
|
||||
UIntPtr n_count = (UIntPtr)frameCount;
|
||||
|
||||
fixed (long* identifiers_ptr = identifiers)
|
||||
{
|
||||
cef_browser_t.get_frame_identifiers(_self, &n_count, identifiers_ptr);
|
||||
|
||||
if ((int)n_count != frameCount) throw new InvalidOperationException(); // FIXME: ...
|
||||
}
|
||||
|
||||
return identifiers;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the names of all existing frames.
|
||||
/// </summary>
|
||||
public string[] GetFrameNames()
|
||||
{
|
||||
var list = libcef.string_list_alloc();
|
||||
cef_browser_t.get_frame_names(_self, list);
|
||||
var result = cef_string_list.ToArray(list);
|
||||
libcef.string_list_free(list);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send a message to the specified |target_process|. Returns true if the
|
||||
/// message was sent successfully.
|
||||
/// </summary>
|
||||
public bool SendProcessMessage(CefProcessId target, CefProcessMessage message)
|
||||
{
|
||||
if (message == null) throw new ArgumentNullException("message");
|
||||
|
||||
return cef_browser_t.send_process_message(_self, target, message.ToNative()) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,663 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class used to represent the browser process aspects of a browser window. The
|
||||
/// methods of this class can only be called in the browser process. They may be
|
||||
/// called on any thread in that process unless otherwise indicated in the
|
||||
/// comments.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefBrowserHost
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a new browser window using the window parameters specified by
|
||||
/// |windowInfo|. All values will be copied internally and the actual window
|
||||
/// will be created on the UI thread. If |request_context| is empty the
|
||||
/// global request context will be used. This method can be called on any
|
||||
/// browser process thread and will not block.
|
||||
/// </summary>
|
||||
public static void CreateBrowser(CefWindowInfo windowInfo, CefClient client, CefBrowserSettings settings, string url, CefRequestContext requestContext)
|
||||
{
|
||||
if (windowInfo == null) throw new ArgumentNullException("windowInfo");
|
||||
if (client == null) throw new ArgumentNullException("client");
|
||||
if (settings == null) throw new ArgumentNullException("settings");
|
||||
// TODO: [ApiUsage] if windowInfo.WindowRenderingDisabled && client doesn't provide RenderHandler implementation -> throw exception
|
||||
|
||||
var n_windowInfo = windowInfo.ToNative();
|
||||
var n_client = client.ToNative();
|
||||
var n_settings = settings.ToNative();
|
||||
var n_requestContext = requestContext != null ? requestContext.ToNative() : null;
|
||||
|
||||
fixed (char* url_ptr = url)
|
||||
{
|
||||
cef_string_t n_url = new cef_string_t(url_ptr, url != null ? url.Length : 0);
|
||||
var n_success = cef_browser_host_t.create_browser(n_windowInfo, n_client, &n_url, n_settings, n_requestContext);
|
||||
if (n_success != 1) throw ExceptionBuilder.FailedToCreateBrowser();
|
||||
}
|
||||
|
||||
// TODO: free n_ structs ?
|
||||
}
|
||||
|
||||
public static void CreateBrowser(CefWindowInfo windowInfo, CefClient client, CefBrowserSettings settings, string url)
|
||||
{
|
||||
CreateBrowser(windowInfo, client, settings, url, null);
|
||||
}
|
||||
|
||||
public static void CreateBrowser(CefWindowInfo windowInfo, CefClient client, CefBrowserSettings settings, Uri url, CefRequestContext requestContext)
|
||||
{
|
||||
CreateBrowser(windowInfo, client, settings, url.ToString(), requestContext);
|
||||
}
|
||||
|
||||
public static void CreateBrowser(CefWindowInfo windowInfo, CefClient client, CefBrowserSettings settings, Uri url)
|
||||
{
|
||||
CreateBrowser(windowInfo, client, settings, url, null);
|
||||
}
|
||||
|
||||
public static void CreateBrowser(CefWindowInfo windowInfo, CefClient client, CefBrowserSettings settings, CefRequestContext requestContext)
|
||||
{
|
||||
CreateBrowser(windowInfo, client, settings, string.Empty, requestContext);
|
||||
}
|
||||
|
||||
public static void CreateBrowser(CefWindowInfo windowInfo, CefClient client, CefBrowserSettings settings)
|
||||
{
|
||||
CreateBrowser(windowInfo, client, settings, string.Empty, null);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Create a new browser window using the window parameters specified by
|
||||
/// |windowInfo|. If |request_context| is empty the global request context
|
||||
/// will be used. This method can only be called on the browser process UI
|
||||
/// thread.
|
||||
/// </summary>
|
||||
public static CefBrowser CreateBrowserSync(CefWindowInfo windowInfo, CefClient client, CefBrowserSettings settings, string url, CefRequestContext requestContext)
|
||||
{
|
||||
if (windowInfo == null) throw new ArgumentNullException("windowInfo");
|
||||
if (client == null) throw new ArgumentNullException("client");
|
||||
if (settings == null) throw new ArgumentNullException("settings");
|
||||
// TODO: [ApiUsage] if windowInfo.WindowRenderingDisabled && client doesn't provide RenderHandler implementation -> throw exception
|
||||
|
||||
var n_windowInfo = windowInfo.ToNative();
|
||||
var n_client = client.ToNative();
|
||||
var n_settings = settings.ToNative();
|
||||
var n_requestContext = requestContext != null ? requestContext.ToNative() : null;
|
||||
|
||||
fixed (char* url_ptr = url)
|
||||
{
|
||||
cef_string_t n_url = new cef_string_t(url_ptr, url != null ? url.Length : 0);
|
||||
var n_browser = cef_browser_host_t.create_browser_sync(n_windowInfo, n_client, &n_url, n_settings, n_requestContext);
|
||||
return CefBrowser.FromNative(n_browser);
|
||||
}
|
||||
|
||||
// TODO: free n_ structs ?
|
||||
}
|
||||
|
||||
public static CefBrowser CreateBrowserSync(CefWindowInfo windowInfo, CefClient client, CefBrowserSettings settings, string url)
|
||||
{
|
||||
return CreateBrowserSync(windowInfo, client, settings, url, null);
|
||||
}
|
||||
|
||||
public static CefBrowser CreateBrowserSync(CefWindowInfo windowInfo, CefClient client, CefBrowserSettings settings, Uri url, CefRequestContext requestContext)
|
||||
{
|
||||
return CreateBrowserSync(windowInfo, client, settings, url.ToString(), requestContext);
|
||||
}
|
||||
|
||||
public static CefBrowser CreateBrowserSync(CefWindowInfo windowInfo, CefClient client, CefBrowserSettings settings, Uri url)
|
||||
{
|
||||
return CreateBrowserSync(windowInfo, client, settings, url, null);
|
||||
}
|
||||
|
||||
public static CefBrowser CreateBrowserSync(CefWindowInfo windowInfo, CefClient client, CefBrowserSettings settings, CefRequestContext requestContext)
|
||||
{
|
||||
return CreateBrowserSync(windowInfo, client, settings, string.Empty, requestContext);
|
||||
}
|
||||
|
||||
public static CefBrowser CreateBrowserSync(CefWindowInfo windowInfo, CefClient client, CefBrowserSettings settings)
|
||||
{
|
||||
return CreateBrowserSync(windowInfo, client, settings, string.Empty);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns the hosted browser object.
|
||||
/// </summary>
|
||||
public CefBrowser GetBrowser()
|
||||
{
|
||||
return CefBrowser.FromNative(cef_browser_host_t.get_browser(_self));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Request that the browser close. The JavaScript 'onbeforeunload' event will
|
||||
/// be fired. If |force_close| is false the event handler, if any, will be
|
||||
/// allowed to prompt the user and the user can optionally cancel the close.
|
||||
/// If |force_close| is true the prompt will not be displayed and the close
|
||||
/// will proceed. Results in a call to CefLifeSpanHandler::DoClose() if the
|
||||
/// event handler allows the close or if |force_close| is true. See
|
||||
/// CefLifeSpanHandler::DoClose() documentation for additional usage
|
||||
/// information.
|
||||
/// </summary>
|
||||
public void CloseBrowser(bool forceClose = false)
|
||||
{
|
||||
cef_browser_host_t.close_browser(_self, forceClose ? 1 : 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set whether the browser is focused.
|
||||
/// </summary>
|
||||
public void SetFocus(bool focus)
|
||||
{
|
||||
cef_browser_host_t.set_focus(_self, focus ? 1 : 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set whether the window containing the browser is visible
|
||||
/// (minimized/unminimized, app hidden/unhidden, etc). Only used on Mac OS X.
|
||||
/// </summary>
|
||||
public void SetWindowVisibility(bool visible)
|
||||
{
|
||||
cef_browser_host_t.set_window_visibility(_self, visible ? 1 : 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the window handle for this browser.
|
||||
/// </summary>
|
||||
public IntPtr GetWindowHandle()
|
||||
{
|
||||
return cef_browser_host_t.get_window_handle(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the window handle of the browser that opened this browser. Will
|
||||
/// return NULL for non-popup windows. This method can be used in combination
|
||||
/// with custom handling of modal windows.
|
||||
/// </summary>
|
||||
public IntPtr GetOpenerWindowHandle()
|
||||
{
|
||||
return cef_browser_host_t.get_opener_window_handle(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the client for this browser.
|
||||
/// </summary>
|
||||
public CefClient GetClient()
|
||||
{
|
||||
return CefClient.FromNative(
|
||||
cef_browser_host_t.get_client(_self)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns the request context for this browser.
|
||||
/// </summary>
|
||||
public CefRequestContext GetRequestContext()
|
||||
{
|
||||
return CefRequestContext.FromNative(
|
||||
cef_browser_host_t.get_request_context(_self)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get the current zoom level. The default zoom level is 0.0. This method can
|
||||
/// only be called on the UI thread.
|
||||
/// </summary>
|
||||
public double GetZoomLevel()
|
||||
{
|
||||
return cef_browser_host_t.get_zoom_level(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change the zoom level to the specified value. Specify 0.0 to reset the
|
||||
/// zoom level. If called on the UI thread the change will be applied
|
||||
/// immediately. Otherwise, the change will be applied asynchronously on the
|
||||
/// UI thread.
|
||||
/// </summary>
|
||||
public void SetZoomLevel(double value)
|
||||
{
|
||||
cef_browser_host_t.set_zoom_level(_self, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call to run a file chooser dialog. Only a single file chooser dialog may be
|
||||
/// pending at any given time. |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 will 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 will be
|
||||
/// selected by default. |callback| will be executed after the dialog is
|
||||
/// dismissed or immediately if another dialog is already pending. The dialog
|
||||
/// will be initiated asynchronously on the UI thread.
|
||||
/// </summary>
|
||||
public void RunFileDialog(CefFileDialogMode mode, string title, string defaultFilePath, string[] acceptFilters, int selectedAcceptFilter, CefRunFileDialogCallback callback)
|
||||
{
|
||||
if (callback == null) throw new ArgumentNullException("callback");
|
||||
|
||||
fixed (char* title_ptr = title)
|
||||
fixed (char* defaultFilePath_ptr = defaultFilePath)
|
||||
{
|
||||
var n_title = new cef_string_t(title_ptr, title != null ? title.Length : 0);
|
||||
var n_defaultFilePath = new cef_string_t(defaultFilePath_ptr, defaultFilePath != null ? defaultFilePath.Length : 0);
|
||||
var n_acceptFilters = cef_string_list.From(acceptFilters);
|
||||
|
||||
cef_browser_host_t.run_file_dialog(_self, mode, &n_title, &n_defaultFilePath, n_acceptFilters, selectedAcceptFilter, callback.ToNative());
|
||||
|
||||
libcef.string_list_free(n_acceptFilters);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Download the file at |url| using CefDownloadHandler.
|
||||
/// </summary>
|
||||
public void StartDownload(string url)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url)) throw new ArgumentNullException("url");
|
||||
|
||||
fixed (char* url_ptr = url)
|
||||
{
|
||||
var n_url = new cef_string_t(url_ptr, url.Length);
|
||||
|
||||
cef_browser_host_t.start_download(_self, &n_url);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Print the current browser contents.
|
||||
/// </summary>
|
||||
public void Print()
|
||||
{
|
||||
cef_browser_host_t.print(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Print the current browser contents to the PDF file specified by |path| and
|
||||
/// execute |callback| on completion. The caller is responsible for deleting
|
||||
/// |path| when done. For PDF printing to work on Linux you must implement the
|
||||
/// CefPrintHandler::GetPdfPaperSize method.
|
||||
/// </summary>
|
||||
public void PrintToPdf(string path, CefPdfPrintSettings settings, CefPdfPrintCallback callback)
|
||||
{
|
||||
fixed (char* path_ptr = path)
|
||||
{
|
||||
var n_path = new cef_string_t(path_ptr, path.Length);
|
||||
|
||||
var n_settings = settings.ToNative();
|
||||
|
||||
cef_browser_host_t.print_to_pdf(_self,
|
||||
&n_path,
|
||||
n_settings,
|
||||
callback.ToNative()
|
||||
);
|
||||
|
||||
cef_pdf_print_settings_t.Clear(n_settings);
|
||||
cef_pdf_print_settings_t.Free(n_settings);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Search for |searchText|. |identifier| can be used to have multiple searches
|
||||
/// running simultaniously. |forward| indicates whether to search forward or
|
||||
/// backward within the page. |matchCase| indicates whether the search should
|
||||
/// be case-sensitive. |findNext| indicates whether this is the first request
|
||||
/// or a follow-up. The CefFindHandler instance, if any, returned via
|
||||
/// CefClient::GetFindHandler will be called to report find results.
|
||||
/// </summary>
|
||||
public void Find(int identifier, string searchText, bool forward, bool matchCase, bool findNext)
|
||||
{
|
||||
fixed (char* searchText_ptr = searchText)
|
||||
{
|
||||
var n_searchText = new cef_string_t(searchText_ptr, searchText.Length);
|
||||
|
||||
cef_browser_host_t.find(_self, identifier, &n_searchText, forward ? 1 : 0, matchCase ? 1 : 0, findNext ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancel all searches that are currently going on.
|
||||
/// </summary>
|
||||
public void StopFinding(bool clearSelection)
|
||||
{
|
||||
cef_browser_host_t.stop_finding(_self, clearSelection ? 1 : 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Open developer tools in its own window. If |inspect_element_at| is non-
|
||||
/// empty the element at the specified (x,y) location will be inspected.
|
||||
/// </summary>
|
||||
public void ShowDevTools(CefWindowInfo windowInfo, CefClient client, CefBrowserSettings browserSettings, CefPoint inspectElementAt)
|
||||
{
|
||||
var n_inspectElementAt = new cef_point_t(inspectElementAt.X, inspectElementAt.Y);
|
||||
cef_browser_host_t.show_dev_tools(_self, windowInfo.ToNative(), client.ToNative(), browserSettings.ToNative(),
|
||||
&n_inspectElementAt);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Explicitly close the developer tools window if one exists for this browser
|
||||
/// instance.
|
||||
/// </summary>
|
||||
public void CloseDevTools()
|
||||
{
|
||||
cef_browser_host_t.close_dev_tools(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve a snapshot of current navigation entries as values sent to the
|
||||
/// specified visitor. If |current_only| is true only the current navigation
|
||||
/// entry will be sent, otherwise all navigation entries will be sent.
|
||||
/// </summary>
|
||||
public void GetNavigationEntries(CefNavigationEntryVisitor visitor, bool currentOnly)
|
||||
{
|
||||
cef_browser_host_t.get_navigation_entries(_self, visitor.ToNative(), currentOnly ? 1 : 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set whether mouse cursor change is disabled.
|
||||
/// </summary>
|
||||
public void SetMouseCursorChangeDisabled(bool disabled)
|
||||
{
|
||||
cef_browser_host_t.set_mouse_cursor_change_disabled(_self, disabled ? 1 : 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if mouse cursor change is disabled.
|
||||
/// </summary>
|
||||
public bool IsMouseCursorChangeDisabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return cef_browser_host_t.is_mouse_cursor_change_disabled(_self) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If a misspelled word is currently selected in an editable node calling
|
||||
/// this method will replace it with the specified |word|.
|
||||
/// </summary>
|
||||
public void ReplaceMisspelling(string word)
|
||||
{
|
||||
fixed (char* word_str = word)
|
||||
{
|
||||
var n_word = new cef_string_t(word_str, word != null ? word.Length : 0);
|
||||
cef_browser_host_t.replace_misspelling(_self, &n_word);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add the specified |word| to the spelling dictionary.
|
||||
/// </summary>
|
||||
public void AddWordToDictionary(string word)
|
||||
{
|
||||
fixed (char* word_str = word)
|
||||
{
|
||||
var n_word = new cef_string_t(word_str, word != null ? word.Length : 0);
|
||||
cef_browser_host_t.add_word_to_dictionary(_self, &n_word);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if window rendering is disabled.
|
||||
/// </summary>
|
||||
public bool IsWindowRenderingDisabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return cef_browser_host_t.is_window_rendering_disabled(_self) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notify the browser that the widget has been resized. The browser will first
|
||||
/// call CefRenderHandler::GetViewRect to get the new size and then call
|
||||
/// CefRenderHandler::OnPaint asynchronously with the updated regions. This
|
||||
/// method is only used when window rendering is disabled.
|
||||
/// </summary>
|
||||
public void WasResized()
|
||||
{
|
||||
cef_browser_host_t.was_resized(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notify the browser that it has been hidden or shown. Layouting and
|
||||
/// CefRenderHandler::OnPaint notification will stop when the browser is
|
||||
/// hidden. This method is only used when window rendering is disabled.
|
||||
/// </summary>
|
||||
public void WasHidden(bool hidden)
|
||||
{
|
||||
cef_browser_host_t.was_hidden(_self, hidden ? 1 : 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send a notification to the browser that the screen info has changed. The
|
||||
/// browser will then call CefRenderHandler::GetScreenInfo to update the
|
||||
/// screen information with the new values. This simulates moving the webview
|
||||
/// window from one display to another, or changing the properties of the
|
||||
/// current display. This method is only used when window rendering is
|
||||
/// disabled.
|
||||
/// </summary>
|
||||
public void NotifyScreenInfoChanged()
|
||||
{
|
||||
cef_browser_host_t.notify_screen_info_changed(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invalidate the view. The browser will call CefRenderHandler::OnPaint
|
||||
/// asynchronously. This method is only used when window rendering is
|
||||
/// disabled.
|
||||
/// </summary>
|
||||
public void Invalidate(CefPaintElementType type)
|
||||
{
|
||||
cef_browser_host_t.invalidate(_self, type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send a key event to the browser.
|
||||
/// </summary>
|
||||
public void SendKeyEvent(CefKeyEvent keyEvent)
|
||||
{
|
||||
if (keyEvent == null) throw new ArgumentNullException("keyEvent");
|
||||
|
||||
var n_event = new cef_key_event_t();
|
||||
keyEvent.ToNative(&n_event);
|
||||
cef_browser_host_t.send_key_event(_self, &n_event);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send a mouse click event to the browser. The |x| and |y| coordinates are
|
||||
/// relative to the upper-left corner of the view.
|
||||
/// </summary>
|
||||
public void SendMouseClickEvent(CefMouseEvent @event, CefMouseButtonType type, bool mouseUp, int clickCount)
|
||||
{
|
||||
var n_event = @event.ToNative();
|
||||
cef_browser_host_t.send_mouse_click_event(_self, &n_event, type, mouseUp ? 1 : 0, clickCount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send a mouse move event to the browser. The |x| and |y| coordinates are
|
||||
/// relative to the upper-left corner of the view.
|
||||
/// </summary>
|
||||
public void SendMouseMoveEvent(CefMouseEvent @event, bool mouseLeave)
|
||||
{
|
||||
var n_event = @event.ToNative();
|
||||
cef_browser_host_t.send_mouse_move_event(_self, &n_event, mouseLeave ? 1 : 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send a mouse wheel event to the browser. The |x| and |y| coordinates are
|
||||
/// relative to the upper-left corner of the view. The |deltaX| and |deltaY|
|
||||
/// values represent the movement delta in the X and Y directions respectively.
|
||||
/// In order to scroll inside select popups with window rendering disabled
|
||||
/// CefRenderHandler::GetScreenPoint should be implemented properly.
|
||||
/// </summary>
|
||||
public void SendMouseWheelEvent(CefMouseEvent @event, int deltaX, int deltaY)
|
||||
{
|
||||
var n_event = @event.ToNative();
|
||||
cef_browser_host_t.send_mouse_wheel_event(_self, &n_event, deltaX, deltaY);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send a focus event to the browser.
|
||||
/// </summary>
|
||||
public void SendFocusEvent(bool setFocus)
|
||||
{
|
||||
cef_browser_host_t.send_focus_event(_self, setFocus ? 1 : 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send a capture lost event to the browser.
|
||||
/// </summary>
|
||||
public void SendCaptureLostEvent()
|
||||
{
|
||||
cef_browser_host_t.send_capture_lost_event(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notify the browser that the window hosting it is about to be moved or
|
||||
/// resized. This method is only used on Windows and Linux.
|
||||
/// </summary>
|
||||
public void NotifyMoveOrResizeStarted()
|
||||
{
|
||||
cef_browser_host_t.notify_move_or_resize_started(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the maximum rate in frames per second (fps) that CefRenderHandler::
|
||||
/// OnPaint will be called for a windowless browser. The actual fps may be
|
||||
/// lower if the browser cannot generate frames at the requested rate. The
|
||||
/// minimum value is 1 and the maximum value is 60 (default 30). This method
|
||||
/// can only be called on the UI thread.
|
||||
/// </summary>
|
||||
public int GetWindowlessFrameRate()
|
||||
{
|
||||
return cef_browser_host_t.get_windowless_frame_rate(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the maximum rate in frames per second (fps) that CefRenderHandler::
|
||||
/// OnPaint will be called for a windowless browser. The actual fps may be
|
||||
/// lower if the browser cannot generate frames at the requested rate. The
|
||||
/// minimum value is 1 and the maximum value is 60 (default 30). Can also be
|
||||
/// set at browser creation via CefBrowserSettings.windowless_frame_rate.
|
||||
/// </summary>
|
||||
public void SetWindowlessFrameRate(int frameRate)
|
||||
{
|
||||
cef_browser_host_t.set_windowless_frame_rate(_self, frameRate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the NSTextInputContext implementation for enabling IME on Mac when
|
||||
/// window rendering is disabled.
|
||||
/// </summary>
|
||||
public IntPtr GetNSTextInputContext()
|
||||
{
|
||||
return cef_browser_host_t.get_nstext_input_context(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles a keyDown event prior to passing it through the NSTextInputClient
|
||||
/// machinery.
|
||||
/// </summary>
|
||||
public void HandleKeyEventBeforeTextInputClient(IntPtr keyEvent)
|
||||
{
|
||||
cef_browser_host_t.handle_key_event_before_text_input_client(_self, keyEvent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs any additional actions after NSTextInputClient handles the event.
|
||||
/// </summary>
|
||||
public void HandleKeyEventAfterTextInputClient(IntPtr keyEvent)
|
||||
{
|
||||
cef_browser_host_t.handle_key_event_after_text_input_client(_self, keyEvent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call this method when the user drags the mouse into the web view (before
|
||||
/// calling DragTargetDragOver/DragTargetLeave/DragTargetDrop).
|
||||
/// |drag_data| should not contain file contents as this type of data is not
|
||||
/// allowed to be dragged into the web view. File contents can be removed using
|
||||
/// CefDragData::ResetFileContents (for example, if |drag_data| comes from
|
||||
/// CefRenderHandler::StartDragging).
|
||||
/// This method is only used when window rendering is disabled.
|
||||
/// </summary>
|
||||
public void DragTargetDragEnter(CefDragData dragData, CefMouseEvent mouseEvent, CefDragOperationsMask allowedOps)
|
||||
{
|
||||
var n_mouseEvent = mouseEvent.ToNative();
|
||||
cef_browser_host_t.drag_target_drag_enter(_self,
|
||||
dragData.ToNative(),
|
||||
&n_mouseEvent,
|
||||
allowedOps);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call this method each time the mouse is moved across the web view during
|
||||
/// a drag operation (after calling DragTargetDragEnter and before calling
|
||||
/// DragTargetDragLeave/DragTargetDrop).
|
||||
/// This method is only used when window rendering is disabled.
|
||||
/// </summary>
|
||||
public void DragTargetDragOver(CefMouseEvent mouseEvent, CefDragOperationsMask allowedOps)
|
||||
{
|
||||
var n_mouseEvent = mouseEvent.ToNative();
|
||||
cef_browser_host_t.drag_target_drag_over(_self, &n_mouseEvent, allowedOps);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call this method when the user drags the mouse out of the web view (after
|
||||
/// calling DragTargetDragEnter).
|
||||
/// This method is only used when window rendering is disabled.
|
||||
/// </summary>
|
||||
public void DragTargetDragLeave()
|
||||
{
|
||||
cef_browser_host_t.drag_target_drag_leave(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call this method when the user completes the drag operation by dropping
|
||||
/// the object onto the web view (after calling DragTargetDragEnter).
|
||||
/// The object being dropped is |drag_data|, given as an argument to
|
||||
/// the previous DragTargetDragEnter call.
|
||||
/// This method is only used when window rendering is disabled.
|
||||
/// </summary>
|
||||
public void DragTargetDrop(CefMouseEvent mouseEvent)
|
||||
{
|
||||
var n_mouseEvent = mouseEvent.ToNative();
|
||||
cef_browser_host_t.drag_target_drop(_self, &n_mouseEvent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call this method when the drag operation started by a
|
||||
/// CefRenderHandler::StartDragging call has ended either in a drop or
|
||||
/// by being cancelled. |x| and |y| are mouse coordinates relative to the
|
||||
/// upper-left corner of the view. If the web view is both the drag source
|
||||
/// and the drag target then all DragTarget* methods should be called before
|
||||
/// DragSource* mthods.
|
||||
/// This method is only used when window rendering is disabled.
|
||||
/// </summary>
|
||||
public void DragSourceEndedAt(int x, int y, CefDragOperationsMask op)
|
||||
{
|
||||
cef_browser_host_t.drag_source_ended_at(_self, x, y, op);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call this method when the drag operation started by a
|
||||
/// CefRenderHandler::StartDragging call has completed. This method may be
|
||||
/// called immediately without first calling DragSourceEndedAt to cancel a
|
||||
/// drag operation. If the web view is both the drag source and the drag
|
||||
/// target then all DragTarget* methods should be called before DragSource*
|
||||
/// mthods.
|
||||
/// This method is only used when window rendering is disabled.
|
||||
/// </summary>
|
||||
public void DragSourceSystemDragEnded()
|
||||
{
|
||||
cef_browser_host_t.drag_source_system_drag_ended(_self);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
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 continuation.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefCallback
|
||||
{
|
||||
/// <summary>
|
||||
/// Continue processing.
|
||||
/// </summary>
|
||||
public void Continue()
|
||||
{
|
||||
cef_callback_t.cont(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancel processing.
|
||||
/// </summary>
|
||||
public void Cancel()
|
||||
{
|
||||
cef_callback_t.cancel(_self);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,300 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class used to create and/or parse command line arguments. Arguments with
|
||||
/// '--', '-' and, on Windows, '/' prefixes are considered switches. Switches
|
||||
/// will always precede any arguments without switch prefixes. Switches can
|
||||
/// optionally have a value specified using the '=' delimiter (e.g.
|
||||
/// "-switch=value"). An argument of "--" will terminate switch parsing with all
|
||||
/// subsequent tokens, regardless of prefix, being interpreted as non-switch
|
||||
/// arguments. Switch names are considered case-insensitive. This class can be
|
||||
/// used before CefInitialize() is called.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefCommandLine
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a new CefCommandLine instance.
|
||||
/// </summary>
|
||||
public static CefCommandLine Create()
|
||||
{
|
||||
return CefCommandLine.FromNative(cef_command_line_t.create());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the singleton global CefCommandLine object. The returned object
|
||||
/// will be read-only.
|
||||
/// </summary>
|
||||
public static CefCommandLine Global
|
||||
{
|
||||
get
|
||||
{
|
||||
// FIXME: looks, like this method asserts inside in cef debug version - 'cause global cmdline is not yet set?
|
||||
return CefCommandLine.FromNative(cef_command_line_t.get_global());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this object is valid. Do not call any other methods if this
|
||||
/// function returns false.
|
||||
/// </summary>
|
||||
public bool IsValid
|
||||
{
|
||||
get { return cef_command_line_t.is_valid(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the values of this object are read-only. Some APIs may
|
||||
/// expose read-only objects.
|
||||
/// </summary>
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get { return cef_command_line_t.is_read_only(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a writable copy of this object.
|
||||
/// </summary>
|
||||
public CefCommandLine Copy()
|
||||
{
|
||||
return CefCommandLine.FromNative(cef_command_line_t.copy(_self));
|
||||
}
|
||||
|
||||
// fixme: what with InitFromArgv ?
|
||||
// <summary>
|
||||
// Initialize the command line with the specified |argc| and |argv| values.
|
||||
// The first argument must be the name of the program. This method is only
|
||||
// supported on non-Windows platforms.
|
||||
// </summary>
|
||||
// public void InitFromArgv(int argc, const char* const* argv) =0;
|
||||
|
||||
// fixme: what with InitFromString ?
|
||||
// <summary>
|
||||
// Initialize the command line with the string returned by calling
|
||||
// GetCommandLineW(). This method is only supported on Windows.
|
||||
// </summary>
|
||||
// public void InitFromString(const CefString& command_line) =0;
|
||||
|
||||
/// <summary>
|
||||
/// Reset the command-line switches and arguments but leave the program
|
||||
/// component unchanged.
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
cef_command_line_t.reset(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the original command line string as a vector of strings.
|
||||
/// The argv array: { program, [(--|-|/)switch[=value]]*, [--], [argument]* }
|
||||
/// </summary>
|
||||
public string[] GetArgv()
|
||||
{
|
||||
var list = libcef.string_list_alloc();
|
||||
cef_command_line_t.get_argv(_self, list);
|
||||
var result = cef_string_list.ToArray(list);
|
||||
libcef.string_list_free(list);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and returns the represented command line string. Use this method
|
||||
/// cautiously because quoting behavior is unclear.
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
return cef_string_userfree.ToString(
|
||||
cef_command_line_t.get_command_line_string(_self)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the program part of the command line string (the first item).
|
||||
/// </summary>
|
||||
public string GetProgram()
|
||||
{
|
||||
return cef_string_userfree.ToString(
|
||||
cef_command_line_t.get_program(_self)
|
||||
) ?? "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the program part of the command line string (the first item).
|
||||
/// </summary>
|
||||
public void SetProgram(string value)
|
||||
{
|
||||
// if (value == null) throw new ArgumentNullException("value");
|
||||
|
||||
fixed (char* value_str = value)
|
||||
{
|
||||
var n_value = new cef_string_t(value_str, value != null ? value.Length : 0);
|
||||
|
||||
cef_command_line_t.set_program(_self, &n_value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the command line has switches.
|
||||
/// </summary>
|
||||
public bool HasSwitches
|
||||
{
|
||||
get { return cef_command_line_t.has_switches(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the command line contains the given switch.
|
||||
/// </summary>
|
||||
public bool HasSwitch(string name)
|
||||
{
|
||||
// TODO: use CheckSwitchName method
|
||||
|
||||
fixed (char* name_str = name)
|
||||
{
|
||||
var n_name = new cef_string_t(name_str, name.Length);
|
||||
|
||||
return cef_command_line_t.has_switch(_self, &n_name) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the value associated with the given switch. If the switch has no
|
||||
/// value or isn't present this method returns the empty string.
|
||||
/// </summary>
|
||||
public string GetSwitchValue(string name)
|
||||
{
|
||||
// TODO: use CheckSwitchName method
|
||||
|
||||
fixed (char* name_str = name)
|
||||
{
|
||||
var n_name = new cef_string_t(name_str, name.Length);
|
||||
|
||||
return cef_string_userfree.ToString(
|
||||
cef_command_line_t.get_switch_value(_self, &n_name)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the map of switch names and values. If a switch has no value an
|
||||
/// empty string is returned.
|
||||
/// </summary>
|
||||
public IDictionary<string, string> GetSwitches()
|
||||
{
|
||||
var switches = libcef.string_map_alloc();
|
||||
cef_command_line_t.get_switches(_self, switches);
|
||||
var result = cef_string_map.ToDictionary(switches);
|
||||
libcef.string_map_free(switches);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a switch to the end of the command line. If the switch has no value
|
||||
/// pass an empty value string.
|
||||
/// </summary>
|
||||
public void AppendSwitch(string name)
|
||||
{
|
||||
// TODO: use CheckSwitchName method
|
||||
if (StringHelper.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
if (name == null) throw new ArgumentNullException("name");
|
||||
throw new ArgumentException("Switch name must be non empty or whitespace only string.", "name");
|
||||
}
|
||||
|
||||
fixed (char* name_str = name)
|
||||
{
|
||||
var n_name = new cef_string_t(name_str, name.Length);
|
||||
|
||||
cef_command_line_t.append_switch(_self, &n_name);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a switch with the specified value to the end of the command line.
|
||||
/// </summary>
|
||||
public void AppendSwitch(string name, string value)
|
||||
{
|
||||
// TODO: use CheckSwitchName method
|
||||
if (StringHelper.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
if (name == null) throw new ArgumentNullException("name");
|
||||
throw new ArgumentException("Switch name must be non empty or whitespace only string.", "name");
|
||||
}
|
||||
|
||||
fixed (char* name_str = name)
|
||||
fixed (char* value_str = value)
|
||||
{
|
||||
var n_name = new cef_string_t(name_str, name.Length);
|
||||
var n_value = new cef_string_t(value_str, value != null ? value.Length : 0);
|
||||
|
||||
cef_command_line_t.append_switch_with_value(_self, &n_name, &n_value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True if there are remaining command line arguments.
|
||||
/// </summary>
|
||||
public bool HasArguments
|
||||
{
|
||||
get { return cef_command_line_t.has_arguments(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the remaining command line arguments.
|
||||
/// </summary>
|
||||
public string[] GetArguments()
|
||||
{
|
||||
var arguments = libcef.string_list_alloc();
|
||||
cef_command_line_t.get_arguments(_self, arguments);
|
||||
var result = cef_string_list.ToArray(arguments);
|
||||
libcef.string_list_free(arguments);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add an argument to the end of the command line.
|
||||
/// </summary>
|
||||
public void AppendArgument(string value)
|
||||
{
|
||||
fixed (char* value_str = value)
|
||||
{
|
||||
var n_value = new cef_string_t(value_str, value.Length);
|
||||
|
||||
cef_command_line_t.append_argument(_self, &n_value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Insert a command before the current command.
|
||||
/// Common for debuggers, like "valgrind" or "gdb --args".
|
||||
/// </summary>
|
||||
public void PrependWrapper(string wrapper)
|
||||
{
|
||||
fixed (char* wrapper_str = wrapper)
|
||||
{
|
||||
var n_wrapper = new cef_string_t(wrapper_str, wrapper.Length);
|
||||
|
||||
cef_command_line_t.prepend_wrapper(_self, &n_wrapper);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Insert an argument to the beginning of the command line.
|
||||
/// Unlike PrependWrapper this method doesn't strip argument by spaces.
|
||||
/// </summary>
|
||||
public void PrependArgument(string argument)
|
||||
{
|
||||
if (argument.IndexOf(' ') >= 0)
|
||||
{
|
||||
// When argument contains spaces, we just prepend command line with dummy wrapper
|
||||
// and then replace it with actual argument.
|
||||
PrependWrapper(".");
|
||||
SetProgram(argument);
|
||||
}
|
||||
else PrependWrapper(argument);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Provides information about the context menu state. The ethods of this class
|
||||
/// can only be accessed on browser process the UI thread.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefContextMenuParams
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the X coordinate of the mouse where the context menu was invoked.
|
||||
/// Coords are relative to the associated RenderView's origin.
|
||||
/// </summary>
|
||||
public int X
|
||||
{
|
||||
get { return cef_context_menu_params_t.get_xcoord(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the Y coordinate of the mouse where the context menu was invoked.
|
||||
/// Coords are relative to the associated RenderView's origin.
|
||||
/// </summary>
|
||||
public int Y
|
||||
{
|
||||
get { return cef_context_menu_params_t.get_ycoord(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns flags representing the type of node that the context menu was
|
||||
/// invoked on.
|
||||
/// </summary>
|
||||
public CefContextMenuTypeFlags ContextMenuType
|
||||
{
|
||||
get { return cef_context_menu_params_t.get_type_flags(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the URL of the link, if any, that encloses the node that the
|
||||
/// context menu was invoked on.
|
||||
/// </summary>
|
||||
public string LinkUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_context_menu_params_t.get_link_url(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the link URL, if any, to be used ONLY for "copy link address". We
|
||||
/// don't validate this field in the frontend process.
|
||||
/// </summary>
|
||||
public string UnfilteredLinkUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_context_menu_params_t.get_unfiltered_link_url(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the source URL, if any, for the element that the context menu was
|
||||
/// invoked on. Example of elements with source URLs are img, audio, and video.
|
||||
/// </summary>
|
||||
public string SourceUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_context_menu_params_t.get_source_url(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the context menu was invoked on an image which has
|
||||
/// non-empty contents.
|
||||
/// </summary>
|
||||
public bool HasImageContents
|
||||
{
|
||||
get { return cef_context_menu_params_t.has_image_contents(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the URL of the top level page that the context menu was invoked on.
|
||||
/// </summary>
|
||||
public string PageUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_context_menu_params_t.get_page_url(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the URL of the subframe that the context menu was invoked on.
|
||||
/// </summary>
|
||||
public string FrameUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_context_menu_params_t.get_frame_url(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the character encoding of the subframe that the context menu was
|
||||
/// invoked on.
|
||||
/// </summary>
|
||||
public string FrameCharset
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_context_menu_params_t.get_frame_charset(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the type of context node that the context menu was invoked on.
|
||||
/// </summary>
|
||||
public CefContextMenuMediaType MediaType
|
||||
{
|
||||
get { return cef_context_menu_params_t.get_media_type(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns flags representing the actions supported by the media element, if
|
||||
/// any, that the context menu was invoked on.
|
||||
/// </summary>
|
||||
public CefContextMenuMediaStateFlags MediaState
|
||||
{
|
||||
get { return cef_context_menu_params_t.get_media_state_flags(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the text of the selection, if any, that the context menu was
|
||||
/// invoked on.
|
||||
/// </summary>
|
||||
public string SelectionText
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_context_menu_params_t.get_selection_text(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the text of the misspelled word, if any, that the context menu was
|
||||
/// invoked on.
|
||||
/// </summary>
|
||||
public string GetMisspelledWord()
|
||||
{
|
||||
var n_result = cef_context_menu_params_t.get_misspelled_word(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if suggestions exist, false otherwise. Fills in |suggestions|
|
||||
/// from the spell check service for the misspelled word if there is one.
|
||||
/// </summary>
|
||||
public string[] GetDictionarySuggestions()
|
||||
{
|
||||
var n_suggestions = libcef.string_list_alloc();
|
||||
cef_context_menu_params_t.get_dictionary_suggestions(_self, n_suggestions);
|
||||
var suggestions = cef_string_list.ToArray(n_suggestions);
|
||||
libcef.string_list_free(n_suggestions);
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the context menu was invoked on an editable node.
|
||||
/// </summary>
|
||||
public bool IsEditable
|
||||
{
|
||||
get { return cef_context_menu_params_t.is_editable(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the context menu was invoked on an editable node where
|
||||
/// spell-check is enabled.
|
||||
/// </summary>
|
||||
public bool IsSpellCheckEnabled
|
||||
{
|
||||
get { return cef_context_menu_params_t.is_spell_check_enabled(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns flags representing the actions supported by the editable node, if
|
||||
/// any, that the context menu was invoked on.
|
||||
/// </summary>
|
||||
public CefContextMenuEditStateFlags EditState
|
||||
{
|
||||
get { return cef_context_menu_params_t.get_edit_state_flags(_self); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for managing cookies. The methods of this class may be called on
|
||||
/// any thread unless otherwise indicated.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefCookieManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the global cookie manager. By default data will be stored at
|
||||
/// CefSettings.cache_path if specified or in memory otherwise. If |callback|
|
||||
/// is non-NULL it will be executed asnychronously on the IO thread after the
|
||||
/// manager's storage has been initialized. Using this method is equivalent to
|
||||
/// calling CefRequestContext::GetGlobalContext()->GetDefaultCookieManager().
|
||||
/// </summary>
|
||||
public static CefCookieManager GetGlobal(CefCompletionCallback callback)
|
||||
{
|
||||
var n_callback = callback != null ? callback.ToNative() : null;
|
||||
return CefCookieManager.FromNativeOrNull(
|
||||
cef_cookie_manager_t.get_global_manager(n_callback)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new cookie manager. If |path| is empty data will be stored in
|
||||
/// memory only. Otherwise, data will be stored at the specified |path|. To
|
||||
/// persist session cookies (cookies without an expiry date or validity
|
||||
/// interval) set |persist_session_cookies| to true. Session cookies are
|
||||
/// generally intended to be transient and most Web browsers do not persist
|
||||
/// them. If |callback| is non-NULL it will be executed asnychronously on the
|
||||
/// IO thread after the manager's storage has been initialized.
|
||||
/// </summary>
|
||||
public static CefCookieManager Create(string path, bool persistSessionCookies, CefCompletionCallback callback)
|
||||
{
|
||||
fixed (char* path_str = path)
|
||||
{
|
||||
var n_path = new cef_string_t(path_str, path != null ? path.Length : 0);
|
||||
var n_callback = callback != null ? callback.ToNative() : null;
|
||||
|
||||
return CefCookieManager.FromNativeOrNull(
|
||||
cef_cookie_manager_t.create_manager(&n_path, persistSessionCookies ? 1 : 0, n_callback)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the schemes supported by this manager. The default schemes ("http",
|
||||
/// "https", "ws" and "wss") will always be supported. If |callback| is non-
|
||||
/// NULL it will be executed asnychronously on the IO thread after the change
|
||||
/// has been applied. Must be called before any cookies are accessed.
|
||||
/// </summary>
|
||||
public void SetSupportedSchemes(string[] schemes, CefCompletionCallback callback)
|
||||
{
|
||||
var n_schemes = cef_string_list.From(schemes);
|
||||
var n_callback = callback != null ? callback.ToNative() : null;
|
||||
|
||||
cef_cookie_manager_t.set_supported_schemes(_self, n_schemes, n_callback);
|
||||
|
||||
libcef.string_list_free(n_schemes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Visit all cookies on the IO thread. The returned cookies are ordered by
|
||||
/// longest path, then by earliest creation date. Returns false if cookies
|
||||
/// cannot be accessed.
|
||||
/// </summary>
|
||||
public bool VisitAllCookies(CefCookieVisitor visitor)
|
||||
{
|
||||
if (visitor == null) throw new ArgumentNullException("visitor");
|
||||
|
||||
return cef_cookie_manager_t.visit_all_cookies(_self, visitor.ToNative()) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Visit a subset of cookies on the IO thread. The results are filtered by the
|
||||
/// given url scheme, host, domain and path. If |includeHttpOnly| is true
|
||||
/// HTTP-only cookies will also be included in the results. The returned
|
||||
/// cookies are ordered by longest path, then by earliest creation date.
|
||||
/// Returns false if cookies cannot be accessed.
|
||||
/// </summary>
|
||||
public bool VisitUrlCookies(string url, bool includeHttpOnly, CefCookieVisitor visitor)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url)) throw new ArgumentNullException("url");
|
||||
if (visitor == null) throw new ArgumentNullException("visitor");
|
||||
|
||||
fixed (char* url_str = url)
|
||||
{
|
||||
var n_url = new cef_string_t(url_str, url.Length);
|
||||
|
||||
return cef_cookie_manager_t.visit_url_cookies(_self, &n_url, includeHttpOnly ? 1 : 0, visitor.ToNative()) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a cookie given a valid URL and explicit user-provided cookie
|
||||
/// attributes. This function expects each attribute to be well-formed. It will
|
||||
/// check for disallowed characters (e.g. the ';' character is disallowed
|
||||
/// within the cookie value attribute) and fail without setting the cookie if
|
||||
/// such characters are found. If |callback| is non-NULL it will be executed
|
||||
/// asnychronously on the IO thread after the cookie has been set. Returns
|
||||
/// false if an invalid URL is specified or if cookies cannot be accessed.
|
||||
/// </summary>
|
||||
public bool SetCookie(string url, CefCookie cookie, CefSetCookieCallback callback)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url)) throw new ArgumentNullException("url");
|
||||
if (cookie == null) throw new ArgumentNullException("cookie");
|
||||
|
||||
int n_result;
|
||||
var n_cookie = cookie.ToNative();
|
||||
fixed (char* url_str = url)
|
||||
{
|
||||
var n_url = new cef_string_t(url_str, url.Length);
|
||||
var n_callback = callback != null ? callback.ToNative() : null;
|
||||
|
||||
n_result = cef_cookie_manager_t.set_cookie(_self, &n_url, n_cookie, n_callback);
|
||||
}
|
||||
CefCookie.Free(n_cookie);
|
||||
return n_result != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete all cookies that match the specified parameters. If both |url| and
|
||||
/// |cookie_name| values are specified all host and domain cookies matching
|
||||
/// both will be deleted. If only |url| is specified all host cookies (but not
|
||||
/// domain cookies) irrespective of path will be deleted. If |url| is empty all
|
||||
/// cookies for all hosts and domains will be deleted. If |callback| is
|
||||
/// non-NULL it will be executed asnychronously on the IO thread after the
|
||||
/// cookies have been deleted. Returns false if a non-empty invalid URL is
|
||||
/// specified or if cookies cannot be accessed. Cookies can alternately be
|
||||
/// deleted using the Visit*Cookies() methods.
|
||||
/// </summary>
|
||||
public bool DeleteCookies(string url, string cookieName, CefDeleteCookiesCallback callback)
|
||||
{
|
||||
fixed (char* url_str = url)
|
||||
fixed (char* cookieName_str = cookieName)
|
||||
{
|
||||
var n_url = new cef_string_t(url_str, url != null ? url.Length : 0);
|
||||
var n_cookieName = new cef_string_t(cookieName_str, cookieName != null ? cookieName.Length : 0);
|
||||
var n_callback = callback != null ? callback.ToNative() : null;
|
||||
|
||||
return cef_cookie_manager_t.delete_cookies(_self, &n_url, &n_cookieName, n_callback) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the directory path that will be used for storing cookie data. If
|
||||
/// |path| is empty data will be stored in memory only. Otherwise, data will be
|
||||
/// stored at the specified |path|. To persist session cookies (cookies without
|
||||
/// an expiry date or validity interval) set |persist_session_cookies| to true.
|
||||
/// Session cookies are generally intended to be transient and most Web
|
||||
/// browsers do not persist them. If |callback| is non-NULL it will be executed
|
||||
/// asnychronously on the IO thread after the manager's storage has been
|
||||
/// initialized. Returns false if cookies cannot be accessed.
|
||||
/// </summary>
|
||||
public bool SetStoragePath(string path, bool persistSessionCookies, CefCompletionCallback callback)
|
||||
{
|
||||
fixed (char* path_str = path)
|
||||
{
|
||||
var n_path = new cef_string_t(path_str, path != null ? path.Length : 0);
|
||||
var n_callback = callback != null ? callback.ToNative() : null;
|
||||
|
||||
return cef_cookie_manager_t.set_storage_path(_self, &n_path, persistSessionCookies ? 1 : 0, n_callback) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Flush the backing store (if any) to disk. If |callback| is non-NULL it will
|
||||
/// be executed asnychronously on the IO thread after the flush is complete.
|
||||
/// Returns false if cookies cannot be accessed.
|
||||
/// </summary>
|
||||
public bool FlushStore(CefCompletionCallback callback)
|
||||
{
|
||||
var n_handler = callback != null ? callback.ToNative() : null;
|
||||
|
||||
return cef_cookie_manager_t.flush_store(_self, n_handler) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,402 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class representing a dictionary value. Can be used on any process and thread.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefDictionaryValue
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new object that is not owned by any other object.
|
||||
/// </summary>
|
||||
public static CefDictionaryValue Create()
|
||||
{
|
||||
return CefDictionaryValue.FromNative(
|
||||
cef_dictionary_value_t.create()
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this object is valid. This object may become invalid if
|
||||
/// the underlying data is owned by another object (e.g. list or dictionary)
|
||||
/// and that other object is then modified or destroyed. Do not call any other
|
||||
/// methods if this method returns false.
|
||||
/// </summary>
|
||||
public bool IsValid
|
||||
{
|
||||
get { return cef_dictionary_value_t.is_valid(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this object is currently owned by another object.
|
||||
/// </summary>
|
||||
public bool IsOwned
|
||||
{
|
||||
get { return cef_dictionary_value_t.is_owned(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the values of this object are read-only. Some APIs may
|
||||
/// expose read-only objects.
|
||||
/// </summary>
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get { return cef_dictionary_value_t.is_read_only(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this object and |that| object have the same underlying
|
||||
/// data. If true modifications to this object will also affect |that| object
|
||||
/// and vice-versa.
|
||||
/// </summary>
|
||||
public bool IsSame(CefDictionaryValue that)
|
||||
{
|
||||
return cef_dictionary_value_t.is_same(_self, that.ToNative()) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this object and |that| object have an equivalent underlying
|
||||
/// value but are not necessarily the same object.
|
||||
/// </summary>
|
||||
public bool IsEqual(CefDictionaryValue that)
|
||||
{
|
||||
return cef_dictionary_value_t.is_equal(_self, that.ToNative()) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a writable copy of this object. If |exclude_empty_children| is true
|
||||
/// any empty dictionaries or lists will be excluded from the copy.
|
||||
/// </summary>
|
||||
public CefDictionaryValue Copy(bool excludeEmptyChildren)
|
||||
{
|
||||
return CefDictionaryValue.FromNative(
|
||||
cef_dictionary_value_t.copy(_self, excludeEmptyChildren ? 1 : 0)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the number of values.
|
||||
/// </summary>
|
||||
public int Count
|
||||
{
|
||||
get { return (int)cef_dictionary_value_t.get_size(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all values. Returns true on success.
|
||||
/// </summary>
|
||||
public bool Clear()
|
||||
{
|
||||
return cef_dictionary_value_t.clear(_self) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the current dictionary has a value for the given key.
|
||||
/// </summary>
|
||||
public bool HasKey(string key)
|
||||
{
|
||||
fixed (char* key_str = key)
|
||||
{
|
||||
var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);
|
||||
|
||||
return cef_dictionary_value_t.has_key(_self, &n_key) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads all keys for this dictionary into the specified vector.
|
||||
/// </summary>
|
||||
public string[] GetKeys()
|
||||
{
|
||||
var list = libcef.string_list_alloc();
|
||||
var success = cef_dictionary_value_t.get_keys(_self, list) != 0;
|
||||
if (!success) throw new InvalidOperationException(); // TODO: use ExceptionBuilder
|
||||
var result = cef_string_list.ToArray(list);
|
||||
libcef.string_list_free(list);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the value at the specified key. Returns true is the value was
|
||||
/// removed successfully.
|
||||
/// </summary>
|
||||
public bool Remove(string key)
|
||||
{
|
||||
fixed (char* key_str = key)
|
||||
{
|
||||
var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);
|
||||
return cef_dictionary_value_t.remove(_self, &n_key) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the value type for the specified key.
|
||||
/// </summary>
|
||||
public CefValueType GetValueType(string key)
|
||||
{
|
||||
fixed (char* key_str = key)
|
||||
{
|
||||
var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);
|
||||
return cef_dictionary_value_t.get_type(_self, &n_key);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the value at the specified key. For simple types the returned
|
||||
/// value will copy existing data and modifications to the value will not
|
||||
/// modify this object. For complex types (binary, dictionary and list) the
|
||||
/// returned value will reference existing data and modifications to the value
|
||||
/// will modify this object.
|
||||
/// </summary>
|
||||
public CefValue GetValue(string key)
|
||||
{
|
||||
fixed (char* key_str = key)
|
||||
{
|
||||
var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);
|
||||
|
||||
var n_result = cef_dictionary_value_t.get_value(_self, &n_key);
|
||||
|
||||
return CefValue.FromNativeOrNull(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the value at the specified key as type bool.
|
||||
/// </summary>
|
||||
public bool GetBool(string key)
|
||||
{
|
||||
fixed (char* key_str = key)
|
||||
{
|
||||
var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);
|
||||
return cef_dictionary_value_t.get_bool(_self, &n_key) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the value at the specified key as type int.
|
||||
/// </summary>
|
||||
public int GetInt(string key)
|
||||
{
|
||||
fixed (char* key_str = key)
|
||||
{
|
||||
var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);
|
||||
return cef_dictionary_value_t.get_int(_self, &n_key);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the value at the specified key as type double.
|
||||
/// </summary>
|
||||
public double GetDouble(string key)
|
||||
{
|
||||
fixed (char* key_str = key)
|
||||
{
|
||||
var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);
|
||||
return cef_dictionary_value_t.get_double(_self, &n_key);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the value at the specified key as type string.
|
||||
/// </summary>
|
||||
public string GetString(string key)
|
||||
{
|
||||
fixed (char* key_str = key)
|
||||
{
|
||||
var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);
|
||||
var n_result = cef_dictionary_value_t.get_string(_self, &n_key);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the value at the specified key as type binary. The returned
|
||||
/// value will reference existing data.
|
||||
/// </summary>
|
||||
public CefBinaryValue GetBinary(string key)
|
||||
{
|
||||
fixed (char* key_str = key)
|
||||
{
|
||||
var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);
|
||||
var n_result = cef_dictionary_value_t.get_binary(_self, &n_key);
|
||||
return CefBinaryValue.FromNative(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the value at the specified key as type dictionary. The returned
|
||||
/// value will reference existing data and modifications to the value will
|
||||
/// modify this object.
|
||||
/// </summary>
|
||||
public CefDictionaryValue GetDictionary(string key)
|
||||
{
|
||||
fixed (char* key_str = key)
|
||||
{
|
||||
var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);
|
||||
var n_result = cef_dictionary_value_t.get_dictionary(_self, &n_key);
|
||||
return CefDictionaryValue.FromNative(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the value at the specified key as type list. The returned value
|
||||
/// will reference existing data and modifications to the value will modify
|
||||
/// this object.
|
||||
/// </summary>
|
||||
public CefListValue GetList(string key)
|
||||
{
|
||||
fixed (char* key_str = key)
|
||||
{
|
||||
var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);
|
||||
var n_result = cef_dictionary_value_t.get_list(_self, &n_key);
|
||||
return CefListValue.FromNative(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the value at the specified key. Returns true if the value was set
|
||||
/// successfully. If |value| represents simple data then the underlying data
|
||||
/// will be copied and modifications to |value| will not modify this object. If
|
||||
/// |value| represents complex data (binary, dictionary or list) then the
|
||||
/// underlying data will be referenced and modifications to |value| will modify
|
||||
/// this object.
|
||||
/// </summary>
|
||||
public bool SetValue(string key, CefValue value)
|
||||
{
|
||||
fixed (char* key_str = key)
|
||||
{
|
||||
var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);
|
||||
var n_value = value.ToNative();
|
||||
|
||||
return cef_dictionary_value_t.set_value(_self, &n_key, n_value) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the value at the specified key as type null. Returns true if the
|
||||
/// value was set successfully.
|
||||
/// </summary>
|
||||
public bool SetNull(string key)
|
||||
{
|
||||
fixed (char* key_str = key)
|
||||
{
|
||||
var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);
|
||||
return cef_dictionary_value_t.set_null(_self, &n_key) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the value at the specified key as type bool. Returns true if the
|
||||
/// value was set successfully.
|
||||
/// </summary>
|
||||
public bool SetBool(string key, bool value)
|
||||
{
|
||||
fixed (char* key_str = key)
|
||||
{
|
||||
var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);
|
||||
return cef_dictionary_value_t.set_bool(_self, &n_key, value ? 1 : 0) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the value at the specified key as type int. Returns true if the
|
||||
/// value was set successfully.
|
||||
/// </summary>
|
||||
public bool SetInt(string key, int value)
|
||||
{
|
||||
fixed (char* key_str = key)
|
||||
{
|
||||
var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);
|
||||
return cef_dictionary_value_t.set_int(_self, &n_key, value) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the value at the specified key as type double. Returns true if the
|
||||
/// value was set successfully.
|
||||
/// </summary>
|
||||
public bool SetDouble(string key, double value)
|
||||
{
|
||||
fixed (char* key_str = key)
|
||||
{
|
||||
var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);
|
||||
return cef_dictionary_value_t.set_double(_self, &n_key, value) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the value at the specified key as type string. Returns true if the
|
||||
/// value was set successfully.
|
||||
/// </summary>
|
||||
public bool SetString(string key, string value)
|
||||
{
|
||||
fixed (char* key_str = key)
|
||||
fixed (char* value_str = value)
|
||||
{
|
||||
var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);
|
||||
var n_value = new cef_string_t(value_str, value != null ? value.Length : 0);
|
||||
return cef_dictionary_value_t.set_string(_self, &n_key, &n_value) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the value at the specified key as type binary. Returns true if the
|
||||
/// value was set successfully. If |value| is currently owned by another object
|
||||
/// then the value will be copied and the |value| reference will not change.
|
||||
/// Otherwise, ownership will be transferred to this object and the |value|
|
||||
/// reference will be invalidated.
|
||||
/// </summary>
|
||||
public bool SetBinary(string key, CefBinaryValue value)
|
||||
{
|
||||
//FIXME: what means reference will be invalidated ?
|
||||
if (value == null) throw new ArgumentNullException("value");
|
||||
|
||||
fixed (char* key_str = key)
|
||||
{
|
||||
var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);
|
||||
return cef_dictionary_value_t.set_binary(_self, &n_key, value.ToNative()) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the value at the specified key as type dict. Returns true if the
|
||||
/// value was set successfully. If |value| is currently owned by another object
|
||||
/// then the value will be copied and the |value| reference will not change.
|
||||
/// Otherwise, ownership will be transferred to this object and the |value|
|
||||
/// reference will be invalidated.
|
||||
/// </summary>
|
||||
public bool SetDictionary(string key, CefDictionaryValue value)
|
||||
{
|
||||
if (value == null) throw new ArgumentNullException("value");
|
||||
|
||||
fixed (char* key_str = key)
|
||||
{
|
||||
var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);
|
||||
return cef_dictionary_value_t.set_dictionary(_self, &n_key, value.ToNative()) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the value at the specified key as type list. Returns true if the
|
||||
/// value was set successfully. If |value| is currently owned by another object
|
||||
/// then the value will be copied and the |value| reference will not change.
|
||||
/// Otherwise, ownership will be transferred to this object and the |value|
|
||||
/// reference will be invalidated.
|
||||
/// </summary>
|
||||
public bool SetList(string key, CefListValue value)
|
||||
{
|
||||
if (value == null) throw new ArgumentNullException("value");
|
||||
|
||||
fixed (char* key_str = key)
|
||||
{
|
||||
var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);
|
||||
return cef_dictionary_value_t.set_list(_self, &n_key, value.ToNative()) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class used to represent a DOM document. The methods of this class should only
|
||||
/// be called on the render process main thread thread.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefDomDocument
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the document type.
|
||||
/// </summary>
|
||||
public CefDomDocumentType DocumentType
|
||||
{
|
||||
get { return cef_domdocument_t.get_type(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the root document node.
|
||||
/// </summary>
|
||||
public CefDomNode Root
|
||||
{
|
||||
get
|
||||
{
|
||||
return CefDomNode.FromNative(
|
||||
cef_domdocument_t.get_document(_self)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the BODY node of an HTML document.
|
||||
/// </summary>
|
||||
public CefDomNode Body
|
||||
{
|
||||
get
|
||||
{
|
||||
return CefDomNode.FromNative(
|
||||
cef_domdocument_t.get_body(_self)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the HEAD node of an HTML document.
|
||||
/// </summary>
|
||||
public CefDomNode Head
|
||||
{
|
||||
get
|
||||
{
|
||||
return CefDomNode.FromNative(
|
||||
cef_domdocument_t.get_head(_self)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the title of an HTML document.
|
||||
/// </summary>
|
||||
public string Title
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_domdocument_t.get_title(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the document element with the specified ID value.
|
||||
/// </summary>
|
||||
public CefDomNode GetElementById(string id)
|
||||
{
|
||||
fixed (char* id_str = id)
|
||||
{
|
||||
var n_id = new cef_string_t(id_str, id.Length);
|
||||
return CefDomNode.FromNativeOrNull(
|
||||
cef_domdocument_t.get_element_by_id(_self, &n_id)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the node that currently has keyboard focus.
|
||||
/// </summary>
|
||||
public CefDomNode FocusedNode
|
||||
{
|
||||
get
|
||||
{
|
||||
return CefDomNode.FromNativeOrNull(
|
||||
cef_domdocument_t.get_focused_node(_self)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if a portion of the document is selected.
|
||||
/// </summary>
|
||||
public bool HasSelection
|
||||
{
|
||||
get { return cef_domdocument_t.has_selection(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the selection offset within the start node.
|
||||
/// </summary>
|
||||
public int SelectionStartOffset
|
||||
{
|
||||
get { return cef_domdocument_t.get_selection_start_offset(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the selection offset within the end node.
|
||||
/// </summary>
|
||||
public int GetSelectionEndOffset
|
||||
{
|
||||
get { return cef_domdocument_t.get_selection_end_offset(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the contents of this selection as markup.
|
||||
/// </summary>
|
||||
public string SelectionAsMarkup
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_domdocument_t.get_selection_as_markup(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the contents of this selection as text.
|
||||
/// </summary>
|
||||
public string GetSelectionAsText
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_domdocument_t.get_selection_as_text(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the base URL for the document.
|
||||
/// </summary>
|
||||
public string BaseUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_domdocument_t.get_base_url(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a complete URL based on the document base URL and the specified
|
||||
/// partial URL.
|
||||
/// </summary>
|
||||
public string GetCompleteUrl(string partialUrl)
|
||||
{
|
||||
fixed (char* partialUrl_str = partialUrl)
|
||||
{
|
||||
var n_partialUrl = new cef_string_t(partialUrl_str, partialUrl.Length);
|
||||
var n_result = cef_domdocument_t.get_complete_url(_self, &n_partialUrl);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,293 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class used to represent a DOM node. The methods of this class should only be
|
||||
/// called on the render process main thread.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefDomNode
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the type for this node.
|
||||
/// </summary>
|
||||
public CefDomNodeType NodeType
|
||||
{
|
||||
get { return cef_domnode_t.get_type(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this is a text node.
|
||||
/// </summary>
|
||||
public bool IsText
|
||||
{
|
||||
get { return cef_domnode_t.is_text(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this is an element node.
|
||||
/// </summary>
|
||||
public bool IsElement
|
||||
{
|
||||
get { return cef_domnode_t.is_element(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this is an editable node.
|
||||
/// </summary>
|
||||
public bool IsEditable
|
||||
{
|
||||
get { return cef_domnode_t.is_editable(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this is a form control element node.
|
||||
/// </summary>
|
||||
public bool IsFormControlElement
|
||||
{
|
||||
get { return cef_domnode_t.is_form_control_element(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the type of this form control element node.
|
||||
/// </summary>
|
||||
public string FormControlElementType
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_domnode_t.get_form_control_element_type(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this object is pointing to the same handle as |that|
|
||||
/// object.
|
||||
/// </summary>
|
||||
public bool IsSame(CefDomNode that)
|
||||
{
|
||||
return cef_domnode_t.is_same(_self, that.ToNative()) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the name of this node.
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_domnode_t.get_name(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the value of this node.
|
||||
/// </summary>
|
||||
public string Value
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_domnode_t.get_value(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the value of this node. Returns true on success.
|
||||
/// </summary>
|
||||
public bool SetValue(string value)
|
||||
{
|
||||
fixed (char* value_str = value)
|
||||
{
|
||||
var n_value = new cef_string_t(value_str, value != null ? value.Length : 0);
|
||||
|
||||
return cef_domnode_t.set_value(_self, &n_value) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the contents of this node as markup.
|
||||
/// </summary>
|
||||
public string GetAsMarkup()
|
||||
{
|
||||
var n_result = cef_domnode_t.get_as_markup(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the document associated with this node.
|
||||
/// </summary>
|
||||
public CefDomDocument Document
|
||||
{
|
||||
get
|
||||
{
|
||||
return CefDomDocument.FromNative(
|
||||
cef_domnode_t.get_document(_self)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the parent node.
|
||||
/// </summary>
|
||||
public CefDomNode Parent
|
||||
{
|
||||
get
|
||||
{
|
||||
return CefDomNode.FromNativeOrNull(
|
||||
cef_domnode_t.get_parent(_self)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the previous sibling node.
|
||||
/// </summary>
|
||||
public CefDomNode PreviousSibling
|
||||
{
|
||||
get
|
||||
{
|
||||
return CefDomNode.FromNativeOrNull(
|
||||
cef_domnode_t.get_previous_sibling(_self)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the next sibling node.
|
||||
/// </summary>
|
||||
public CefDomNode NextSibling
|
||||
{
|
||||
get
|
||||
{
|
||||
return CefDomNode.FromNativeOrNull(
|
||||
cef_domnode_t.get_next_sibling(_self)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this node has child nodes.
|
||||
/// </summary>
|
||||
public bool HasChildren
|
||||
{
|
||||
get { return cef_domnode_t.has_children(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the first child node.
|
||||
/// </summary>
|
||||
public CefDomNode FirstChild
|
||||
{
|
||||
get
|
||||
{
|
||||
return CefDomNode.FromNativeOrNull(
|
||||
cef_domnode_t.get_first_child(_self)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the last child node.
|
||||
/// </summary>
|
||||
public CefDomNode LastChild
|
||||
{
|
||||
get
|
||||
{
|
||||
return CefDomNode.FromNativeOrNull(
|
||||
cef_domnode_t.get_last_child(_self)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The following methods are valid only for element nodes.
|
||||
/// Returns the tag name of this element.
|
||||
/// </summary>
|
||||
public string ElementTagName
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_domnode_t.get_element_tag_name(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this element has attributes.
|
||||
/// </summary>
|
||||
public bool HasAttributes
|
||||
{
|
||||
get { return cef_domnode_t.has_element_attributes(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this element has an attribute named |attrName|.
|
||||
/// </summary>
|
||||
public bool HasAttribute(string attrName)
|
||||
{
|
||||
fixed (char* attrName_str = attrName)
|
||||
{
|
||||
var n_attrName = new cef_string_t(attrName_str, attrName.Length);
|
||||
return cef_domnode_t.has_element_attribute(_self, &n_attrName) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the element attribute named |attrName|.
|
||||
/// </summary>
|
||||
public string GetAttribute(string attrName)
|
||||
{
|
||||
fixed (char* attrName_str = attrName)
|
||||
{
|
||||
var n_attrName = new cef_string_t(attrName_str, attrName.Length);
|
||||
var n_result = cef_domnode_t.get_element_attribute(_self, &n_attrName);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a map of all element attributes.
|
||||
/// </summary>
|
||||
public IDictionary<string, string> GetAttributes()
|
||||
{
|
||||
var attrMap = libcef.string_map_alloc();
|
||||
cef_domnode_t.get_element_attributes(_self, attrMap);
|
||||
var result = cef_string_map.ToDictionary(attrMap);
|
||||
libcef.string_map_free(attrMap);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the value for the element attribute named |attrName|. Returns true on
|
||||
/// success.
|
||||
/// </summary>
|
||||
public bool SetAttribute(string attrName, string value)
|
||||
{
|
||||
fixed (char* attrName_str = attrName)
|
||||
fixed (char* value_str = value)
|
||||
{
|
||||
var n_attrName = new cef_string_t(attrName_str, attrName.Length);
|
||||
var n_value = new cef_string_t(value_str, value != null ? value.Length : 0);
|
||||
return cef_domnode_t.set_element_attribute(_self, &n_attrName, &n_value) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the inner text of the element.
|
||||
/// </summary>
|
||||
public string InnerText
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_domnode_t.get_element_inner_text(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class used to represent a download item.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefDownloadItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if this object is valid. Do not call any other methods if this
|
||||
/// function returns false.
|
||||
/// </summary>
|
||||
public bool IsValid
|
||||
{
|
||||
get { return cef_download_item_t.is_valid(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the download is in progress.
|
||||
/// </summary>
|
||||
public bool IsInProgress
|
||||
{
|
||||
get { return cef_download_item_t.is_in_progress(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the download is complete.
|
||||
/// </summary>
|
||||
public bool IsComplete
|
||||
{
|
||||
get { return cef_download_item_t.is_complete(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the download has been canceled or interrupted.
|
||||
/// </summary>
|
||||
public bool IsCanceled
|
||||
{
|
||||
get { return cef_download_item_t.is_canceled(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a simple speed estimate in bytes/s.
|
||||
/// </summary>
|
||||
public long CurrentSpeed
|
||||
{
|
||||
get { return cef_download_item_t.get_current_speed(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the rough percent complete or -1 if the receive total size is
|
||||
/// unknown.
|
||||
/// </summary>
|
||||
public int PercentComplete
|
||||
{
|
||||
get { return cef_download_item_t.get_percent_complete(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the total number of bytes.
|
||||
/// </summary>
|
||||
public long TotalBytes
|
||||
{
|
||||
get { return cef_download_item_t.get_total_bytes(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the number of received bytes.
|
||||
/// </summary>
|
||||
public long ReceivedBytes
|
||||
{
|
||||
get { return cef_download_item_t.get_received_bytes(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the time that the download started.
|
||||
/// </summary>
|
||||
public DateTime StartTime
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_download_item_t.get_start_time(_self);
|
||||
return cef_time_t.ToDateTime(&n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the time that the download ended.
|
||||
/// </summary>
|
||||
public DateTime EndTime
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_download_item_t.get_end_time(_self);
|
||||
return cef_time_t.ToDateTime(&n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the full path to the downloaded or downloading file.
|
||||
/// </summary>
|
||||
public string FullPath
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_download_item_t.get_full_path(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the unique identifier for this download.
|
||||
/// </summary>
|
||||
public uint Id
|
||||
{
|
||||
get { return cef_download_item_t.get_id(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the URL.
|
||||
/// </summary>
|
||||
public string Url
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_download_item_t.get_url(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the original URL before any redirections.
|
||||
/// </summary>
|
||||
public string OriginalUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_download_item_t.get_original_url(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the suggested file name.
|
||||
/// </summary>
|
||||
public string SuggestedFileName
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_download_item_t.get_suggested_file_name(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the content disposition.
|
||||
/// </summary>
|
||||
public string ContentDisposition
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_download_item_t.get_content_disposition(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the mime type.
|
||||
/// </summary>
|
||||
public string MimeType
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_download_item_t.get_mime_type(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Callback interface used to asynchronously cancel a download.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefDownloadItemCallback
|
||||
{
|
||||
/// <summary>
|
||||
/// Call to cancel the download.
|
||||
/// </summary>
|
||||
public void Cancel()
|
||||
{
|
||||
cef_download_item_callback_t.cancel(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call to pause the download.
|
||||
/// </summary>
|
||||
public void Pause()
|
||||
{
|
||||
cef_download_item_callback_t.pause(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call to resume the download.
|
||||
/// </summary>
|
||||
public void Resume()
|
||||
{
|
||||
cef_download_item_callback_t.resume(_self);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,278 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class used to represent drag data. The methods of this class may be called
|
||||
/// on any thread.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefDragData
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a new CefDragData object.
|
||||
/// </summary>
|
||||
public static CefDragData Create()
|
||||
{
|
||||
return CefDragData.FromNative(cef_drag_data_t.create());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a copy of the current object.
|
||||
/// </summary>
|
||||
public CefDragData Clone()
|
||||
{
|
||||
return CefDragData.FromNative(cef_drag_data_t.clone(_self));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this object is read-only.
|
||||
/// </summary>
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get { return cef_drag_data_t.is_read_only(_self) != 0; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the drag data is a link.
|
||||
/// </summary>
|
||||
public bool IsLink
|
||||
{
|
||||
get { return cef_drag_data_t.is_link(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the drag data is a text or html fragment.
|
||||
/// </summary>
|
||||
public bool IsFragment
|
||||
{
|
||||
get { return cef_drag_data_t.is_fragment(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the drag data is a file.
|
||||
/// </summary>
|
||||
public bool IsFile
|
||||
{
|
||||
get { return cef_drag_data_t.is_file(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the link URL that is being dragged.
|
||||
/// </summary>
|
||||
public string LinkUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_drag_data_t.get_link_url(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the title associated with the link being dragged.
|
||||
/// </summary>
|
||||
public string LinkTitle
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_drag_data_t.get_link_title(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the metadata, if any, associated with the link being dragged.
|
||||
/// </summary>
|
||||
public string LinkMetadata
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_drag_data_t.get_link_metadata(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the plain text fragment that is being dragged.
|
||||
/// </summary>
|
||||
public string FragmentText
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_drag_data_t.get_fragment_text(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the text/html fragment that is being dragged.
|
||||
/// </summary>
|
||||
public string FragmentHtml
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_drag_data_t.get_fragment_html(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the base URL that the fragment came from. This value is used for
|
||||
/// resolving relative URLs and may be empty.
|
||||
/// </summary>
|
||||
public string FragmentBaseUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_drag_data_t.get_fragment_base_url(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the name of the file being dragged out of the browser window.
|
||||
/// </summary>
|
||||
public string FileName
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_drag_data_t.get_file_name(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write the contents of the file being dragged out of the web view into
|
||||
/// |writer|. Returns the number of bytes sent to |writer|. If |writer| is
|
||||
/// NULL this method will return the size of the file contents in bytes.
|
||||
/// Call GetFileName() to get a suggested name for the file.
|
||||
/// </summary>
|
||||
public ulong GetFileContents(CefStreamWriter writer)
|
||||
{
|
||||
var n_writer = writer != null ? writer.ToNative() : null;
|
||||
return (ulong)cef_drag_data_t.get_file_contents(_self, n_writer);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the list of file names that are being dragged into the browser
|
||||
/// window.
|
||||
/// </summary>
|
||||
public string[] GetFileNames()
|
||||
{
|
||||
cef_string_list* n_result = null;
|
||||
try
|
||||
{
|
||||
n_result = libcef.string_list_alloc();
|
||||
var success = cef_drag_data_t.get_file_names(_self, n_result) != 0;
|
||||
if (!success) return null;
|
||||
return cef_string_list.ToArray(n_result);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (n_result != null) libcef.string_list_free(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the link URL that is being dragged.
|
||||
/// </summary>
|
||||
public void SetLinkURL(string url)
|
||||
{
|
||||
fixed (char* url_str = url)
|
||||
{
|
||||
var n_url = new cef_string_t(url_str, url != null ? url.Length : 0);
|
||||
cef_drag_data_t.set_link_url(_self, &n_url);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the title associated with the link being dragged.
|
||||
/// </summary>
|
||||
public void SetLinkTitle(string title)
|
||||
{
|
||||
fixed (char* title_str = title)
|
||||
{
|
||||
var n_title = new cef_string_t(title_str, title != null ? title.Length : 0);
|
||||
cef_drag_data_t.set_link_title(_self, &n_title);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the metadata associated with the link being dragged.
|
||||
/// </summary>
|
||||
public void SetLinkMetadata(string data)
|
||||
{
|
||||
fixed (char* data_str = data)
|
||||
{
|
||||
var n_data = new cef_string_t(data_str, data != null ? data.Length : 0);
|
||||
cef_drag_data_t.set_link_metadata(_self, &n_data);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the plain text fragment that is being dragged.
|
||||
/// </summary>
|
||||
public void SetFragmentText(string text)
|
||||
{
|
||||
fixed (char* text_str = text)
|
||||
{
|
||||
var n_text = new cef_string_t(text_str, text != null ? text.Length : 0);
|
||||
cef_drag_data_t.set_fragment_text(_self, &n_text);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the text/html fragment that is being dragged.
|
||||
/// </summary>
|
||||
public void SetFragmentHtml(string html)
|
||||
{
|
||||
fixed (char* html_str = html)
|
||||
{
|
||||
var n_html = new cef_string_t(html_str, html != null ? html.Length : 0);
|
||||
cef_drag_data_t.set_fragment_html(_self, &n_html);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the base URL that the fragment came from.
|
||||
/// </summary>
|
||||
public void SetFragmentBaseURL(string baseUrl)
|
||||
{
|
||||
fixed (char* baseUrl_str = baseUrl)
|
||||
{
|
||||
var n_baseUrl = new cef_string_t(baseUrl_str, baseUrl != null ? baseUrl.Length : 0);
|
||||
cef_drag_data_t.set_fragment_base_url(_self, &n_baseUrl);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reset the file contents. You should do this before calling
|
||||
/// CefBrowserHost::DragTargetDragEnter as the web view does not allow us to
|
||||
/// drag in this kind of data.
|
||||
/// </summary>
|
||||
public void ResetFileContents()
|
||||
{
|
||||
cef_drag_data_t.reset_file_contents(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a file that is being dragged into the webview.
|
||||
/// </summary>
|
||||
public void AddFile(string path, string displayName)
|
||||
{
|
||||
fixed (char* path_str = path)
|
||||
fixed (char* displayName_str = displayName)
|
||||
{
|
||||
var n_path = new cef_string_t(path_str, path != null ? path.Length : 0);
|
||||
var n_displayName = new cef_string_t(displayName_str, displayName != null ? displayName.Length : 0);
|
||||
|
||||
cef_drag_data_t.add_file(_self, &n_path, &n_displayName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Callback interface for asynchronous continuation of file dialog requests.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefFileDialogCallback
|
||||
{
|
||||
/// <summary>
|
||||
/// Continue the file selection. |selected_accept_filter| should be the 0-based
|
||||
/// index of the value selected from the accept filters array passed to
|
||||
/// CefDialogHandler::OnFileDialog. |file_paths| should be a single value or a
|
||||
/// list of values depending on the dialog mode. An empty |file_paths| value is
|
||||
/// treated the same as calling Cancel().
|
||||
/// </summary>
|
||||
public void Continue(int selectedAcceptFilter, string[] filePaths)
|
||||
{
|
||||
var n_filePaths = cef_string_list.From(filePaths);
|
||||
|
||||
cef_file_dialog_callback_t.cont(_self, selectedAcceptFilter, n_filePaths);
|
||||
|
||||
libcef.string_list_free(n_filePaths);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancel the file selection.
|
||||
/// </summary>
|
||||
public void Cancel()
|
||||
{
|
||||
cef_file_dialog_callback_t.cancel(_self);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,273 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class used to represent a frame in the browser window. When used in the
|
||||
/// browser process the methods of this class may be called on any thread unless
|
||||
/// otherwise indicated in the comments. When used in the render process the
|
||||
/// methods of this class may only be called on the main thread.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefFrame
|
||||
{
|
||||
/// <summary>
|
||||
/// True if this object is currently attached to a valid frame.
|
||||
/// </summary>
|
||||
public bool IsValid
|
||||
{
|
||||
get { return cef_frame_t.is_valid(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Execute undo in this frame.
|
||||
/// </summary>
|
||||
public void Undo()
|
||||
{
|
||||
cef_frame_t.undo(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Execute redo in this frame.
|
||||
/// </summary>
|
||||
public void Redo()
|
||||
{
|
||||
cef_frame_t.redo(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Execute cut in this frame.
|
||||
/// </summary>
|
||||
public void Cut()
|
||||
{
|
||||
cef_frame_t.cut(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Execute copy in this frame.
|
||||
/// </summary>
|
||||
public void Copy()
|
||||
{
|
||||
cef_frame_t.copy(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Execute paste in this frame.
|
||||
/// </summary>
|
||||
public void Paste()
|
||||
{
|
||||
cef_frame_t.paste(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Execute delete in this frame.
|
||||
/// </summary>
|
||||
public void Delete()
|
||||
{
|
||||
cef_frame_t.del(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Execute select all in this frame.
|
||||
/// </summary>
|
||||
public void SelectAll()
|
||||
{
|
||||
cef_frame_t.select_all(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save this frame's HTML source to a temporary file and open it in the
|
||||
/// default text viewing application. This method can only be called from the
|
||||
/// browser process.
|
||||
/// </summary>
|
||||
public void ViewSource()
|
||||
{
|
||||
cef_frame_t.view_source(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve this frame's HTML source as a string sent to the specified
|
||||
/// visitor.
|
||||
/// </summary>
|
||||
public void GetSource(CefStringVisitor visitor)
|
||||
{
|
||||
if (visitor == null) throw new ArgumentNullException("visitor");
|
||||
|
||||
cef_frame_t.get_source(_self, visitor.ToNative());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve this frame's display text as a string sent to the specified
|
||||
/// visitor.
|
||||
/// </summary>
|
||||
public void GetText(CefStringVisitor visitor)
|
||||
{
|
||||
if (visitor == null) throw new ArgumentNullException("visitor");
|
||||
|
||||
cef_frame_t.get_text(_self, visitor.ToNative());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load the request represented by the |request| object.
|
||||
/// </summary>
|
||||
public void LoadRequest(CefRequest request)
|
||||
{
|
||||
if (request == null) throw new ArgumentNullException("request");
|
||||
|
||||
cef_frame_t.load_request(_self, request.ToNative());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load the specified |url|.
|
||||
/// </summary>
|
||||
public void LoadUrl(string url)
|
||||
{
|
||||
fixed (char* url_str = url)
|
||||
{
|
||||
var n_url = new cef_string_t(url_str, url != null ? url.Length : 0);
|
||||
cef_frame_t.load_url(_self, &n_url);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load the contents of |string_val| with the specified dummy |url|. |url|
|
||||
/// should have a standard scheme (for example, http scheme) or behaviors like
|
||||
/// link clicks and web security restrictions may not behave as expected.
|
||||
/// </summary>
|
||||
public void LoadString(string content, string url)
|
||||
{
|
||||
fixed (char* content_str = content)
|
||||
fixed (char* url_str = url)
|
||||
{
|
||||
var n_content = new cef_string_t(content_str, content != null ? content.Length : 0);
|
||||
var n_url = new cef_string_t(url_str, url != null ? url.Length : 0);
|
||||
cef_frame_t.load_string(_self, &n_content, &n_url);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Execute a string of JavaScript code in this frame. The |script_url|
|
||||
/// parameter is the URL where the script in question can be found, if any.
|
||||
/// The renderer may request this URL to show the developer the source of the
|
||||
/// error. The |start_line| parameter is the base line number to use for error
|
||||
/// reporting.
|
||||
/// </summary>
|
||||
public void ExecuteJavaScript(string code, string url, int line)
|
||||
{
|
||||
fixed (char* code_str = code)
|
||||
fixed (char* url_str = url)
|
||||
{
|
||||
var n_code = new cef_string_t(code_str, code != null ? code.Length : 0);
|
||||
var n_url = new cef_string_t(url_str, url != null ? url.Length : 0);
|
||||
cef_frame_t.execute_java_script(_self, &n_code, &n_url, line);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this is the main (top-level) frame.
|
||||
/// </summary>
|
||||
public bool IsMain
|
||||
{
|
||||
get { return cef_frame_t.is_main(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this is the focused frame.
|
||||
/// </summary>
|
||||
public bool IsFocused
|
||||
{
|
||||
get { return cef_frame_t.is_focused(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the name for this frame. If the frame has an assigned name (for
|
||||
/// example, set via the iframe "name" attribute) then that value will be
|
||||
/// returned. Otherwise a unique name will be constructed based on the frame
|
||||
/// parent hierarchy. The main (top-level) frame will always have an empty name
|
||||
/// value.
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_frame_t.get_name(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the globally unique identifier for this frame.
|
||||
/// </summary>
|
||||
public long Identifier
|
||||
{
|
||||
get { return cef_frame_t.get_identifier(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the parent of this frame or NULL if this is the main (top-level)
|
||||
/// frame.
|
||||
/// </summary>
|
||||
public CefFrame Parent
|
||||
{
|
||||
get
|
||||
{
|
||||
return CefFrame.FromNativeOrNull(
|
||||
cef_frame_t.get_parent(_self)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the URL currently loaded in this frame.
|
||||
/// </summary>
|
||||
public string Url
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_frame_t.get_url(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the browser that this frame belongs to.
|
||||
/// </summary>
|
||||
public CefBrowser Browser
|
||||
{
|
||||
get
|
||||
{
|
||||
return CefBrowser.FromNative(
|
||||
cef_frame_t.get_browser(_self)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the V8 context associated with the frame. This method can only be
|
||||
/// called from the render process.
|
||||
/// </summary>
|
||||
public CefV8Context V8Context
|
||||
{
|
||||
get
|
||||
{
|
||||
return CefV8Context.FromNative(
|
||||
cef_frame_t.get_v8context(_self)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Visit the DOM document. This method can only be called from the render
|
||||
/// process.
|
||||
/// </summary>
|
||||
public void VisitDom(CefDomVisitor visitor)
|
||||
{
|
||||
if (visitor == null) throw new ArgumentNullException("visitor");
|
||||
|
||||
cef_frame_t.visit_dom(_self, visitor.ToNative());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Callback interface used for asynchronous continuation of geolocation
|
||||
/// permission requests.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefGeolocationCallback
|
||||
{
|
||||
/// <summary>
|
||||
/// Call to allow or deny geolocation access.
|
||||
/// </summary>
|
||||
public void Continue(bool allow)
|
||||
{
|
||||
// FIXME: it is can be executed only once - so may be make it self-disposable ?
|
||||
|
||||
cef_geolocation_callback_t.cont(_self, allow ? 1 : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Callback interface used for asynchronous continuation of JavaScript dialog
|
||||
/// requests.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefJSDialogCallback
|
||||
{
|
||||
/// <summary>
|
||||
/// Continue the JS dialog request. Set |success| to true if the OK button was
|
||||
/// pressed. The |user_input| value should be specified for prompt dialogs.
|
||||
/// </summary>
|
||||
public void Continue(bool success, string userInput)
|
||||
{
|
||||
fixed (char* userInput_str = userInput)
|
||||
{
|
||||
var n_userInput = new cef_string_t(userInput_str, userInput != null ? userInput.Length : 0);
|
||||
|
||||
cef_jsdialog_callback_t.cont(_self, success ? 1 : 0, &n_userInput);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,303 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class representing a list value. Can be used on any process and thread.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefListValue
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new object that is not owned by any other object.
|
||||
/// </summary>
|
||||
public static CefListValue Create()
|
||||
{
|
||||
return CefListValue.FromNative(
|
||||
cef_list_value_t.create()
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this object is valid. This object may become invalid if
|
||||
/// the underlying data is owned by another object (e.g. list or dictionary)
|
||||
/// and that other object is then modified or destroyed. Do not call any other
|
||||
/// methods if this method returns false.
|
||||
/// </summary>
|
||||
public bool IsValid
|
||||
{
|
||||
get { return cef_list_value_t.is_valid(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this object is currently owned by another object.
|
||||
/// </summary>
|
||||
public bool IsOwned
|
||||
{
|
||||
get { return cef_list_value_t.is_owned(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the values of this object are read-only. Some APIs may
|
||||
/// expose read-only objects.
|
||||
/// </summary>
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get { return cef_list_value_t.is_read_only(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this object and |that| object have the same underlying
|
||||
/// data. If true modifications to this object will also affect |that| object
|
||||
/// and vice-versa.
|
||||
/// </summary>
|
||||
public bool IsSame(CefListValue that)
|
||||
{
|
||||
return cef_list_value_t.is_same(_self, that.ToNative()) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this object and |that| object have an equivalent underlying
|
||||
/// value but are not necessarily the same object.
|
||||
/// </summary>
|
||||
public bool IsEqual(CefListValue that)
|
||||
{
|
||||
return cef_list_value_t.is_equal(_self, that.ToNative()) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a writable copy of this object.
|
||||
/// </summary>
|
||||
public CefListValue Copy()
|
||||
{
|
||||
return CefListValue.FromNative(
|
||||
cef_list_value_t.copy(_self)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the number of values. If the number of values is expanded all
|
||||
/// new value slots will default to type null. Returns true on success.
|
||||
/// </summary>
|
||||
public bool SetSize(int size)
|
||||
{
|
||||
return cef_list_value_t.set_size(_self, (UIntPtr)size) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the number of values.
|
||||
/// </summary>
|
||||
public int Count
|
||||
{
|
||||
get { return (int)cef_list_value_t.get_size(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all values. Returns true on success.
|
||||
/// </summary>
|
||||
public bool Clear()
|
||||
{
|
||||
return cef_list_value_t.clear(_self) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the value at the specified index.
|
||||
/// </summary>
|
||||
public bool Remove(int index)
|
||||
{
|
||||
return cef_list_value_t.remove(_self, index) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the value type at the specified index.
|
||||
/// </summary>
|
||||
public CefValueType GetValueType(int index)
|
||||
{
|
||||
return cef_list_value_t.get_type(_self, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the value at the specified index. For simple types the returned
|
||||
/// value will copy existing data and modifications to the value will not
|
||||
/// modify this object. For complex types (binary, dictionary and list) the
|
||||
/// returned value will reference existing data and modifications to the value
|
||||
/// will modify this object.
|
||||
/// </summary>
|
||||
public CefValue GetValue(int index)
|
||||
{
|
||||
return CefValue.FromNativeOrNull(
|
||||
cef_list_value_t.get_value(_self, index)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the value at the specified index as type bool.
|
||||
/// </summary>
|
||||
public bool GetBool(int index)
|
||||
{
|
||||
return cef_list_value_t.get_bool(_self, index) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the value at the specified index as type int.
|
||||
/// </summary>
|
||||
public int GetInt(int index)
|
||||
{
|
||||
return cef_list_value_t.get_int(_self, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the value at the specified index as type double.
|
||||
/// </summary>
|
||||
public double GetDouble(int index)
|
||||
{
|
||||
return cef_list_value_t.get_double(_self, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the value at the specified index as type string.
|
||||
/// </summary>
|
||||
public string GetString(int index)
|
||||
{
|
||||
var n_result = cef_list_value_t.get_string(_self, index);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the value at the specified index as type binary. The returned
|
||||
/// value will reference existing data.
|
||||
/// </summary>
|
||||
public CefBinaryValue GetBinary(int index)
|
||||
{
|
||||
return CefBinaryValue.FromNativeOrNull(
|
||||
cef_list_value_t.get_binary(_self, index)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the value at the specified index as type dictionary. The returned
|
||||
/// value will reference existing data and modifications to the value will
|
||||
/// modify this object.
|
||||
/// </summary>
|
||||
public CefDictionaryValue GetDictionary(int index)
|
||||
{
|
||||
return CefDictionaryValue.FromNativeOrNull(
|
||||
cef_list_value_t.get_dictionary(_self, index)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the value at the specified index as type list. The returned
|
||||
/// value will reference existing data and modifications to the value will
|
||||
/// modify this object.
|
||||
/// </summary>
|
||||
public CefListValue GetList(int index)
|
||||
{
|
||||
return CefListValue.FromNativeOrNull(
|
||||
cef_list_value_t.get_list(_self, index)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Sets the value at the specified index. Returns true if the value was set
|
||||
/// successfully. If |value| represents simple data then the underlying data
|
||||
/// will be copied and modifications to |value| will not modify this object. If
|
||||
/// |value| represents complex data (binary, dictionary or list) then the
|
||||
/// underlying data will be referenced and modifications to |value| will modify
|
||||
/// this object.
|
||||
/// </summary>
|
||||
public bool SetValue(int index, CefValue value)
|
||||
{
|
||||
return cef_list_value_t.set_value(_self, index, value.ToNative()) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the value at the specified index as type null. Returns true if the
|
||||
/// value was set successfully.
|
||||
/// </summary>
|
||||
public bool SetNull(int index)
|
||||
{
|
||||
return cef_list_value_t.set_null(_self, index) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the value at the specified index as type bool. Returns true if the
|
||||
/// value was set successfully.
|
||||
/// </summary>
|
||||
public bool SetBool(int index, bool value)
|
||||
{
|
||||
return cef_list_value_t.set_bool(_self, index, value ? 1 : 0) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the value at the specified index as type int. Returns true if the
|
||||
/// value was set successfully.
|
||||
/// </summary>
|
||||
public bool SetInt(int index, int value)
|
||||
{
|
||||
return cef_list_value_t.set_int(_self, index, value) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the value at the specified index as type double. Returns true if the
|
||||
/// value was set successfully.
|
||||
/// </summary>
|
||||
public bool SetDouble(int index, double value)
|
||||
{
|
||||
return cef_list_value_t.set_double(_self, index, value) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the value at the specified index as type string. Returns true if the
|
||||
/// value was set successfully.
|
||||
/// </summary>
|
||||
public bool SetString(int index, string value)
|
||||
{
|
||||
fixed (char* value_str = value)
|
||||
{
|
||||
var n_value = new cef_string_t(value_str, value != null ? value.Length : 0);
|
||||
return cef_list_value_t.set_string(_self, index, &n_value) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the value at the specified index as type binary. Returns true if the
|
||||
/// value was set successfully. If |value| is currently owned by another object
|
||||
/// then the value will be copied and the |value| reference will not change.
|
||||
/// Otherwise, ownership will be transferred to this object and the |value|
|
||||
/// reference will be invalidated.
|
||||
/// </summary>
|
||||
public bool SetBinary(int index, CefBinaryValue value)
|
||||
{
|
||||
return cef_list_value_t.set_binary(_self, index, value.ToNative()) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the value at the specified index as type dict. Returns true if the
|
||||
/// value was set successfully. If |value| is currently owned by another object
|
||||
/// then the value will be copied and the |value| reference will not change.
|
||||
/// Otherwise, ownership will be transferred to this object and the |value|
|
||||
/// reference will be invalidated.
|
||||
/// </summary>
|
||||
public bool SetDictionary(int index, CefDictionaryValue value)
|
||||
{
|
||||
return cef_list_value_t.set_dictionary(_self, index, value.ToNative()) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the value at the specified index as type list. Returns true if the
|
||||
/// value was set successfully. If |value| is currently owned by another object
|
||||
/// then the value will be copied and the |value| reference will not change.
|
||||
/// Otherwise, ownership will be transferred to this object and the |value|
|
||||
/// reference will be invalidated.
|
||||
/// </summary>
|
||||
public bool SetList(int index, CefListValue value)
|
||||
{
|
||||
return cef_list_value_t.set_list(_self, index, value.ToNative()) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,521 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Supports creation and modification of menus. 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. The methods of
|
||||
/// this class can only be accessed on the browser process the UI thread.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefMenuModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Clears the menu. Returns true on success.
|
||||
/// </summary>
|
||||
public bool Clear()
|
||||
{
|
||||
return cef_menu_model_t.clear(_self) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the number of items in this menu.
|
||||
/// </summary>
|
||||
public int Count
|
||||
{
|
||||
get { return cef_menu_model_t.get_count(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a separator to the menu. Returns true on success.
|
||||
/// </summary>
|
||||
public bool AddSeparator()
|
||||
{
|
||||
return cef_menu_model_t.add_separator(_self) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add an item to the menu. Returns true on success.
|
||||
/// </summary>
|
||||
public bool AddItem(int commandId, string label)
|
||||
{
|
||||
fixed (char* label_str = label)
|
||||
{
|
||||
var n_label = new cef_string_t(label_str, label.Length);
|
||||
return cef_menu_model_t.add_item(_self, commandId, &n_label) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a check item to the menu. Returns true on success.
|
||||
/// </summary>
|
||||
public bool AddCheckItem(int commandId, string label)
|
||||
{
|
||||
fixed (char* label_str = label)
|
||||
{
|
||||
var n_label = new cef_string_t(label_str, label.Length);
|
||||
return cef_menu_model_t.add_check_item(_self, commandId, &n_label) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a radio item to the menu. Only a single item with the specified
|
||||
/// |group_id| can be checked at a time. Returns true on success.
|
||||
/// </summary>
|
||||
public bool AddRadioItem(int commandId, string label, int groupId)
|
||||
{
|
||||
fixed (char* label_str = label)
|
||||
{
|
||||
var n_label = new cef_string_t(label_str, label.Length);
|
||||
return cef_menu_model_t.add_radio_item(_self, commandId, &n_label, groupId) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a sub-menu to the menu. The new sub-menu is returned.
|
||||
/// </summary>
|
||||
public CefMenuModel AddSubMenu(int commandId, string label)
|
||||
{
|
||||
fixed (char* label_str = label)
|
||||
{
|
||||
var n_label = new cef_string_t(label_str, label.Length);
|
||||
return CefMenuModel.FromNative(
|
||||
cef_menu_model_t.add_sub_menu(_self, commandId, &n_label)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Insert a separator in the menu at the specified |index|. Returns true on
|
||||
/// success.
|
||||
/// </summary>
|
||||
public bool InsertSeparatorAt(int index)
|
||||
{
|
||||
return cef_menu_model_t.insert_separator_at(_self, index) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Insert an item in the menu at the specified |index|. Returns true on
|
||||
/// success.
|
||||
/// </summary>
|
||||
public bool InsertItemAt(int index, int commandId, string label)
|
||||
{
|
||||
fixed (char* label_str = label)
|
||||
{
|
||||
var n_label = new cef_string_t(label_str, label.Length);
|
||||
return cef_menu_model_t.insert_item_at(_self, index, commandId, &n_label) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Insert a check item in the menu at the specified |index|. Returns true on
|
||||
/// success.
|
||||
/// </summary>
|
||||
public bool InsertCheckItemAt(int index, int commandId, string label)
|
||||
{
|
||||
fixed (char* label_str = label)
|
||||
{
|
||||
var n_label = new cef_string_t(label_str, label.Length);
|
||||
return cef_menu_model_t.insert_check_item_at(_self, index, commandId, &n_label) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Insert a radio item in the menu at the specified |index|. Only a single
|
||||
/// item with the specified |group_id| can be checked at a time. Returns true
|
||||
/// on success.
|
||||
/// </summary>
|
||||
public bool InsertRadioItemAt(int index, int commandId, string label, int groupId)
|
||||
{
|
||||
fixed (char* label_str = label)
|
||||
{
|
||||
var n_label = new cef_string_t(label_str, label.Length);
|
||||
return cef_menu_model_t.insert_radio_item_at(_self, index, commandId, &n_label, groupId) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Insert a sub-menu in the menu at the specified |index|. The new sub-menu
|
||||
/// is returned.
|
||||
/// </summary>
|
||||
public CefMenuModel InsertSubMenuAt(int index, int commandId, string label)
|
||||
{
|
||||
fixed (char* label_str = label)
|
||||
{
|
||||
var n_label = new cef_string_t(label_str, label.Length);
|
||||
return CefMenuModel.FromNative(
|
||||
cef_menu_model_t.add_sub_menu(_self, commandId, &n_label)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the item with the specified |commandId|. Returns true on success.
|
||||
/// </summary>
|
||||
public bool Remove(int commandId)
|
||||
{
|
||||
return cef_menu_model_t.remove(_self, commandId) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the item at the specified |index|. Returns true on success.
|
||||
/// </summary>
|
||||
public bool RemoveAt(int index)
|
||||
{
|
||||
return cef_menu_model_t.remove_at(_self, index) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the index associated with the specified |commandId| or -1 if not
|
||||
/// found due to the command id not existing in the menu.
|
||||
/// </summary>
|
||||
public int GetIndexOf(int commandId)
|
||||
{
|
||||
return cef_menu_model_t.get_index_of(_self, commandId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the command id at the specified |index| or -1 if not found due to
|
||||
/// invalid range or the index being a separator.
|
||||
/// </summary>
|
||||
public int GetCommandIdAt(int index)
|
||||
{
|
||||
return cef_menu_model_t.get_command_id_at(_self, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the command id at the specified |index|. Returns true on success.
|
||||
/// </summary>
|
||||
public bool SetCommandIdAt(int index, int commandId)
|
||||
{
|
||||
return cef_menu_model_t.set_command_id_at(_self, index, commandId) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the label for the specified |commandId| or empty if not found.
|
||||
/// </summary>
|
||||
public string GetLabel(int commandId)
|
||||
{
|
||||
var n_result = cef_menu_model_t.get_label(_self, commandId);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the label at the specified |index| or empty if not found due to
|
||||
/// invalid range or the index being a separator.
|
||||
/// </summary>
|
||||
public string GetLabelAt(int index)
|
||||
{
|
||||
var n_result = cef_menu_model_t.get_label_at(_self, index);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the label for the specified |commandId|. Returns true on success.
|
||||
/// </summary>
|
||||
public bool SetLabel(int commandId, string label)
|
||||
{
|
||||
fixed (char* label_str = label)
|
||||
{
|
||||
var n_label = new cef_string_t(label_str, label.Length);
|
||||
return cef_menu_model_t.set_label(_self, commandId, &n_label) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the label at the specified |index|. Returns true on success.
|
||||
/// </summary>
|
||||
public bool SetLabelAt(int index, string label)
|
||||
{
|
||||
fixed (char* label_str = label)
|
||||
{
|
||||
var n_label = new cef_string_t(label_str, label.Length);
|
||||
return cef_menu_model_t.set_label_at(_self, index, &n_label) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the item type for the specified |commandId|.
|
||||
/// </summary>
|
||||
public CefMenuItemType GetItemType(int commandId)
|
||||
{
|
||||
return cef_menu_model_t.get_type(_self, commandId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the item type at the specified |index|.
|
||||
/// </summary>
|
||||
public CefMenuItemType GetItemTypeAt(int index)
|
||||
{
|
||||
return cef_menu_model_t.get_type_at(_self, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the group id for the specified |commandId| or -1 if invalid.
|
||||
/// </summary>
|
||||
public int GetGroupId(int commandId)
|
||||
{
|
||||
return cef_menu_model_t.get_group_id(_self, commandId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the group id at the specified |index| or -1 if invalid.
|
||||
/// </summary>
|
||||
public int GetGroupIdAt(int index)
|
||||
{
|
||||
return cef_menu_model_t.get_group_id_at(_self, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the group id for the specified |commandId|. Returns true on success.
|
||||
/// </summary>
|
||||
public bool SetGroupId(int commandId, int groupId)
|
||||
{
|
||||
return cef_menu_model_t.set_group_id(_self, commandId, groupId) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the group id at the specified |index|. Returns true on success.
|
||||
/// </summary>
|
||||
public bool SetGroupIdAt(int index, int groupId)
|
||||
{
|
||||
return cef_menu_model_t.set_group_id_at(_self, index, groupId) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the submenu for the specified |commandId| or empty if invalid.
|
||||
/// </summary>
|
||||
public CefMenuModel GetSubMenu(int commandId)
|
||||
{
|
||||
return CefMenuModel.FromNativeOrNull(
|
||||
cef_menu_model_t.get_sub_menu(_self, commandId)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the submenu at the specified |index| or empty if invalid.
|
||||
/// </summary>
|
||||
public CefMenuModel GetSubMenuAt(int index)
|
||||
{
|
||||
return CefMenuModel.FromNativeOrNull(
|
||||
cef_menu_model_t.get_sub_menu_at(_self, index)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the specified |commandId| is visible.
|
||||
/// </summary>
|
||||
public bool IsVisible(int commandId)
|
||||
{
|
||||
return cef_menu_model_t.is_visible(_self, commandId) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the specified |index| is visible.
|
||||
/// </summary>
|
||||
public bool IsVisibleAt(int index)
|
||||
{
|
||||
return cef_menu_model_t.is_visible(_self, index) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change the visibility of the specified |commandId|. Returns true on
|
||||
/// success.
|
||||
/// </summary>
|
||||
public bool SetVisible(int commandId, bool visible)
|
||||
{
|
||||
return cef_menu_model_t.set_visible(_self, commandId, visible ? 1 : 0) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change the visibility at the specified |index|. Returns true on success.
|
||||
/// </summary>
|
||||
public bool SetVisibleAt(int index, bool visible)
|
||||
{
|
||||
return cef_menu_model_t.set_visible(_self, index, visible ? 1 : 0) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the specified |commandId| is enabled.
|
||||
/// </summary>
|
||||
public bool IsEnabled(int commandId)
|
||||
{
|
||||
return cef_menu_model_t.is_enabled(_self, commandId) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the specified |index| is enabled.
|
||||
/// </summary>
|
||||
public bool IsEnabledAt(int index)
|
||||
{
|
||||
return cef_menu_model_t.is_enabled_at(_self, index) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change the enabled status of the specified |commandId|. Returns true on
|
||||
/// success.
|
||||
/// </summary>
|
||||
public bool SetEnabled(int commandId, bool enabled)
|
||||
{
|
||||
return cef_menu_model_t.set_enabled(_self, commandId, enabled ? 1 : 0) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change the enabled status at the specified |index|. Returns true on
|
||||
/// success.
|
||||
/// </summary>
|
||||
public bool SetEnabledAt(int index, bool enabled)
|
||||
{
|
||||
return cef_menu_model_t.set_enabled_at(_self, index, enabled ? 1 : 0) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the specified |commandId| is checked. Only applies to
|
||||
/// check and radio items.
|
||||
/// </summary>
|
||||
public bool IsChecked(int commandId)
|
||||
{
|
||||
return cef_menu_model_t.is_checked(_self, commandId) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the specified |index| is checked. Only applies to check
|
||||
/// and radio items.
|
||||
/// </summary>
|
||||
public bool IsCheckedAt(int index)
|
||||
{
|
||||
return cef_menu_model_t.is_checked_at(_self, index) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check the specified |commandId|. Only applies to check and radio items.
|
||||
/// Returns true on success.
|
||||
/// </summary>
|
||||
public bool SetChecked(int commandId, bool value)
|
||||
{
|
||||
return cef_menu_model_t.set_checked(_self, commandId, value ? 1 : 0) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check the specified |index|. Only applies to check and radio items. Returns
|
||||
/// true on success.
|
||||
/// </summary>
|
||||
public bool SetCheckedAt(int index, bool value)
|
||||
{
|
||||
return cef_menu_model_t.set_checked_at(_self, index, value ? 1 : 0) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the specified |commandId| has a keyboard accelerator
|
||||
/// assigned.
|
||||
/// </summary>
|
||||
public bool HasAccelerator(int commandId)
|
||||
{
|
||||
return cef_menu_model_t.has_accelerator(_self, commandId) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the specified |index| has a keyboard accelerator assigned.
|
||||
/// </summary>
|
||||
public bool HasAcceleratorAt(int index)
|
||||
{
|
||||
return cef_menu_model_t.has_accelerator(_self, index) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the keyboard accelerator for the specified |commandId|. |key_code| can
|
||||
/// be any virtual key or character value. Returns true on success.
|
||||
/// </summary>
|
||||
public bool SetAccelerator(int commandId, int keyCode, bool shiftPressed, bool ctrlPressed, bool altPressed)
|
||||
{
|
||||
return cef_menu_model_t.set_accelerator(
|
||||
_self,
|
||||
commandId,
|
||||
keyCode,
|
||||
shiftPressed ? 1 : 0,
|
||||
ctrlPressed ? 1 : 0,
|
||||
altPressed ? 1 : 0
|
||||
) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the keyboard accelerator at the specified |index|. |key_code| can be
|
||||
/// any virtual key or character value. Returns true on success.
|
||||
/// </summary>
|
||||
public bool SetAcceleratorAt(int index, int keyCode, bool shiftPressed, bool ctrlPressed, bool altPressed)
|
||||
{
|
||||
return cef_menu_model_t.set_accelerator_at(
|
||||
_self,
|
||||
index,
|
||||
keyCode,
|
||||
shiftPressed ? 1 : 0,
|
||||
ctrlPressed ? 1 : 0,
|
||||
altPressed ? 1 : 0
|
||||
) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove the keyboard accelerator for the specified |commandId|. Returns
|
||||
/// true on success.
|
||||
/// </summary>
|
||||
public bool RemoveAccelerator(int commandId)
|
||||
{
|
||||
return cef_menu_model_t.remove_accelerator(_self, commandId) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove the keyboard accelerator at the specified |index|. Returns true on
|
||||
/// success.
|
||||
/// </summary>
|
||||
public bool RemoveAcceleratorAt(int index)
|
||||
{
|
||||
return cef_menu_model_t.remove_accelerator_at(_self, index) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the keyboard accelerator for the specified |commandId|. Returns
|
||||
/// true on success.
|
||||
/// </summary>
|
||||
public bool GetAccelerator(int commandId, out int keyCode, out bool shiftPressed, out bool ctrlPressed, out bool altPressed)
|
||||
{
|
||||
int n_keyCode;
|
||||
int n_shiftPressed;
|
||||
int n_ctrlPressed;
|
||||
int n_altPressed;
|
||||
|
||||
var result = cef_menu_model_t.get_accelerator(_self, commandId, &n_keyCode, &n_shiftPressed, &n_ctrlPressed, &n_altPressed) != 0;
|
||||
|
||||
keyCode = n_keyCode;
|
||||
shiftPressed = n_shiftPressed != 0;
|
||||
ctrlPressed = n_ctrlPressed != 0;
|
||||
altPressed = n_altPressed != 0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the keyboard accelerator for the specified |index|. Returns true
|
||||
/// on success.
|
||||
/// </summary>
|
||||
public bool GetAcceleratorAt(int index, out int keyCode, out bool shiftPressed, out bool ctrlPressed, out bool altPressed)
|
||||
{
|
||||
int n_keyCode;
|
||||
int n_shiftPressed;
|
||||
int n_ctrlPressed;
|
||||
int n_altPressed;
|
||||
|
||||
var result = cef_menu_model_t.get_accelerator_at(_self, index, &n_keyCode, &n_shiftPressed, &n_ctrlPressed, &n_altPressed) != 0;
|
||||
|
||||
keyCode = n_keyCode;
|
||||
shiftPressed = n_shiftPressed != 0;
|
||||
ctrlPressed = n_ctrlPressed != 0;
|
||||
altPressed = n_altPressed != 0;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class used to represent an entry in navigation history.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefNavigationEntry
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if this object is valid. Do not call any other methods if this
|
||||
/// function returns false.
|
||||
/// </summary>
|
||||
public bool IsValid
|
||||
{
|
||||
get { return cef_navigation_entry_t.is_valid(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the actual URL of the page. For some pages this may be data: URL or
|
||||
/// similar. Use GetDisplayURL() to return a display-friendly version.
|
||||
/// </summary>
|
||||
public string Url
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_value = cef_navigation_entry_t.get_url(_self);
|
||||
return cef_string_userfree.ToString(n_value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a display-friendly version of the URL.
|
||||
/// </summary>
|
||||
public string GetDisplayUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_value = cef_navigation_entry_t.get_display_url(_self);
|
||||
return cef_string_userfree.ToString(n_value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the original URL that was entered by the user before any redirects.
|
||||
/// </summary>
|
||||
public string OriginalUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_value = cef_navigation_entry_t.get_original_url(_self);
|
||||
return cef_string_userfree.ToString(n_value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the title set by the page. This value may be empty.
|
||||
/// </summary>
|
||||
public string Title
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_value = cef_navigation_entry_t.get_title(_self);
|
||||
return cef_string_userfree.ToString(n_value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the transition type which indicates what the user did to move to
|
||||
/// this page from the previous page.
|
||||
/// </summary>
|
||||
public CefTransitionType TransitionType
|
||||
{
|
||||
get { return cef_navigation_entry_t.get_transition_type(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this navigation includes post data.
|
||||
/// </summary>
|
||||
public bool HasPostData
|
||||
{
|
||||
get { return cef_navigation_entry_t.has_post_data(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the time for the last known successful navigation completion. A
|
||||
/// navigation may be completed more than once if the page is reloaded. May be
|
||||
/// 0 if the navigation has not yet completed.
|
||||
/// </summary>
|
||||
public DateTime CompletionTime
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_value = cef_navigation_entry_t.get_completion_time(_self);
|
||||
return n_value.ToDateTime();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the HTTP status code for the last known successful navigation
|
||||
/// response. May be 0 if the response has not yet been received or if the
|
||||
/// navigation has not yet completed.
|
||||
/// </summary>
|
||||
public int HttpStatusCode
|
||||
{
|
||||
get { return cef_navigation_entry_t.get_http_status_code(_self); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class used to represent post data for a web request. The methods of this
|
||||
/// class may be called on any thread.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefPostData
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a new CefPostData object.
|
||||
/// </summary>
|
||||
public static CefPostData Create()
|
||||
{
|
||||
return CefPostData.FromNative(
|
||||
cef_post_data_t.create()
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this object is read-only.
|
||||
/// </summary>
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get { return cef_post_data_t.is_read_only(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the number of existing post data elements.
|
||||
/// </summary>
|
||||
public int Count
|
||||
{
|
||||
get { return (int)cef_post_data_t.get_element_count(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the post data elements.
|
||||
/// </summary>
|
||||
public CefPostDataElement[] GetElements()
|
||||
{
|
||||
// FIXME: CefPostDataElement.GetElements(): check CEF C API impl
|
||||
var count = Count;
|
||||
if (count == 0) return new CefPostDataElement[0];
|
||||
|
||||
UIntPtr n_elementsCount = (UIntPtr)count;
|
||||
var n_elements = new cef_post_data_element_t*[count];
|
||||
fixed (cef_post_data_element_t** n_elements_ptr = n_elements)
|
||||
{
|
||||
cef_post_data_t.get_elements(_self, &n_elementsCount, n_elements_ptr);
|
||||
if ((int)n_elementsCount > count) throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
count = (int)n_elementsCount;
|
||||
var elements = new CefPostDataElement[count];
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
elements[i] = CefPostDataElement.FromNative(n_elements[i]);
|
||||
}
|
||||
|
||||
return elements;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove the specified post data element. Returns true if the removal
|
||||
/// succeeds.
|
||||
/// </summary>
|
||||
public bool Remove(CefPostDataElement element)
|
||||
{
|
||||
return cef_post_data_t.remove_element(_self, element.ToNative()) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add the specified post data element. Returns true if the add succeeds.
|
||||
/// </summary>
|
||||
public bool Add(CefPostDataElement element)
|
||||
{
|
||||
return cef_post_data_t.add_element(_self, element.ToNative()) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all existing post data elements.
|
||||
/// </summary>
|
||||
public void RemoveAll()
|
||||
{
|
||||
cef_post_data_t.remove_elements(_self);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class used to represent a single element in the request post data. The
|
||||
/// methods of this class may be called on any thread.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefPostDataElement
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a new CefPostDataElement object.
|
||||
/// </summary>
|
||||
public static CefPostDataElement Create()
|
||||
{
|
||||
return CefPostDataElement.FromNative(
|
||||
cef_post_data_element_t.create()
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this object is read-only.
|
||||
/// </summary>
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get { return cef_post_data_element_t.is_read_only(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all contents from the post data element.
|
||||
/// </summary>
|
||||
public void SetToEmpty()
|
||||
{
|
||||
cef_post_data_element_t.set_to_empty(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The post data element will represent a file.
|
||||
/// </summary>
|
||||
public void SetToFile(string fileName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(fileName)) throw new ArgumentException("Argument can't be null or empty.", "fileName");
|
||||
|
||||
fixed (char* fileName_str = fileName)
|
||||
{
|
||||
var n_fileName = new cef_string_t(fileName_str, fileName.Length);
|
||||
cef_post_data_element_t.set_to_file(_self, &n_fileName);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The post data element will represent bytes. The bytes passed
|
||||
/// in will be copied.
|
||||
/// </summary>
|
||||
public void SetToBytes(byte[] bytes)
|
||||
{
|
||||
if (bytes == null) throw new ArgumentNullException("bytes");
|
||||
|
||||
fixed (byte* bytes_ptr = bytes)
|
||||
{
|
||||
cef_post_data_element_t.set_to_bytes(_self, (UIntPtr)bytes.Length, bytes_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the type of this post data element.
|
||||
/// </summary>
|
||||
public CefPostDataElementType ElementType
|
||||
{
|
||||
get { return cef_post_data_element_t.get_type(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the file name.
|
||||
/// </summary>
|
||||
public string GetFile()
|
||||
{
|
||||
var n_result = cef_post_data_element_t.get_file(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the number of bytes.
|
||||
/// </summary>
|
||||
public long BytesCount
|
||||
{
|
||||
get { return (long)cef_post_data_element_t.get_bytes_count(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read up to |size| bytes into |bytes| and return the number of bytes
|
||||
/// actually read.
|
||||
/// </summary>
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
var size = BytesCount;
|
||||
if (size == 0) return new byte[0];
|
||||
|
||||
var bytes = new byte[size];
|
||||
fixed (byte* bytes_ptr = bytes)
|
||||
{
|
||||
var written = (long)cef_post_data_element_t.get_bytes(_self, (UIntPtr)size, bytes_ptr);
|
||||
if (written != size) throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 asynchronous continuation of print dialog requests.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefPrintDialogCallback
|
||||
{
|
||||
/// <summary>
|
||||
/// Continue printing with the specified |settings|.
|
||||
/// </summary>
|
||||
public void Continue(CefPrintSettings settings)
|
||||
{
|
||||
cef_print_dialog_callback_t.cont(_self, settings.ToNative());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancel the printing.
|
||||
/// </summary>
|
||||
public void Cancel()
|
||||
{
|
||||
cef_print_dialog_callback_t.cancel(_self);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Callback interface for asynchronous continuation of print job requests.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefPrintJobCallback
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicate completion of the print job.
|
||||
/// </summary>
|
||||
public void Continue()
|
||||
{
|
||||
cef_print_job_callback_t.cont(_self);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,285 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class representing print settings.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefPrintSettings
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a new CefPrintSettings object.
|
||||
/// </summary>
|
||||
public static CefPrintSettings Create()
|
||||
{
|
||||
return CefPrintSettings.FromNative(
|
||||
cef_print_settings_t.create()
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this object is valid. Do not call any other methods if this
|
||||
/// function returns false.
|
||||
/// </summary>
|
||||
public bool IsValid
|
||||
{
|
||||
get
|
||||
{
|
||||
return cef_print_settings_t.is_valid(_self) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the values of this object are read-only. Some APIs may
|
||||
/// expose read-only objects.
|
||||
/// </summary>
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get
|
||||
{
|
||||
return cef_print_settings_t.is_read_only(_self) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a writable copy of this object.
|
||||
/// </summary>
|
||||
public CefPrintSettings Copy()
|
||||
{
|
||||
return CefPrintSettings.FromNative(
|
||||
cef_print_settings_t.copy(_self)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the page orientation.
|
||||
/// </summary>
|
||||
public void SetOrientation(bool landscape)
|
||||
{
|
||||
cef_print_settings_t.set_orientation(_self, landscape ? 1 : 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the orientation is landscape.
|
||||
/// </summary>
|
||||
public bool IsLandscape()
|
||||
{
|
||||
return cef_print_settings_t.is_landscape(_self) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the printer printable area in device units.
|
||||
/// Some platforms already provide flipped area. Set |landscape_needs_flip|
|
||||
/// to false on those platforms to avoid double flipping.
|
||||
/// </summary>
|
||||
public void SetPrinterPrintableArea(CefSize physicalSizeDeviceUnits, CefRectangle printableAreaDeviceUnits, bool landscapeNeedsFlip)
|
||||
{
|
||||
var n_physicalSizeDeviceUnits = new cef_size_t(
|
||||
physicalSizeDeviceUnits.Width,
|
||||
physicalSizeDeviceUnits.Height
|
||||
);
|
||||
|
||||
var n_printableAreaDeviceUnits = new cef_rect_t(
|
||||
printableAreaDeviceUnits.X,
|
||||
printableAreaDeviceUnits.Y,
|
||||
printableAreaDeviceUnits.Width,
|
||||
printableAreaDeviceUnits.Height
|
||||
);
|
||||
|
||||
cef_print_settings_t.set_printer_printable_area(
|
||||
_self,
|
||||
&n_physicalSizeDeviceUnits,
|
||||
&n_printableAreaDeviceUnits,
|
||||
landscapeNeedsFlip ? 1 : 0
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the device name.
|
||||
/// </summary>
|
||||
public void SetDeviceName(string name)
|
||||
{
|
||||
fixed (char* name_str = name)
|
||||
{
|
||||
var n_name = new cef_string_t(name_str, name != null ? name.Length : 0);
|
||||
cef_print_settings_t.set_device_name(_self, &n_name);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the device name.
|
||||
/// </summary>
|
||||
public string DeviceName
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_print_settings_t.get_device_name(_self);
|
||||
if (n_result == null) return null;
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the DPI (dots per inch).
|
||||
/// </summary>
|
||||
public void SetDpi(int dpi)
|
||||
{
|
||||
cef_print_settings_t.set_dpi(_self, dpi);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the DPI (dots per inch).
|
||||
/// </summary>
|
||||
public int GetDpi()
|
||||
{
|
||||
return cef_print_settings_t.get_dpi(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the page ranges.
|
||||
/// </summary>
|
||||
public void SetPageRanges(CefPageRange[] ranges)
|
||||
{
|
||||
var count = ranges != null ? ranges.Length : 0;
|
||||
var n_ranges = new cef_page_range_t[count];
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
n_ranges[i].from = ranges[i].From;
|
||||
n_ranges[i].to = ranges[i].To;
|
||||
}
|
||||
|
||||
fixed (cef_page_range_t* n_ranges_ptr = n_ranges)
|
||||
{
|
||||
cef_print_settings_t.set_page_ranges(_self, (UIntPtr)count, n_ranges_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the number of page ranges that currently exist.
|
||||
/// </summary>
|
||||
public int GetPageRangesCount()
|
||||
{
|
||||
return (int)cef_print_settings_t.get_page_ranges_count(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the page ranges.
|
||||
/// </summary>
|
||||
public CefPageRange[] GetPageRanges()
|
||||
{
|
||||
var count = GetPageRangesCount();
|
||||
if (count == 0) return new CefPageRange[0];
|
||||
|
||||
var n_ranges = new cef_page_range_t[count];
|
||||
UIntPtr n_count = (UIntPtr)count;
|
||||
fixed (cef_page_range_t* n_ranges_ptr = n_ranges)
|
||||
{
|
||||
cef_print_settings_t.get_page_ranges(_self, &n_count, n_ranges_ptr);
|
||||
}
|
||||
|
||||
count = (int)n_count;
|
||||
if (count == 0) return new CefPageRange[0];
|
||||
|
||||
var ranges = new CefPageRange[count];
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
ranges[i].From = n_ranges[i].from;
|
||||
ranges[i].To = n_ranges[i].to;
|
||||
}
|
||||
|
||||
return ranges;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set whether only the selection will be printed.
|
||||
/// </summary>
|
||||
public void SetSelectionOnly(bool selectionOnly)
|
||||
{
|
||||
cef_print_settings_t.set_selection_only(_self, selectionOnly ? 1 : 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if only the selection will be printed.
|
||||
/// </summary>
|
||||
public bool IsSelectionOnly
|
||||
{
|
||||
get
|
||||
{
|
||||
return cef_print_settings_t.is_selection_only(_self) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set whether pages will be collated.
|
||||
/// </summary>
|
||||
public void SetCollate(bool collate)
|
||||
{
|
||||
cef_print_settings_t.set_collate(_self, collate ? 1 : 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if pages will be collated.
|
||||
/// </summary>
|
||||
public bool WillCollate
|
||||
{
|
||||
get
|
||||
{
|
||||
return cef_print_settings_t.will_collate(_self) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the color model.
|
||||
/// </summary>
|
||||
public void SetColorModel(CefColorModel colorModel)
|
||||
{
|
||||
cef_print_settings_t.set_color_model(_self, colorModel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the color model.
|
||||
/// </summary>
|
||||
public CefColorModel GetColorModel()
|
||||
{
|
||||
return cef_print_settings_t.get_color_model(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the number of copies.
|
||||
/// </summary>
|
||||
public void SetCopies(int copies)
|
||||
{
|
||||
cef_print_settings_t.set_copies(_self, copies);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the number of copies.
|
||||
/// </summary>
|
||||
public int GetCopies()
|
||||
{
|
||||
return cef_print_settings_t.get_copies(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the duplex mode.
|
||||
/// </summary>
|
||||
public void SetDuplexMode(CefDuplexMode mode)
|
||||
{
|
||||
cef_print_settings_t.set_duplex_mode(_self, mode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the duplex mode.
|
||||
/// </summary>
|
||||
public CefDuplexMode GetDuplexMode()
|
||||
{
|
||||
return cef_print_settings_t.get_duplex_mode(_self);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class representing a message. Can be used on any process and thread.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefProcessMessage
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a new CefProcessMessage object with the specified name.
|
||||
/// </summary>
|
||||
public static CefProcessMessage Create(string name)
|
||||
{
|
||||
fixed (char* name_str = name)
|
||||
{
|
||||
var n_name = new cef_string_t(name_str, name != null ? name.Length : 0);
|
||||
return CefProcessMessage.FromNative(
|
||||
cef_process_message_t.create(&n_name)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this object is valid. Do not call any other methods if this
|
||||
/// function returns false.
|
||||
/// </summary>
|
||||
public bool IsValid
|
||||
{
|
||||
get { return cef_process_message_t.is_valid(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the values of this object are read-only. Some APIs may
|
||||
/// expose read-only objects.
|
||||
/// </summary>
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get { return cef_process_message_t.is_read_only(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a writable copy of this object.
|
||||
/// </summary>
|
||||
public CefProcessMessage Copy()
|
||||
{
|
||||
return CefProcessMessage.FromNative(
|
||||
cef_process_message_t.copy(_self)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the message name.
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_process_message_t.get_name(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
// FIXME: caching ?
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the list of arguments.
|
||||
/// </summary>
|
||||
public CefListValue Arguments
|
||||
{
|
||||
get
|
||||
{
|
||||
return CefListValue.FromNative(
|
||||
cef_process_message_t.get_argument_list(_self)
|
||||
);
|
||||
// FIXME: caching ?
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class used to represent a web request. The methods of this class may be
|
||||
/// called on any thread.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a new CefRequest object.
|
||||
/// </summary>
|
||||
public static CefRequest Create()
|
||||
{
|
||||
return CefRequest.FromNative(
|
||||
cef_request_t.create()
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this object is read-only.
|
||||
/// </summary>
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get { return cef_request_t.is_read_only(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the fully qualified URL.
|
||||
/// </summary>
|
||||
public string Url
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_request_t.get_url(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null) throw new ArgumentNullException("value");
|
||||
|
||||
fixed (char* value_str = value)
|
||||
{
|
||||
var n_value = new cef_string_t(value_str, value.Length);
|
||||
cef_request_t.set_url(_self, &n_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the request method type.
|
||||
/// The value will default to POST if post data is provided and GET otherwise.
|
||||
/// </summary>
|
||||
public string Method
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_request_t.get_method(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
set
|
||||
{
|
||||
fixed (char* value_str = value)
|
||||
{
|
||||
var n_value = new cef_string_t(value_str, value != null ? value.Length : 0);
|
||||
cef_request_t.set_method(_self, &n_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the post data.
|
||||
/// </summary>
|
||||
public CefPostData PostData
|
||||
{
|
||||
get
|
||||
{
|
||||
return CefPostData.FromNativeOrNull(
|
||||
cef_request_t.get_post_data(_self)
|
||||
);
|
||||
}
|
||||
set
|
||||
{
|
||||
var n_value = value != null ? value.ToNative() : null;
|
||||
cef_request_t.set_post_data(_self, n_value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the header values.
|
||||
/// </summary>
|
||||
public NameValueCollection GetHeaderMap()
|
||||
{
|
||||
var headerMap = libcef.string_multimap_alloc();
|
||||
cef_request_t.get_header_map(_self, headerMap);
|
||||
var result = cef_string_multimap.ToNameValueCollection(headerMap);
|
||||
libcef.string_multimap_free(headerMap);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the header values.
|
||||
/// </summary>
|
||||
public void SetHeaderMap(NameValueCollection headers)
|
||||
{
|
||||
var headerMap = cef_string_multimap.From(headers);
|
||||
cef_request_t.set_header_map(_self, headerMap);
|
||||
libcef.string_multimap_free(headerMap);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set all values at one time.
|
||||
/// </summary>
|
||||
public void Set(string url, string method, CefPostData postData, NameValueCollection headers)
|
||||
{
|
||||
fixed (char* url_str = url)
|
||||
fixed (char* method_str = method)
|
||||
{
|
||||
var n_url = new cef_string_t(url_str, url != null ? url.Length : 0);
|
||||
var n_method = new cef_string_t(method_str, method_str != null ? method.Length : 0);
|
||||
var n_postData = postData != null ? postData.ToNative() : null;
|
||||
var n_headerMap = cef_string_multimap.From(headers);
|
||||
cef_request_t.set(_self, &n_url, &n_method, n_postData, n_headerMap);
|
||||
libcef.string_multimap_free(n_headerMap);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the options used in combination with CefUrlRequest.
|
||||
/// </summary>
|
||||
public CefUrlRequestOptions Options
|
||||
{
|
||||
get { return (CefUrlRequestOptions)cef_request_t.get_flags(_self); }
|
||||
set { cef_request_t.set_flags(_self, (int)value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the URL to the first party for cookies used in combination with
|
||||
/// CefWebURLRequest.
|
||||
/// </summary>
|
||||
public string FirstPartyForCookies
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_request_t.get_first_party_for_cookies(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
set
|
||||
{
|
||||
fixed (char* value_str = value)
|
||||
{
|
||||
var n_value = new cef_string_t(value_str, value != null ? value.Length : 0);
|
||||
cef_request_t.set_first_party_for_cookies(_self, &n_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the resource type for this request. Only available in the browser
|
||||
/// process.
|
||||
/// </summary>
|
||||
public CefResourceType ResourceType
|
||||
{
|
||||
get
|
||||
{
|
||||
return cef_request_t.get_resource_type(_self);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the transition type for this request. Only available in the browser
|
||||
/// process and only applies to requests that represent a main frame or
|
||||
/// sub-frame navigation.
|
||||
/// </summary>
|
||||
public CefTransitionType TransitionType
|
||||
{
|
||||
get
|
||||
{
|
||||
return cef_request_t.get_transition_type(_self);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the globally unique identifier for this request or 0 if not
|
||||
/// specified. Can be used by CefRequestHandler implementations in the browser
|
||||
/// process to track a single request across multiple callbacks.
|
||||
/// </summary>
|
||||
public ulong Identifier
|
||||
{
|
||||
get
|
||||
{
|
||||
return cef_request_t.get_identifier(_self);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Callback interface used for asynchronous continuation of url requests.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefRequestCallback
|
||||
{
|
||||
/// <summary>
|
||||
/// Continue the url request. If |allow| is true the request will be continued.
|
||||
/// Otherwise, the request will be canceled.
|
||||
/// </summary>
|
||||
public void Continue(bool allow)
|
||||
{
|
||||
cef_request_callback_t.cont(_self, allow ? 1 : 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancel the url request.
|
||||
/// </summary>
|
||||
public void Cancel()
|
||||
{
|
||||
cef_request_callback_t.cancel(_self);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// A request context provides request handling for a set of related browser
|
||||
/// or URL request objects. A request context can be specified when creating a
|
||||
/// new browser via the CefBrowserHost static factory methods or when creating a
|
||||
/// new URL request via the CefURLRequest static factory methods. Browser objects
|
||||
/// with different request contexts will never be hosted in the same render
|
||||
/// process. Browser objects with the same request context may or may not be
|
||||
/// hosted in the same render process depending on the process model. Browser
|
||||
/// objects created indirectly via the JavaScript window.open function or
|
||||
/// targeted links will share the same render process and the same request
|
||||
/// context as the source browser. When running in single-process mode there is
|
||||
/// only a single render process (the main process) and so all browsers created
|
||||
/// in single-process mode will share the same request context. This will be the
|
||||
/// first request context passed into a CefBrowserHost static factory method and
|
||||
/// all other request context objects will be ignored.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefRequestContext
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the global context object.
|
||||
/// </summary>
|
||||
public static CefRequestContext GetGlobalContext()
|
||||
{
|
||||
return CefRequestContext.FromNative(
|
||||
cef_request_context_t.get_global_context()
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new context object with the specified |settings| and optional
|
||||
/// |handler|.
|
||||
/// </summary>
|
||||
public static CefRequestContext CreateContext(CefRequestContextSettings settings, CefRequestContextHandler handler)
|
||||
{
|
||||
var n_settings = settings.ToNative();
|
||||
|
||||
var result = CefRequestContext.FromNative(
|
||||
cef_request_context_t.create_context(
|
||||
n_settings,
|
||||
handler != null ? handler.ToNative() : null
|
||||
)
|
||||
);
|
||||
|
||||
CefRequestContextSettings.Free(n_settings);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new context object that shares storage with |other| and uses an
|
||||
/// optional |handler|.
|
||||
/// </summary>
|
||||
public static CefRequestContext CreateContext(CefRequestContext other, CefRequestContextHandler handler)
|
||||
{
|
||||
return CefRequestContext.FromNative(
|
||||
cef_request_context_t.create_context(
|
||||
other.ToNative(),
|
||||
handler != null ? handler.ToNative() : null
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this object is pointing to the same context as |that|
|
||||
/// object.
|
||||
/// </summary>
|
||||
public bool IsSame(CefRequestContext other)
|
||||
{
|
||||
if (other == null) return false;
|
||||
|
||||
return cef_request_context_t.is_same(_self, other.ToNative()) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this object is sharing the same storage as |that| object.
|
||||
/// </summary>
|
||||
public bool IsSharingWith(CefRequestContext other)
|
||||
{
|
||||
return cef_request_context_t.is_sharing_with(_self, other.ToNative()) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this object is the global context. The global context is
|
||||
/// used by default when creating a browser or URL request with a NULL context
|
||||
/// argument.
|
||||
/// </summary>
|
||||
public bool IsGlobal
|
||||
{
|
||||
get
|
||||
{
|
||||
return cef_request_context_t.is_global(_self) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the handler for this context if any.
|
||||
/// </summary>
|
||||
public CefRequestContextHandler GetHandler()
|
||||
{
|
||||
return CefRequestContextHandler.FromNativeOrNull(
|
||||
cef_request_context_t.get_handler(_self)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cache path for this object. If empty an "incognito mode"
|
||||
/// in-memory cache is being used.
|
||||
/// </summary>
|
||||
public string CachePath
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_request_context_t.get_cache_path(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the default cookie manager for this object. This will be the global
|
||||
/// cookie manager if this object is the global request context. Otherwise,
|
||||
/// this will be the default cookie manager used when this request context does
|
||||
/// not receive a value via CefRequestContextHandler::GetCookieManager(). If
|
||||
/// |callback| is non-NULL it will be executed asnychronously on the IO thread
|
||||
/// after the manager's storage has been initialized.
|
||||
/// </summary>
|
||||
public CefCookieManager GetDefaultCookieManager(CefCompletionCallback callback)
|
||||
{
|
||||
var n_callback = callback != null ? callback.ToNative() : null;
|
||||
|
||||
return CefCookieManager.FromNativeOrNull(
|
||||
cef_request_context_t.get_default_cookie_manager(_self, n_callback)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register a scheme handler factory for the specified |scheme_name| and
|
||||
/// optional |domain_name|. An empty |domain_name| value for a standard scheme
|
||||
/// will cause the factory to match all domain names. The |domain_name| value
|
||||
/// will be ignored for non-standard schemes. If |scheme_name| is a built-in
|
||||
/// scheme and no handler is returned by |factory| then the built-in scheme
|
||||
/// handler factory will be called. If |scheme_name| is a custom scheme then
|
||||
/// you must also implement the CefApp::OnRegisterCustomSchemes() method in all
|
||||
/// processes. This function may be called multiple times to change or remove
|
||||
/// the factory that matches the specified |scheme_name| and optional
|
||||
/// |domain_name|. Returns false if an error occurs. This function may be
|
||||
/// called on any thread in the browser process.
|
||||
/// </summary>
|
||||
public bool RegisterSchemeHandlerFactory(string schemeName, string domainName, CefSchemeHandlerFactory factory)
|
||||
{
|
||||
if (string.IsNullOrEmpty(schemeName)) throw new ArgumentNullException("schemeName");
|
||||
if (factory == null) throw new ArgumentNullException("factory");
|
||||
|
||||
fixed (char* schemeName_str = schemeName)
|
||||
fixed (char* domainName_str = domainName)
|
||||
{
|
||||
var n_schemeName = new cef_string_t(schemeName_str, schemeName.Length);
|
||||
var n_domainName = new cef_string_t(domainName_str, domainName != null ? domainName.Length : 0);
|
||||
|
||||
return cef_request_context_t.register_scheme_handler_factory(_self, &n_schemeName, &n_domainName, factory.ToNative()) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear all registered scheme handler factories. Returns false on error. This
|
||||
/// function may be called on any thread in the browser process.
|
||||
/// </summary>
|
||||
public bool ClearSchemeHandlerFactories()
|
||||
{
|
||||
return cef_request_context_t.clear_scheme_handler_factories(_self) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class used to represent a web response. The methods of this class may be
|
||||
/// called on any thread.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a new CefResponse object.
|
||||
/// </summary>
|
||||
public static CefResponse Create()
|
||||
{
|
||||
return CefResponse.FromNative(
|
||||
cef_response_t.create()
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this object is read-only.
|
||||
/// </summary>
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get { return cef_response_t.is_read_only(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the response status code.
|
||||
/// </summary>
|
||||
public int Status
|
||||
{
|
||||
get { return cef_response_t.get_status(_self); }
|
||||
set { cef_response_t.set_status(_self, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the response status text.
|
||||
/// </summary>
|
||||
public string StatusText
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_response_t.get_status_text(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
set
|
||||
{
|
||||
fixed (char* value_str = value)
|
||||
{
|
||||
var n_value = new cef_string_t(value_str, value != null ? value.Length : 0);
|
||||
cef_response_t.set_status_text(_self, &n_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the response mime type.
|
||||
/// </summary>
|
||||
public string MimeType
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_response_t.get_mime_type(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
set
|
||||
{
|
||||
fixed (char* value_str = value)
|
||||
{
|
||||
var n_value = new cef_string_t(value_str, value != null ? value.Length : 0);
|
||||
cef_response_t.set_mime_type(_self, &n_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the value for the specified response header field.
|
||||
/// </summary>
|
||||
public string GetHeader(string name)
|
||||
{
|
||||
if (name == null) throw new ArgumentNullException("name");
|
||||
|
||||
fixed (char* name_str = name)
|
||||
{
|
||||
var n_name = new cef_string_t(name_str, name.Length);
|
||||
var n_result = cef_response_t.get_header(_self, &n_name);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all response header fields.
|
||||
/// </summary>
|
||||
public NameValueCollection GetHeaderMap()
|
||||
{
|
||||
var headerMap = libcef.string_multimap_alloc();
|
||||
cef_response_t.get_header_map(_self, headerMap);
|
||||
var result = cef_string_multimap.ToNameValueCollection(headerMap);
|
||||
libcef.string_multimap_free(headerMap);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set all response header fields.
|
||||
/// </summary>
|
||||
public void SetHeaderMap(NameValueCollection headers)
|
||||
{
|
||||
var headerMap = cef_string_multimap.From(headers);
|
||||
cef_response_t.set_header_map(_self, headerMap);
|
||||
libcef.string_multimap_free(headerMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class that manages custom scheme registrations.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefSchemeRegistrar
|
||||
{
|
||||
/// <summary>
|
||||
/// Register a custom scheme. This method should not be called for the built-in
|
||||
/// HTTP, HTTPS, FILE, FTP, ABOUT and DATA schemes.
|
||||
/// If |is_standard| is true the scheme will be treated as a standard scheme.
|
||||
/// Standard schemes are subject to URL canonicalization and parsing rules as
|
||||
/// defined in the Common Internet Scheme Syntax RFC 1738 Section 3.1 available
|
||||
/// at http://www.ietf.org/rfc/rfc1738.txt
|
||||
/// In particular, the syntax for standard scheme URLs must be of the form:
|
||||
/// <pre>
|
||||
/// [scheme]://[username]:[password]@[host]:[port]/[url-path]
|
||||
/// </pre>
|
||||
/// Standard scheme URLs must have a host component that is a fully qualified
|
||||
/// domain name as defined in Section 3.5 of RFC 1034 [13] and Section 2.1 of
|
||||
/// RFC 1123. These URLs will be canonicalized to "scheme://host/path" in the
|
||||
/// simplest case and "scheme://username:password@host:port/path" in the most
|
||||
/// explicit case. For example, "scheme:host/path" and "scheme:///host/path"
|
||||
/// will both be canonicalized to "scheme://host/path". The origin of a
|
||||
/// standard scheme URL is the combination of scheme, host and port (i.e.,
|
||||
/// "scheme://host:port" in the most explicit case).
|
||||
/// For non-standard scheme URLs only the "scheme:" component is parsed and
|
||||
/// canonicalized. The remainder of the URL will be passed to the handler
|
||||
/// as-is. For example, "scheme:///some%20text" will remain the same.
|
||||
/// Non-standard scheme URLs cannot be used as a target for form submission.
|
||||
/// If |is_local| is true the scheme will be treated as local (i.e., with the
|
||||
/// same security rules as those applied to "file" URLs). Normal pages cannot
|
||||
/// link to or access local URLs. Also, by default, local URLs can only perform
|
||||
/// XMLHttpRequest calls to the same URL (origin + path) that originated the
|
||||
/// request. To allow XMLHttpRequest calls from a local URL to other URLs with
|
||||
/// the same origin set the CefSettings.file_access_from_file_urls_allowed
|
||||
/// value to true. To allow XMLHttpRequest calls from a local URL to all
|
||||
/// origins set the CefSettings.universal_access_from_file_urls_allowed value
|
||||
/// to true.
|
||||
/// If |is_display_isolated| is true the scheme will be treated as display-
|
||||
/// isolated. This means that pages cannot display these URLs unless they are
|
||||
/// from the same scheme. For example, pages in another origin cannot create
|
||||
/// iframes or hyperlinks to URLs with this scheme.
|
||||
/// This function may be called on any thread. It should only be called once
|
||||
/// per unique |scheme_name| value. If |scheme_name| is already registered or
|
||||
/// if an error occurs this method will return false.
|
||||
/// </summary>
|
||||
public bool AddCustomScheme(string schemeName, bool standard, bool local, bool displayIsolated)
|
||||
{
|
||||
if (schemeName == null) throw new ArgumentNullException("schemeName");
|
||||
|
||||
fixed (char* schemeName_str = schemeName)
|
||||
{
|
||||
var n_schemeName = new cef_string_t(schemeName_str, schemeName.Length);
|
||||
return cef_scheme_registrar_t.add_custom_scheme(
|
||||
_self,
|
||||
&n_schemeName,
|
||||
standard ? 1 : 0,
|
||||
local ? 1 : 0,
|
||||
displayIsolated ? 1 : 0
|
||||
) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class representing the issuer or subject field of an X.509 certificate.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefSslCertPrincipal
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns a name that can be used to represent the issuer. It tries in this
|
||||
/// order: CN, O and OU and returns the first non-empty one found.
|
||||
/// </summary>
|
||||
public string DisplayName
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_sslcert_principal_t.get_display_name(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the common name.
|
||||
/// </summary>
|
||||
public string CommonName
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_sslcert_principal_t.get_common_name(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the locality name.
|
||||
/// </summary>
|
||||
public string LocalityName
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_sslcert_principal_t.get_locality_name(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the state or province name.
|
||||
/// </summary>
|
||||
public string StateOrProvinceName
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_sslcert_principal_t.get_state_or_province_name(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the country name.
|
||||
/// </summary>
|
||||
public string CountryName
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_sslcert_principal_t.get_country_name(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the list of street addresses.
|
||||
/// </summary>
|
||||
public string[] StreetAddresses
|
||||
{
|
||||
get
|
||||
{
|
||||
cef_string_list* n_result = libcef.string_list_alloc();
|
||||
cef_sslcert_principal_t.get_street_addresses(_self, n_result);
|
||||
var result = cef_string_list.ToArray(n_result);
|
||||
libcef.string_list_free(n_result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the list of organization names.
|
||||
/// </summary>
|
||||
public string[] OrganizationNames
|
||||
{
|
||||
get
|
||||
{
|
||||
cef_string_list* n_result = libcef.string_list_alloc();
|
||||
cef_sslcert_principal_t.get_organization_names(_self, n_result);
|
||||
var result = cef_string_list.ToArray(n_result);
|
||||
libcef.string_list_free(n_result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the list of organization unit names.
|
||||
/// </summary>
|
||||
public string[] OrganizationUnitNames
|
||||
{
|
||||
get
|
||||
{
|
||||
cef_string_list* n_result = libcef.string_list_alloc();
|
||||
cef_sslcert_principal_t.get_organization_unit_names(_self, n_result);
|
||||
var result = cef_string_list.ToArray(n_result);
|
||||
libcef.string_list_free(n_result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the list of domain components.
|
||||
/// </summary>
|
||||
public string[] DomainComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
cef_string_list* n_result = libcef.string_list_alloc();
|
||||
cef_sslcert_principal_t.get_domain_components(_self, n_result);
|
||||
var result = cef_string_list.ToArray(n_result);
|
||||
libcef.string_list_free(n_result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class representing SSL information.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefSslInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the subject of the X.509 certificate. For HTTPS server
|
||||
/// certificates this represents the web server. The common name of the
|
||||
/// subject should match the host name of the web server.
|
||||
/// </summary>
|
||||
public CefSslCertPrincipal Subject
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_sslinfo_t.get_subject(_self);
|
||||
return CefSslCertPrincipal.FromNative(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the issuer of the X.509 certificate.
|
||||
/// </summary>
|
||||
public CefSslCertPrincipal Issuer
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_sslinfo_t.get_issuer(_self);
|
||||
return CefSslCertPrincipal.FromNative(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the DER encoded serial number for the X.509 certificate. The value
|
||||
/// possibly includes a leading 00 byte.
|
||||
/// </summary>
|
||||
public CefBinaryValue SerialNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_sslinfo_t.get_serial_number(_self);
|
||||
return CefBinaryValue.FromNative(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the date before which the X.509 certificate is invalid.
|
||||
/// CefTime.GetTimeT() will return 0 if no date was specified.
|
||||
/// </summary>
|
||||
public DateTime ValidStart
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_sslinfo_t.get_valid_start(_self);
|
||||
return cef_time_t.ToDateTime(&n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the date after which the X.509 certificate is invalid.
|
||||
/// CefTime.GetTimeT() will return 0 if no date was specified.
|
||||
/// </summary>
|
||||
public DateTime ValidExpiry
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_sslinfo_t.get_valid_expiry(_self);
|
||||
return cef_time_t.ToDateTime(&n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the DER encoded data for the X.509 certificate.
|
||||
/// </summary>
|
||||
public CefBinaryValue DerEncoded
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_sslinfo_t.get_derencoded(_self);
|
||||
return CefBinaryValue.FromNative(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the PEM encoded data for the X.509 certificate.
|
||||
/// </summary>
|
||||
public CefBinaryValue PemEncoded
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_sslinfo_t.get_pemencoded(_self);
|
||||
return CefBinaryValue.FromNative(n_result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class used to read data from a stream. The methods of this class may be
|
||||
/// called on any thread.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefStreamReader
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a new CefStreamReader object from a file.
|
||||
/// </summary>
|
||||
public static CefStreamReader Create(string fileName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(fileName)) throw new ArgumentNullException("fileName");
|
||||
|
||||
fixed (char* fileName_str = fileName)
|
||||
{
|
||||
var n_fileName = new cef_string_t(fileName_str, fileName != null ? fileName.Length : 0);
|
||||
|
||||
return CefStreamReader.FromNative(
|
||||
cef_stream_reader_t.create_for_file(&n_fileName)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new CefStreamReader object from data.
|
||||
/// </summary>
|
||||
public static CefStreamReader Create(void* data, long size)
|
||||
{
|
||||
return CefStreamReader.FromNative(
|
||||
cef_stream_reader_t.create_for_data(data, (UIntPtr)size)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new CefStreamReader object from a custom handler.
|
||||
/// </summary>
|
||||
public static CefStreamReader Create(CefReadHandler handler)
|
||||
{
|
||||
if (handler == null) throw new ArgumentNullException("handler");
|
||||
|
||||
return CefStreamReader.FromNative(
|
||||
cef_stream_reader_t.create_for_handler(handler.ToNative())
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read raw binary data.
|
||||
/// </summary>
|
||||
public int Read(byte[] buffer, int offset, int length)
|
||||
{
|
||||
if (offset < 0 || length < 0 || buffer.Length - offset < length) throw new ArgumentOutOfRangeException();
|
||||
|
||||
fixed (byte* ptr = &buffer[offset])
|
||||
{
|
||||
return (int)cef_stream_reader_t.read(_self, ptr, (UIntPtr)1, (UIntPtr)length);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Seek to the specified offset position. |whence| may be any one of
|
||||
/// SEEK_CUR, SEEK_END or SEEK_SET. Returns zero on success and non-zero on
|
||||
/// failure.
|
||||
/// </summary>
|
||||
public bool Seek(long offset, SeekOrigin whence)
|
||||
{
|
||||
return cef_stream_reader_t.seek(_self, offset, (int)whence) == 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the current offset position.
|
||||
/// </summary>
|
||||
public long Tell()
|
||||
{
|
||||
return cef_stream_reader_t.tell(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return non-zero if at end of file.
|
||||
/// </summary>
|
||||
public bool Eof()
|
||||
{
|
||||
return cef_stream_reader_t.eof(_self) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this reader performs work like accessing the file system
|
||||
/// which may block. Used as a hint for determining the thread to access the
|
||||
/// reader from.
|
||||
/// </summary>
|
||||
public bool MayBlock()
|
||||
{
|
||||
return cef_stream_reader_t.may_block(_self) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class used to write data to a stream. The methods of this class may be called
|
||||
/// on any thread.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefStreamWriter
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a new CefStreamWriter object for a file.
|
||||
/// </summary>
|
||||
public static CefStreamWriter Create(string fileName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(fileName)) throw new ArgumentNullException("fileName");
|
||||
|
||||
fixed (char* fileName_str = fileName)
|
||||
{
|
||||
var n_fileName = new cef_string_t(fileName_str, fileName != null ? fileName.Length : 0);
|
||||
return CefStreamWriter.FromNative(
|
||||
cef_stream_writer_t.create_for_file(&n_fileName)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new CefStreamWriter object for a custom handler.
|
||||
/// </summary>
|
||||
public static CefStreamWriter Create(CefWriteHandler handler)
|
||||
{
|
||||
if (handler == null) throw new ArgumentNullException("handler");
|
||||
|
||||
return CefStreamWriter.FromNative(
|
||||
cef_stream_writer_t.create_for_handler(handler.ToNative())
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write raw binary data.
|
||||
/// </summary>
|
||||
public int Write(byte[] buffer, int offset, int length)
|
||||
{
|
||||
if (offset < 0 || length < 0 || buffer.Length - offset < length) throw new ArgumentOutOfRangeException();
|
||||
|
||||
fixed (byte* ptr = &buffer[offset])
|
||||
{
|
||||
return (int)cef_stream_writer_t.write(_self, ptr, (UIntPtr)1, (UIntPtr)length);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Seek to the specified offset position. |whence| may be any one of
|
||||
/// SEEK_CUR, SEEK_END or SEEK_SET. Returns zero on success and non-zero on
|
||||
/// failure.
|
||||
/// </summary>
|
||||
public bool Seek(long offset, SeekOrigin whence)
|
||||
{
|
||||
return cef_stream_writer_t.seek(_self, offset, (int)whence) == 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the current offset position.
|
||||
/// </summary>
|
||||
public long Tell()
|
||||
{
|
||||
return cef_stream_writer_t.tell(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Flush the stream.
|
||||
/// </summary>
|
||||
public bool Flush()
|
||||
{
|
||||
return cef_stream_writer_t.flush(_self) == 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this writer performs work like accessing the file system
|
||||
/// which may block. Used as a hint for determining the thread to access the
|
||||
/// writer from.
|
||||
/// </summary>
|
||||
public bool MayBlock()
|
||||
{
|
||||
return cef_stream_writer_t.may_block(_self) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class that asynchronously executes tasks on the associated thread. It is safe
|
||||
/// to call the methods of this class on any thread.
|
||||
/// CEF maintains multiple internal threads that are used for handling different
|
||||
/// types of tasks in different processes. The cef_thread_id_t definitions in
|
||||
/// cef_types.h list the common CEF threads. Task runners are also available for
|
||||
/// other CEF threads as appropriate (for example, V8 WebWorker threads).
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefTaskRunner
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the task runner for the current thread. Only CEF threads will have
|
||||
/// task runners. An empty reference will be returned if this method is called
|
||||
/// on an invalid thread.
|
||||
/// </summary>
|
||||
public static CefTaskRunner GetForCurrentThread()
|
||||
{
|
||||
return CefTaskRunner.FromNativeOrNull(cef_task_runner_t.get_for_current_thread());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the task runner for the specified CEF thread.
|
||||
/// </summary>
|
||||
public static CefTaskRunner GetForThread(CefThreadId threadId)
|
||||
{
|
||||
return CefTaskRunner.FromNativeOrNull(cef_task_runner_t.get_for_thread(threadId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this object is pointing to the same task runner as |that|
|
||||
/// object.
|
||||
/// </summary>
|
||||
public bool IsSame(CefTaskRunner that)
|
||||
{
|
||||
return cef_task_runner_t.is_same(_self, that.ToNative()) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this task runner belongs to the current thread.
|
||||
/// </summary>
|
||||
public bool BelongsToCurrentThread
|
||||
{
|
||||
get { return cef_task_runner_t.belongs_to_current_thread(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this task runner is for the specified CEF thread.
|
||||
/// </summary>
|
||||
public bool BelongsToThread(CefThreadId threadId)
|
||||
{
|
||||
return cef_task_runner_t.belongs_to_thread(_self, threadId) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Post a task for execution on the thread associated with this task runner.
|
||||
/// Execution will occur asynchronously.
|
||||
/// </summary>
|
||||
public bool PostTask(CefTask task)
|
||||
{
|
||||
return cef_task_runner_t.post_task(_self, task.ToNative()) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Post a task for delayed execution on the thread associated with this task
|
||||
/// runner. Execution will occur asynchronously. Delayed tasks are not
|
||||
/// supported on V8 WebWorker threads and will be executed without the
|
||||
/// specified delay.
|
||||
/// </summary>
|
||||
public bool PostDelayedTask(CefTask task, long delay)
|
||||
{
|
||||
return cef_task_runner_t.post_delayed_task(_self, task.ToNative(), delay) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class used to make a URL request. URL requests are not associated with a
|
||||
/// browser instance so no CefClient callbacks will be executed. URL requests
|
||||
/// can be created on any valid CEF thread in either the browser or render
|
||||
/// process. Once created the methods of the URL request object must be accessed
|
||||
/// on the same thread that created it.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefUrlRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a new URL request. Only GET, POST, HEAD, DELETE and PUT request
|
||||
/// methods are supported. Multiple post data elements are not supported and
|
||||
/// elements of type PDE_TYPE_FILE are only supported for requests originating
|
||||
/// from the browser process. Requests originating from the render process will
|
||||
/// receive the same handling as requests originating from Web content -- if
|
||||
/// the response contains Content-Disposition or Mime-Type header values that
|
||||
/// would not normally be rendered then the response may receive special
|
||||
/// handling inside the browser (for example, via the file download code path
|
||||
/// instead of the URL request code path). The |request| object will be marked
|
||||
/// as read-only after calling this method. In the browser process if
|
||||
/// |request_context| is empty the global request context will be used. In the
|
||||
/// render process |request_context| must be empty and the context associated
|
||||
/// with the current renderer process' browser will be used.
|
||||
/// </summary>
|
||||
public static CefUrlRequest Create(CefRequest request, CefUrlRequestClient client, CefRequestContext requestContext)
|
||||
{
|
||||
if (request == null) throw new ArgumentNullException("request");
|
||||
|
||||
var n_request = request.ToNative();
|
||||
var n_client = client.ToNative();
|
||||
var n_requestContext = requestContext != null ? requestContext.ToNative() : null;
|
||||
|
||||
return CefUrlRequest.FromNative(
|
||||
cef_urlrequest_t.create(n_request, n_client, n_requestContext)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the request object used to create this URL request. The returned
|
||||
/// object is read-only and should not be modified.
|
||||
/// </summary>
|
||||
public CefRequest GetRequest()
|
||||
{
|
||||
return CefRequest.FromNative(
|
||||
cef_urlrequest_t.get_request(_self)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the client.
|
||||
/// </summary>
|
||||
public CefUrlRequestClient GetClient()
|
||||
{
|
||||
return CefUrlRequestClient.FromNative(
|
||||
cef_urlrequest_t.get_client(_self)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the request status.
|
||||
/// </summary>
|
||||
public CefUrlRequestStatus RequestStatus
|
||||
{
|
||||
get { return cef_urlrequest_t.get_request_status(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the request error if status is UR_CANCELED or UR_FAILED, or 0
|
||||
/// otherwise.
|
||||
/// </summary>
|
||||
public CefErrorCode RequestError
|
||||
{
|
||||
get { return cef_urlrequest_t.get_request_error(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the response, or NULL if no response information is available.
|
||||
/// Response information will only be available after the upload has completed.
|
||||
/// The returned object is read-only and should not be modified.
|
||||
/// </summary>
|
||||
public CefResponse GetResponse()
|
||||
{
|
||||
return CefResponse.FromNativeOrNull(
|
||||
cef_urlrequest_t.get_response(_self)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancel the request.
|
||||
/// </summary>
|
||||
public void Cancel()
|
||||
{
|
||||
cef_urlrequest_t.cancel(_self);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class representing a V8 context handle. V8 handles can only be accessed from
|
||||
/// the thread on which they are created. Valid threads for creating a V8 handle
|
||||
/// include the render process main thread (TID_RENDERER) and WebWorker threads.
|
||||
/// A task runner for posting tasks on the associated thread can be retrieved via
|
||||
/// the CefV8Context::GetTaskRunner() method.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefV8Context
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the current (top) context object in the V8 context stack.
|
||||
/// </summary>
|
||||
public static CefV8Context GetCurrentContext()
|
||||
{
|
||||
return CefV8Context.FromNative(
|
||||
cef_v8context_t.get_current_context()
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the entered (bottom) context object in the V8 context stack.
|
||||
/// </summary>
|
||||
public static CefV8Context GetEnteredContext()
|
||||
{
|
||||
return CefV8Context.FromNative(
|
||||
cef_v8context_t.get_entered_context()
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if V8 is currently inside a context.
|
||||
/// </summary>
|
||||
public static bool InContext
|
||||
{
|
||||
get { return cef_v8context_t.in_context() != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the task runner associated with this context. V8 handles can only
|
||||
/// be accessed from the thread on which they are created. This method can be
|
||||
/// called on any render process thread.
|
||||
/// </summary>
|
||||
public CefTaskRunner GetTaskRunner()
|
||||
{
|
||||
return CefTaskRunner.FromNative(
|
||||
cef_v8context_t.get_task_runner(_self)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the underlying handle is valid and it can be accessed on
|
||||
/// the current thread. Do not call any other methods if this method returns
|
||||
/// false.
|
||||
/// </summary>
|
||||
public bool IsValid
|
||||
{
|
||||
get { return cef_v8context_t.is_valid(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the browser for this context. This method will return an empty
|
||||
/// reference for WebWorker contexts.
|
||||
/// </summary>
|
||||
public CefBrowser GetBrowser()
|
||||
{
|
||||
return CefBrowser.FromNativeOrNull(
|
||||
cef_v8context_t.get_browser(_self)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the frame for this context. This method will return an empty
|
||||
/// reference for WebWorker contexts.
|
||||
/// </summary>
|
||||
public CefFrame GetFrame()
|
||||
{
|
||||
return CefFrame.FromNativeOrNull(
|
||||
cef_v8context_t.get_frame(_self)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the global object for this context. The context must be entered
|
||||
/// before calling this method.
|
||||
/// </summary>
|
||||
public CefV8Value GetGlobal()
|
||||
{
|
||||
return CefV8Value.FromNative(
|
||||
cef_v8context_t.get_global(_self)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enter this context. A context must be explicitly entered before creating a
|
||||
/// V8 Object, Array, Function or Date asynchronously. Exit() must be called
|
||||
/// the same number of times as Enter() before releasing this context. V8
|
||||
/// objects belong to the context in which they are created. Returns true if
|
||||
/// the scope was entered successfully.
|
||||
/// </summary>
|
||||
public bool Enter()
|
||||
{
|
||||
return cef_v8context_t.enter(_self) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Exit this context. Call this method only after calling Enter(). Returns
|
||||
/// true if the scope was exited successfully.
|
||||
/// </summary>
|
||||
public bool Exit()
|
||||
{
|
||||
return cef_v8context_t.exit(_self) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this object is pointing to the same handle as |that|
|
||||
/// object.
|
||||
/// </summary>
|
||||
public bool IsSame(CefV8Context that)
|
||||
{
|
||||
if (that == null) return false;
|
||||
return cef_v8context_t.is_same(_self, that.ToNative()) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates the specified JavaScript code using this context's global object.
|
||||
/// On success |retval| will be set to the return value, if any, and the
|
||||
/// function will return true. On failure |exception| will be set to the
|
||||
/// exception, if any, and the function will return false.
|
||||
/// </summary>
|
||||
public bool TryEval(string code, out CefV8Value returnValue, out CefV8Exception exception)
|
||||
{
|
||||
bool result;
|
||||
cef_v8value_t* n_retval = null;
|
||||
cef_v8exception_t* n_exception = null;
|
||||
|
||||
fixed (char* code_str = code)
|
||||
{
|
||||
var n_code = new cef_string_t(code_str, code != null ? code.Length : 0);
|
||||
result = cef_v8context_t.eval(_self, &n_code, &n_retval, &n_exception) != 0;
|
||||
}
|
||||
|
||||
returnValue = n_retval != null ? CefV8Value.FromNative(n_retval) : null;
|
||||
exception = n_exception != null ? CefV8Exception.FromNative(n_exception) : null;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class representing a V8 exception. The methods of this class may be called on
|
||||
/// any render process thread.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefV8Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the exception message.
|
||||
/// </summary>
|
||||
public string Message
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_v8exception_t.get_message(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the line of source code that the exception occurred within.
|
||||
/// </summary>
|
||||
public string SourceLine
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_v8exception_t.get_source_line(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the resource name for the script from where the function causing
|
||||
/// the error originates.
|
||||
/// </summary>
|
||||
public string ScriptResourceName
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_v8exception_t.get_script_resource_name(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the 1-based number of the line where the error occurred or 0 if the
|
||||
/// line number is unknown.
|
||||
/// </summary>
|
||||
public int LineNumber
|
||||
{
|
||||
get { return cef_v8exception_t.get_line_number(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the index within the script of the first character where the error
|
||||
/// occurred.
|
||||
/// </summary>
|
||||
public int StartPosition
|
||||
{
|
||||
get { return cef_v8exception_t.get_start_position(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the index within the script of the last character where the error
|
||||
/// occurred.
|
||||
/// </summary>
|
||||
public int EndPosition
|
||||
{
|
||||
get { return cef_v8exception_t.get_end_position(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the index within the line of the first character where the error
|
||||
/// occurred.
|
||||
/// </summary>
|
||||
public int StartColumn
|
||||
{
|
||||
get { return cef_v8exception_t.get_start_column(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the index within the line of the last character where the error
|
||||
/// occurred.
|
||||
/// </summary>
|
||||
public int EndColumn
|
||||
{
|
||||
get { return cef_v8exception_t.get_end_column(_self); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class representing a V8 stack frame handle. V8 handles can only be accessed
|
||||
/// from the thread on which they are created. Valid threads for creating a V8
|
||||
/// handle include the render process main thread (TID_RENDERER) and WebWorker
|
||||
/// threads. A task runner for posting tasks on the associated thread can be
|
||||
/// retrieved via the CefV8Context::GetTaskRunner() method.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefV8StackFrame
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the underlying handle is valid and it can be accessed on
|
||||
/// the current thread. Do not call any other methods if this method returns
|
||||
/// false.
|
||||
/// </summary>
|
||||
public bool IsValid
|
||||
{
|
||||
get { return cef_v8stack_frame_t.is_valid(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the name of the resource script that contains the function.
|
||||
/// </summary>
|
||||
public string ScriptName
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_v8stack_frame_t.get_script_name(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the name of the resource script that contains the function or the
|
||||
/// sourceURL value if the script name is undefined and its source ends with
|
||||
/// a "//@ sourceURL=..." string.
|
||||
/// </summary>
|
||||
public string ScriptNameOrSourceUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_v8stack_frame_t.get_script_name_or_source_url(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the name of the function.
|
||||
/// </summary>
|
||||
public string FunctionName
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_v8stack_frame_t.get_function_name(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the 1-based line number for the function call or 0 if unknown.
|
||||
/// </summary>
|
||||
public int LineNumber
|
||||
{
|
||||
get { return cef_v8stack_frame_t.get_line_number(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the 1-based column offset on the line for the function call or 0 if
|
||||
/// unknown.
|
||||
/// </summary>
|
||||
public int Column
|
||||
{
|
||||
get { return cef_v8stack_frame_t.get_column(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the function was compiled using eval().
|
||||
/// </summary>
|
||||
public bool IsEval
|
||||
{
|
||||
get { return cef_v8stack_frame_t.is_eval(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the function was called as a constructor via "new".
|
||||
/// </summary>
|
||||
public bool IsConstructor
|
||||
{
|
||||
get { return cef_v8stack_frame_t.is_constructor(_self) != 0; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class representing a V8 stack trace handle. V8 handles can only be accessed
|
||||
/// from the thread on which they are created. Valid threads for creating a V8
|
||||
/// handle include the render process main thread (TID_RENDERER) and WebWorker
|
||||
/// threads. A task runner for posting tasks on the associated thread can be
|
||||
/// retrieved via the CefV8Context::GetTaskRunner() method.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefV8StackTrace
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the stack trace for the currently active context. |frame_limit| is
|
||||
/// the maximum number of frames that will be captured.
|
||||
/// </summary>
|
||||
public static CefV8StackTrace GetCurrent(int frameLimit)
|
||||
{
|
||||
return CefV8StackTrace.FromNative(
|
||||
cef_v8stack_trace_t.get_current(frameLimit)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the underlying handle is valid and it can be accessed on
|
||||
/// the current thread. Do not call any other methods if this method returns
|
||||
/// false.
|
||||
/// </summary>
|
||||
public bool IsValid
|
||||
{
|
||||
get { return cef_v8stack_trace_t.is_valid(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the number of stack frames.
|
||||
/// </summary>
|
||||
public int FrameCount
|
||||
{
|
||||
get { return cef_v8stack_trace_t.get_frame_count(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the stack frame at the specified 0-based index.
|
||||
/// </summary>
|
||||
public CefV8StackFrame GetFrame(int index)
|
||||
{
|
||||
return CefV8StackFrame.FromNative(
|
||||
cef_v8stack_trace_t.get_frame(_self, index)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,662 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class representing a V8 value handle. V8 handles can only be accessed from
|
||||
/// the thread on which they are created. Valid threads for creating a V8 handle
|
||||
/// include the render process main thread (TID_RENDERER) and WebWorker threads.
|
||||
/// A task runner for posting tasks on the associated thread can be retrieved via
|
||||
/// the CefV8Context::GetTaskRunner() method.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefV8Value
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a new CefV8Value object of type undefined.
|
||||
/// </summary>
|
||||
public static CefV8Value CreateUndefined()
|
||||
{
|
||||
return CefV8Value.FromNative(
|
||||
cef_v8value_t.create_undefined()
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new CefV8Value object of type null.
|
||||
/// </summary>
|
||||
public static CefV8Value CreateNull()
|
||||
{
|
||||
return CefV8Value.FromNative(
|
||||
cef_v8value_t.create_null()
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new CefV8Value object of type bool.
|
||||
/// </summary>
|
||||
public static CefV8Value CreateBool(bool value)
|
||||
{
|
||||
return CefV8Value.FromNative(
|
||||
cef_v8value_t.create_bool(value ? 1 : 0)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new CefV8Value object of type int.
|
||||
/// </summary>
|
||||
public static CefV8Value CreateInt(int value)
|
||||
{
|
||||
return CefV8Value.FromNative(
|
||||
cef_v8value_t.create_int(value)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new CefV8Value object of type unsigned int.
|
||||
/// </summary>
|
||||
public static CefV8Value CreateUInt(uint value)
|
||||
{
|
||||
return CefV8Value.FromNative(
|
||||
cef_v8value_t.create_uint(value)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new CefV8Value object of type double.
|
||||
/// </summary>
|
||||
public static CefV8Value CreateDouble(double value)
|
||||
{
|
||||
return CefV8Value.FromNative(
|
||||
cef_v8value_t.create_double(value)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new CefV8Value object of type Date. This method should only be
|
||||
/// called from within the scope of a CefRenderProcessHandler, CefV8Handler or
|
||||
/// CefV8Accessor callback, or in combination with calling Enter() and Exit()
|
||||
/// on a stored CefV8Context reference.
|
||||
/// </summary>
|
||||
public static CefV8Value CreateDate(DateTime value)
|
||||
{
|
||||
var n_value = new cef_time_t(value);
|
||||
return CefV8Value.FromNative(
|
||||
cef_v8value_t.create_date(&n_value)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new CefV8Value object of type string.
|
||||
/// </summary>
|
||||
public static CefV8Value CreateString(string value)
|
||||
{
|
||||
fixed (char* value_str = value)
|
||||
{
|
||||
var n_value = new cef_string_t(value_str, value != null ? value.Length : 0);
|
||||
return CefV8Value.FromNative(
|
||||
cef_v8value_t.create_string(&n_value)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new CefV8Value object of type object with optional accessor. This
|
||||
/// method should only be called from within the scope of a
|
||||
/// CefRenderProcessHandler, CefV8Handler or CefV8Accessor callback, or in
|
||||
/// combination with calling Enter() and Exit() on a stored CefV8Context
|
||||
/// reference.
|
||||
/// </summary>
|
||||
public static CefV8Value CreateObject(CefV8Accessor accessor)
|
||||
{
|
||||
return CefV8Value.FromNative(
|
||||
cef_v8value_t.create_object(accessor != null ? accessor.ToNative() : null)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new CefV8Value object of type array with the specified |length|.
|
||||
/// If |length| is negative the returned array will have length 0. This method
|
||||
/// should only be called from within the scope of a CefRenderProcessHandler,
|
||||
/// CefV8Handler or CefV8Accessor callback, or in combination with calling
|
||||
/// Enter() and Exit() on a stored CefV8Context reference.
|
||||
/// </summary>
|
||||
public static CefV8Value CreateArray(int length)
|
||||
{
|
||||
return CefV8Value.FromNative(
|
||||
cef_v8value_t.create_array(length)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new CefV8Value object of type function. This method should only be
|
||||
/// called from within the scope of a CefRenderProcessHandler, CefV8Handler or
|
||||
/// CefV8Accessor callback, or in combination with calling Enter() and Exit()
|
||||
/// on a stored CefV8Context reference.
|
||||
/// </summary>
|
||||
public static CefV8Value CreateFunction(string name, CefV8Handler handler)
|
||||
{
|
||||
fixed (char* name_str = name)
|
||||
{
|
||||
var n_name = new cef_string_t(name_str, name != null ? name.Length : 0);
|
||||
|
||||
return CefV8Value.FromNative(
|
||||
cef_v8value_t.create_function(&n_name, handler.ToNative())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the underlying handle is valid and it can be accessed on
|
||||
/// the current thread. Do not call any other methods if this method returns
|
||||
/// false.
|
||||
/// </summary>
|
||||
public bool IsValid
|
||||
{
|
||||
get { return cef_v8value_t.is_valid(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True if the value type is undefined.
|
||||
/// </summary>
|
||||
public bool IsUndefined
|
||||
{
|
||||
get { return cef_v8value_t.is_undefined(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True if the value type is null.
|
||||
/// </summary>
|
||||
public bool IsNull
|
||||
{
|
||||
get { return cef_v8value_t.is_null(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True if the value type is bool.
|
||||
/// </summary>
|
||||
public bool IsBool
|
||||
{
|
||||
get { return cef_v8value_t.is_bool(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True if the value type is int.
|
||||
/// </summary>
|
||||
public bool IsInt
|
||||
{
|
||||
get { return cef_v8value_t.is_int(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True if the value type is unsigned int.
|
||||
/// </summary>
|
||||
public bool IsUInt
|
||||
{
|
||||
get { return cef_v8value_t.is_uint(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True if the value type is double.
|
||||
/// </summary>
|
||||
public bool IsDouble
|
||||
{
|
||||
get { return cef_v8value_t.is_double(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True if the value type is Date.
|
||||
/// </summary>
|
||||
public bool IsDate
|
||||
{
|
||||
get { return cef_v8value_t.is_date(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True if the value type is string.
|
||||
/// </summary>
|
||||
public bool IsString
|
||||
{
|
||||
get { return cef_v8value_t.is_string(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True if the value type is object.
|
||||
/// </summary>
|
||||
public bool IsObject
|
||||
{
|
||||
get { return cef_v8value_t.is_object(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True if the value type is array.
|
||||
/// </summary>
|
||||
public bool IsArray
|
||||
{
|
||||
get { return cef_v8value_t.is_array(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True if the value type is function.
|
||||
/// </summary>
|
||||
public bool IsFunction
|
||||
{
|
||||
get { return cef_v8value_t.is_function(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this object is pointing to the same handle as |that|
|
||||
/// object.
|
||||
/// </summary>
|
||||
public bool IsSame(CefV8Value that)
|
||||
{
|
||||
if (that == null) return false;
|
||||
|
||||
return cef_v8value_t.is_same(_self, that.ToNative()) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a bool value. The underlying data will be converted to if
|
||||
/// necessary.
|
||||
/// </summary>
|
||||
public bool GetBoolValue()
|
||||
{
|
||||
return cef_v8value_t.get_bool_value(_self) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return an int value. The underlying data will be converted to if
|
||||
/// necessary.
|
||||
/// </summary>
|
||||
public int GetIntValue()
|
||||
{
|
||||
return cef_v8value_t.get_int_value(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return an unisgned int value. The underlying data will be converted to if
|
||||
/// necessary.
|
||||
/// </summary>
|
||||
public uint GetUIntValue()
|
||||
{
|
||||
return cef_v8value_t.get_uint_value(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a double value. The underlying data will be converted to if
|
||||
/// necessary.
|
||||
/// </summary>
|
||||
public double GetDoubleValue()
|
||||
{
|
||||
return cef_v8value_t.get_double_value(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a Date value. The underlying data will be converted to if
|
||||
/// necessary.
|
||||
/// </summary>
|
||||
public DateTime GetDateValue()
|
||||
{
|
||||
var value = cef_v8value_t.get_date_value(_self);
|
||||
return cef_time_t.ToDateTime(&value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a string value. The underlying data will be converted to if
|
||||
/// necessary.
|
||||
/// </summary>
|
||||
public string GetStringValue()
|
||||
{
|
||||
var n_result = cef_v8value_t.get_string_value(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// OBJECT METHODS - These methods are only available on objects. Arrays and
|
||||
/// functions are also objects. String- and integer-based keys can be used
|
||||
/// interchangably with the framework converting between them as necessary.
|
||||
/// Returns true if this is a user created object.
|
||||
/// </summary>
|
||||
public bool IsUserCreated
|
||||
{
|
||||
get { return cef_v8value_t.is_user_created(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the last method call resulted in an exception. This
|
||||
/// attribute exists only in the scope of the current CEF value object.
|
||||
/// </summary>
|
||||
public bool HasException
|
||||
{
|
||||
get { return cef_v8value_t.has_exception(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the exception resulting from the last method call. This attribute
|
||||
/// exists only in the scope of the current CEF value object.
|
||||
/// </summary>
|
||||
public CefV8Exception GetException()
|
||||
{
|
||||
return CefV8Exception.FromNativeOrNull(
|
||||
cef_v8value_t.get_exception(_self)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the last exception and returns true on success.
|
||||
/// </summary>
|
||||
public bool ClearException()
|
||||
{
|
||||
return cef_v8value_t.clear_exception(_self) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this object will re-throw future exceptions. This attribute
|
||||
/// exists only in the scope of the current CEF value object.
|
||||
/// </summary>
|
||||
public bool WillRethrowExceptions()
|
||||
{
|
||||
return cef_v8value_t.will_rethrow_exceptions(_self) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set whether this object will re-throw future exceptions. By default
|
||||
/// exceptions are not re-thrown. If a exception is re-thrown the current
|
||||
/// context should not be accessed again until after the exception has been
|
||||
/// caught and not re-thrown. Returns true on success. This attribute exists
|
||||
/// only in the scope of the current CEF value object.
|
||||
/// </summary>
|
||||
public bool SetRethrowExceptions(bool rethrow)
|
||||
{
|
||||
return cef_v8value_t.set_rethrow_exceptions(_self, rethrow ? 1 : 0) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the object has a value with the specified identifier.
|
||||
/// </summary>
|
||||
public bool HasValue(string key)
|
||||
{
|
||||
fixed (char* key_str = key)
|
||||
{
|
||||
var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);
|
||||
return cef_v8value_t.has_value_bykey(_self, &n_key) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the object has a value with the specified identifier.
|
||||
/// </summary>
|
||||
public bool HasValue(int index)
|
||||
{
|
||||
return cef_v8value_t.has_value_byindex(_self, index) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the value with the specified identifier and returns true on
|
||||
/// success. Returns false if this method is called incorrectly or an exception
|
||||
/// is thrown. For read-only and don't-delete values this method will return
|
||||
/// true even though deletion failed.
|
||||
/// </summary>
|
||||
public bool DeleteValue(string key)
|
||||
{
|
||||
fixed (char* key_str = key)
|
||||
{
|
||||
var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);
|
||||
return cef_v8value_t.delete_value_bykey(_self, &n_key) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the value with the specified identifier and returns true on
|
||||
/// success. Returns false if this method is called incorrectly, deletion fails
|
||||
/// or an exception is thrown. For read-only and don't-delete values this
|
||||
/// method will return true even though deletion failed.
|
||||
/// </summary>
|
||||
public bool DeleteValue(int index)
|
||||
{
|
||||
return cef_v8value_t.delete_value_byindex(_self, index) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the value with the specified identifier on success. Returns NULL
|
||||
/// if this method is called incorrectly or an exception is thrown.
|
||||
/// </summary>
|
||||
public CefV8Value GetValue(string key)
|
||||
{
|
||||
fixed (char* key_str = key)
|
||||
{
|
||||
var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);
|
||||
return CefV8Value.FromNativeOrNull(
|
||||
cef_v8value_t.get_value_bykey(_self, &n_key)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the value with the specified identifier on success. Returns NULL
|
||||
/// if this method is called incorrectly or an exception is thrown.
|
||||
/// </summary>
|
||||
public CefV8Value GetValue(int index)
|
||||
{
|
||||
return CefV8Value.FromNativeOrNull(
|
||||
cef_v8value_t.get_value_byindex(_self, index)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Associates a value with the specified identifier and returns true on
|
||||
/// success. Returns false if this method is called incorrectly or an exception
|
||||
/// is thrown. For read-only values this method will return true even though
|
||||
/// assignment failed.
|
||||
/// </summary>
|
||||
public bool SetValue(string key, CefV8Value value, CefV8PropertyAttribute attribute)
|
||||
{
|
||||
fixed (char* key_str = key)
|
||||
{
|
||||
var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);
|
||||
return cef_v8value_t.set_value_bykey(_self, &n_key, value.ToNative(), attribute) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Associates a value with the specified identifier and returns true on
|
||||
/// success. Returns false if this method is called incorrectly or an exception
|
||||
/// is thrown. For read-only values this method will return true even though
|
||||
/// assignment failed.
|
||||
/// </summary>
|
||||
public bool SetValue(int index, CefV8Value value)
|
||||
{
|
||||
return cef_v8value_t.set_value_byindex(_self, index, value.ToNative()) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers an identifier and returns true on success. Access to the
|
||||
/// identifier will be forwarded to the CefV8Accessor instance passed to
|
||||
/// CefV8Value::CreateObject(). Returns false if this method is called
|
||||
/// incorrectly or an exception is thrown. For read-only values this method
|
||||
/// will return true even though assignment failed.
|
||||
/// </summary>
|
||||
public bool SetValue(string key, CefV8AccessControl settings, CefV8PropertyAttribute attribute)
|
||||
{
|
||||
fixed (char* key_str = key)
|
||||
{
|
||||
var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);
|
||||
return cef_v8value_t.set_value_byaccessor(_self, &n_key, settings, attribute) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read the keys for the object's values into the specified vector. Integer-
|
||||
/// based keys will also be returned as strings.
|
||||
/// </summary>
|
||||
public bool TryGetKeys(out string[] keys)
|
||||
{
|
||||
var list = libcef.string_list_alloc();
|
||||
var result = cef_v8value_t.get_keys(_self, list) != 0;
|
||||
if (result) keys = cef_string_list.ToArray(list);
|
||||
else keys = null;
|
||||
libcef.string_list_free(list);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read the keys for the object's values into the specified vector. Integer-
|
||||
/// based keys will also be returned as strings.
|
||||
/// </summary>
|
||||
public string[] GetKeys()
|
||||
{
|
||||
string[] keys;
|
||||
if (TryGetKeys(out keys)) return keys;
|
||||
else throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the user data for this object and returns true on success. Returns
|
||||
/// false if this method is called incorrectly. This method can only be called
|
||||
/// on user created objects.
|
||||
/// </summary>
|
||||
public bool SetUserData(CefUserData userData)
|
||||
{
|
||||
return cef_v8value_t.set_user_data(_self, userData != null ? (cef_base_t*)userData.ToNative() : null) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the user data, if any, assigned to this object.
|
||||
/// </summary>
|
||||
public CefUserData GetUserData()
|
||||
{
|
||||
return CefUserData.FromNativeOrNull(
|
||||
(cef_user_data_t*)cef_v8value_t.get_user_data(_self)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the amount of externally allocated memory registered for the
|
||||
/// object.
|
||||
/// </summary>
|
||||
public int GetExternallyAllocatedMemory()
|
||||
{
|
||||
return cef_v8value_t.get_externally_allocated_memory(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adjusts the amount of registered external memory for the object. Used to
|
||||
/// give V8 an indication of the amount of externally allocated memory that is
|
||||
/// kept alive by JavaScript objects. V8 uses this information to decide when
|
||||
/// to perform global garbage collection. Each CefV8Value tracks the amount of
|
||||
/// external memory associated with it and automatically decreases the global
|
||||
/// total by the appropriate amount on its destruction. |change_in_bytes|
|
||||
/// specifies the number of bytes to adjust by. This method returns the number
|
||||
/// of bytes associated with the object after the adjustment. This method can
|
||||
/// only be called on user created objects.
|
||||
/// </summary>
|
||||
public int AdjustExternallyAllocatedMemory(int changeInBytes)
|
||||
{
|
||||
return cef_v8value_t.adjust_externally_allocated_memory(_self, changeInBytes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ARRAY METHODS - These methods are only available on arrays.
|
||||
/// Returns the number of elements in the array.
|
||||
/// </summary>
|
||||
public int GetArrayLength()
|
||||
{
|
||||
return cef_v8value_t.get_array_length(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// FUNCTION METHODS - These methods are only available on functions.
|
||||
/// Returns the function name.
|
||||
/// </summary>
|
||||
public string GetFunctionName()
|
||||
{
|
||||
var n_result = cef_v8value_t.get_function_name(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the function handler or NULL if not a CEF-created function.
|
||||
/// </summary>
|
||||
public CefV8Handler GetFunctionHandler()
|
||||
{
|
||||
return CefV8Handler.FromNativeOrNull(
|
||||
cef_v8value_t.get_function_handler(_self)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Execute the function using the current V8 context. This method should only
|
||||
/// be called from within the scope of a CefV8Handler or CefV8Accessor
|
||||
/// callback, or in combination with calling Enter() and Exit() on a stored
|
||||
/// CefV8Context reference. |object| is the receiver ('this' object) of the
|
||||
/// function. If |object| is empty the current context's global object will be
|
||||
/// used. |arguments| is the list of arguments that will be passed to the
|
||||
/// function. Returns the function return value on success. Returns NULL if
|
||||
/// this method is called incorrectly or an exception is thrown.
|
||||
/// </summary>
|
||||
public CefV8Value ExecuteFunction(CefV8Value obj, CefV8Value[] arguments)
|
||||
{
|
||||
var n_arguments = CreateArguments(arguments);
|
||||
cef_v8value_t* n_retval;
|
||||
|
||||
fixed (cef_v8value_t** n_arguments_ptr = n_arguments)
|
||||
{
|
||||
n_retval = cef_v8value_t.execute_function(
|
||||
_self,
|
||||
obj != null ? obj.ToNative() : null,
|
||||
n_arguments != null ? (UIntPtr)n_arguments.Length : UIntPtr.Zero,
|
||||
n_arguments_ptr
|
||||
);
|
||||
}
|
||||
|
||||
return CefV8Value.FromNativeOrNull(n_retval);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Execute the function using the specified V8 context. |object| is the
|
||||
/// receiver ('this' object) of the function. If |object| is empty the
|
||||
/// specified context's global object will be used. |arguments| is the list of
|
||||
/// arguments that will be passed to the function. Returns the function return
|
||||
/// value on success. Returns NULL if this method is called incorrectly or an
|
||||
/// exception is thrown.
|
||||
/// </summary>
|
||||
public CefV8Value ExecuteFunctionWithContext(CefV8Context context, CefV8Value obj, CefV8Value[] arguments)
|
||||
{
|
||||
var n_arguments = CreateArguments(arguments);
|
||||
cef_v8value_t* n_retval;
|
||||
|
||||
fixed (cef_v8value_t** n_arguments_ptr = n_arguments)
|
||||
{
|
||||
n_retval = cef_v8value_t.execute_function_with_context(
|
||||
_self,
|
||||
context.ToNative(),
|
||||
obj != null ? obj.ToNative() : null,
|
||||
n_arguments != null ? (UIntPtr)n_arguments.Length : UIntPtr.Zero,
|
||||
n_arguments_ptr
|
||||
);
|
||||
}
|
||||
|
||||
return CefV8Value.FromNativeOrNull(n_retval);
|
||||
}
|
||||
|
||||
private static cef_v8value_t*[] CreateArguments(CefV8Value[] arguments)
|
||||
{
|
||||
if (arguments == null) return null;
|
||||
|
||||
var length = arguments.Length;
|
||||
if (length == 0) return null;
|
||||
|
||||
var result = new cef_v8value_t*[arguments.Length];
|
||||
|
||||
for (var i = 0; i < length; i++)
|
||||
{
|
||||
result[i] = arguments[i].ToNative();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,258 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class that wraps other data value types. Complex types (binary, dictionary
|
||||
/// and list) will be referenced but not owned by this object. Can be used on any
|
||||
/// process and thread.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefValue
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new object.
|
||||
/// </summary>
|
||||
public static CefValue Create()
|
||||
{
|
||||
return CefValue.FromNative(cef_value_t.create());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the underlying data is valid. This will always be true for
|
||||
/// simple types. For complex types (binary, dictionary and list) the
|
||||
/// underlying data may become invalid if owned by another object (e.g. list or
|
||||
/// dictionary) and that other object is then modified or destroyed. This value
|
||||
/// object can be re-used by calling Set*() even if the underlying data is
|
||||
/// invalid.
|
||||
/// </summary>
|
||||
public bool IsValid
|
||||
{
|
||||
get
|
||||
{
|
||||
return cef_value_t.is_valid(_self) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the underlying data is owned by another object.
|
||||
/// </summary>
|
||||
public bool IsOwned
|
||||
{
|
||||
get
|
||||
{
|
||||
return cef_value_t.is_owned(_self) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the underlying data is read-only. Some APIs may expose
|
||||
/// read-only objects.
|
||||
/// </summary>
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get
|
||||
{
|
||||
return cef_value_t.is_read_only(_self) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this object and |that| object have the same underlying
|
||||
/// data. If true modifications to this object will also affect |that| object
|
||||
/// and vice-versa.
|
||||
/// </summary>
|
||||
public bool IsSame(CefValue that)
|
||||
{
|
||||
return cef_value_t.is_same(_self, that.ToNative()) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this object and |that| object have an equivalent underlying
|
||||
/// value but are not necessarily the same object.
|
||||
/// </summary>
|
||||
public bool IsEqual(CefValue that)
|
||||
{
|
||||
return cef_value_t.is_equal(_self, that.ToNative()) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a copy of this object. The underlying data will also be copied.
|
||||
/// </summary>
|
||||
public CefValue Copy()
|
||||
{
|
||||
return CefValue.FromNative(
|
||||
cef_value_t.copy(_self)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the underlying value type.
|
||||
/// </summary>
|
||||
public CefValueType GetValueType()
|
||||
{
|
||||
return cef_value_t.get_type(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the underlying value as type bool.
|
||||
/// </summary>
|
||||
public bool GetBool()
|
||||
{
|
||||
return cef_value_t.get_bool(_self) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the underlying value as type int.
|
||||
/// </summary>
|
||||
public int GetInt()
|
||||
{
|
||||
return cef_value_t.get_int(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the underlying value as type double.
|
||||
/// </summary>
|
||||
public double GetDouble()
|
||||
{
|
||||
return cef_value_t.get_double(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the underlying value as type string.
|
||||
/// </summary>
|
||||
public string GetString()
|
||||
{
|
||||
var n_result = cef_value_t.get_string(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the underlying value as type binary. The returned reference may
|
||||
/// become invalid if the value is owned by another object or if ownership is
|
||||
/// transferred to another object in the future. To maintain a reference to
|
||||
/// the value after assigning ownership to a dictionary or list pass this
|
||||
/// object to the SetValue() method instead of passing the returned reference
|
||||
/// to SetBinary().
|
||||
/// </summary>
|
||||
public CefBinaryValue GetBinary()
|
||||
{
|
||||
return CefBinaryValue.FromNative(
|
||||
cef_value_t.get_binary(_self)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the underlying value as type dictionary. The returned reference may
|
||||
/// become invalid if the value is owned by another object or if ownership is
|
||||
/// transferred to another object in the future. To maintain a reference to
|
||||
/// the value after assigning ownership to a dictionary or list pass this
|
||||
/// object to the SetValue() method instead of passing the returned reference
|
||||
/// to SetDictionary().
|
||||
/// </summary>
|
||||
public CefDictionaryValue GetDictionary()
|
||||
{
|
||||
return CefDictionaryValue.FromNative(
|
||||
cef_value_t.get_dictionary(_self)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the underlying value as type list. The returned reference may
|
||||
/// become invalid if the value is owned by another object or if ownership is
|
||||
/// transferred to another object in the future. To maintain a reference to
|
||||
/// the value after assigning ownership to a dictionary or list pass this
|
||||
/// object to the SetValue() method instead of passing the returned reference
|
||||
/// to SetList().
|
||||
/// </summary>
|
||||
public CefListValue GetList()
|
||||
{
|
||||
return CefListValue.FromNative(
|
||||
cef_value_t.get_list(_self)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the underlying value as type null. Returns true if the value was set
|
||||
/// successfully.
|
||||
/// </summary>
|
||||
public bool SetNull()
|
||||
{
|
||||
return cef_value_t.set_null(_self) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the underlying value as type bool. Returns true if the value was set
|
||||
/// successfully.
|
||||
/// </summary>
|
||||
public bool SetBool(bool value)
|
||||
{
|
||||
return cef_value_t.set_bool(_self, value ? 1 : 0) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the underlying value as type int. Returns true if the value was set
|
||||
/// successfully.
|
||||
/// </summary>
|
||||
public bool SetInt(int value)
|
||||
{
|
||||
return cef_value_t.set_int(_self, value) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the underlying value as type double. Returns true if the value was set
|
||||
/// successfully.
|
||||
/// </summary>
|
||||
public bool SetDouble(double value)
|
||||
{
|
||||
return cef_value_t.set_double(_self, value) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the underlying value as type string. Returns true if the value was set
|
||||
/// successfully.
|
||||
/// </summary>
|
||||
public bool SetString(string value)
|
||||
{
|
||||
fixed (char* value_str = value)
|
||||
{
|
||||
var n_value = new cef_string_t(value_str, value != null ? value.Length : 0);
|
||||
|
||||
return cef_value_t.set_string(_self, &n_value) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the underlying value as type binary. Returns true if the value was set
|
||||
/// successfully. This object keeps a reference to |value| and ownership of the
|
||||
/// underlying data remains unchanged.
|
||||
/// </summary>
|
||||
public bool SetBinary(CefBinaryValue value)
|
||||
{
|
||||
return cef_value_t.set_binary(_self, value.ToNative()) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the underlying value as type dict. Returns true if the value was set
|
||||
/// successfully. This object keeps a reference to |value| and ownership of the
|
||||
/// underlying data remains unchanged.
|
||||
/// </summary>
|
||||
public bool SetDictionary(CefDictionaryValue value)
|
||||
{
|
||||
return cef_value_t.set_dictionary(_self, value.ToNative()) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the underlying value as type list. Returns true if the value was set
|
||||
/// successfully. This object keeps a reference to |value| and ownership of the
|
||||
/// underlying data remains unchanged.
|
||||
/// </summary>
|
||||
public bool SetList(CefListValue value)
|
||||
{
|
||||
return cef_value_t.set_list(_self, value.ToNative()) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Information about a specific web plugin.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefWebPluginInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the plugin name (i.e. Flash).
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_web_plugin_info_t.get_name(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the plugin file path (DLL/bundle/library).
|
||||
/// </summary>
|
||||
public string Path
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_web_plugin_info_t.get_path(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the version of the plugin (may be OS-specific).
|
||||
/// </summary>
|
||||
public string Version
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_web_plugin_info_t.get_version(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a description of the plugin from the version information.
|
||||
/// </summary>
|
||||
public string Description
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_web_plugin_info_t.get_description(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,348 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class that supports the reading of XML data via the libxml streaming API.
|
||||
/// The methods of this class should only be called on the thread that creates
|
||||
/// the object.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefXmlReader
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a new CefXmlReader object. The returned object's methods can only
|
||||
/// be called from the thread that created the object.
|
||||
/// </summary>
|
||||
public static CefXmlReader Create(CefStreamReader stream, CefXmlEncoding encodingType, string uri)
|
||||
{
|
||||
if (stream == null) throw new ArgumentNullException("stream");
|
||||
|
||||
fixed (char* uri_str = uri)
|
||||
{
|
||||
var n_uri = new cef_string_t(uri_str, uri != null ? uri.Length : 0);
|
||||
return CefXmlReader.FromNative(
|
||||
cef_xml_reader_t.create(stream.ToNative(), encodingType, &n_uri)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves the cursor to the next node in the document. This method must be
|
||||
/// called at least once to set the current cursor position. Returns true if
|
||||
/// the cursor position was set successfully.
|
||||
/// </summary>
|
||||
public bool MoveToNextNode()
|
||||
{
|
||||
return cef_xml_reader_t.move_to_next_node(_self) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Close the document. This should be called directly to ensure that cleanup
|
||||
/// occurs on the correct thread.
|
||||
/// </summary>
|
||||
public bool Close()
|
||||
{
|
||||
return cef_xml_reader_t.close(_self) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if an error has been reported by the XML parser.
|
||||
/// </summary>
|
||||
public bool HasError
|
||||
{
|
||||
get { return cef_xml_reader_t.has_error(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the error string.
|
||||
/// </summary>
|
||||
public string Error
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_xml_reader_t.get_error(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The below methods retrieve data for the node at the current cursor
|
||||
/// position.
|
||||
/// Returns the node type.
|
||||
/// </summary>
|
||||
public CefXmlNodeType NodeType
|
||||
{
|
||||
get { return cef_xml_reader_t.get_type(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the node depth. Depth starts at 0 for the root node.
|
||||
/// </summary>
|
||||
public int Depth
|
||||
{
|
||||
get { return cef_xml_reader_t.get_depth(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the local name. See
|
||||
/// http://www.w3.org/TR/REC-xml-names/#NT-LocalPart for additional details.
|
||||
/// </summary>
|
||||
public string LocalName
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_xml_reader_t.get_local_name(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the namespace prefix. See http://www.w3.org/TR/REC-xml-names/ for
|
||||
/// additional details.
|
||||
/// </summary>
|
||||
public string Prefix
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_xml_reader_t.get_prefix(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the qualified name, equal to (Prefix:)LocalName. See
|
||||
/// http://www.w3.org/TR/REC-xml-names/#ns-qualnames for additional details.
|
||||
/// </summary>
|
||||
public string QualifiedName
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_xml_reader_t.get_qualified_name(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the URI defining the namespace associated with the node. See
|
||||
/// http://www.w3.org/TR/REC-xml-names/ for additional details.
|
||||
/// </summary>
|
||||
public string NamespaceUri
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_xml_reader_t.get_namespace_uri(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the base URI of the node. See http://www.w3.org/TR/xmlbase/ for
|
||||
/// additional details.
|
||||
/// </summary>
|
||||
public string BaseUri
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_xml_reader_t.get_base_uri(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the xml:lang scope within which the node resides. See
|
||||
/// http://www.w3.org/TR/REC-xml/#sec-lang-tag for additional details.
|
||||
/// </summary>
|
||||
public string XmlLang
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_xml_reader_t.get_xml_lang(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the node represents an empty element. <a/> is considered
|
||||
/// empty but <a></a> is not.
|
||||
/// </summary>
|
||||
public bool IsEmptyElement
|
||||
{
|
||||
get { return cef_xml_reader_t.is_empty_element(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the node has a text value.
|
||||
/// </summary>
|
||||
public bool HasValue
|
||||
{
|
||||
get { return cef_xml_reader_t.has_value(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the text value.
|
||||
/// </summary>
|
||||
public string Value
|
||||
{
|
||||
get
|
||||
{
|
||||
var n_result = cef_xml_reader_t.get_value(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the node has attributes.
|
||||
/// </summary>
|
||||
public bool HasAttributes
|
||||
{
|
||||
get { return cef_xml_reader_t.has_attributes(_self) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the number of attributes.
|
||||
/// </summary>
|
||||
public int AttributeCount
|
||||
{
|
||||
get { return (int)cef_xml_reader_t.get_attribute_count(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the value of the attribute at the specified 0-based index.
|
||||
/// </summary>
|
||||
public string GetAttribute(int index)
|
||||
{
|
||||
var n_result = cef_xml_reader_t.get_attribute_byindex(_self, index);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the value of the attribute with the specified qualified name.
|
||||
/// </summary>
|
||||
public string GetAttribute(string qualifiedName)
|
||||
{
|
||||
fixed (char* qualifiedName_str = qualifiedName)
|
||||
{
|
||||
var n_qualifiedName = new cef_string_t(qualifiedName_str, qualifiedName != null ? qualifiedName.Length : 0);
|
||||
var n_result = cef_xml_reader_t.get_attribute_byqname(_self, &n_qualifiedName);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the value of the attribute with the specified local name and
|
||||
/// namespace URI.
|
||||
/// </summary>
|
||||
public string GetAttribute(string localName, string namespaceUri)
|
||||
{
|
||||
fixed (char* localName_str = localName)
|
||||
fixed (char* namespaceUri_str = namespaceUri)
|
||||
{
|
||||
var n_localName = new cef_string_t(localName_str, localName != null ? localName.Length : 0);
|
||||
var n_namespaceUri = new cef_string_t(namespaceUri_str, namespaceUri != null ? namespaceUri.Length : 0);
|
||||
|
||||
var n_result = cef_xml_reader_t.get_attribute_bylname(_self, &n_localName, &n_namespaceUri);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an XML representation of the current node's children.
|
||||
/// </summary>
|
||||
public string GetInnerXml()
|
||||
{
|
||||
var n_result = cef_xml_reader_t.get_inner_xml(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an XML representation of the current node including its children.
|
||||
/// </summary>
|
||||
public string GetOuterXml()
|
||||
{
|
||||
var n_result = cef_xml_reader_t.get_outer_xml(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the line number for the current node.
|
||||
/// </summary>
|
||||
public int LineNumber
|
||||
{
|
||||
get { return cef_xml_reader_t.get_line_number(_self); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attribute nodes are not traversed by default. The below methods can be
|
||||
/// used to move the cursor to an attribute node. MoveToCarryingElement() can
|
||||
/// be called afterwards to return the cursor to the carrying element. The
|
||||
/// depth of an attribute node will be 1 + the depth of the carrying element.
|
||||
/// Moves the cursor to the attribute at the specified 0-based index. Returns
|
||||
/// true if the cursor position was set successfully.
|
||||
/// </summary>
|
||||
public bool MoveToAttribute(int index)
|
||||
{
|
||||
return cef_xml_reader_t.move_to_attribute_byindex(_self, index) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves the cursor to the attribute with the specified qualified name.
|
||||
/// Returns true if the cursor position was set successfully.
|
||||
/// </summary>
|
||||
public bool MoveToAttribute(string qualifiedName)
|
||||
{
|
||||
fixed (char* qualifiedName_str = qualifiedName)
|
||||
{
|
||||
var n_qualifiedName = new cef_string_t(qualifiedName_str, qualifiedName != null ? qualifiedName.Length : 0);
|
||||
|
||||
return cef_xml_reader_t.move_to_attribute_byqname(_self, &n_qualifiedName) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves the cursor to the attribute with the specified local name and
|
||||
/// namespace URI. Returns true if the cursor position was set successfully.
|
||||
/// </summary>
|
||||
public bool MoveToAttribute(string localName, string namespaceUri)
|
||||
{
|
||||
fixed (char* localName_str = localName)
|
||||
fixed (char* namespaceUri_str = namespaceUri)
|
||||
{
|
||||
var n_localName = new cef_string_t(localName_str, localName != null ? localName.Length : 0);
|
||||
var n_namespaceUri = new cef_string_t(namespaceUri_str, namespaceUri != null ? namespaceUri.Length : 0);
|
||||
|
||||
return cef_xml_reader_t.move_to_attribute_bylname(_self, &n_localName, &n_namespaceUri) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves the cursor to the first attribute in the current element. Returns
|
||||
/// true if the cursor position was set successfully.
|
||||
/// </summary>
|
||||
public bool MoveToFirstAttribute()
|
||||
{
|
||||
return cef_xml_reader_t.move_to_first_attribute(_self) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves the cursor to the next attribute in the current element. Returns
|
||||
/// true if the cursor position was set successfully.
|
||||
/// </summary>
|
||||
public bool MoveToNextAttribute()
|
||||
{
|
||||
return cef_xml_reader_t.move_to_next_attribute(_self) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves the cursor back to the carrying element. Returns true if the cursor
|
||||
/// position was set successfully.
|
||||
/// </summary>
|
||||
public bool MoveToCarryingElement()
|
||||
{
|
||||
return cef_xml_reader_t.move_to_carrying_element(_self) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
namespace Cef3
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Cef3.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// Class that supports the reading of zip archives via the zlib unzip API.
|
||||
/// The methods of this class should only be called on the thread that creates
|
||||
/// the object.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class CefZipReader
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a new CefZipReader object. The returned object's methods can only
|
||||
/// be called from the thread that created the object.
|
||||
/// </summary>
|
||||
public static CefZipReader Create(CefStreamReader stream)
|
||||
{
|
||||
if (stream == null) throw new ArgumentNullException("stream");
|
||||
|
||||
return CefZipReader.FromNative(
|
||||
cef_zip_reader_t.create(stream.ToNative())
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves the cursor to the first file in the archive. Returns true if the
|
||||
/// cursor position was set successfully.
|
||||
/// </summary>
|
||||
public bool MoveToFirstFile()
|
||||
{
|
||||
return cef_zip_reader_t.move_to_first_file(_self) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves the cursor to the next file in the archive. Returns true if the
|
||||
/// cursor position was set successfully.
|
||||
/// </summary>
|
||||
public bool MoveToNextFile()
|
||||
{
|
||||
return cef_zip_reader_t.move_to_next_file(_self) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves the cursor to the specified file in the archive. If |caseSensitive|
|
||||
/// is true then the search will be case sensitive. Returns true if the cursor
|
||||
/// position was set successfully.
|
||||
/// </summary>
|
||||
public bool MoveToFile(string fileName, bool caseSensitive)
|
||||
{
|
||||
fixed (char* fileName_str = fileName)
|
||||
{
|
||||
var n_fileName = new cef_string_t(fileName_str, fileName != null ? fileName.Length : 0);
|
||||
|
||||
return cef_zip_reader_t.move_to_file(_self, &n_fileName, caseSensitive ? 1 : 0) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes the archive. This should be called directly to ensure that cleanup
|
||||
/// occurs on the correct thread.
|
||||
/// </summary>
|
||||
public bool Close()
|
||||
{
|
||||
return cef_zip_reader_t.close(_self) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The below methods act on the file at the current cursor position.
|
||||
/// Returns the name of the file.
|
||||
/// </summary>
|
||||
public string GetFileName()
|
||||
{
|
||||
var n_result = cef_zip_reader_t.get_file_name(_self);
|
||||
return cef_string_userfree.ToString(n_result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the uncompressed size of the file.
|
||||
/// </summary>
|
||||
public long GetFileSize()
|
||||
{
|
||||
return cef_zip_reader_t.get_file_size(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the last modified timestamp for the file.
|
||||
/// </summary>
|
||||
public DateTime GetFileLastModified()
|
||||
{
|
||||
var time = cef_zip_reader_t.get_file_last_modified(_self);
|
||||
return cef_time_t.ToDateTime(&time);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens the file for reading of uncompressed data. A read password may
|
||||
/// optionally be specified.
|
||||
/// </summary>
|
||||
public bool OpenFile(string password)
|
||||
{
|
||||
fixed (char* password_str = password)
|
||||
{
|
||||
var n_password = new cef_string_t(password_str, password != null ? password.Length : 0);
|
||||
return cef_zip_reader_t.open_file(_self, &n_password) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes the file.
|
||||
/// </summary>
|
||||
public bool CloseFile()
|
||||
{
|
||||
return cef_zip_reader_t.close_file(_self) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read uncompressed file contents into the specified buffer. Returns < 0 if
|
||||
/// an error occurred, 0 if at the end of file, or the number of bytes read.
|
||||
/// </summary>
|
||||
public int ReadFile(byte[] buffer, int offset, int length)
|
||||
{
|
||||
if (offset < 0 || length < 0 || buffer.Length - offset < length) throw new ArgumentOutOfRangeException();
|
||||
|
||||
fixed (byte* buffer_ptr = buffer)
|
||||
{
|
||||
return cef_zip_reader_t.read_file(_self, buffer_ptr + offset, (UIntPtr)length);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current offset in the uncompressed file contents.
|
||||
/// </summary>
|
||||
public long Tell()
|
||||
{
|
||||
return cef_zip_reader_t.tell(_self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if at end of the file contents.
|
||||
/// </summary>
|
||||
public bool Eof()
|
||||
{
|
||||
return cef_zip_reader_t.eof(_self) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user