Beispiel #1
0
        /// <summary>
        /// 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 &apos;;&apos; character is disallowed
        /// within the cookie value attribute) and fail without setting the cookie if
        /// such characters are found. If |callback| is non-NULL it will be executed
        /// asnychronously on the UI thread after the cookie has been set. Returns
        /// false (0) if an invalid URL is specified or if cookies cannot be accessed.
        /// </summary>
        public unsafe virtual bool SetCookie(string url, CefCookie cookie, CefSetCookieCallback callback)
        {
            fixed(char *s0 = url)
            {
                var cstr0 = new cef_string_t {
                    Str = s0, Length = url != null ? url.Length : 0
                };

                return(SafeCall(NativeInstance->SetCookie(&cstr0, (cef_cookie_t *)&cookie, (callback != null) ? callback.GetNativeInstance() : null) != 0));
            }
        }
Beispiel #2
0
        /// <summary>
        /// Sets a cookie given a valid URL and explicit user-provided cookie
        /// attributes.
        /// </summary>
        /// <param name="url">The cookie URL.</param>
        /// <param name="cookie">The cookie.</param>
        /// <param name="callback">
        /// If <paramref name="callback"/> is non-NULL it will be executed
        /// asnychronously on the CEF UI thread after the cookie has been set.
        /// </param>
        /// <returns>
        /// true if the operation is completed successfully; false if cookies cannot be accessed.
        /// </returns>
        /// <exception cref="ArgumentNullException">The <paramref name="url"/> is null or the <paramref name="cookie"/> is null.</exception>
        /// <exception cref="ArgumentOutOfRangeException">An invalid URL is specified.</exception>
        public unsafe bool SetCookie(string url, CefNetCookie cookie, CefSetCookieCallback callback)
        {
            if (url is null)
            {
                throw new ArgumentNullException(nameof(url));
            }
            if (cookie is null)
            {
                throw new ArgumentNullException(nameof(cookie));
            }

            if (Uri.TryCreate(url, UriKind.Absolute, out Uri uri) &&
                (Uri.UriSchemeHttp.Equals(uri.Scheme, StringComparison.Ordinal) || Uri.UriSchemeHttps.Equals(uri.Scheme, StringComparison.Ordinal)))
            {
                CefCookie aCookie = cookie.ToCefCookie();
                try
                {
                    if (cookie.Domain != null && !cookie.Domain.StartsWith("."))
                        aCookie.Domain = null;

                    fixed(char *s0 = url)
                    {
                        var cstr0 = new cef_string_t {
                            Str = s0, Length = url.Length
                        };

                        return(SafeCall(NativeInstance->SetCookie(&cstr0, (cef_cookie_t *)&aCookie, (callback != null) ? callback.GetNativeInstance() : null) != 0));
                    }
                }
                finally
                {
                    aCookie.Dispose();
                }
            }
            throw new ArgumentOutOfRangeException(nameof(url));
        }
Beispiel #3
0
 /// <summary>
 /// Method that will be called once for each cookie. |count| is the 0-based
 /// index for the current cookie. |total| is the total number of cookies. Set
 /// |deleteCookie| to true (1) to delete the cookie currently being visited.
 /// Return false (0) to stop visiting cookies. This function may never be
 /// called if no cookies are found.
 /// </summary>
 public unsafe virtual bool Visit(CefCookie cookie, int count, int total, ref int deleteCookie)
 {
     return(default);
Beispiel #4
0
 /// <summary>
 /// Called on the IO thread before a resource request is sent. The |browser|
 /// and |frame| values represent the source of the request, and may be NULL for
 /// requests originating from service workers or cef_urlrequest_t. |request|
 /// cannot be modified in this callback. Return true (1) if the specified
 /// cookie can be sent with the request or false (0) otherwise.
 /// </summary>
 protected internal unsafe virtual bool CanSendCookie(CefBrowser browser, CefFrame frame, CefRequest request, CefCookie cookie)
 {
     return(default);
Beispiel #5
0
 /// <summary>
 /// Method that will be called once for each cookie. |count| is the 0-based
 /// index for the current cookie. |total| is the total number of cookies. Set
 /// |deleteCookie| to true (1) to delete the cookie currently being visited.
 /// Return false (0) to stop visiting cookies. This function may never be
 /// called if no cookies are found.
 /// </summary>
 protected internal unsafe virtual bool Visit(CefCookie cookie, int count, int total, ref int deleteCookie)
 {
     return(default);
Beispiel #6
0
 /// <summary>
 /// Called on the IO thread before a resource request is sent. The |browser|
 /// and |frame| values represent the source of the request, and may be NULL for
 /// requests originating from service workers or cef_urlrequest_t. |request|
 /// cannot be modified in this callback. Return true (1) if the specified
 /// cookie can be sent with the request or false (0) otherwise.
 /// </summary>
 public unsafe virtual bool CanSendCookie(CefBrowser browser, CefFrame frame, CefRequest request, CefCookie cookie)
 {
     return(default);