Ejemplo n.º 1
0
        /// <summary>
        /// Allows overriding user agent with the given string.
        /// </summary>
        /// <param name = "userAgent">User agent to use.</param>
        /// <param name = "acceptLanguage">Browser langugage to emulate.</param>
        /// <param name = "platform">The platform navigator.platform should return.</param>
        /// <param name = "userAgentMetadata">To be sent in Sec-CH-UA-* headers and returned in navigator.userAgentData</param>
        /// <returns>returns System.Threading.Tasks.Task&lt;DevToolsMethodResponse&gt;</returns>
        public async System.Threading.Tasks.Task <DevToolsMethodResponse> SetUserAgentOverrideAsync(string userAgent, string acceptLanguage = null, string platform = null, CefSharp.DevTools.Emulation.UserAgentMetadata userAgentMetadata = null)
        {
            ValidateSetUserAgentOverride(userAgent, acceptLanguage, platform, userAgentMetadata);
            var dict = new System.Collections.Generic.Dictionary <string, object>();

            dict.Add("userAgent", userAgent);
            if (!(string.IsNullOrEmpty(acceptLanguage)))
            {
                dict.Add("acceptLanguage", acceptLanguage);
            }

            if (!(string.IsNullOrEmpty(platform)))
            {
                dict.Add("platform", platform);
            }

            if ((userAgentMetadata) != (null))
            {
                dict.Add("userAgentMetadata", userAgentMetadata.ToDictionary());
            }

            var methodResult = await _client.ExecuteDevToolsMethodAsync("Emulation.setUserAgentOverride", dict);

            return(methodResult);
        }
Ejemplo n.º 2
0
 partial void ValidateSetUserAgentOverride(string userAgent, string acceptLanguage = null, string platform = null, CefSharp.DevTools.Emulation.UserAgentMetadata userAgentMetadata = null);