| 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> |
| public bool CacheEnabled { get; set; } = true; |
| public bool CacheEnabled { get; set; } = true; |
| } |
| } |
| |
| |
| /// <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> |
. | /// Closes view. |
| /// Sets cookie data. |
| /// </summary> |
| /// </summary> |
. | void Close(); |
| /// <param name="url">Cookie URL.</param> |
| |
| /// <param name="cookie">Cookie data.</param> |
| |
| void SetCookies(string url, HttpCookie cookie); |
| |
| |
| /// <summary> |
| /// <summary> |
. | /// Occurs when web view navigatates to a new page. |
| /// Closes view. |
| /// </summary> |
| /// </summary> |
. | [Obsolete("Use LoadingChanged event instead.")] |
| void Close(); |
| event EventHandler NavigationChanged; |
| |
| |
| |
| /// <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> |
| /// <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> |
| |
| /// If true the cookie will only be sent for HTTPS requests. |
| |
| /// </summary> |
| |
| public bool Secure { get; set; } |
| |
| |
| |
| /// <summary> |
| |
| /// If true the cookie will only be sent for HTTP requests. |
| |
| /// </summary> |
| |
| public bool HttpOnly { get; set; } |
| |
| |
| |
| /// <summary> |
| |
| /// The cookie last access date. This is automatically populated by the system on access. |
| |
| /// </summary> |
| |
| public DateTime LastAccess { get; set; } |
| |
| |
| |
| /// <summary> |
| |
| /// Same site |
| |
| /// </summary> |
| |
| public CookieSameSite SameSite { get; set; } |
| |
| |
| |
| /// <summary> |
| |
| /// Priority |
| |
| /// </summary> |
| |
| public CookiePriority Priority { get; set; } |
| |
| } |
| |
| |
| |
| /// <summary> |
| |
| /// Cookie same site values. |
| |
| /// </summary> |
| |
| /// <remarks> |
| |
| /// See https://source.chromium.org/chromium/chromium/src/+/master:net/cookies/cookie_constants.h |
| |
| /// </remarks> |
| |
| public enum CookieSameSite |
| |
| { |
| |
| /// <summary> |
| |
| /// Unspecified |
| |
| /// </summary> |
| |
| Unspecified = 0, |
| |
| /// <summary> |
| |
| /// 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 |
| |
| /// value to have reasonably robust defense against some classes of cross-site request |
| |
| /// forgery (CSRF) attacks. |
| |
| /// </summary> |
| |
| NoRestriction = 1, |
| |
| /// <summary> |
| |
| /// 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 |
| |
| /// in modern browsers. |
| |
| /// </summary> |
| |
| LaxMode = 2, |
| |
| /// <summary> |
| |
| /// Cookies will only be sent in a first-party context and not be sent along with |
| |
| /// requests initiated by third party websites. |
| |
| /// </summary> |
| |
| StrictMode = 3 |
| |
| } |
| |
| |
| |
| /// <summary> |
| |
| /// Cookie priority values. |
| |
| /// </summary> |
| |
| public enum CookiePriority |
| |
| { |
| |
| /// <summary> |
| |
| /// Low Priority |
| |
| /// </summary> |
| |
| Low = -1, |
| |
| /// <summary> |
| |
| /// Medium Priority |
| |
| /// </summary> |
| |
| Medium = 0, |
| |
| /// <summary> |
| |
| /// High Priority |
| |
| /// </summary> |
| |
| High = 1 |
| } |
| } |
| } |
| } |
| |
| |