Пример #1
0
        /// <summary>
        /// Returns true (1) if this object is pointing to the same task runner as
        /// |that| object.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_task_capi.h">cef/include/capi/cef_task_capi.h</see>.
        /// </remarks>
        public bool IsSame(CfrTaskRunner that)
        {
            var connection = RemotePtr.connection;
            var call       = new CfxTaskRunnerIsSameRemoteCall();

            call.@this = RemotePtr.ptr;
            if (!CfrObject.CheckConnection(that, connection))
            {
                throw new ArgumentException("Render process connection mismatch.", "that");
            }
            call.that = CfrObject.Unwrap(that).ptr;
            call.RequestExecution(connection);
            return(call.__retval);
        }
Пример #2
0
        /// <summary>
        /// Post a task for execution on the thread associated with this task runner.
        /// Execution will occur asynchronously.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_task_capi.h">cef/include/capi/cef_task_capi.h</see>.
        /// </remarks>
        public bool PostTask(CfrTask task)
        {
            var connection = RemotePtr.connection;
            var call       = new CfxTaskRunnerPostTaskRemoteCall();

            call.@this = RemotePtr.ptr;
            if (!CfrObject.CheckConnection(task, connection))
            {
                throw new ArgumentException("Render process connection mismatch.", "task");
            }
            call.task = CfrObject.Unwrap(task).ptr;
            call.RequestExecution(connection);
            return(call.__retval);
        }
Пример #3
0
        /// <summary>
        /// Register a new V8 extension with the specified JavaScript extension code and
        /// handler. Functions implemented by the handler are prototyped using the
        /// keyword 'native'. The calling of a native function is restricted to the scope
        /// in which the prototype of the native function is defined. This function may
        /// only be called on the render process main thread.
        ///
        /// Example JavaScript extension code: &lt;pre>
        ///   // create the 'example' global object if it doesn't already exist.
        ///   if (!example)
        ///     example = {};
        ///   // create the 'example.test' global object if it doesn't already exist.
        ///   if (!example.test)
        ///     example.test = {};
        ///   (function() {
        ///     // Define the function 'example.test.myfunction'.
        ///     example.test.myfunction = function() {
        ///       // Call CfrV8Handler.Execute() with the function name 'MyFunction'
        ///       // and no arguments.
        ///       native function MyFunction();
        ///       return MyFunction();
        ///     };
        ///     // Define the getter function for parameter 'example.test.myparam'.
        ///     example.test.__defineGetter__('myparam', function() {
        ///       // Call CfrV8Handler.Execute() with the function name 'GetMyParam'
        ///       // and no arguments.
        ///       native function GetMyParam();
        ///       return GetMyParam();
        ///     });
        ///     // Define the setter function for parameter 'example.test.myparam'.
        ///     example.test.__defineSetter__('myparam', function(b) {
        ///       // Call CfrV8Handler.Execute() with the function name 'SetMyParam'
        ///       // and a single argument.
        ///       native function SetMyParam();
        ///       if(b) SetMyParam(b);
        ///     });
        ///
        ///     // Extension definitions can also contain normal JavaScript variables
        ///     // and functions.
        ///     var myint = 0;
        ///     example.test.increment = function() {
        ///       myint += 1;
        ///       return myint;
        ///     };
        ///   })();
        /// &lt;/pre> Example usage in the page: &lt;pre>
        ///   // Call the function.
        ///   example.test.myfunction();
        ///   // Set the parameter.
        ///   example.test.myparam = value;
        ///   // Get the parameter.
        ///   value = example.test.myparam;
        ///   // Call another function.
        ///   example.test.increment();
        /// &lt;/pre>
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_v8_capi.h">cef/include/capi/cef_v8_capi.h</see>.
        /// </remarks>
        public static bool RegisterExtension(string extensionName, string javascriptCode, CfrV8Handler handler)
        {
            var connection = CfxRemoteCallContext.CurrentContext.connection;
            var call       = new CfxRuntimeRegisterExtensionRemoteCall();

            call.extensionName  = extensionName;
            call.javascriptCode = javascriptCode;
            if (!CfrObject.CheckConnection(handler, connection))
            {
                throw new ArgumentException("Render process connection mismatch.", "handler");
            }
            call.handler = CfrObject.Unwrap(handler).ptr;
            call.RequestExecution(connection);
            return(call.__retval);
        }
