Ejemplo n.º 1
0
 public bool SetValue(string key, DateTime value, CefV8PropertyAttribute attributes)
 {
     using (var aValue = new CefV8Value(value))
     {
         return(SetValueByKey(key, aValue, attributes));
     }
 }
Ejemplo n.º 2
0
 public bool SetValue(string key, string value, CefV8PropertyAttribute attribute)
 {
     using (CefV8Value str = new CefV8Value(value))
     {
         return(SetValueByKey(key, str, attribute));
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Call from CefRenderProcessHandler::OnContextCreated. Registers the
        /// JavaScripts functions with the new context.
        /// </summary>
        public void OnContextCreated(CefBrowser browser, CefFrame frame, CefV8Context context)
        {
            Helpers.RequireRendererThread();

            // Do not keep any references to CefV8Value objects, otherwise
            // we should release all of them in OnContextReleased method (so we
            // can't rely on GC for this purpose).

            // Register function handlers with the 'window' object.
            using (var window = context.GetGlobal())
            {
                var handler = new V8HandlerImpl(this, _config);
                CefV8PropertyAttribute attributes = CefV8PropertyAttribute.ReadOnly | CefV8PropertyAttribute.DontEnum | CefV8PropertyAttribute.DontDelete;

                // Add the query function.
                using (var queryFunc = CefV8Value.CreateFunction(_config.JSQueryFunction, handler))
                {
                    window.SetValue(_config.JSQueryFunction, queryFunc, attributes);
                }

                // Add the cancel function.
                using (var cancelFunc = CefV8Value.CreateFunction(_config.JSCancelFunction, handler))
                {
                    window.SetValue(_config.JSCancelFunction, cancelFunc, attributes);
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Sets the value of property associated with the specified keys chain.
        /// </summary>
        /// <param name="names">Names of properties.</param>
        /// <param name="value">The new value.</param>
        /// <param name="attribute">A bitwise combination of <see cref="CefV8PropertyAttribute"/>.</param>
        public void SetValue(string[] names, CefV8Value value, CefV8PropertyAttribute attribute)
        {
            if (names == null)
            {
                throw new ArgumentNullException(nameof(names));
            }

            int last = names.Length - 1;

            if (last < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(names));
            }

            CefV8Value self = this;

            if (last > 0)
            {
                self = GetValue(new ArraySegment <string>(names, 0, last));
            }
            if (!self.SetValueByKey(names[last], value, attribute))
            {
                throw new InvalidOperationException();
            }
        }
        /// <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 = CefV8PropertyAttribute.None)
        {
            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>
        /// 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 = CefV8PropertyAttribute.None)
        {
            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);
            }
        }
Ejemplo n.º 7
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)
        {
            ThrowIfObjectIsInvalid();
            fixed(char *key_str = key)
            {
                var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);

                return(cef_v8value_t.invoke_set_value_byaccessor(this.ptr, &n_key, (cef_v8_accesscontrol_t)settings, (cef_v8_propertyattribute_t)attribute) != 0);
            }
        }
Ejemplo n.º 8
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(string key, CefV8Value value, CefV8PropertyAttribute attribute = CefV8PropertyAttribute.None)
        {
            ThrowIfObjectIsInvalid();
            fixed(char *key_str = key)
            {
                var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);

                return(cef_v8value_t.invoke_set_value_bykey(this.ptr, &n_key, value.GetNativePointerAndAddRef(), (cef_v8_propertyattribute_t)attribute) != 0);
            }
        }
Ejemplo n.º 9
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>
        public unsafe virtual bool SetValueByKey(string key, CefV8Value value, CefV8PropertyAttribute attribute)
        {
            fixed(char *s0 = key)
            {
                var cstr0 = new cef_string_t {
                    Str = s0, Length = key != null ? key.Length : 0
                };

                return(SafeCall(NativeInstance->SetValueByKey(&cstr0, (value != null) ? value.GetNativeInstance() : null, attribute) != 0));
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Call from CefRenderProcessHandler::OnContextCreated. Registers the
        /// JavaScripts functions with the new context.
        /// </summary>
        public void OnContextCreated(CefBrowser browser, CefFrame frame, CefV8Context context)
        {
            Helpers.RequireRendererThread();

            // Register function handlers with the 'window' object.
            var window = context.GetGlobal();

            var handler = new V8HandlerImpl(this, _config);
            CefV8PropertyAttribute attributes = CefV8PropertyAttribute.ReadOnly | CefV8PropertyAttribute.DontEnum | CefV8PropertyAttribute.DontDelete;

            // Add the query function.
            var queryFunc = CefV8Value.CreateFunction(_config.JSQueryFunction, handler);

            window.SetValue(_config.JSQueryFunction, queryFunc, attributes);

            // Add the cancel function.
            var cancelFunc = CefV8Value.CreateFunction(_config.JSCancelFunction, handler);

            window.SetValue(_config.JSCancelFunction, cancelFunc, attributes);
        }
Ejemplo n.º 11
0
 public unsafe int SetValueByKey([Immutable] cef_string_t *key, cef_v8value_t *value, CefV8PropertyAttribute attribute)
 {
     fixed(cef_v8value_t *self = &this)
     {
         return(((delegate * unmanaged[Stdcall] < cef_v8value_t *, cef_string_t *, cef_v8value_t *, CefV8PropertyAttribute, int >)set_value_bykey)(self, key, value, attribute));
     }
 }
Ejemplo n.º 12
0
 public bool SetValue(string key, CefV8AccessControl settings, CefV8PropertyAttribute attributes)
 {
     return(SetValueByAccessor(key, settings, attributes));
 }
Ejemplo n.º 13
0
 public bool SetValue(string key, CefV8Value value, CefV8PropertyAttribute attributes)
 {
     return(SetValueByKey(key, value, attributes));
 }
Ejemplo n.º 14
0
 public unsafe int SetValueByAccessor([Immutable] cef_string_t *key, CefV8AccessControl settings, CefV8PropertyAttribute attribute)
 {
     fixed(cef_v8value_t *self = &this)
     {
         return(((delegate * unmanaged[Stdcall] < cef_v8value_t *, cef_string_t *, CefV8AccessControl, CefV8PropertyAttribute, int >)set_value_byaccessor)(self, key, settings, attribute));
     }
 }
 /// <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 int SetValue(cef_string_t *key, CefV8AccessControl settings, CefV8PropertyAttribute attribute)
 {
     throw new NotImplementedException(); // TODO: CefV8Value.SetValue
 }
 /// <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 int SetValue(cef_string_t *key, cef_v8value_t *value, CefV8PropertyAttribute attribute)
 {
     throw new NotImplementedException(); // TODO: CefV8Value.SetValue
 }
Ejemplo n.º 17
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(string key, CefV8Value value, CefV8PropertyAttribute attribute = CefV8PropertyAttribute.None)
        {
            ThrowIfObjectIsInvalid();
            fixed (char* key_str = key)
            {
                var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);

                return cef_v8value_t.invoke_set_value_bykey(this.ptr, &n_key, value.GetNativePointerAndAddRef(), (cef_v8_propertyattribute_t)attribute) != 0;
            }
        }
Ejemplo n.º 18
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)
        {
            ThrowIfObjectIsInvalid();
            fixed (char* key_str = key)
            {
                var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);

                return cef_v8value_t.invoke_set_value_byaccessor(this.ptr, &n_key, (cef_v8_accesscontrol_t)settings, (cef_v8_propertyattribute_t)attribute) != 0;
            }
        }
