Exemple #1
0
        /// <summary>
        /// Parses the specified |jsonString| and returns a dictionary or list
        /// representation. If JSON parsing fails this function returns NULL and
        /// populates |errorCodeOut| and |errorMsgOut| with an error code and a
        /// formatted error message respectively.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_parser_capi.h">cef/include/capi/cef_parser_capi.h</see>.
        /// </remarks>
        public static CfxValue ParseJsonAndReturnError(string jsonString, CfxJsonParserOptions options, out CfxJsonParserError errorCodeOut, ref string errorMsgOut)
        {
            var    jsonString_pinned = new PinnedString(jsonString);
            int    errorCodeOut_tmp;
            var    errorMsgOut_pinned = new PinnedString(errorMsgOut);
            IntPtr errorMsgOut_str    = errorMsgOut_pinned.Obj.PinnedPtr;
            int    errorMsgOut_length = errorMsgOut_pinned.Length;
            var    __retval           = CfxApi.cfx_parse_jsonand_return_error(jsonString_pinned.Obj.PinnedPtr, jsonString_pinned.Length, (int)options, out errorCodeOut_tmp, ref errorMsgOut_str, ref errorMsgOut_length);

            jsonString_pinned.Obj.Free();
            errorCodeOut = (CfxJsonParserError)errorCodeOut_tmp;
            if (errorMsgOut_str != errorMsgOut_pinned.Obj.PinnedPtr)
            {
                if (errorMsgOut_length > 0)
                {
                    errorMsgOut = System.Runtime.InteropServices.Marshal.PtrToStringUni(errorMsgOut_str, errorMsgOut_length);
                    // free the native string?
                }
                else
                {
                    errorMsgOut = null;
                }
            }
            errorMsgOut_pinned.Obj.Free();
            return(CfxValue.Wrap(__retval));
        }
Exemple #2
0
        /// <summary>
        /// Register a plugin crash. Can be called on any thread in the browser process
        /// but will be executed on the IO thread.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_web_plugin_capi.h">cef/include/capi/cef_web_plugin_capi.h</see>.
        /// </remarks>
        public static void RegisterWebPluginCrash(string path)
        {
            var path_pinned = new PinnedString(path);

            CfxApi.cfx_register_web_plugin_crash(path_pinned.Obj.PinnedPtr, path_pinned.Length);
            path_pinned.Obj.Free();
        }
Exemple #3
0
        /// <summary>
        /// Force a plugin to shutdown. Can be called on any thread in the browser
        /// process but will be executed on the IO thread.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_web_plugin_capi.h">cef/include/capi/cef_web_plugin_capi.h</see>.
        /// </remarks>
        public static void ForceWebPluginShutdown(string path)
        {
            var path_pinned = new PinnedString(path);

            CfxApi.cfx_force_web_plugin_shutdown(path_pinned.Obj.PinnedPtr, path_pinned.Length);
            path_pinned.Obj.Free();
        }
Exemple #4
0
        /// <summary>
        /// Query if a plugin is unstable. Can be called on any thread in the browser
        /// process.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_web_plugin_capi.h">cef/include/capi/cef_web_plugin_capi.h</see>.
        /// </remarks>
        public static void IsWebPluginUnstable(string path, CfxWebPluginUnstableCallback callback)
        {
            var path_pinned = new PinnedString(path);

            CfxApi.cfx_is_web_plugin_unstable(path_pinned.Obj.PinnedPtr, path_pinned.Length, CfxWebPluginUnstableCallback.Unwrap(callback));
            path_pinned.Obj.Free();
        }
        /// <summary>
        /// Call to continue the download. Set |downloadPath| 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 |showDialog| to true
        /// (1) if you do wish to show the default "Save As" dialog.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_download_handler_capi.h">cef/include/capi/cef_download_handler_capi.h</see>.
        /// </remarks>
        public void Continue(string downloadPath, bool showDialog)
        {
            var downloadPath_pinned = new PinnedString(downloadPath);

            CfxApi.BeforeDownloadCallback.cfx_before_download_callback_cont(NativePtr, downloadPath_pinned.Obj.PinnedPtr, downloadPath_pinned.Length, showDialog ? 1 : 0);
            downloadPath_pinned.Obj.Free();
        }
Exemple #6
0
        /// <summary>
        /// Initialize the command line with the string returned by calling
        /// GetCommandLineW(). This function is only supported on Windows.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_command_line_capi.h">cef/include/capi/cef_command_line_capi.h</see>.
        /// </remarks>
        public void InitFromString(string commandLine)
        {
            var commandLine_pinned = new PinnedString(commandLine);

            CfxApi.cfx_command_line_init_from_string(NativePtr, commandLine_pinned.Obj.PinnedPtr, commandLine_pinned.Length);
            commandLine_pinned.Obj.Free();
        }
        internal static void get_byindex(IntPtr gcHandlePtr, out int __retval, int index, IntPtr @object, out int object_release, out IntPtr retval, out IntPtr exception_str, out int exception_length, out IntPtr exception_gc_handle)
        {
            var self = (CfxV8Interceptor)System.Runtime.InteropServices.GCHandle.FromIntPtr(gcHandlePtr).Target;

            if (self == null || self.CallbacksDisabled)
            {
                __retval            = default(int);
                object_release      = 1;
                retval              = default(IntPtr);
                exception_str       = IntPtr.Zero;
                exception_length    = 0;
                exception_gc_handle = IntPtr.Zero;
                return;
            }
            var e = new CfxGetByIndexEventArgs(index, @object);

            self.m_GetByIndex?.Invoke(self, e);
            e.m_isInvalid  = true;
            object_release = e.m_object_wrapped == null? 1 : 0;
            retval         = CfxV8Value.Unwrap(e.m_retval_wrapped);
            if (e.m_exception_wrapped != null && e.m_exception_wrapped.Length > 0)
            {
                var exception_pinned = new PinnedString(e.m_exception_wrapped);
                exception_str       = exception_pinned.Obj.PinnedPtr;
                exception_length    = exception_pinned.Length;
                exception_gc_handle = exception_pinned.Obj.GCHandlePtr();
            }
            else
            {
                exception_str       = IntPtr.Zero;
                exception_length    = 0;
                exception_gc_handle = IntPtr.Zero;
            }
            __retval = e.m_returnValue ? 1 : 0;
        }