Пример #4
0
        /// <summary>
        /// Post a task for execution on the specified thread. Equivalent to using
        /// CfrTaskRunner.GetForThread(threadId).PostTask(task).
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_task_capi.h">cef/include/capi/cef_task_capi.h</see>.
        /// </remarks>
        public static bool PostTask(CfxThreadId threadId, CfrTask task)
        {
            var connection = CfxRemoteCallContext.CurrentContext.connection;
            var call       = new CfxRuntimePostTaskRemoteCall();

            call.threadId = (int)threadId;
            if (!CfrObject.CheckConnection(task, connection))
            {
                throw new ArgumentException("Render process connection mismatch.", "task");
            }
            call.task = CfrObject.Unwrap(task).ptr;
            call.RequestExecution(connection);
            GC.KeepAlive(task);
            return(call.__retval);
        }
Пример #5
0
        /// <summary>
        /// Sets the value at the specified index as type list. Returns true (1) 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>
        /// <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 SetList(ulong index, CfrListValue value)
        {
            var connection = RemotePtr.connection;
            var call       = new CfxListValueSetListRemoteCall();

            call.@this = RemotePtr.ptr;
            call.index = index;
            if (!CfrObject.CheckConnection(value, connection))
            {
                throw new ArgumentException("Render process connection mismatch.", "value");
            }
            call.value = CfrObject.Unwrap(value).ptr;
            call.RequestExecution(connection);
            return(call.__retval);
        }
Пример #6
0
        /// <summary>
        /// Create a new CfrXmlReader 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 CfrXmlReader Create(CfrStreamReader stream, CfxXmlEncodingType encodingType, string uri)
        {
            var connection = CfxRemoteCallContext.CurrentContext.connection;
            var call       = new CfxXmlReaderCreateRemoteCall();

            if (!CfrObject.CheckConnection(stream, connection))
            {
                throw new ArgumentException("Render process connection mismatch.", "stream");
            }
            call.stream       = CfrObject.Unwrap(stream).ptr;
            call.encodingType = (int)encodingType;
            call.uri          = uri;
            call.RequestExecution(connection);
            return(CfrXmlReader.Wrap(new RemotePtr(connection, call.__retval)));
        }
Пример #7
0
        /// <summary>
        /// Send a message to the specified |targetProcess|. Returns true (1) if the
        /// message was sent successfully.
        /// </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 bool SendProcessMessage(CfxProcessId targetProcess, CfrProcessMessage message)
        {
            var connection = RemotePtr.connection;
            var call       = new CfxBrowserSendProcessMessageRemoteCall();

            call.@this         = RemotePtr.ptr;
            call.targetProcess = (int)targetProcess;
            if (!CfrObject.CheckConnection(message, connection))
            {
                throw new ArgumentException("Render process connection mismatch.", "message");
            }
            call.message = CfrObject.Unwrap(message).ptr;
            call.RequestExecution(connection);
            return(call.__retval);
        }
Пример #8
0
        /// <summary>
        /// Create a new server that binds to |address| and |port|. |address| must be a
        /// valid IPv4 or IPv6 address (e.g. 127.0.0.1 or ::1) and |port| must be a port
        /// number outside of the reserved range (e.g. between 1025 and 65535 on most
        /// platforms). |backlog| is the maximum number of pending connections. A new
        /// thread will be created for each CreateServer call (the "dedicated server
        /// thread"). It is therefore recommended to use a different CfrServerHandler
        /// instance for each CreateServer call to avoid thread safety issues in the
        /// CfrServerHandler implementation. The
        /// CfrServerHandler.OnServerCreated function will be called on the
        /// dedicated server thread to report success or failure. See
        /// CfrServerHandler.OnServerCreated documentation for a description of
        /// server lifespan.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_server_capi.h">cef/include/capi/cef_server_capi.h</see>.
        /// </remarks>
        public static void Create(string address, ushort port, int backlog, CfrServerHandler handler)
        {
            var connection = CfxRemoteCallContext.CurrentContext.connection;
            var call       = new CfxServerCreateRemoteCall();

            call.address = address;
            call.port    = port;
            call.backlog = backlog;
            if (!CfrObject.CheckConnection(handler, connection))
            {
                throw new ArgumentException("Render process connection mismatch.", "handler");
            }
            call.handler = CfrObject.Unwrap(handler).ptr;
            call.RequestExecution(connection);
        }
Пример #9
0
        /// <summary>
        /// Sets the value at the specified key as type dict. Returns true (1) 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>
        /// <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 SetDictionary(string key, CfrDictionaryValue value)
        {
            var connection = RemotePtr.connection;
            var call       = new CfxDictionaryValueSetDictionaryRemoteCall();

            call.@this = RemotePtr.ptr;
            call.key   = key;
            if (!CfrObject.CheckConnection(value, connection))
            {
                throw new ArgumentException("Render process connection mismatch.", "value");
            }
            call.value = CfrObject.Unwrap(value).ptr;
            call.RequestExecution(connection);
            return(call.__retval);
        }
