| using Playnite.SDK.Events; |
| using Playnite.SDK.Events; |
| using System; |
| using System; |
| using System.Collections.Generic; |
| using System.Collections.Generic; |
| using System.Linq; |
| using System.Linq; |
| using System.Text; |
| using System.Text; |
| using System.Threading.Tasks; |
| using System.Threading.Tasks; |
| using System.Windows.Media; |
| using System.Windows.Media; |
| |
| |
| namespace Playnite.SDK |
| namespace Playnite.SDK |
| { |
| { |
| /// <summary> |
| /// <summary> |
| /// Represents browser view settings. |
| /// Represents browser view settings. |
| /// </summary> |
| /// </summary> |
| public class WebViewSettings |
| public class WebViewSettings |
| { |
| { |
| /// <summary> |
| /// <summary> |
| /// Gets or sets value indicating whether JavaScript exection is enabled. |
| /// Gets or sets value indicating whether JavaScript exection is enabled. |
| /// </summary> |
| /// </summary> |
| public bool JavaScriptEnabled { get; set; } = true; |
| public bool JavaScriptEnabled { get; set; } = true; |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Gets or sets value indicating whether cache is enabled. |
| /// Gets or sets value indicating whether cache is enabled. |
| /// </summary> |
| /// </summary> |
. | |
| [Obsolete("AppCache was removed from CEF")] |
| public bool CacheEnabled { get; set; } = true; |
| public bool CacheEnabled { get; set; } = true; |
. | |
| |
| |
| /// <summary> |
| |
| /// User agent to be used for specific browser instance. Leave empty to use default. |
| |
| /// </summary> |
| |
| public string UserAgent { get; set; } |
| |
| |
| |
| /// <summary> |
| |
| /// Gets or sets window width. |
| |
| /// </summary> |
| |
| public int WindowWidth { get; set; } = 0; |
| |
| |
| |
| /// <summary> |
| |
| /// Gets or sets window height. |
| |
| /// </summary> |
| |
| public int WindowHeight { get; set; } = 0; |
| |
| |
| |
| /// <summary> |
| |
| /// Gets or sets window background color. |
| |
| /// </summary> |
| |
| public Color WindowBackground { get; set; } |
| } |
| } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Represents JavaScript evaluation resut. |
| /// Represents JavaScript evaluation resut. |
| /// </summary> |
| /// </summary> |
| public class JavaScriptEvaluationResult |
| public class JavaScriptEvaluationResult |
| { |
| { |
| /// <summary> |
| /// <summary> |
| /// Gets or sets error message. |
| /// Gets or sets error message. |
| /// </summary> |
| /// </summary> |
| public string Message { get; set; } |
| public string Message { get; set; } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Gets or sets value indicating whether the javascript executed successfully. |
| /// Gets or sets value indicating whether the javascript executed successfully. |
| /// </summary> |
| /// </summary> |
| public bool Success { get; set; } |
| public bool Success { get; set; } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Gets or sets result of script evaluation. |
| /// Gets or sets result of script evaluation. |
| /// </summary> |
| /// </summary> |
| public object Result { get; set; } |
| public object Result { get; set; } |
| } |
| } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Describes web view object. |
| /// Describes web view object. |
| /// </summary> |
| /// </summary> |
| public interface IWebView : IDisposable |
| public interface IWebView : IDisposable |
| { |
| { |
| /// <summary> |
| /// <summary> |
| /// Gets a flag that indicates if you can execute javascript in the main frame. |
| /// Gets a flag that indicates if you can execute javascript in the main frame. |
| /// </summary> |
| /// </summary> |
| bool CanExecuteJavascriptInMainFrame { get; } |
| bool CanExecuteJavascriptInMainFrame { get; } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Open view. |
| /// Open view. |
| /// </summary> |
| /// </summary> |
| void Open(); |
| void Open(); |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Open view as modal dialog. |
| /// Open view as modal dialog. |
| /// </summary> |
| /// </summary> |
| /// <returns></returns> |
| /// <returns></returns> |
| bool? OpenDialog(); |
| bool? OpenDialog(); |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Navigates to url and wait for page to be loaded. |
| /// Navigates to url and wait for page to be loaded. |
| /// </summary> |
| /// </summary> |
| /// <param name="url">URL to load.</param> |
| /// <param name="url">URL to load.</param> |
| void NavigateAndWait(string url); |
| void NavigateAndWait(string url); |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Navigates to url. |
| /// Navigates to url. |
| /// </summary> |
| /// </summary> |
| /// <param name="url">URL to load.</param> |
| /// <param name="url">URL to load.</param> |
| void Navigate(string url); |
| void Navigate(string url); |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Gets page text. |
| /// Gets page text. |
| /// </summary> |
| /// </summary> |
| /// <returns>Page text.</returns> |
| /// <returns>Page text.</returns> |
| string GetPageText(); |
| string GetPageText(); |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Gets page text. |
| /// Gets page text. |
| /// </summary> |
| /// </summary> |
| /// <returns>Page text.</returns> |
| /// <returns>Page text.</returns> |
| Task<string> GetPageTextAsync(); |
| Task<string> GetPageTextAsync(); |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Gets document source. |
| /// Gets document source. |
| /// </summary> |
| /// </summary> |
| /// <returns>Document source.</returns> |
| /// <returns>Document source.</returns> |
| string GetPageSource(); |
| string GetPageSource(); |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Gets document source. |
| /// Gets document source. |
| /// </summary> |
| /// </summary> |
| /// <returns>Document source task.</returns> |
| /// <returns>Document source task.</returns> |
| Task<string> GetPageSourceAsync(); |
| Task<string> GetPageSourceAsync(); |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Gets current URL address. |
| /// Gets current URL address. |
| /// </summary> |
| /// </summary> |
| /// <returns>URL address.</returns> |
| /// <returns>URL address.</returns> |
| string GetCurrentAddress(); |
| string GetCurrentAddress(); |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Deletes all cookies from specified domain. |
| /// Deletes all cookies from specified domain. |
| /// </summary> |
| /// </summary> |
| /// <param name="domain">Cookie domain.</param> |
| /// <param name="domain">Cookie domain.</param> |
| void DeleteDomainCookies(string domain); |
| void DeleteDomainCookies(string domain); |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Deletes cookies. |
| /// Deletes cookies. |
| /// </summary> |
| /// </summary> |
| /// <param name="url">Cookie URL.</param> |
| /// <param name="url">Cookie URL.</param> |
| /// <param name="name">Cookie name.</param> |
| /// <param name="name">Cookie name.</param> |
| void DeleteCookies(string url, string name); |
| void DeleteCookies(string url, string name); |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Gets all cookies. |
| /// Gets all cookies. |
| /// </summary> |
| /// </summary> |
| /// <returns>List of cookies.</returns> |
| /// <returns>List of cookies.</returns> |
| List<HttpCookie> GetCookies(); |
| List<HttpCookie> GetCookies(); |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Sets cookie data. |
| /// Sets cookie data. |
| /// </summary> |
| /// </summary> |
| /// <param name="url">Cookie URL.</param> |
| /// <param name="url">Cookie URL.</param> |
| /// <param name="domain">Cookie domain.</param> |
| /// <param name="domain">Cookie domain.</param> |
| /// <param name="name">Cookie name.</param> |
| /// <param name="name">Cookie name.</param> |
| /// <param name="value">Cookie value.</param> |
| /// <param name="value">Cookie value.</param> |
| /// <param name="path">Cookie url path.</param> |
| /// <param name="path">Cookie url path.</param> |
| /// <param name="expires">Expiration date.</param> |
| /// <param name="expires">Expiration date.</param> |
| void SetCookies(string url, string domain, string name, string value, string path, DateTime expires); |
| void SetCookies(string url, string domain, string name, string value, string path, DateTime expires); |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Sets cookie data. |
| /// Sets cookie data. |
| /// </summary> |
| /// </summary> |
| /// <param name="url">Cookie URL.</param> |
| /// <param name="url">Cookie URL.</param> |
| /// <param name="cookie">Cookie data.</param> |
| /// <param name="cookie">Cookie data.</param> |
| void SetCookies(string url, HttpCookie cookie); |
| void SetCookies(string url, HttpCookie cookie); |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Closes view. |
| /// Closes view. |
| /// </summary> |
| /// </summary> |
| void Close(); |
| void Close(); |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Occurs when web view loading changes, for example when page is loaded. |
| /// Occurs when web view loading changes, for example when page is loaded. |
| /// </summary> |
| /// </summary> |
| event EventHandler<WebViewLoadingChangedEventArgs> LoadingChanged; |
| event EventHandler<WebViewLoadingChangedEventArgs> LoadingChanged; |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Evaluates JavaScript script in the browser instance. |
| /// Evaluates JavaScript script in the browser instance. |
| /// </summary> |
| /// </summary> |
| /// <param name="script"></param> |
| /// <param name="script"></param> |
| /// <returns></returns> |
| /// <returns></returns> |
| Task<JavaScriptEvaluationResult> EvaluateScriptAsync(string script); |
| Task<JavaScriptEvaluationResult> EvaluateScriptAsync(string script); |
| } |
| } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Describes web view factory provider. |
| /// Describes web view factory provider. |
| /// </summary> |
| /// </summary> |
| public interface IWebViewFactory |
| public interface IWebViewFactory |
| { |
| { |
| /// <summary> |
| /// <summary> |
| /// Creates new offscreen web view. |
| /// Creates new offscreen web view. |
| /// </summary> |
| /// </summary> |
| /// <returns>Offscreen web view.</returns> |
| /// <returns>Offscreen web view.</returns> |
| IWebView CreateOffscreenView(); |
| IWebView CreateOffscreenView(); |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Creates new offscreen web view with specific settings. |
| /// Creates new offscreen web view with specific settings. |
| /// </summary> |
| /// </summary> |
| /// <param name="settings">Browser view settings.</param> |
| /// <param name="settings">Browser view settings.</param> |
| /// <returns></returns> |
| /// <returns></returns> |
| IWebView CreateOffscreenView(WebViewSettings settings); |
| IWebView CreateOffscreenView(WebViewSettings settings); |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Creates new web view. |
| /// Creates new web view. |
| /// </summary> |
| /// </summary> |
| /// <param name="width">View widht.</param> |
| /// <param name="width">View widht.</param> |
| /// <param name="height">View height.</param> |
| /// <param name="height">View height.</param> |
| /// <returns>Web view.</returns> |
| /// <returns>Web view.</returns> |
| IWebView CreateView(int width, int height); |
| IWebView CreateView(int width, int height); |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Creates new web view. |
| /// Creates new web view. |
| /// </summary> |
| /// </summary> |
| /// <param name="width">View widht.</param> |
| /// <param name="width">View widht.</param> |
| /// <param name="height">View height.</param> |
| /// <param name="height">View height.</param> |
| /// <param name="background">View background color.</param> |
| /// <param name="background">View background color.</param> |
| /// <returns>Web view.</returns> |
| /// <returns>Web view.</returns> |
| IWebView CreateView(int width, int height, Color background); |
| IWebView CreateView(int width, int height, Color background); |
. | |
| |
| |
| /// <summary> |
| |
| /// Creates new web view. |
| |
| /// </summary> |
| |
| /// <param name="settings">Browser view settings.</param> |
| |
| /// <returns></returns> |
| |
| IWebView CreateView(WebViewSettings settings); |
| } |
| } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Represetn web view cookie object. |
| /// Represetn web view cookie object. |
| /// </summary> |
| /// </summary> |
| public class HttpCookie |
| public class HttpCookie |
| { |
| { |
| /// <summary> |
| /// <summary> |
| /// Creates new instance of <see cref="HttpCookie"/>. |
| /// Creates new instance of <see cref="HttpCookie"/>. |
| /// </summary> |
| /// </summary> |
| public HttpCookie() |
| public HttpCookie() |
| { |
| { |
| } |
| } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// The cookie name. |
| /// The cookie name. |
| /// </summary> |
| /// </summary> |
| public string Name { get; set; } |
| public string Name { get; set; } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// The cookie value. |
| /// The cookie value. |
| /// </summary> |
| /// </summary> |
| public string Value { get; set; } |
| public string Value { get; set; } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// The cookie domain. |
| /// The cookie domain. |
| /// </summary> |
| /// </summary> |
| public string Domain { get; set; } |
| public string Domain { get; set; } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// The cookie path. |
| /// The cookie path. |
| /// </summary> |
| /// </summary> |
| public string Path { get; set; } |
| public string Path { get; set; } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// The cookie expire date. |
| /// The cookie expire date. |
| /// </summary> |
| /// </summary> |
| public DateTime? Expires { get; set; } |
| public DateTime? Expires { get; set; } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// The cookie creation date. |
| /// The cookie creation date. |
| /// </summary> |
| /// </summary> |
| public DateTime Creation { get; set; } |
| public DateTime Creation { get; set; } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// If true the cookie will only be sent for HTTPS requests. |
| /// If true the cookie will only be sent for HTTPS requests. |
| /// </summary> |
| /// </summary> |
| public bool Secure { get; set; } |
| public bool Secure { get; set; } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// If true the cookie will only be sent for HTTP requests. |
| /// If true the cookie will only be sent for HTTP requests. |
| /// </summary> |
| /// </summary> |
| public bool HttpOnly { get; set; } |
| public bool HttpOnly { get; set; } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// The cookie last access date. This is automatically populated by the system on access. |
| /// The cookie last access date. This is automatically populated by the system on access. |
| /// </summary> |
| /// </summary> |
| public DateTime LastAccess { get; set; } |
| public DateTime LastAccess { get; set; } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Same site |
| /// Same site |
| /// </summary> |
| /// </summary> |
| public CookieSameSite SameSite { get; set; } |
| public CookieSameSite SameSite { get; set; } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Priority |
| /// Priority |
| /// </summary> |
| /// </summary> |
| public CookiePriority Priority { get; set; } |
| public CookiePriority Priority { get; set; } |
| } |
| } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Cookie same site values. |
| /// Cookie same site values. |
| /// </summary> |
| /// </summary> |
| /// <remarks> |
| /// <remarks> |
| /// See https://source.chromium.org/chromium/chromium/src/+/master:net/cookies/cookie_constants.h |
| /// See https://source.chromium.org/chromium/chromium/src/+/master:net/cookies/cookie_constants.h |
| /// </remarks> |
| /// </remarks> |
| public enum CookieSameSite |
| public enum CookieSameSite |
| { |
| { |
| /// <summary> |
| /// <summary> |
| /// Unspecified |
| /// Unspecified |
| /// </summary> |
| /// </summary> |
| Unspecified = 0, |
| Unspecified = 0, |
| /// <summary> |
| /// <summary> |
| /// Cookies will be sent in all contexts, i.e sending cross-origin is allowed. None |
| /// Cookies will be sent in all contexts, i.e sending cross-origin is allowed. None |
| /// used to be the default value, but recent browser versions made Lax the default |
| /// used to be the default value, but recent browser versions made Lax the default |
| /// value to have reasonably robust defense against some classes of cross-site request |
| /// value to have reasonably robust defense against some classes of cross-site request |
| /// forgery (CSRF) attacks. |
| /// forgery (CSRF) attacks. |
| /// </summary> |
| /// </summary> |
| NoRestriction = 1, |
| NoRestriction = 1, |
| /// <summary> |
| /// <summary> |
| /// Cookies are allowed to be sent with top-level navigations and will be sent along |
| /// Cookies are allowed to be sent with top-level navigations and will be sent along |
| /// with GET request initiated by third party website. This is the default value |
| /// with GET request initiated by third party website. This is the default value |
| /// in modern browsers. |
| /// in modern browsers. |
| /// </summary> |
| /// </summary> |
| LaxMode = 2, |
| LaxMode = 2, |
| /// <summary> |
| /// <summary> |
| /// Cookies will only be sent in a first-party context and not be sent along with |
| /// Cookies will only be sent in a first-party context and not be sent along with |
| /// requests initiated by third party websites. |
| /// requests initiated by third party websites. |
| /// </summary> |
| /// </summary> |
| StrictMode = 3 |
| StrictMode = 3 |
| } |
| } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Cookie priority values. |
| /// Cookie priority values. |
| /// </summary> |
| /// </summary> |
| public enum CookiePriority |
| public enum CookiePriority |
| { |
| { |
| /// <summary> |
| /// <summary> |
| /// Low Priority |
| /// Low Priority |
| /// </summary> |
| /// </summary> |
| Low = -1, |
| Low = -1, |
| /// <summary> |
| /// <summary> |
| /// Medium Priority |
| /// Medium Priority |
| /// </summary> |
| /// </summary> |
| Medium = 0, |
| Medium = 0, |
| /// <summary> |
| /// <summary> |
| /// High Priority |
| /// High Priority |
| /// </summary> |
| /// </summary> |
| High = 1 |
| High = 1 |
| } |
| } |
| } |
| } |
| |
| |