Exemple #8
0
        /// <summary>
        /// Add a plugin directory. This change may not take affect until after
        /// cef_refresh_web_plugins() is called. Can be called on any thread in the
        /// browser process.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_web_plugin_capi.h">cef/include/capi/cef_web_plugin_capi.h</see>.
        /// </remarks>
        public static void AddWebPluginDirectory(string dir)
        {
            var dir_pinned = new PinnedString(dir);

            CfxApi.cfx_add_web_plugin_directory(dir_pinned.Obj.PinnedPtr, dir_pinned.Length);
            dir_pinned.Obj.Free();
        }
Exemple #9
0
        internal static void on_tooltip(IntPtr gcHandlePtr, out int __retval, IntPtr browser, ref IntPtr text_str, ref int text_length)
        {
            var self = (CfxDisplayHandler)System.Runtime.InteropServices.GCHandle.FromIntPtr(gcHandlePtr).Target;

            if (self == null)
            {
                __retval = default(int);
                return;
            }
            var e            = new CfxOnTooltipEventArgs(browser, text_str, text_length);
            var eventHandler = self.m_OnTooltip;

            if (eventHandler != null)
            {
                eventHandler(self, e);
            }
            e.m_isInvalid = true;
            if (e.m_browser_wrapped == null)
            {
                CfxApi.cfx_release(e.m_browser);
            }
            if (e.m_text_changed)
            {
                var text_pinned = new PinnedString(e.m_text_wrapped);
                text_str    = text_pinned.Obj.PinnedPtr;
                text_length = text_pinned.Length;
            }
            __retval = e.m_returnValue ? 1 : 0;
        }
        internal static void set_byname(IntPtr gcHandlePtr, out int __retval, IntPtr name_str, int name_length, IntPtr @object, out int object_release, IntPtr value, out int value_release, out IntPtr exception_str, out int exception_length, out IntPtr exception_gc_handle)
        {
            var self = (CfxV8Interceptor)System.Runtime.InteropServices.GCHandle.FromIntPtr(gcHandlePtr).Target;

            if (self == null || self.CallbacksDisabled)
            {
                __retval            = default(int);
                object_release      = 1;
                value_release       = 1;
                exception_str       = IntPtr.Zero;
                exception_length    = 0;
                exception_gc_handle = IntPtr.Zero;
                return;
            }
            var e = new CfxSetByNameEventArgs(name_str, name_length, @object, value);

            self.m_SetByName?.Invoke(self, e);
            e.m_isInvalid  = true;
            object_release = e.m_object_wrapped == null? 1 : 0;
            value_release  = e.m_value_wrapped == null? 1 : 0;
            if (e.m_exception_wrapped != null && e.m_exception_wrapped.Length > 0)
            {
                var exception_pinned = new PinnedString(e.m_exception_wrapped);
                exception_str       = exception_pinned.Obj.PinnedPtr;
                exception_length    = exception_pinned.Length;
                exception_gc_handle = exception_pinned.Obj.GCHandlePtr();
            }
            else
            {
                exception_str       = IntPtr.Zero;
                exception_length    = 0;
                exception_gc_handle = IntPtr.Zero;
            }
            __retval = e.m_returnValue ? 1 : 0;
        }
Exemple #11
0
        /// <summary>
        /// Insert a command before the current command. Common for debuggers, like
        /// "valgrind" or "gdb --args".
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_command_line_capi.h">cef/include/capi/cef_command_line_capi.h</see>.
        /// </remarks>
        public void PrependWrapper(string wrapper)
        {
            var wrapper_pinned = new PinnedString(wrapper);

            CfxApi.cfx_command_line_prepend_wrapper(NativePtr, wrapper_pinned.Obj.PinnedPtr, wrapper_pinned.Length);
            wrapper_pinned.Obj.Free();
        }
Exemple #12
0
        /// <summary>
        /// Add an argument to the end of the command line.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_command_line_capi.h">cef/include/capi/cef_command_line_capi.h</see>.
        /// </remarks>
        public void AppendArgument(string argument)
        {
            var argument_pinned = new PinnedString(argument);

            CfxApi.cfx_command_line_append_argument(NativePtr, argument_pinned.Obj.PinnedPtr, argument_pinned.Length);
            argument_pinned.Obj.Free();
        }
Exemple #13
0
        /// <summary>
        /// Add a switch to the end of the command line. If the switch has no value
        /// pass an NULL value string.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_command_line_capi.h">cef/include/capi/cef_command_line_capi.h</see>.
        /// </remarks>
        public void AppendSwitch(string name)
        {
            var name_pinned = new PinnedString(name);

            CfxApi.cfx_command_line_append_switch(NativePtr, name_pinned.Obj.PinnedPtr, name_pinned.Length);
            name_pinned.Obj.Free();
        }
Exemple #14
0
        /// <summary>
        /// Remove a plugin path (directory + file). This change may not take affect
        /// until after cef_refresh_web_plugins() is called. Can be called on any thread
        /// in the browser process.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_web_plugin_capi.h">cef/include/capi/cef_web_plugin_capi.h</see>.
        /// </remarks>
        public static void RemoveWebPluginPath(string path)
        {
            var path_pinned = new PinnedString(path);

            CfxApi.cfx_remove_web_plugin_path(path_pinned.Obj.PinnedPtr, path_pinned.Length);
            path_pinned.Obj.Free();
        }
Exemple #15
0
        /// <summary>
        /// Set the referrer URL and policy. If non-NULL the referrer URL must be fully
        /// qualified with an HTTP or HTTPS scheme component. Any username, password or
        /// ref component will be removed.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_request_capi.h">cef/include/capi/cef_request_capi.h</see>.
        /// </remarks>
        public void SetReferrer(string referrerUrl, CfxReferrerPolicy policy)
        {
            var referrerUrl_pinned = new PinnedString(referrerUrl);

            CfxApi.cfx_request_set_referrer(NativePtr, referrerUrl_pinned.Obj.PinnedPtr, referrerUrl_pinned.Length, (int)policy);
            referrerUrl_pinned.Obj.Free();
        }
