protected override CefResourceHandler GetResourceHandler(CefBrowser browser, CefFrame frame, CefRequest request)
            {
                if (request.Url == OwnerWebView.DefaultLocalUrl)
                {
                    return(AsyncResourceHandler.FromText(OwnerWebView.htmlToLoad ?? ""));
                }

                if (UrlHelper.IsChromeInternalUrl(request.Url))
                {
                    return(null);
                }

                var resourceHandler = new ResourceHandler(request, OwnerWebView.GetRequestUrl(request.Url, (ResourceType)request.ResourceType));

                void TriggerBeforeResourceLoadEvent()
                {
                    var beforeResourceLoad = OwnerWebView.BeforeResourceLoad;

                    if (beforeResourceLoad != null)
                    {
                        OwnerWebView.ExecuteWithAsyncErrorHandling(() => beforeResourceLoad(resourceHandler));
                    }
                }

                if (Uri.TryCreate(resourceHandler.Url, UriKind.Absolute, out var url) && url.Scheme == ResourceUrl.EmbeddedScheme)
                {
                    resourceHandler.BeginAsyncResponse(() => {
                        var urlWithoutQuery = new UriBuilder(url);
                        if (!string.IsNullOrEmpty(url.Query))
                        {
                            urlWithoutQuery.Query = string.Empty;
                        }

                        OwnerWebView.ExecuteWithAsyncErrorHandling(() => ResourcesProvider.LoadEmbeddedResource(resourceHandler, urlWithoutQuery.Uri));

                        TriggerBeforeResourceLoadEvent();

                        if (resourceHandler.Handled || OwnerWebView.IgnoreMissingResources)
                        {
                            return;
                        }

                        var resourceLoadFailed = OwnerWebView.ResourceLoadFailed;
                        if (resourceLoadFailed != null)
                        {
                            resourceLoadFailed(url.ToString());
                        }
                        else
                        {
                            OwnerWebView.ForwardUnhandledAsyncException(new InvalidOperationException("Resource not found: " + url));
                        }
                    });
                }
                else
                {
                    TriggerBeforeResourceLoadEvent();
                }

                return(resourceHandler.Handler);
            }
            protected override bool OnBeforeBrowse(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, bool userGesture, bool isRedirect)
            {
                if (OwnerWebView.FilterUrl(request.Url))
                {
                    return(false);
                }

                if (OwnerWebView.IsHistoryDisabled && (request.TransitionType & TransitionType.ForwardBack) == TransitionType.ForwardBack)
                {
                    return(true);
                }

                bool cancel = false;

                if (OwnerWebView.BeforeNavigate != null)
                {
                    var wrappedRequest = new Request(request, OwnerWebView.GetRequestUrl(request.Url, (ResourceType)request.ResourceType));
                    OwnerWebView.ExecuteWithAsyncErrorHandling(() => OwnerWebView.BeforeNavigate(wrappedRequest));
                    cancel = wrappedRequest.Canceled;
                }

                return(cancel);
            }
            protected override bool OnBeforeBrowse(CefBrowser browser, CefFrame frame, CefRequest request, bool userGesture, bool isRedirect)
            {
                if (UrlHelper.IsInternalUrl(request.Url))
                {
                    return(false);
                }

                if (OwnerWebView.IsHistoryDisabled && request.TransitionType.HasFlag(CefTransitionType.ForwardBackFlag))
                {
                    return(true);
                }

                var cancel         = false;
                var beforeNavigate = OwnerWebView.BeforeNavigate;

                if (beforeNavigate != null)
                {
                    var wrappedRequest = new Request(request, OwnerWebView.GetRequestUrl(request.Url, (ResourceType)request.ResourceType));
                    OwnerWebView.ExecuteWithAsyncErrorHandling(() => beforeNavigate(wrappedRequest));
                    cancel = wrappedRequest.Canceled;
                }

                return(cancel);
            }