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(); } }
protected override bool Visit(CefCookie cookie, int count, int total, out bool delete) { delete = false; this.Total = total; if (null != cookie) { if (cookie.Name != __temp_cookie_key_securityGetCookies) { this.Results.Add(cookie); } } if ((count + 1) == total) { //遍历完毕最后的Cookie后,通知订阅事件 var agrs = new CookieVistCompletedEventAgrs() { Results = this.Results }; this.OnVistCookiesCompleted(agrs); } return(true); }
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); }
protected override bool Visit(CefCookie cookie, int count, int total, out bool delete) { delete = true; //LogManager.WriteLog(cookie.Domain + " " + cookie.Name + " " + cookie.Value); return(true); }
protected internal override bool Visit(CefCookie cookie, int count, int total, ref int deleteCookie) { if (string.Equals(cookie.Domain, _domain, StringComparison.OrdinalIgnoreCase)) { if (_name is null || _name.Equals(cookie.Name, StringComparison.OrdinalIgnoreCase)) { _count++; deleteCookie = 1; } } return(_continue); }
protected override bool Visit(CefCookie cookie, int count, int total, out bool delete) { delete = deleteCookies;// 删除 CefCookies.Add(cookie); //LogManager.WriteLog(cookie.Domain + " " + cookie.Name + " " + cookie.Value); if (count + 1 == total) { LogManager.WriteLog("释放"); GlobalVar.IscookiesAutoResetEvent.Set(); } return(true);//继续遍历 }
protected override bool Visit(CefCookie cookie, int count, int total, out bool delete) { delete = false cookie.Add(new < Tuple <string, string>(cookie.Name.cookie.Value)); if (count == total = 1) { useAllCookies(cookies); } return(true); }
protected override bool Visit(CefCookie cookie, int count, int total, out bool delete) { Cookies.Add(new Cookie { Name = cookie.Name, Value = cookie.Value, Domain = cookie.Domain, Path = cookie.Path }); if (count == total) { _source.SetResult(Cookies); } delete = false; return(true); }
protected internal override bool Visit(CefCookie cookie, int count, int total, ref int deleteCookie) { try { _cookies.Capacity = total; } catch (OutOfMemoryException e) { _completionSource.TrySetException(e); return(false); } if (_filter is null || _filter(cookie)) { _cookies.Add(new CefNetCookie(cookie)); } return(_continue); }
/// <summary> /// Initializes a new instance of the <see cref="CefNetCookie"/> class. /// </summary> public CefNetCookie(CefCookie cookie) { _name = cookie.Name; _value = cookie.Value ?? string.Empty; this.Path = cookie.Path; this.Domain = cookie.Domain; this.Secure = cookie.Secure; this.HttpOnly = cookie.HttpOnly; this.TimeStamp = cookie.Creation.ToDateTime(); this.LastAccess = cookie.LastAccess.ToDateTime(); if (cookie.HasExpires) { this.Expires = cookie.Expires.ToDateTime(); } this.SameSite = cookie.SameSite; this.Priority = cookie.Priority; }
/// <summary> /// 设置cookies /// </summary> /// <param name="urls"></param> /// <param name="cookies"></param> /// <param name="domain"></param> public static void SetCookie(string domain, Dictionary <string, string> cookies) { CefCookieManager manager = CefCookieManager.GetGlobal(null); string url = "http://" + domain; foreach (var c in cookies) { CefCookie cookie = new CefCookie(); cookie.Name = c.Key; cookie.Value = c.Value; cookie.Domain = domain; cookie.Path = "/"; cookie.HttpOnly = false; //cookie.Expires = DateTime.Now.AddDays(100); //cookie.expires.year = 2200; //cookie.expires.month = 4; //cookie.expires.day_of_week = 5; //cookie.expires.day_of_month = 11; // BSCookieTask bt = new BSCookieTask(url, cookie); //CefRuntime.PostTask(CefThreadId.IO, bt); manager.SetCookie(url, cookie, null); } }
protected override bool Visit(CefCookie cookie, int count, int total, out bool delete) { delete = false; // LogManager.WriteLog(cookie.Domain + " " + cookie.Value); //待付款 if (cookie.Name == cookiename) { TradeCookies.Domain = cookie.Domain; TradeCookies.Name = cookie.Name; if (!string.IsNullOrEmpty(cookie.Value)) { LogManager.WriteLog("Visit cookies. " + cookiename); if (cookiename == "list_bought_items") { lock (GlobalVar.ConfirmGoodsUrls) { convertCookie2List(cookie.Value).ForEach(_ => GlobalVar.ConfirmGoodsUrls.Enqueue(_)); } } else if (cookiename == "list_rate_items") { lock (GlobalVar.RateGoodsUrls) { GlobalVar.RateGoodsUrls.Clear(); convertCookie2List(cookie.Value).ForEach(_ => GlobalVar.RateGoodsUrls.Enqueue(_)); } } else { } }// } //待评价 //待退 //待... // LogManager.WriteLog(cookie.Domain + " " + cookie.Name + " " + cookie.Value); return(true); }
protected override bool CanSetCookie(CefCookie cookie) { return false; }
protected override bool CanGetCookie(CefCookie cookie) { return(true); }
protected internal unsafe override bool CanSaveCookie(CefBrowser browser, CefFrame frame, CefRequest request, CefResponse response, CefCookie cookie) { return(_implementation.CanSaveCookie(browser, frame, request, response, cookie)); }
public CefWebCookieVisitor(CefCookie cookie) { _cefCookie = cookie; }
/// <summary> /// Called on the IO thread after a resource response is received. /// </summary> /// <param name="browser"> /// Represent the source browser of the request, and may be NULL for requests originating from service workers or CefURLRequest. /// </param> /// <param name="frame"> /// Represent the source frame of the request, and may be NULL for requests originating from service workers or CefURLRequest. /// </param> /// <param name="request"> /// The request. Cannot be modified in this callback. /// </param> /// <param name="cookie"> /// The cookie. /// </param> /// <returns> /// Return true if the specified cookie returned with the response can be saved or false otherwise. /// </returns> internal protected virtual bool CanSaveCookie(CefBrowser browser, CefFrame frame, CefRequest request, CefResponse response, CefCookie cookie) { return(true); }
protected internal unsafe override bool Visit(CefCookie cookie, int count, int total, ref int deleteCookie) { return(_implementation.Visit(cookie, count, total, ref deleteCookie)); }
protected override bool CanSetCookie(CefCookie cookie) { throw new NotImplementedException(); }
/// <summary> /// 设置Cookie /// </summary> public void SetCookie(string url, CefCookie cookie) { CefCookieManager.Global.SetCookie(url, cookie); }
public CwbCookieTask(string url, CefCookie cookie) { Url = url; Cookie = cookie; }
protected override bool Visit(CefCookie cookie, int count, int total, out bool delete) { delete = false; cefCookieCollection.Add(cookie); return(true); }
public override bool CanSaveCookie(CefBrowser browser, CefFrame frame, CefRequest request, CefResponse response, CefCookie cookie) { return(_implementation.CanSaveCookie(browser, frame, request, response, cookie)); }
public BSCookieTask(string url, CefCookie newCookie) { this.cookie = newCookie; this.url = url; }
protected override bool CanSetCookie(CefCookie cookie) { return(false); }
protected override bool Visit(CefCookie cookie, int count, int total, out bool delete) { delete = true; return(true); }
protected override bool CanSetCookie(CefCookie cookie) => false;
public override bool Visit(CefCookie cookie, int count, int total, ref int deleteCookie) { return(_implementation.Visit(cookie, count, total, ref deleteCookie)); }
protected override bool CanSendCookie(CefBrowser browser, CefFrame frame, CefRequest request, CefCookie cookie) { return(true); //throw new NotImplementedException(); }