Exemple #16
0
        /// <summary>
        /// Unregister an internal plugin. This may be undone the next time
        /// cef_refresh_web_plugins() is called. Can be called on any thread in the
        /// browser process.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_web_plugin_capi.h">cef/include/capi/cef_web_plugin_capi.h</see>.
        /// </remarks>
        public static void UnregisterInternalWebPlugin(string path)
        {
            var path_pinned = new PinnedString(path);

            CfxApi.cfx_unregister_internal_web_plugin(path_pinned.Obj.PinnedPtr, path_pinned.Length);
            path_pinned.Obj.Free();
        }
        /// <summary>
        /// Attempts to resolve |origin| to a list of associated IP addresses.
        /// |callback| will be executed on the UI thread after completion.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_request_context_capi.h">cef/include/capi/cef_request_context_capi.h</see>.
        /// </remarks>
        public void ResolveHost(string origin, CfxResolveCallback callback)
        {
            var origin_pinned = new PinnedString(origin);

            CfxApi.RequestContext.cfx_request_context_resolve_host(NativePtr, origin_pinned.Obj.PinnedPtr, origin_pinned.Length, CfxResolveCallback.Unwrap(callback));
            origin_pinned.Obj.Free();
        }
Exemple #18
0
        /// <summary>
        /// Load the specified |url|.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_frame_capi.h">cef/include/capi/cef_frame_capi.h</see>.
        /// </remarks>
        public void LoadUrl(string url)
        {
            var url_pinned = new PinnedString(url);

            CfxApi.Frame.cfx_frame_load_url(NativePtr, url_pinned.Obj.PinnedPtr, url_pinned.Length);
            url_pinned.Obj.Free();
        }
        /// <summary>
        /// Load an extension.
        ///
        /// If extension resources will be read from disk using the default load
        /// implementation then |rootDirectory| should be the absolute path to the
        /// extension resources directory and |manifest| should be NULL. If extension
        /// resources will be provided by the client (e.g. via CfxRequestHandler
        /// and/or CfxExtensionHandler) then |rootDirectory| should be a path
        /// component unique to the extension (if not absolute this will be internally
        /// prefixed with the PK_DIR_RESOURCES path) and |manifest| should contain the
        /// contents that would otherwise be read from the "manifest.json" file on
        /// disk.
        ///
        /// The loaded extension will be accessible in all contexts sharing the same
        /// storage (HasExtension returns true (1)). However, only the context on which
        /// this function was called is considered the loader (DidLoadExtension returns
        /// true (1)) and only the loader will receive CfxRequestContextHandler
        /// callbacks for the extension.
        ///
        /// CfxExtensionHandler.OnExtensionLoaded will be called on load success or
        /// CfxExtensionHandler.OnExtensionLoadFailed will be called on load
        /// failure.
        ///
        /// If the extension specifies a background script via the "background"
        /// manifest key then CfxExtensionHandler.OnBeforeBackgroundBrowser will be
        /// called to create the background browser. See that function for additional
        /// information about background scripts.
        ///
        /// For visible extension views the client application should evaluate the
        /// manifest to determine the correct extension URL to load and then pass that
        /// URL to the CfxBrowserHost.CreateBrowser* function after the extension
        /// has loaded. For example, the client can look for the "browser_action"
        /// manifest key as documented at
        /// https://developer.chrome.com/extensions/browserAction. Extension URLs take
        /// the form "chrome-extension://&lt;extension_id>/&lt;path>".
        ///
        /// Browsers that host extensions differ from normal browsers as follows:
        ///  - Can access chrome.* JavaScript APIs if allowed by the manifest. Visit
        ///    chrome://extensions-support for the list of extension APIs currently
        ///    supported by CEF.
        ///  - Main frame navigation to non-extension content is blocked.
        ///  - Pinch-zooming is disabled.
        ///  - CfxBrowserHost.GetExtension returns the hosted extension.
        ///  - CfxBrowserHost.IsBackgroundHost returns true for background hosts.
        ///
        /// See https://developer.chrome.com/extensions for extension implementation
        /// and usage documentation.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_request_context_capi.h">cef/include/capi/cef_request_context_capi.h</see>.
        /// </remarks>
        public void LoadExtension(string rootDirectory, CfxDictionaryValue manifest, CfxExtensionHandler handler)
        {
            var rootDirectory_pinned = new PinnedString(rootDirectory);

            CfxApi.RequestContext.cfx_request_context_load_extension(NativePtr, rootDirectory_pinned.Obj.PinnedPtr, rootDirectory_pinned.Length, CfxDictionaryValue.Unwrap(manifest), CfxExtensionHandler.Unwrap(handler));
            rootDirectory_pinned.Obj.Free();
        }
        /// <summary>
        /// Download the file at |url| using CfxDownloadHandler.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_browser_capi.h">cef/include/capi/cef_browser_capi.h</see>.
        /// </remarks>
        public void StartDownload(string url)
        {
            var url_pinned = new PinnedString(url);

            CfxApi.BrowserHost.cfx_browser_host_start_download(NativePtr, url_pinned.Obj.PinnedPtr, url_pinned.Length);
            url_pinned.Obj.Free();
        }
Exemple #21
0
        internal static void get_response_headers(IntPtr gcHandlePtr, IntPtr response, out int response_release, out long response_length, out IntPtr redirectUrl_str, out int redirectUrl_length, out IntPtr redirectUrl_gc_handle)
        {
            var self = (CfxResourceHandler)System.Runtime.InteropServices.GCHandle.FromIntPtr(gcHandlePtr).Target;

            if (self == null || self.CallbacksDisabled)
            {
                response_release      = 1;
                response_length       = default(long);
                redirectUrl_str       = IntPtr.Zero;
                redirectUrl_length    = 0;
                redirectUrl_gc_handle = IntPtr.Zero;
                return;
            }
            var e = new CfxGetResponseHeadersEventArgs(response);

            self.m_GetResponseHeaders?.Invoke(self, e);
            e.m_isInvalid    = true;
            response_release = e.m_response_wrapped == null? 1 : 0;
            response_length  = e.m_response_length;
            if (e.m_redirectUrl_wrapped != null && e.m_redirectUrl_wrapped.Length > 0)
            {
                var redirectUrl_pinned = new PinnedString(e.m_redirectUrl_wrapped);
                redirectUrl_str       = redirectUrl_pinned.Obj.PinnedPtr;
                redirectUrl_length    = redirectUrl_pinned.Length;
                redirectUrl_gc_handle = redirectUrl_pinned.Obj.GCHandlePtr();
            }
            else
            {
                redirectUrl_str       = IntPtr.Zero;
                redirectUrl_length    = 0;
                redirectUrl_gc_handle = IntPtr.Zero;
            }
        }
        /// <summary>
        /// Returns the value associated with the given switch. If the switch has no
        /// value or isn't present this function returns the NULL string.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_command_line_capi.h">cef/include/capi/cef_command_line_capi.h</see>.
        /// </remarks>
        public string GetSwitchValue(string name)
        {
            var name_pinned = new PinnedString(name);
            var __retval    = CfxApi.CommandLine.cfx_command_line_get_switch_value(NativePtr, name_pinned.Obj.PinnedPtr, name_pinned.Length);

            name_pinned.Obj.Free();
            return(StringFunctions.ConvertStringUserfree(__retval));
        }
