예제 #1
0
 private void CheckSelf(cef_request_context_handler_t *self)
 {
     if (_self != self)
     {
         throw ExceptionBuilder.InvalidSelfReference();
     }
 }
        private void on_request_context_initialized(cef_request_context_handler_t *self, cef_request_context_t *request_context)
        {
            CheckSelf(self);

            var mRequestContext = CefRequestContext.FromNative(request_context);

            OnRequestContextInitialized(mRequestContext);
        }
예제 #3
0
 protected virtual void Dispose(bool disposing)
 {
     if (_self != null)
     {
         cef_request_context_handler_t.Free(_self);
         _self = null;
     }
 }
예제 #4
0
        public CefRequestContextHandler()
        {
            cef_request_context_handler_t *self = this.NativeInstance;

            self->on_request_context_initialized = (void *)Marshal.GetFunctionPointerForDelegate(fnOnRequestContextInitialized);
            self->on_before_plugin_load          = (void *)Marshal.GetFunctionPointerForDelegate(fnOnBeforePluginLoad);
            self->get_resource_request_handler   = (void *)Marshal.GetFunctionPointerForDelegate(fnGetResourceRequestHandler);
        }
예제 #5
0
 protected virtual void Dispose(bool disposing)
 {
     if (_self != null)
     {
         cef_request_context_handler_t.Free(_self);
         _self = null;
     }
 }
        private cef_cookie_manager_t *get_cookie_manager(cef_request_context_handler_t *self)
        {
            CheckSelf(self);

            var result = GetCookieManager();

            return(result != null?result.ToNative() : null);
        }
예제 #7
0
        internal static CefRequestContextHandler FromNative(cef_request_context_handler_t *ptr)
        {
            var value = FromNativeOrNull(ptr);

            if (value == null)
            {
                throw ExceptionBuilder.ObjectNotFound();
            }
            return(value);
        }
예제 #8
0
        private static unsafe void OnRequestContextInitializedImpl(cef_request_context_handler_t *self, cef_request_context_t *request_context)
        {
            var instance = GetInstance((IntPtr)self) as CefRequestContextHandler;

            if (instance == null || ((ICefRequestContextHandlerPrivate)instance).AvoidOnRequestContextInitialized())
            {
                ReleaseIfNonNull((cef_base_ref_counted_t *)request_context);
                return;
            }
            instance.OnRequestContextInitialized(CefRequestContext.Wrap(CefRequestContext.Create, request_context));
        }
예제 #9
0
        internal static CefRequestContextHandler FromNativeOrNull(cef_request_context_handler_t *ptr)
        {
            CefRequestContextHandler value = null;
            bool found;

            lock (_roots)
            {
                found = _roots.TryGetValue((IntPtr)ptr, out value);
            }
            return(found ? value : null);
        }
예제 #10
0
 private void add_ref(cef_request_context_handler_t *self)
 {
     lock (SyncRoot)
     {
         var result = ++_refct;
         if (result == 1)
         {
             lock (_roots) { _roots.Add((IntPtr)_self, this); }
         }
     }
 }
 private int release(cef_request_context_handler_t *self)
 {
     lock (SyncRoot)
     {
         var result = --_refct;
         if (result == 0)
         {
             lock (_roots) { _roots.Remove((IntPtr)_self); }
         }
         return(result);
     }
 }
        protected CefRequestContextHandler()
        {
            _self = cef_request_context_handler_t.Alloc();

            _ds0 = new cef_request_context_handler_t.add_ref_delegate(add_ref);
            _self->_base._add_ref = Marshal.GetFunctionPointerForDelegate(_ds0);
            _ds1 = new cef_request_context_handler_t.release_delegate(release);
            _self->_base._release = Marshal.GetFunctionPointerForDelegate(_ds1);
            _ds2 = new cef_request_context_handler_t.get_refct_delegate(get_refct);
            _self->_base._get_refct = Marshal.GetFunctionPointerForDelegate(_ds2);
            _ds3 = new cef_request_context_handler_t.get_cookie_manager_delegate(get_cookie_manager);
            _self->_get_cookie_manager = Marshal.GetFunctionPointerForDelegate(_ds3);
        }
예제 #13
0
        protected CefRequestContextHandler()
        {
            _self = cef_request_context_handler_t.Alloc();

            _ds0 = new cef_request_context_handler_t.add_ref_delegate(add_ref);
            _self->_base._add_ref = Marshal.GetFunctionPointerForDelegate(_ds0);
            _ds1 = new cef_request_context_handler_t.release_delegate(release);
            _self->_base._release = Marshal.GetFunctionPointerForDelegate(_ds1);
            _ds2 = new cef_request_context_handler_t.get_refct_delegate(get_refct);
            _self->_base._get_refct = Marshal.GetFunctionPointerForDelegate(_ds2);
            _ds3 = new cef_request_context_handler_t.get_cookie_manager_delegate(get_cookie_manager);
            _self->_get_cookie_manager = Marshal.GetFunctionPointerForDelegate(_ds3);
        }
