Ejemplo n.º 1
0
        private CefReturnValue RequestHandler_InterceptBeforeResourceLoad(IWebBrowser arg1, IBrowser arg2, IFrame arg3, IRequest arg4, IRequestCallback arg5)
        {
            if (OnBeforeResourceLoad == null)
            {
                return(CefReturnValue.Continue);
            }
            var args = new BeforeResourceLoadEventArgs(arg4.Url, arg4.ResourceType);

            OnBeforeResourceLoad.Invoke(this, args);
            if (args.CacheToQueue)
            {
                ResourceCacheManager.CreateResource(arg4.Identifier);
            }
            return(!args.Cancel ? CefReturnValue.Continue : CefReturnValue.Cancel);
        }
Ejemplo n.º 2
0
        private void RequestHandler_InterceptResourceLoadComplete(IWebBrowser arg1, IBrowser arg2, IFrame arg3, IRequest arg4, IResponse arg5, UrlRequestStatus arg6, long arg7)
        {
            var stream = ResourceCacheManager.GetResource(arg4.Identifier);

            if (stream != null)
            {
                stream.Seek(0, System.IO.SeekOrigin.Begin);
            }
            try
            {
                this.OnResourceLoadComplete?.Invoke(this, new ResourceLoadCompleteEventArgs(arg4.Url, arg4.ResourceType, arg7, stream, arg6));
            }
            finally
            {
                ResourceCacheManager.DeleteResource(arg4.Identifier);
            }
        }