Exemple #23
0
        /// <summary>
        /// Parse the specified |url| into its component parts. Returns false (0) if the
        /// URL is NULL or invalid.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_parser_capi.h">cef/include/capi/cef_parser_capi.h</see>.
        /// </remarks>
        public static bool ParseUrl(string url, CfxUrlParts parts)
        {
            var url_pinned = new PinnedString(url);
            var __retval   = CfxApi.cfx_parse_url(url_pinned.Obj.PinnedPtr, url_pinned.Length, CfxUrlParts.Unwrap(parts));

            url_pinned.Obj.Free();
            return(0 != __retval);
        }
Exemple #24
0
        /// <summary>
        /// Escapes characters in |text| which are unsuitable for use as a query
        /// parameter value. Everything except alphanumerics and -_.!~*'() will be
        /// converted to "%XX". If |usePlus| is true (1) spaces will change to "+". The
        /// result is basically the same as encodeURIComponent in Javacript.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_parser_capi.h">cef/include/capi/cef_parser_capi.h</see>.
        /// </remarks>
        public static string UriEncode(string text, bool usePlus)
        {
            var text_pinned = new PinnedString(text);
            var __retval    = CfxApi.cfx_uriencode(text_pinned.Obj.PinnedPtr, text_pinned.Length, usePlus ? 1 : 0);

            text_pinned.Obj.Free();
            return(StringFunctions.ConvertStringUserfree(__retval));
        }
Exemple #25
0
        /// <summary>
        /// Unescapes |text| and returns the result. Unescaping consists of looking for
        /// the exact pattern "%XX" where each X is a hex digit and converting to the
        /// character with the numerical value of those digits (e.g. "i%20=%203%3b"
        /// unescapes to "i = 3;"). If |convertToUtf8| is true (1) this function will
        /// attempt to interpret the initial decoded result as UTF-8. If the result is
        /// convertable into UTF-8 it will be returned as converted. Otherwise the
        /// initial decoded result will be returned.  The |unescapeRule| parameter
        /// supports further customization the decoding process.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_parser_capi.h">cef/include/capi/cef_parser_capi.h</see>.
        /// </remarks>
        public static string UriDecode(string text, bool convertToUtf8, CfxUriUnescapeRule unescapeRule)
        {
            var text_pinned = new PinnedString(text);
            var __retval    = CfxApi.cfx_uridecode(text_pinned.Obj.PinnedPtr, text_pinned.Length, convertToUtf8 ? 1 : 0, (int)unescapeRule);

            text_pinned.Obj.Free();
            return(StringFunctions.ConvertStringUserfree(__retval));
        }
Exemple #26
0
        /// <summary>
        /// Returns the mime type for the specified file extension or an NULL string if
        /// unknown.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_parser_capi.h">cef/include/capi/cef_parser_capi.h</see>.
        /// </remarks>
        public static string GetMimeType(string extension)
        {
            var extension_pinned = new PinnedString(extension);
            var __retval         = CfxApi.cfx_get_mime_type(extension_pinned.Obj.PinnedPtr, extension_pinned.Length);

            extension_pinned.Obj.Free();
            return(StringFunctions.ConvertStringUserfree(__retval));
        }
Exemple #27
0
        /// <summary>
        /// Parses the specified |jsonString| and returns a dictionary or list
        /// representation. If JSON parsing fails this function returns NULL.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_parser_capi.h">cef/include/capi/cef_parser_capi.h</see>.
        /// </remarks>
        public static CfxValue ParseJson(string jsonString, CfxJsonParserOptions options)
        {
            var jsonString_pinned = new PinnedString(jsonString);
            var __retval          = CfxApi.cfx_parse_json(jsonString_pinned.Obj.PinnedPtr, jsonString_pinned.Length, (int)options);

            jsonString_pinned.Obj.Free();
            return(CfxValue.Wrap(__retval));
        }
Exemple #28
0
        /// <summary>
        /// Stop tracing events on all processes.
        /// This function will fail and return false (0) if a previous call to
        /// CfxEndTracingAsync is already pending or if CfxBeginTracing was not called.
        /// |tracingFile| is the path at which tracing data will be written and
        /// |callback| is the callback that will be executed once all processes have sent
        /// their trace data. If |tracingFile| is NULL a new temporary file path will be
        /// used. If |callback| is NULL no trace data will be written.
        /// This function must be called on the browser process UI thread.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_trace_capi.h">cef/include/capi/cef_trace_capi.h</see>.
        /// </remarks>
        public static bool EndTracing(string tracingFile, CfxEndTracingCallback callback)
        {
            var tracingFile_pinned = new PinnedString(tracingFile);
            var __retval           = CfxApi.cfx_end_tracing(tracingFile_pinned.Obj.PinnedPtr, tracingFile_pinned.Length, CfxEndTracingCallback.Unwrap(callback));

            tracingFile_pinned.Obj.Free();
            return(0 != __retval);
        }