예제 #14
0
        public CefRequestContextHandler()
        {
            cef_request_context_handler_t *self = this.NativeInstance;

                        #if NET_LESS_5_0
            self->on_request_context_initialized = (void *)Marshal.GetFunctionPointerForDelegate(fnOnRequestContextInitialized);
            self->on_before_plugin_load          = (void *)Marshal.GetFunctionPointerForDelegate(fnOnBeforePluginLoad);
            self->get_resource_request_handler   = (void *)Marshal.GetFunctionPointerForDelegate(fnGetResourceRequestHandler);
                        #else
            self->on_request_context_initialized = (delegate * unmanaged[Stdcall] < cef_request_context_handler_t *, cef_request_context_t *, void >) & OnRequestContextInitializedImpl;
            self->on_before_plugin_load          = (delegate * unmanaged[Stdcall] < cef_request_context_handler_t *, cef_string_t *, cef_string_t *, int, cef_string_t *, cef_web_plugin_info_t *, CefPluginPolicy *, int >) & OnBeforePluginLoadImpl;
            self->get_resource_request_handler   = (delegate * unmanaged[Stdcall] < cef_request_context_handler_t *, cef_browser_t *, cef_frame_t *, cef_request_t *, int, int, cef_string_t *, int *, cef_resource_request_handler_t * >) & GetResourceRequestHandlerImpl;
                        #endif
        }
예제 #15
0
        protected CefRequestContextHandler()
        {
            _self = cef_request_context_handler_t.Alloc();

            _ds0 = new cef_request_context_handler_t.add_ref_delegate(add_ref);
            _self->_base._add_ref = Marshal.GetFunctionPointerForDelegate(_ds0);
            _ds1 = new cef_request_context_handler_t.release_delegate(release);
            _self->_base._release = Marshal.GetFunctionPointerForDelegate(_ds1);
            _ds2 = new cef_request_context_handler_t.has_one_ref_delegate(has_one_ref);
            _self->_base._has_one_ref = Marshal.GetFunctionPointerForDelegate(_ds2);
            _ds3 = new cef_request_context_handler_t.get_cookie_manager_delegate(get_cookie_manager);
            _self->_get_cookie_manager = Marshal.GetFunctionPointerForDelegate(_ds3);
            _ds4 = new cef_request_context_handler_t.on_before_plugin_load_delegate(on_before_plugin_load);
            _self->_on_before_plugin_load = Marshal.GetFunctionPointerForDelegate(_ds4);
        }
예제 #16
0
        private int on_before_plugin_load(cef_request_context_handler_t *self, cef_string_t *mime_type, cef_string_t *plugin_url, cef_string_t *top_origin_url, cef_web_plugin_info_t *plugin_info, CefPluginPolicy *plugin_policy)
        {
            CheckSelf(self);

            var mMimeType     = cef_string_t.ToString(mime_type);
            var mPluginUrl    = cef_string_t.ToString(plugin_url);
            var mTopOriginUrl = cef_string_t.ToString(top_origin_url);
            var mPluginInfo   = CefWebPluginInfo.FromNative(plugin_info);
            var mPluginPolicy = *plugin_policy;

            var result = OnBeforePluginLoad(mMimeType, mPluginUrl, mTopOriginUrl, mPluginInfo, ref mPluginPolicy);

            *plugin_policy = mPluginPolicy;

            return(result ? 1 : 0);
        }
        private cef_resource_request_handler_t *get_resource_request_handler(cef_request_context_handler_t *self, cef_browser_t *browser, cef_frame_t *frame, cef_request_t *request, int is_navigation, int is_download, cef_string_t *request_initiator, int *disable_default_handling)
        {
            CheckSelf(self);

            var m_browser                = CefBrowser.FromNativeOrNull(browser);
            var m_frame                  = CefFrame.FromNativeOrNull(frame);
            var m_request                = CefRequest.FromNative(request);
            var m_isNavigation           = is_navigation != 0;
            var m_isDownload             = is_download != 0;
            var m_requestInitiator       = cef_string_t.ToString(request_initiator);
            var m_disableDefaultHandling = *disable_default_handling != 0;

            var m_result = GetResourceRequestHandler(m_browser, m_frame, m_request, m_isNavigation, m_isDownload, m_requestInitiator, ref m_disableDefaultHandling);

            *disable_default_handling = m_disableDefaultHandling ? 1 : 0;

            return(m_result != null?m_result.ToNative() : null);
        }
 /// <summary>
 /// Creates a new context object that shares storage with |other| and uses an
 /// optional |handler|.
 /// </summary>
 public static cef_request_context_t *CreateContext(cef_request_context_t *other, cef_request_context_handler_t *handler)
 {
     throw new NotImplementedException(); // TODO: CefRequestContext.CreateContext
 }
예제 #19
0
 internal static void Free(cef_request_context_handler_t *ptr)
 {
     Marshal.FreeHGlobal((IntPtr)ptr);
 }
 private int get_refct(cef_request_context_handler_t *self)
 {
     return(_refct);
 }
예제 #21
0
 public CefRequestContextHandler(cef_request_context_handler_t *instance)
     : base((cef_base_ref_counted_t *)instance)
 {
 }
예제 #22
0
 private cef_cookie_manager_t *get_cookie_manager(cef_request_context_handler_t *self)
 {
     CheckSelf(self);
     throw new NotImplementedException(); // TODO: CefRequestContextHandler.GetCookieManager
 }
예제 #23
0
 private int has_at_least_one_ref(cef_request_context_handler_t *self)
 {
     lock (SyncRoot) { return(_refct != 0 ? 1 : 0); }
 }
 public static extern cef_request_context_t *create_context(cef_request_context_handler_t *handler);