Ejemplo n.º 19
0
        public static int set_value_byaccessor(cef_v8value_t *self, cef_string_t *key, CefV8AccessControl settings, CefV8PropertyAttribute attribute)
        {
            set_value_byaccessor_delegate d;
            var p = self->_set_value_byaccessor;

            if (p == _p24)
            {
                d = _d24;
            }
            else
            {
                d = (set_value_byaccessor_delegate)Marshal.GetDelegateForFunctionPointer(p, typeof(set_value_byaccessor_delegate));
                if (_p24 == IntPtr.Zero)
                {
                    _d24 = d; _p24 = p;
                }
            }
            return(d(self, key, settings, attribute));
        }
Ejemplo n.º 20
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(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;
     }
 }
Ejemplo n.º 21
0
        /// <summary>
        /// Registers an identifier and returns true (1) on success. Access to the
        /// identifier will be forwarded to the cef_v8accessor_t instance passed to
        /// cef_v8value_t::cef_v8value_create_object(). 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>
        public unsafe virtual bool SetValueByAccessor(string key, CefV8AccessControl settings, CefV8PropertyAttribute attribute)
        {
            fixed(char *s0 = key)
            {
                var cstr0 = new cef_string_t {
                    Str = s0, Length = key != null ? key.Length : 0
                };

                return(SafeCall(NativeInstance->SetValueByAccessor(&cstr0, settings, attribute) != 0));
            }
        }
Ejemplo n.º 22
0
 public unsafe extern int SetValueByKey([Immutable] cef_string_t *key, cef_v8value_t *value, CefV8PropertyAttribute attribute);
Ejemplo n.º 23
0
 public static int set_value_bykey(cef_v8value_t* self, cef_string_t* key, cef_v8value_t* value, CefV8PropertyAttribute attribute)
 {
     set_value_bykey_delegate d;
     var p = self->_set_value_bykey;
     if (p == _p22) { d = _d22; }
     else
     {
         d = (set_value_bykey_delegate)Marshal.GetDelegateForFunctionPointer(p, typeof(set_value_bykey_delegate));
         if (_p22 == IntPtr.Zero) { _d22 = d; _p22 = p; }
     }
     return d(self, key, value, attribute);
 }
Ejemplo n.º 24
0
 public static int set_value_byaccessor(cef_v8value_t* self, cef_string_t* key, CefV8AccessControl settings, CefV8PropertyAttribute attribute)
 {
     set_value_byaccessor_delegate d;
     var p = self->_set_value_byaccessor;
     if (p == _p24) { d = _d24; }
     else
     {
         d = (set_value_byaccessor_delegate)Marshal.GetDelegateForFunctionPointer(p, typeof(set_value_byaccessor_delegate));
         if (_p24 == IntPtr.Zero) { _d24 = d; _p24 = p; }
     }
     return d(self, key, settings, attribute);
 }
Ejemplo n.º 25
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;
     }
 }
Ejemplo n.º 26
0
 public unsafe extern int SetValueByAccessor([Immutable] cef_string_t *key, CefV8AccessControl settings, CefV8PropertyAttribute attribute);
Ejemplo n.º 27
0
        public static int set_value_bykey(cef_v8value_t *self, cef_string_t *key, cef_v8value_t *value, CefV8PropertyAttribute attribute)
        {
            set_value_bykey_delegate d;
            var p = self->_set_value_bykey;

            if (p == _p22)
            {
                d = _d22;
            }
            else
            {
                d = (set_value_bykey_delegate)Marshal.GetDelegateForFunctionPointer(p, typeof(set_value_bykey_delegate));
                if (_p22 == IntPtr.Zero)
                {
                    _d22 = d; _p22 = p;
                }
            }
            return(d(self, key, value, attribute));
        }