Exemple #29
0
        /// <summary>
        /// This is a convenience function for formatting a URL in a concise and human-
        /// friendly way to help users make security-related decisions (or in other
        /// circumstances when people need to distinguish sites, origins, or otherwise-
        /// simplified URLs from each other). Internationalized domain names (IDN) may be
        /// presented in Unicode if the conversion is considered safe. The returned value
        /// will (a) omit the path for standard schemes, excepting file and filesystem,
        /// and (b) omit the port if it is the default for the scheme. Do not use this
        /// for URLs which will be parsed or sent to other applications.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_parser_capi.h">cef/include/capi/cef_parser_capi.h</see>.
        /// </remarks>
        public static string FormatUrlForSecurityDisplay(string originUrl)
        {
            var originUrl_pinned = new PinnedString(originUrl);
            var __retval         = CfxApi.cfx_format_url_for_security_display(originUrl_pinned.Obj.PinnedPtr, originUrl_pinned.Length);

            originUrl_pinned.Obj.Free();
            return(StringFunctions.ConvertStringUserfree(__retval));
        }
        /// <summary>
        /// Returns true (1) if the command line contains the given switch.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_command_line_capi.h">cef/include/capi/cef_command_line_capi.h</see>.
        /// </remarks>
        public bool HasSwitch(string name)
        {
            var name_pinned = new PinnedString(name);
            var __retval    = CfxApi.CommandLine.cfx_command_line_has_switch(NativePtr, name_pinned.Obj.PinnedPtr, name_pinned.Length);

            name_pinned.Obj.Free();
            return(0 != __retval);
        }
Exemple #31
0
 internal static void CfxStringListCopyToNative(List<string> source, IntPtr target, out PinnedString[] handles)
 {
     handles = new PinnedString[source.Count];
     var ih = 0;
     CfxApi.cfx_string_list_clear(target);
     foreach(var str in source) {
         var hValue = new PinnedString(str);
         CfxApi.cfx_string_list_append(target, hValue.Obj.PinnedPtr, hValue.Length);
         handles[ih++] = hValue;
     }
 }
Exemple #32
0
 /// <summary>
 /// Creates a new cookie manager. If |path| is NULL 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
 /// |persistSessionCookies| to true (1). 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>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_cookie_capi.h">cef/include/capi/cef_cookie_capi.h</see>.
 /// </remarks>
 public static CfxCookieManager CreateManager(string path, bool persistSessionCookies, CfxCompletionCallback callback)
 {
     var path_pinned = new PinnedString(path);
     var __retval = CfxApi.cfx_cookie_manager_create_manager(path_pinned.Obj.PinnedPtr, path_pinned.Length, persistSessionCookies ? 1 : 0, CfxCompletionCallback.Unwrap(callback));
     path_pinned.Obj.Free();
     return CfxCookieManager.Wrap(__retval);
 }
Exemple #33
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 (1)
 /// 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 (0) if cookies cannot be accessed.
 /// </summary>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_cookie_capi.h">cef/include/capi/cef_cookie_capi.h</see>.
 /// </remarks>
 public bool VisitUrlCookies(string url, bool includeHttpOnly, CfxCookieVisitor visitor)
 {
     var url_pinned = new PinnedString(url);
     var __retval = CfxApi.cfx_cookie_manager_visit_url_cookies(NativePtr, url_pinned.Obj.PinnedPtr, url_pinned.Length, includeHttpOnly ? 1 : 0, CfxCookieVisitor.Unwrap(visitor));
     url_pinned.Obj.Free();
     return 0 != __retval;
 }
Exemple #34
0
 /// <summary>
 /// Sets the directory path that will be used for storing cookie data. If
 /// |path| is NULL 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 |persistSessionCookies| to true
 /// (1). 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 (0) if cookies cannot be accessed.
 /// </summary>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_cookie_capi.h">cef/include/capi/cef_cookie_capi.h</see>.
 /// </remarks>
 public bool SetStoragePath(string path, bool persistSessionCookies, CfxCompletionCallback callback)
 {
     var path_pinned = new PinnedString(path);
     var __retval = CfxApi.cfx_cookie_manager_set_storage_path(NativePtr, path_pinned.Obj.PinnedPtr, path_pinned.Length, persistSessionCookies ? 1 : 0, CfxCompletionCallback.Unwrap(callback));
     path_pinned.Obj.Free();
     return 0 != __retval;
 }
Exemple #35
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 (0) if an invalid URL is specified or if cookies cannot be accessed.
 /// </summary>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_cookie_capi.h">cef/include/capi/cef_cookie_capi.h</see>.
 /// </remarks>
 public bool SetCookie(string url, CfxCookie cookie, CfxSetCookieCallback callback)
 {
     var url_pinned = new PinnedString(url);
     var __retval = CfxApi.cfx_cookie_manager_set_cookie(NativePtr, url_pinned.Obj.PinnedPtr, url_pinned.Length, CfxCookie.Unwrap(cookie), CfxSetCookieCallback.Unwrap(callback));
     url_pinned.Obj.Free();
     return 0 != __retval;
 }
Exemple #36
0
 /// <summary>
 /// Continue the JS dialog request. Set |success| to true (1) if the OK button
 /// was pressed. The |userInput| value should be specified for prompt dialogs.
 /// </summary>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_jsdialog_handler_capi.h">cef/include/capi/cef_jsdialog_handler_capi.h</see>.
 /// </remarks>
 public void Continue(bool success, string userInput)
 {
     var userInput_pinned = new PinnedString(userInput);
     CfxApi.cfx_jsdialog_callback_cont(NativePtr, success ? 1 : 0, userInput_pinned.Obj.PinnedPtr, userInput_pinned.Length);
     userInput_pinned.Obj.Free();
 }
Exemple #37
0
 /// <summary>
 /// Create a new CfxXmlReader object. The returned object's functions can
 /// only be called from the thread that created the object.
 /// </summary>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_xml_reader_capi.h">cef/include/capi/cef_xml_reader_capi.h</see>.
 /// </remarks>
 public static CfxXmlReader Create(CfxStreamReader stream, CfxXmlEncodingType encodingType, string uri)
 {
     var uri_pinned = new PinnedString(uri);
     var __retval = CfxApi.cfx_xml_reader_create(CfxStreamReader.Unwrap(stream), (int)encodingType, uri_pinned.Obj.PinnedPtr, uri_pinned.Length);
     uri_pinned.Obj.Free();
     return CfxXmlReader.Wrap(__retval);
 }
Exemple #38
0
        // used in api calls to set and get data
        internal static IntPtr UnwrapCfxStringList(List<string> list, out PinnedString[] handles)
        {
            var target = CfxApi.cfx_string_list_alloc();
            if(target == IntPtr.Zero)
                throw new OutOfMemoryException();

            CfxStringListCopyToNative(list, target, out handles);
            return target;
        }
