Ejemplo n.º 1
0
        /// <summary>
        /// The on register custom schemes.
        /// </summary>
        /// <param name="registrar">
        /// The registrar.
        /// </param>
        protected override void OnRegisterCustomSchemes(CefSchemeRegistrar registrar)
        {
            var schemes = _requestSchemeProvider?.GetAllSchemes();

            if (schemes != null && schemes.Any())
            {
                foreach (var scheme in schemes)
                {
                    bool isStandardScheme = UrlScheme.IsStandardScheme(scheme.Scheme);
                    if (!isStandardScheme)
                    {
                        var option = CefSchemeOptions.Local | CefSchemeOptions.CorsEnabled;
                        registrar.AddCustomScheme(scheme.Scheme, option);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The on register custom schemes.
        /// </summary>
        /// <param name="registrar">
        /// The registrar.
        /// </param>
        protected override void OnRegisterCustomSchemes(CefSchemeRegistrar registrar)
        {
            var schemes = _requestSchemeProvider?.GetAllSchemes();

            if (schemes == null)
            {
                schemes = new List <UrlScheme>();
            }

            var schemeHandlerList = _handlersResolver?.Invoke(typeof(IChromelySchemeHandler));

            if (schemeHandlerList != null && schemeHandlerList.Any())
            {
                foreach (var handler in schemeHandlerList)
                {
                    if (handler is IChromelySchemeHandler schemeHandler)
                    {
                        if (schemeHandler?.Scheme != null && schemeHandler.Scheme.ValidSchemeHost)
                        {
                            // add if not already added
                            var firstOrDefault = schemes.FirstOrDefault(x => x.ValidSchemeHost &&
                                                                        x.Scheme.ToLower().Equals(schemeHandler.Scheme.Scheme.ToLower()) &&
                                                                        x.Host.ToLower().Equals(schemeHandler.Scheme.Host.ToLower()));
                            if (firstOrDefault == null)
                            {
                                schemes.Add(schemeHandler.Scheme);
                            }
                        }
                    }
                }
            }

            foreach (var scheme in schemes)
            {
                bool isStandardScheme = UrlScheme.IsStandardScheme(scheme.Scheme);
                if (!isStandardScheme)
                {
                    var option = CefSchemeOptions.Local | CefSchemeOptions.CorsEnabled;
                    registrar.AddCustomScheme(scheme.Scheme, option);
                }
            }
        }