// Copyright © 2021 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. namespace CefSharp.Handler { /// /// Inherit from this class to filter cookies that may be sent or received from /// resource requests. The methods of this class will be called on the CEF IO thread /// unless otherwise indicated. /// public class CookieAccessFilter : ICookieAccessFilter { /// bool ICookieAccessFilter.CanSendCookie(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, Cookie cookie) { return CanSendCookie(chromiumWebBrowser, browser, frame, request, cookie); } /// /// Called on the CEF IO thread before a resource request is sent. /// /// The ChromiumWebBrowser control /// the browser object - may be null if originating from ServiceWorker or CefURLRequest /// the frame object - may be null if originating from ServiceWorker or CefURLRequest /// the request object - cannot be modified in this callback /// the cookie object /// Return true if the specified cookie can be sent with the request or false otherwise. protected virtual bool CanSendCookie(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, Cookie cookie) { return false; } /// bool ICookieAccessFilter.CanSaveCookie(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IResponse response, Cookie cookie) { return CanSaveCookie(chromiumWebBrowser, browser, frame, request, response, cookie); } /// /// Called on the CEF IO thread after a resource response is received. /// /// The ChromiumWebBrowser control /// the browser object - may be null if originating from ServiceWorker or CefURLRequest /// the frame object - may be null if originating from ServiceWorker or CefURLRequest /// the request object - cannot be modified in this callback /// the response object - cannot be modified in this callback /// the cookie object /// Return true if the specified cookie returned with the response can be saved or false otherwise. protected virtual bool CanSaveCookie(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IResponse response, Cookie cookie) { return false; } } }