Exemple #39
0
 /// <summary>
 /// Set the value for the element attribute named |attrName|. Returns true (1)
 /// on success.
 /// </summary>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_dom_capi.h">cef/include/capi/cef_dom_capi.h</see>.
 /// </remarks>
 public bool SetElementAttribute(string attrName, string value)
 {
     var attrName_pinned = new PinnedString(attrName);
     var value_pinned = new PinnedString(value);
     var __retval = CfxApi.cfx_domnode_set_element_attribute(NativePtr, attrName_pinned.Obj.PinnedPtr, attrName_pinned.Length, value_pinned.Obj.PinnedPtr, value_pinned.Length);
     attrName_pinned.Obj.Free();
     value_pinned.Obj.Free();
     return 0 != __retval;
 }
Exemple #40
0
 /// <summary>
 /// Returns the element attribute named |attrName|.
 /// </summary>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_dom_capi.h">cef/include/capi/cef_dom_capi.h</see>.
 /// </remarks>
 public string GetElementAttribute(string attrName)
 {
     var attrName_pinned = new PinnedString(attrName);
     var __retval = CfxApi.cfx_domnode_get_element_attribute(NativePtr, attrName_pinned.Obj.PinnedPtr, attrName_pinned.Length);
     attrName_pinned.Obj.Free();
     return StringFunctions.ConvertStringUserfree(__retval);
 }
Exemple #41
0
 internal static void set(IntPtr gcHandlePtr, out int __retval, IntPtr name_str, int name_length, IntPtr @object, IntPtr value, ref IntPtr exception_str, ref int exception_length)
 {
     var self = (CfxV8Accessor)System.Runtime.InteropServices.GCHandle.FromIntPtr(gcHandlePtr).Target;
     if(self == null) {
         __retval = default(int);
         return;
     }
     var e = new CfxV8AccessorSetEventArgs(name_str, name_length, @object, value, exception_str, exception_length);
     var eventHandler = self.m_Set;
     if(eventHandler != null) eventHandler(self, e);
     e.m_isInvalid = true;
     if(e.m_object_wrapped == null) CfxApi.cfx_release(e.m_object);
     if(e.m_value_wrapped == null) CfxApi.cfx_release(e.m_value);
     if(e.m_exception_changed) {
         var exception_pinned = new PinnedString(e.m_exception_wrapped);
         exception_str = exception_pinned.Obj.PinnedPtr;
         exception_length = exception_pinned.Length;
     }
     __retval = e.m_returnValue ? 1 : 0;
 }
Exemple #42
0
 /// <summary>
 /// Moves the cursor to the attribute with the specified local name and
 /// namespace URI. Returns true (1) if the cursor position was set
 /// successfully.
 /// </summary>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_xml_reader_capi.h">cef/include/capi/cef_xml_reader_capi.h</see>.
 /// </remarks>
 public bool MoveToAttribute(string localName, string namespaceURI)
 {
     var localName_pinned = new PinnedString(localName);
     var namespaceURI_pinned = new PinnedString(namespaceURI);
     var __retval = CfxApi.cfx_xml_reader_move_to_attribute_bylname(NativePtr, localName_pinned.Obj.PinnedPtr, localName_pinned.Length, namespaceURI_pinned.Obj.PinnedPtr, namespaceURI_pinned.Length);
     localName_pinned.Obj.Free();
     namespaceURI_pinned.Obj.Free();
     return 0 != __retval;
 }
Exemple #43
0
 /// <summary>
 /// Moves the cursor to the attribute with the specified qualified name.
 /// Returns true (1) if the cursor position was set successfully.
 /// </summary>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_xml_reader_capi.h">cef/include/capi/cef_xml_reader_capi.h</see>.
 /// </remarks>
 public bool MoveToAttribute(string qualifiedName)
 {
     var qualifiedName_pinned = new PinnedString(qualifiedName);
     var __retval = CfxApi.cfx_xml_reader_move_to_attribute_byqname(NativePtr, qualifiedName_pinned.Obj.PinnedPtr, qualifiedName_pinned.Length);
     qualifiedName_pinned.Obj.Free();
     return 0 != __retval;
 }
Exemple #44
0
 /// <summary>
 /// Returns the value of the attribute with the specified local name and
 /// namespace URI.
 /// </summary>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_xml_reader_capi.h">cef/include/capi/cef_xml_reader_capi.h</see>.
 /// </remarks>
 public string GetAttribute(string localName, string namespaceURI)
 {
     var localName_pinned = new PinnedString(localName);
     var namespaceURI_pinned = new PinnedString(namespaceURI);
     var __retval = CfxApi.cfx_xml_reader_get_attribute_bylname(NativePtr, localName_pinned.Obj.PinnedPtr, localName_pinned.Length, namespaceURI_pinned.Obj.PinnedPtr, namespaceURI_pinned.Length);
     localName_pinned.Obj.Free();
     namespaceURI_pinned.Obj.Free();
     return StringFunctions.ConvertStringUserfree(__retval);
 }
Exemple #45
0
 /// <summary>
 /// Returns the value of the attribute with the specified qualified name.
 /// </summary>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_xml_reader_capi.h">cef/include/capi/cef_xml_reader_capi.h</see>.
 /// </remarks>
 public string GetAttribute(string qualifiedName)
 {
     var qualifiedName_pinned = new PinnedString(qualifiedName);
     var __retval = CfxApi.cfx_xml_reader_get_attribute_byqname(NativePtr, qualifiedName_pinned.Obj.PinnedPtr, qualifiedName_pinned.Length);
     qualifiedName_pinned.Obj.Free();
     return StringFunctions.ConvertStringUserfree(__retval);
 }
Exemple #46
0
 internal static void CfxStringMultimapCopyToNative(List<string[]> source, IntPtr target, out PinnedString[] handles)
 {
     handles = new PinnedString[source.Count * 2];
     var ih = 0;
     CfxApi.cfx_string_multimap_clear(target);
     foreach(var pair in source) {
         var hKey = new PinnedString(pair[0]);
         var hValue = new PinnedString(pair[1]);
         if(CfxApi.cfx_string_multimap_append(target, hKey.Obj.PinnedPtr, hKey.Length, hValue.Obj.PinnedPtr, hValue.Length) == 0)
             throw new CfxException("CfxStringMultimap operation failed.");
         handles[ih++] = hKey;
         handles[ih++] = hValue;
     }
 }
