// Copyright © 2015 The CefSharp Authors. All rights reserved. // // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. using System; namespace CefSharp { /// /// Used for managing cookies. The methods may be called on any thread unless otherwise indicated. /// public interface ICookieManager : IDisposable { /// /// Delete all cookies that match the specified parameters. /// If both and values are specified all host and domain cookies matching both will be deleted. /// If only is specified all host cookies (but not domain cookies) irrespective of path will be deleted. /// If is empty all cookies for all hosts and domains will be deleted. /// Cookies can alternately be deleted using the Visit*Cookies() methods. /// /// The cookie URL. /// The name of the cookie. /// If non-NULL it will be executed asynchronously on the CEF UI thread after the cookies have been deleted. /// Returns false if a non-empty invalid URL is specified or if cookies cannot be accessed; otherwise, true. bool DeleteCookies(string url = null, string name = null, IDeleteCookiesCallback callback = null); /// /// Sets a cookie given a valid URL and explicit user-provided cookie attributes. This function expects each attribute to be well-formed. It will check for disallowed /// characters (e.g. the ';' character is disallowed within the cookie value attribute) and fail without setting the cookie if such characters are found. /// This method will be executed on the CEF UI thread in an async fashion, to be notified upon completion implement /// and pass in as /// /// The cookie URL /// The cookie /// If non-NULL it will be executed asynchronously on the CEF UI thread after the cookie has been set. /// Returns false if an invalid URL is specified or if cookies cannot be accessed. bool SetCookie(string url, Cookie cookie, ISetCookieCallback callback = null); /// /// Set the schemes supported by this manager. Calling this method with an empty value and /// set to false will disable all loading and saving of cookies for this manager. Must be called before any cookies are accessed. /// /// The list of supported schemes. /// If true the default schemes ("http", "https", "ws" and "wss") will also be supported. Calling this method with an empty schemes value and includeDefaults /// set to false will disable all loading and saving of cookies for this manager /// If non-NULL it will be executed asnychronously on the CEF UI thread after the change has been applied. void SetSupportedSchemes(string[] schemes, bool includeDefaults, ICompletionCallback callback = null); /// /// Visit all cookies on the UI thread. The returned cookies are ordered by longest path, then by earliest creation date. /// /// A user-provided Cookie Visitor implementation. /// Returns false if cookies cannot be accessed; otherwise, true. bool VisitAllCookies(ICookieVisitor visitor); /// /// Visit a subset of cookies on the CEF UI thread. /// The results are filtered by the given url scheme, host, domain and path. /// The returned cookies are ordered by longest path, then by earliest creation date. /// /// The URL to use for filtering a subset of the cookies available. /// If true HTTP-only cookies will also be included in the results. /// A user-provided Cookie Visitor implementation. /// Returns false if cookies cannot be accessed; otherwise, true. bool VisitUrlCookies(string url, bool includeHttpOnly, ICookieVisitor visitor); /// /// Flush the backing store (if any) to disk /// This method will be executed on the CEF UI thread in an async fashion, to be notified upon completion implement /// and pass in as /// /// If non-NULL it will be executed asnychronously on the CEF UI thread after the flush is complete. /// Returns false if cookies cannot be accessed. bool FlushStore(ICompletionCallback callback); /// /// Returns true if disposed /// bool IsDisposed { get; } } }