Пример #10
0
        /// <summary>
        /// Set all values at one time.
        /// </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 Set(string url, string method, CfrPostData postData, System.Collections.Generic.List <string[]> headerMap)
        {
            var connection = RemotePtr.connection;
            var call       = new CfxRequestSetRemoteCall();

            call.@this  = RemotePtr.ptr;
            call.url    = url;
            call.method = method;
            if (!CfrObject.CheckConnection(postData, connection))
            {
                throw new ArgumentException("Render process connection mismatch.", "postData");
            }
            call.postData  = CfrObject.Unwrap(postData).ptr;
            call.headerMap = headerMap;
            call.RequestExecution(connection);
        }
Пример #11
0
        /// <summary>
        /// Associates a value with the specified identifier and returns true (1) on
        /// success. Returns false (0) if this function is called incorrectly or an
        /// exception is thrown. For read-only values this function will return true
        /// (1) even though assignment failed.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_v8_capi.h">cef/include/capi/cef_v8_capi.h</see>.
        /// </remarks>
        public bool SetValue(string key, CfrV8Value value, CfxV8PropertyAttribute attribute)
        {
            var connection = RemotePtr.connection;
            var call       = new CfxV8ValueSetValueByKeyRemoteCall();

            call.@this = RemotePtr.ptr;
            call.key   = key;
            if (!CfrObject.CheckConnection(value, connection))
            {
                throw new ArgumentException("Render process connection mismatch.", "value");
            }
            call.value     = CfrObject.Unwrap(value).ptr;
            call.attribute = (int)attribute;
            call.RequestExecution(connection);
            return(call.__retval);
        }
Пример #12
0
        /// <summary>
        /// Create a new CfrV8Value object of type object with optional accessor
        /// and/or interceptor. This function should only be called from within the scope
        /// of a CfrRenderProcessHandler, CfrV8Handler or CfrV8Accessor
        /// callback, or in combination with calling enter() and exit() on a stored
        /// CfrV8Context reference.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_v8_capi.h">cef/include/capi/cef_v8_capi.h</see>.
        /// </remarks>
        public static CfrV8Value CreateObject(CfrV8Accessor accessor, CfrV8Interceptor interceptor)
        {
            var connection = CfxRemoteCallContext.CurrentContext.connection;
            var call       = new CfxV8ValueCreateObjectRemoteCall();

            if (!CfrObject.CheckConnection(accessor, connection))
            {
                throw new ArgumentException("Render process connection mismatch.", "accessor");
            }
            call.accessor = CfrObject.Unwrap(accessor).ptr;
            if (!CfrObject.CheckConnection(interceptor, connection))
            {
                throw new ArgumentException("Render process connection mismatch.", "interceptor");
            }
            call.interceptor = CfrObject.Unwrap(interceptor).ptr;
            call.RequestExecution(connection);
            return(CfrV8Value.Wrap(new RemotePtr(connection, call.__retval)));
        }
Пример #13
0
        /// <summary>
        /// Create a new URL request that will be treated as originating from this
        /// frame and the associated browser. This request may be intercepted by the
        /// client via CfrResourceRequestHandler or CfrSchemeHandlerFactory.
        /// Use CfrUrlRequest.Create instead if you do not want the request to have
        /// this association, in which case it may be handled differently (see
        /// documentation on that function). Requests may originate from both the
        /// browser process and the render process.
        ///
        /// For requests originating from the browser process:
        ///   - POST data may only contain a single element of type PDE_TYPE_FILE or
        ///     PDE_TYPE_BYTES.
        /// For requests originating from the render process:
        ///   - POST data may only contain a single element of type PDE_TYPE_BYTES.
        ///   - 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
        /// function.
        /// </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 CfrUrlRequest CreateUrlRequest(CfrRequest request, CfrUrlRequestClient client)
        {
            var connection = RemotePtr.connection;
            var call       = new CfxFrameCreateUrlRequestRemoteCall();

            call.@this = RemotePtr.ptr;
            if (!CfrObject.CheckConnection(request, connection))
            {
                throw new ArgumentException("Render process connection mismatch.", "request");
            }
            call.request = CfrObject.Unwrap(request).ptr;
            if (!CfrObject.CheckConnection(client, connection))
            {
                throw new ArgumentException("Render process connection mismatch.", "client");
            }
            call.client = CfrObject.Unwrap(client).ptr;
            call.RequestExecution(connection);
            return(CfrUrlRequest.Wrap(new RemotePtr(connection, call.__retval)));
        }