Exemple #47
0
 internal static void FreePinnedStrings(PinnedString[] handles)
 {
     foreach(var h in handles) h.Obj.Free();
 }
Exemple #48
0
 /// <summary>
 /// Attempts to resolve |origin| to a list of associated IP addresses using
 /// cached data. |resolvedIps| will be populated with the list of resolved IP
 /// addresses or NULL if no cached data is available. Returns ERR_NONE on
 /// success. This function must be called on the browser process IO thread.
 /// </summary>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_request_context_capi.h">cef/include/capi/cef_request_context_capi.h</see>.
 /// </remarks>
 public CfxErrorCode ResolveHostCached(string origin, System.Collections.Generic.List<string> resolvedIps)
 {
     var origin_pinned = new PinnedString(origin);
     PinnedString[] resolvedIps_handles;
     var resolvedIps_unwrapped = StringFunctions.UnwrapCfxStringList(resolvedIps, out resolvedIps_handles);
     var __retval = CfxApi.cfx_request_context_resolve_host_cached(NativePtr, origin_pinned.Obj.PinnedPtr, origin_pinned.Length, resolvedIps_unwrapped);
     origin_pinned.Obj.Free();
     StringFunctions.FreePinnedStrings(resolvedIps_handles);
     StringFunctions.CfxStringListCopyToManaged(resolvedIps_unwrapped, resolvedIps);
     CfxApi.cfx_string_list_free(resolvedIps_unwrapped);
     return (CfxErrorCode)__retval;
 }
Exemple #49
0
        //unused
        //internal static List<string[]> WrapCfxStringMultimap(IntPtr value) {
        //    return null;
        //}
        // used in api calls to set and get data
        internal static IntPtr UnwrapCfxStringMultimap(List<string[]> map, out PinnedString[] handles)
        {
            var target = CfxApi.cfx_string_multimap_alloc();
            if(target == IntPtr.Zero)
                throw new OutOfMemoryException();

            CfxStringMultimapCopyToNative(map, target, out handles);
            return target;
        }
Exemple #50
0
 /// <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 NULL to show the
 /// default title ("Open" or "Save" depending on the mode). |defaultFilePath|
 /// is the path with optional directory and/or file name component that will be
 /// initially selected in the dialog. |acceptFilters| 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").
 /// |selectedAcceptFilter| 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>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_browser_capi.h">cef/include/capi/cef_browser_capi.h</see>.
 /// </remarks>
 public void RunFileDialog(CfxFileDialogMode mode, string title, string defaultFilePath, System.Collections.Generic.List<string> acceptFilters, int selectedAcceptFilter, CfxRunFileDialogCallback callback)
 {
     var title_pinned = new PinnedString(title);
     var defaultFilePath_pinned = new PinnedString(defaultFilePath);
     PinnedString[] acceptFilters_handles;
     var acceptFilters_unwrapped = StringFunctions.UnwrapCfxStringList(acceptFilters, out acceptFilters_handles);
     CfxApi.cfx_browser_host_run_file_dialog(NativePtr, (int)mode, title_pinned.Obj.PinnedPtr, title_pinned.Length, defaultFilePath_pinned.Obj.PinnedPtr, defaultFilePath_pinned.Length, acceptFilters_unwrapped, selectedAcceptFilter, CfxRunFileDialogCallback.Unwrap(callback));
     title_pinned.Obj.Free();
     defaultFilePath_pinned.Obj.Free();
     StringFunctions.FreePinnedStrings(acceptFilters_handles);
     StringFunctions.CfxStringListCopyToManaged(acceptFilters_unwrapped, acceptFilters);
     CfxApi.cfx_string_list_free(acceptFilters_unwrapped);
 }
Exemple #51
0
 /// <summary>
 /// Register a scheme handler factory for the specified |schemeName| and
 /// optional |domainName|. An NULL |domainName| value for a standard scheme
 /// will cause the factory to match all domain names. The |domainName| value
 /// will be ignored for non-standard schemes. If |schemeName| is a built-in
 /// scheme and no handler is returned by |factory| then the built-in scheme
 /// handler factory will be called. If |schemeName| is a custom scheme then
 /// you must also implement the CfxApp.OnRegisterCustomSchemes()
 /// function in all processes. This function may be called multiple times to
 /// change or remove the factory that matches the specified |schemeName| and
 /// optional |domainName|. Returns false (0) if an error occurs. This function
 /// may be called on any thread in the browser process.
 /// </summary>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_request_context_capi.h">cef/include/capi/cef_request_context_capi.h</see>.
 /// </remarks>
 public bool RegisterSchemeHandlerFactory(string schemeName, string domainName, CfxSchemeHandlerFactory factory)
 {
     var schemeName_pinned = new PinnedString(schemeName);
     var domainName_pinned = new PinnedString(domainName);
     var __retval = CfxApi.cfx_request_context_register_scheme_handler_factory(NativePtr, schemeName_pinned.Obj.PinnedPtr, schemeName_pinned.Length, domainName_pinned.Obj.PinnedPtr, domainName_pinned.Length, CfxSchemeHandlerFactory.Unwrap(factory));
     schemeName_pinned.Obj.Free();
     domainName_pinned.Obj.Free();
     return 0 != __retval;
 }
Exemple #52
0
 /// <summary>
 /// Attempts to resolve |origin| to a list of associated IP addresses.
 /// |callback| will be executed on the UI thread after completion.
 /// </summary>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_request_context_capi.h">cef/include/capi/cef_request_context_capi.h</see>.
 /// </remarks>
 public void ResolveHost(string origin, CfxResolveCallback callback)
 {
     var origin_pinned = new PinnedString(origin);
     CfxApi.cfx_request_context_resolve_host(NativePtr, origin_pinned.Obj.PinnedPtr, origin_pinned.Length, CfxResolveCallback.Unwrap(callback));
     origin_pinned.Obj.Free();
 }
