protected override bool Visit(CefCookie cookie, int count, int total, out bool delete) { delete = false; switch (_style) { case CwbCookieStyle.csDeleteAllCookie: delete = true; break; case CwbCookieStyle.csVisitUrlCookie: string cookieValue = cookie.Name + "=" + cookie.Value + ";"; _document._cookie += cookieValue; CwbCookie cookieItem = new CwbCookie(); cookieItem.Creation = cookie.Creation; cookieItem.Domain = cookie.Domain; cookieItem.Expires = cookie.Expires; cookieItem.HttpOnly = cookie.HttpOnly; cookieItem.LastAccess = cookie.LastAccess; cookieItem.Name = cookie.Name; cookieItem.Path = cookie.Path; cookieItem.Secure = cookie.Secure; cookieItem.Value = cookie.Value; _document._cookies.Add(cookieItem); break; } return true; }
/// <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 ';' character is disallowed /// within the cookie value attribute) and will return false without setting /// the cookie if such characters are found. This method must be called on the /// IO thread. /// </summary> public bool SetCookie(string url, CefCookie cookie) { if (string.IsNullOrEmpty(url)) { throw new ArgumentNullException("url"); } if (cookie == null) throw new ArgumentNullException("cookie"); }
private int can_get_cookie(cef_resource_handler_t *self, cef_cookie_t *cookie) { CheckSelf(self); var m_cookie = CefCookie.FromNative(cookie); return(CanGetCookie(m_cookie) ? 1 : 0); }
private int visit(cef_cookie_visitor_t *self, cef_cookie_t *cookie, int count, int total, int *deleteCookie) { CheckSelf(self); var mCookie = CefCookie.FromNative(cookie); bool mDelete; var result = Visit(mCookie, count, total, out mDelete); *deleteCookie = mDelete ? 1 : 0; return(result ? 1 : 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 to delete the cookie currently being visited. /// Return false to stop visiting cookies. This method may never be called if /// no cookies are found. /// </summary> protected abstract bool Visit(CefCookie cookie, int count, int total, out bool delete);
/// <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 ';' character is disallowed /// within the cookie value attribute) and will return false without setting /// the cookie if such characters are found. This method must be called on the /// IO thread. /// </summary> public bool SetCookie(string url, CefCookie cookie) { if (string.IsNullOrEmpty(url)) throw new ArgumentNullException("url"); if (cookie == null) throw new ArgumentNullException("cookie"); int n_result; var n_cookie = cookie.ToNative(); fixed (char* url_str = url) { var n_url = new cef_string_t(url_str, url.Length); n_result = cef_cookie_manager_t.set_cookie(_self, &n_url, n_cookie); } CefCookie.Free(n_cookie); return n_result != 0; }
public CwbCookieTask(string url, CefCookie cookie) { Url = url; Cookie = cookie; }
/// <summary> /// Return true if the specified cookie returned with the response can be set /// or false otherwise. /// </summary> protected abstract bool CanSetCookie(CefCookie cookie);
protected override bool CanSetCookie(CefCookie cookie) { return false; }
public void OpenUrl(string Url) { while (true) { if (created) break; Application.DoEvents(); } if (browser != null) { OnNavigating(); CefCookie cookie = new CefCookie(); cookie.Name = "cwberCookieName"; cookie.Value = "cwberCookie"; cookie.Domain = "cwberCookieDomain"; cookie.Path = cookiePath; cookie.Secure = false; cookie.HttpOnly = false; cookie.Expires = DateTime.Now; cookie.Creation = DateTime.Now; CefRuntime.PostTask(CefThreadId.IO, new CwbCookieTask(Url, cookie)); browser.GetMainFrame().LoadUrl(Url); OnNavigated(); } }