/// <summary>
        /// Gets the default encoding to use as initial guess.
        /// </summary>
        /// <param name="context">The current context.</param>
        /// <returns>The encoding from the provider or UTF-8.</returns>
        public static Encoding GetDefaultEncoding(this IBrowsingContext context)
        {
            var provider = context.GetProvider <IEncodingProvider>();
            var locale   = context.GetLanguage();

            return(provider?.Suggest(locale) ?? Encoding.UTF8);
        }
        internal static CssProperty CreateProperty(this IBrowsingContext context, String propertyName)
        {
            var info     = context.GetDeclarationInfo(propertyName);
            var provider = context.GetProvider <CssParser>();

            if (info.Flags != PropertyFlags.Unknown || context.IsAllowingUnknownDeclarations())
            {
                return(new CssProperty(propertyName, info.Converter, info.Flags));
            }

            return(null);
        }
Exemplo n.º 3
0
        public Task ProcessAsync(ResourceRequest request)
        {
            if (_loader != null && Engine != null)
            {
                Download = _loader.FetchWithCorsAsync(new CorsRequest(request)
                {
                    Behavior  = OriginBehavior.Taint,
                    Setting   = _script.CrossOrigin.ToEnum(CorsSetting.None),
                    Integrity = _context.GetProvider <IIntegrityProvider>()
                });
                return(Download.Task);
            }

            return(Task.CompletedTask);
        }
Exemplo n.º 4
0
        public override Task ProcessAsync(ResourceRequest request)
        {
            if (IsAvailable && Engine != null && IsDifferentToCurrentDownloadUrl(request.Target))
            {
                CancelDownload();
                Download = DownloadWithCors(new CorsRequest(request)
                {
                    Setting   = _link.CrossOrigin.ToEnum(CorsSetting.None),
                    Behavior  = OriginBehavior.Taint,
                    Integrity = _context.GetProvider <IIntegrityProvider>()
                });
                return(FinishDownloadAsync());
            }

            return(null);
        }
        private static Boolean IsAllowingUnknownDeclarations(this IBrowsingContext context)
        {
            var parser = context.GetProvider <CssParser>();

            return(parser != null ? parser.Options.IsIncludingUnknownDeclarations : true);
        }
        /// <summary>
        /// Tries to get the command with the given name.
        /// </summary>
        /// <param name="context">The current context.</param>
        /// <param name="commandId">The command to get.</param>
        /// <returns>The command if any.</returns>
        public static ICommand GetCommand(this IBrowsingContext context, String commandId)
        {
            var provider = context.GetProvider <ICommandProvider>();

            return(provider?.GetCommand(commandId));
        }
        /// <summary>
        /// Sets the cookie for the given URL.
        /// </summary>
        /// <param name="context">The current context.</param>
        /// <param name="url">The URL of the cookie.</param>
        /// <param name="value">The cookie value to set.</param>
        public static void SetCookie(this IBrowsingContext context, Url url, String value)
        {
            var provider = context.GetProvider <ICookieProvider>();

            provider?.SetCookie(url, value);
        }
        /// <summary>
        /// Gets the cookie for the given URL, if any.
        /// </summary>
        /// <param name="context">The current context.</param>
        /// <param name="url">The URL of the cookie.</param>
        /// <returns>The cookie or the empty string.</returns>
        public static String GetCookie(this IBrowsingContext context, Url url)
        {
            var provider = context.GetProvider <ICookieProvider>();

            return(provider?.GetCookie(url) ?? String.Empty);
        }