Exemple #53
0
 /// <summary>
 /// Returns the value for the preference with the specified |name|. Returns
 /// NULL if the preference does not exist. The returned object contains a copy
 /// of the underlying preference value and modifications to the returned object
 /// will not modify the underlying preference value. This function must be
 /// called on the browser process UI thread.
 /// </summary>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_request_context_capi.h">cef/include/capi/cef_request_context_capi.h</see>.
 /// </remarks>
 public CfxValue GetPreference(string name)
 {
     var name_pinned = new PinnedString(name);
     var __retval = CfxApi.cfx_request_context_get_preference(NativePtr, name_pinned.Obj.PinnedPtr, name_pinned.Length);
     name_pinned.Obj.Free();
     return CfxValue.Wrap(__retval);
 }
Exemple #54
0
 /// <summary>
 /// Returns true (1) if a preference with the specified |name| exists. This
 /// function must be called on the browser process UI thread.
 /// </summary>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_request_context_capi.h">cef/include/capi/cef_request_context_capi.h</see>.
 /// </remarks>
 public bool HasPreference(string name)
 {
     var name_pinned = new PinnedString(name);
     var __retval = CfxApi.cfx_request_context_has_preference(NativePtr, name_pinned.Obj.PinnedPtr, name_pinned.Length);
     name_pinned.Obj.Free();
     return 0 != __retval;
 }
Exemple #55
0
 /// <summary>
 /// Set the value of this node. Returns true (1) on success.
 /// </summary>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_dom_capi.h">cef/include/capi/cef_dom_capi.h</see>.
 /// </remarks>
 public bool SetValue(string value)
 {
     var value_pinned = new PinnedString(value);
     var __retval = CfxApi.cfx_domnode_set_value(NativePtr, value_pinned.Obj.PinnedPtr, value_pinned.Length);
     value_pinned.Obj.Free();
     return 0 != __retval;
 }
Exemple #56
0
 internal static void on_resource_redirect(IntPtr gcHandlePtr, IntPtr browser, IntPtr frame, IntPtr request, ref IntPtr new_url_str, ref int new_url_length)
 {
     var self = (CfxRequestHandler)System.Runtime.InteropServices.GCHandle.FromIntPtr(gcHandlePtr).Target;
     if(self == null) {
         return;
     }
     var e = new CfxOnResourceRedirectEventArgs(browser, frame, request, new_url_str, new_url_length);
     var eventHandler = self.m_OnResourceRedirect;
     if(eventHandler != null) eventHandler(self, e);
     e.m_isInvalid = true;
     if(e.m_browser_wrapped == null) CfxApi.cfx_release(e.m_browser);
     if(e.m_frame_wrapped == null) CfxApi.cfx_release(e.m_frame);
     if(e.m_request_wrapped == null) CfxApi.cfx_release(e.m_request);
     if(e.m_new_url_changed) {
         var new_url_pinned = new PinnedString(e.m_new_url_wrapped);
         new_url_str = new_url_pinned.Obj.PinnedPtr;
         new_url_length = new_url_pinned.Length;
     }
 }
Exemple #57
0
 /// <summary>
 /// Sets the value at the specified index as type string. Returns true (1) if
 /// the value was set successfully.
 /// </summary>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_values_capi.h">cef/include/capi/cef_values_capi.h</see>.
 /// </remarks>
 public bool SetString(int index, string value)
 {
     var value_pinned = new PinnedString(value);
     var __retval = CfxApi.cfx_list_value_set_string(NativePtr, index, value_pinned.Obj.PinnedPtr, value_pinned.Length);
     value_pinned.Obj.Free();
     return 0 != __retval;
 }
Exemple #58
0
 /// <summary>
 /// Delete all cookies that match the specified parameters. If both |url| and
 /// |cookieName| 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 NULL 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 (0) if a non-NULL invalid URL is specified
 /// or if cookies cannot be accessed. Cookies can alternately be deleted using
 /// the Visit*Cookies() functions.
 /// </summary>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_cookie_capi.h">cef/include/capi/cef_cookie_capi.h</see>.
 /// </remarks>
 public bool DeleteCookies(string url, string cookieName, CfxDeleteCookiesCallback callback)
 {
     var url_pinned = new PinnedString(url);
     var cookieName_pinned = new PinnedString(cookieName);
     var __retval = CfxApi.cfx_cookie_manager_delete_cookies(NativePtr, url_pinned.Obj.PinnedPtr, url_pinned.Length, cookieName_pinned.Obj.PinnedPtr, cookieName_pinned.Length, CfxDeleteCookiesCallback.Unwrap(callback));
     url_pinned.Obj.Free();
     cookieName_pinned.Obj.Free();
     return 0 != __retval;
 }
Exemple #59
0
 /// <summary>
 /// Set the |value| associated with preference |name|. Returns true (1) if the
 /// value is set successfully and false (0) otherwise. If |value| is NULL the
 /// preference will be restored to its default value. If setting the preference
 /// fails then |error| will be populated with a detailed description of the
 /// problem. This function must be called on the browser process UI thread.
 /// </summary>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_request_context_capi.h">cef/include/capi/cef_request_context_capi.h</see>.
 /// </remarks>
 public bool SetPreference(string name, CfxValue value, ref string error)
 {
     var name_pinned = new PinnedString(name);
     var error_pinned = new PinnedString(error);
     IntPtr error_str = error_pinned.Obj.PinnedPtr;
     int error_length = error_pinned.Length;
     var __retval = CfxApi.cfx_request_context_set_preference(NativePtr, name_pinned.Obj.PinnedPtr, name_pinned.Length, CfxValue.Unwrap(value), ref error_str, ref error_length);
     name_pinned.Obj.Free();
     if(error_str != error_pinned.Obj.PinnedPtr) {
         if(error_length > 0) {
             error = System.Runtime.InteropServices.Marshal.PtrToStringUni(error_str, error_length);
             // free the native string?
         } else {
             error = null;
         }
     }
     error_pinned.Obj.Free();
     return 0 != __retval;
 }
Exemple #60
0
 /// <summary>
 /// Download the file at |url| using CfxDownloadHandler.
 /// </summary>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_browser_capi.h">cef/include/capi/cef_browser_capi.h</see>.
 /// </remarks>
 public void StartDownload(string url)
 {
     var url_pinned = new PinnedString(url);
     CfxApi.cfx_browser_host_start_download(NativePtr, url_pinned.Obj.PinnedPtr, url_pinned.Length);
     url_pinned.Obj.Free();
 }