CookieManager Rewrite - remove all the async wrappers and expose the underlying CEF API

Remove CookieAsyncWrapper as it's no longer required to perform the operations directly on the CEF IO thread.
Async extension methods will be added to maintain existing functionality
This commit is contained in:
amaitland
2017-02-14 11:40:12 +10:00
parent ee5fd34ee6
commit 6e443ca091
14 changed files with 369 additions and 210 deletions
+2 -1
View File
@@ -252,6 +252,8 @@
<ItemGroup>
<ClInclude Include="BrowserSettings.h" />
<ClInclude Include="Cef.h" />
<ClInclude Include="Internals\CefDeleteCookiesCallbackAdapter.h" />
<ClInclude Include="Internals\CefSetCookieCallbackAdapter.h" />
<ClInclude Include="Internals\CefCertificateCallbackWrapper.h" />
<ClInclude Include="CookieManager.h" />
<ClInclude Include="Internals\CefNavigationEntryVisitorAdapter.h" />
@@ -310,7 +312,6 @@
<ClInclude Include="Internals\Serialization\JsObjectsSerialization.h" />
<ClInclude Include="SchemeHandlerFactoryWrapper.h" />
<ClInclude Include="ResourceHandlerWrapper.h" />
<ClInclude Include="CookieAsyncWrapper.h" />
<ClInclude Include="Stdafx.h" />
<ClInclude Include="Internals\StringUtils.h" />
<ClInclude Include="vcclr_local.h" />
+6 -3
View File
@@ -142,9 +142,6 @@
<ClInclude Include="Internals\CefTaskWrapper.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="CookieAsyncWrapper.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Internals\ReportUnhandledExceptions.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -265,6 +262,12 @@
<ClInclude Include="Internals\CefRegisterCdmCallbackAdapter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Internals\CefSetCookieCallbackAdapter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Internals\CefDeleteCookiesCallbackAdapter.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Internals\CefSharpBrowserWrapper.h">
-81
View File
@@ -1,81 +0,0 @@
// Copyright © 2010-2016 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.
#pragma once
#include "Stdafx.h"
namespace CefSharp
{
private ref class CookieAsyncWrapper
{
MCefRefPtr<CefCookieManager> _cookieManager;
String^ _url;
String^ _name;
String^ _value;
String^ _domain;
String^ _path;
bool _secure;
bool _httponly;
bool _hasExpires;
DateTime _expires;
public:
//Used for SetCookies
CookieAsyncWrapper(const CefRefPtr<CefCookieManager> &cookieManager, String^ url, String^ name, String^ value, String^ domain, String^ path, bool secure, bool httponly, bool hasExpires, DateTime expires) :
_url(url), _name(name), _value(value), _domain(domain), _path(path), _secure(secure), _httponly(httponly), _hasExpires(hasExpires), _expires(expires), _cookieManager(cookieManager.get())
{
}
//Used for DeleteCookies
CookieAsyncWrapper(const CefRefPtr<CefCookieManager> &cookieManager, String^ url, String^ name) :
_url(url), _name(name), _cookieManager(cookieManager.get())
{
}
bool SetCookie()
{
CefCookie cookie;
StringUtils::AssignNativeFromClr(cookie.name, _name);
StringUtils::AssignNativeFromClr(cookie.value, _value);
StringUtils::AssignNativeFromClr(cookie.domain, _domain);
StringUtils::AssignNativeFromClr(cookie.path, _path);
cookie.secure = _secure;
cookie.httponly = _httponly;
cookie.has_expires = _hasExpires;
cookie.expires.year = _expires.Year;
cookie.expires.month = _expires.Month;
cookie.expires.day_of_month = _expires.Day;
cookie.expires.hour = _expires.Hour;
cookie.expires.minute = _expires.Minute;
cookie.expires.second = _expires.Second;
cookie.expires.millisecond = _expires.Millisecond;
auto result = _cookieManager->SetCookie(StringUtils::ToNative(_url), cookie, NULL);
delete this;
return result;
}
bool DeleteCookies()
{
auto result = _cookieManager->DeleteCookies(StringUtils::ToNative(_url), StringUtils::ToNative(_name), NULL);
delete this;
return result;
}
!CookieAsyncWrapper()
{
_cookieManager = nullptr;
}
~CookieAsyncWrapper()
{
this->!CookieAsyncWrapper();
}
};
}
+46 -69
View File
@@ -5,9 +5,10 @@
#include "Stdafx.h"
#include "CookieManager.h"
#include "CookieAsyncWrapper.h"
#include "Internals\CookieVisitor.h"
#include "Internals\CefCompletionCallbackAdapter.h"
#include "Internals\CefSetCookieCallbackAdapter.h"
#include "Internals\CefDeleteCookiesCallbackAdapter.h"
#include "Cef.h"
namespace CefSharp
@@ -20,66 +21,66 @@ namespace CefSharp
}
}
Task<bool>^ CookieManager::DeleteCookiesAsync(String^ url, String^ name)
bool CookieManager::DeleteCookies(String^ url, String^ name, IDeleteCookiesCallback^ callback)
{
ThrowIfDisposed();
auto cookieInvoker = gcnew CookieAsyncWrapper(_cookieManager.get(), url, name);
CefRefPtr<CefDeleteCookiesCallback> wrapper = callback == nullptr ? NULL : new CefDeleteCookiesCallbackAdapter(callback);
if (CefCurrentlyOn(TID_IO))
return _cookieManager->DeleteCookies(StringUtils::ToNative(url), StringUtils::ToNative(name), wrapper);
}
bool CookieManager::SetCookie(String^ url, Cookie^ cookie, ISetCookieCallback^ callback)
{
ThrowIfDisposed();
CefRefPtr<CefSetCookieCallback> wrapper = callback == nullptr ? NULL : new CefSetCookieCallbackAdapter(callback);
CefCookie c;
StringUtils::AssignNativeFromClr(c.name, cookie->Name);
StringUtils::AssignNativeFromClr(c.value, cookie->Value);
StringUtils::AssignNativeFromClr(c.domain, cookie->Domain);
StringUtils::AssignNativeFromClr(c.path, cookie->Path);
c.secure = cookie->Secure;
c.httponly = cookie->HttpOnly;
c.has_expires = cookie->Expires.HasValue;
if (cookie->Expires.HasValue)
{
auto source = gcnew TaskCompletionSource<bool>();
CefSharp::Internals::TaskExtensions::TrySetResultAsync<bool>(source, cookieInvoker->DeleteCookies());
return source->Task;
auto expires = cookie->Expires.Value;
c.expires.year = expires.Year;
c.expires.month = expires.Month;
c.expires.day_of_month = expires.Day;
c.expires.hour = expires.Hour;
c.expires.minute = expires.Minute;
c.expires.second = expires.Second;
c.expires.millisecond = expires.Millisecond;
}
return Cef::IOThreadTaskFactory->StartNew(gcnew Func<bool>(cookieInvoker, &CookieAsyncWrapper::DeleteCookies));
auto timeSpan = cookie->Creation- DateTime(1970, 1, 1);
c.creation = CefTime(timeSpan.TotalSeconds);
timeSpan = cookie->LastAccess - DateTime(1970, 1, 1);
c.last_access = CefTime(timeSpan.TotalSeconds);
return _cookieManager->SetCookie(StringUtils::ToNative(url), c, wrapper);
}
Task<bool>^ CookieManager::SetCookieAsync(String^ url, Cookie^ cookie)
bool CookieManager::SetStoragePath(String^ path, bool persistSessionCookies, ICompletionCallback^ callback)
{
ThrowIfDisposed();
auto cookieInvoker = gcnew CookieAsyncWrapper(_cookieManager.get(), url, cookie->Name, cookie->Value, cookie->Domain, cookie->Path, cookie->Secure, cookie->HttpOnly, cookie->Expires.HasValue, cookie->Expires.HasValue ? cookie->Expires.Value : DateTime());
CefRefPtr<CefCompletionCallback> wrapper = callback == nullptr ? NULL : new CefCompletionCallbackAdapter(callback);
if (CefCurrentlyOn(TID_IO))
{
auto source = gcnew TaskCompletionSource<bool>();
CefSharp::Internals::TaskExtensions::TrySetResultAsync<bool>(source, cookieInvoker->SetCookie());
return source->Task;
}
return Cef::IOThreadTaskFactory->StartNew(gcnew Func<bool>(cookieInvoker, &CookieAsyncWrapper::SetCookie));
return _cookieManager->SetStoragePath(StringUtils::ToNative(path), persistSessionCookies, wrapper);
}
bool CookieManager::SetStoragePath(String^ path, bool persistSessionCookies)
void CookieManager::SetSupportedSchemes(cli::array<String^>^ schemes, ICompletionCallback^ callback)
{
ThrowIfDisposed();
return _cookieManager->SetStoragePath(StringUtils::ToNative(path), persistSessionCookies, NULL);
}
CefRefPtr<CefCompletionCallback> wrapper = callback == nullptr ? NULL : new CefCompletionCallbackAdapter(callback);
void CookieManager::SetSupportedSchemes(... cli::array<String^>^ schemes)
{
ThrowIfDisposed();
_cookieManager->SetSupportedSchemes(StringUtils::ToNative(schemes), NULL);
}
Task<List<Cookie^>^>^ CookieManager::VisitAllCookiesAsync()
{
ThrowIfDisposed();
auto cookieVisitor = gcnew TaskCookieVisitor();
auto result = VisitAllCookies(cookieVisitor);
if (result == false)
{
delete cookieVisitor;
}
return cookieVisitor->Task;
_cookieManager->SetSupportedSchemes(StringUtils::ToNative(schemes), wrapper);
}
bool CookieManager::VisitAllCookies(ICookieVisitor^ visitor)
@@ -91,22 +92,6 @@ namespace CefSharp
return _cookieManager->VisitAllCookies(cookieVisitor);
}
Task<List<Cookie^>^>^ CookieManager::VisitUrlCookiesAsync(String^ url, bool includeHttpOnly)
{
ThrowIfDisposed();
auto cookieVisitor = gcnew TaskCookieVisitor();
auto result = VisitUrlCookies(url, includeHttpOnly, cookieVisitor);
if (result == false)
{
delete cookieVisitor;
}
return cookieVisitor->Task;
}
bool CookieManager::VisitUrlCookies(String^ url, bool includeHttpOnly, ICookieVisitor^ visitor)
{
ThrowIfDisposed();
@@ -116,20 +101,12 @@ namespace CefSharp
return _cookieManager->VisitUrlCookies(StringUtils::ToNative(url), includeHttpOnly, cookieVisitor);
}
Task<bool>^ CookieManager::FlushStoreAsync()
bool CookieManager::FlushStore(ICompletionCallback^ callback)
{
ThrowIfDisposed();
auto handler = gcnew TaskCompletionHandler();
CefRefPtr<CefCompletionCallback> wrapper = callback == nullptr ? NULL : new CefCompletionCallbackAdapter(callback);
CefRefPtr<CefCompletionCallback> wrapper = new CefCompletionCallbackAdapter(handler);
if (_cookieManager->FlushStore(wrapper))
{
return handler->Task;
}
//returns false if cookies cannot be accessed.
return CefSharp::Internals::TaskExtensions::FromResult(false);
return _cookieManager->FlushStore(wrapper);
}
}
+13 -7
View File
@@ -53,15 +53,21 @@ namespace CefSharp
this->!CookieManager();
}
virtual Task<bool>^ DeleteCookiesAsync(String^ url, String^ name);
virtual Task<bool>^ SetCookieAsync(String^ url, Cookie^ cookie);
virtual bool SetStoragePath(String^ path, bool persistSessionSookies);
virtual void SetSupportedSchemes(... cli::array<String^>^ schemes);
virtual Task<List<Cookie^>^>^ VisitAllCookiesAsync();
virtual bool DeleteCookies(String^ url, String^ name, IDeleteCookiesCallback^ callback);
virtual bool SetCookie(String^ url, Cookie^ cookie, ISetCookieCallback^ callback);
virtual bool SetStoragePath(String^ path, bool persistSessionSookies, ICompletionCallback^ callback);
virtual void SetSupportedSchemes(cli::array<String^>^ schemes, ICompletionCallback^ callback);
virtual bool VisitAllCookies(ICookieVisitor^ visitor);
virtual Task<List<Cookie^>^>^ VisitUrlCookiesAsync(String^ url, bool includeHttpOnly);
virtual bool VisitUrlCookies(String^ url, bool includeHttpOnly, ICookieVisitor^ visitor);
virtual Task<bool>^ FlushStoreAsync();
virtual bool FlushStore(ICompletionCallback^ callback);
virtual property bool IsDisposed
{
bool get()
{
return !_cookieManager.get();
}
}
operator CefRefPtr<CefCookieManager>()
{
@@ -9,28 +9,31 @@
namespace CefSharp
{
private class CefCompletionCallbackAdapter : public CefCompletionCallback
{
private:
gcroot<ICompletionCallback^> _handler;
namespace Internals
{
private class CefCompletionCallbackAdapter : public CefCompletionCallback
{
private:
gcroot<ICompletionCallback^> _handler;
public:
CefCompletionCallbackAdapter(ICompletionCallback^ handler)
{
_handler = handler;
}
public:
CefCompletionCallbackAdapter(ICompletionCallback^ handler)
{
_handler = handler;
}
~CefCompletionCallbackAdapter()
{
delete _handler;
_handler = nullptr;
}
~CefCompletionCallbackAdapter()
{
delete _handler;
_handler = nullptr;
}
void OnComplete() OVERRIDE
{
_handler->OnComplete();
}
void OnComplete() OVERRIDE
{
_handler->OnComplete();
}
IMPLEMENT_REFCOUNTING(CefCompletionCallbackAdapter);
};
IMPLEMENT_REFCOUNTING(CefCompletionCallbackAdapter);
};
}
}
@@ -0,0 +1,40 @@
// Copyright © 2010-2016 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.
#pragma once
#include "Stdafx.h"
#include "include/cef_cookie.h"
namespace CefSharp
{
namespace Internals
{
private class CefDeleteCookiesCallbackAdapter : public CefDeleteCookiesCallback
{
private:
gcroot<IDeleteCookiesCallback^> _handler;
public:
CefDeleteCookiesCallbackAdapter(IDeleteCookiesCallback^ handler)
{
_handler = handler;
}
~CefDeleteCookiesCallbackAdapter()
{
delete _handler;
_handler = nullptr;
}
void OnComplete(int numDeleted) OVERRIDE
{
_handler->OnComplete(numDeleted);
}
IMPLEMENT_REFCOUNTING(CefDeleteCookiesCallbackAdapter);
};
}
}
@@ -0,0 +1,42 @@
// Copyright © 2010-2016 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.
#pragma once
#include "Stdafx.h"
#include "include/cef_cookie.h"
namespace CefSharp
{
namespace Internals
{
private class CefSetCookieCallbackAdapter : public CefSetCookieCallback
{
private:
gcroot<ISetCookieCallback^> _handler;
public:
CefSetCookieCallbackAdapter(ISetCookieCallback^ handler)
{
_handler = handler;
}
~CefSetCookieCallbackAdapter()
{
delete _handler;
_handler = nullptr;
}
void OnComplete(bool success) OVERRIDE
{
_handler->OnComplete(success);
}
IMPLEMENT_REFCOUNTING(CefSetCookieCallbackAdapter);
};
}
}
+115
View File
@@ -0,0 +1,115 @@
// Copyright © 2010-2017 The CefSharp Project. 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;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace CefSharp
{
public static class AsyncExtensions
{
/// <summary>
/// Deletes all cookies that matches all the provided parameters asynchronously. If both <paramref name="url"/> and <paramref name="name"/> are empty, all cookies will be deleted.
/// </summary>
/// <param name="url">The cookie URL. If an empty string is provided, any URL will be matched.</param>
/// <param name="name">The name of the cookie. If an empty string is provided, any URL will be matched.</param>
/// <return>A task that represents the delete operation. The value of the TResult parameter contains false if a non-empty invalid URL is specified, or if cookies cannot be accessed; otherwise, true.</return>
//public static Task<bool> DeleteCookiesAsync(this ICookieManager cookieManager, string url = null, string name = null)
//{
// if(cookieManager == null)
// {
// throw new NullReferenceException("cookieManager");
// }
// if(cookieManager.IsDisposed)
// {
// throw new ObjectDisposedException("cookieManager");
// }
// auto cookieInvoker = gcnew CookieAsyncWrapper(_cookieManager.get(), url, name);
// if (CefCurrentlyOn(TID_IO))
// {
// auto source = gcnew TaskCompletionSource<bool>();
// CefSharp::Internals::TaskExtensions::TrySetResultAsync<bool>(source, cookieInvoker->DeleteCookies());
// return source->Task;
// }
// return Cef::IOThreadTaskFactory->StartNew(gcnew Func<bool>(cookieInvoker, &CookieAsyncWrapper::DeleteCookies));
//}
//public static Task<bool> SetCookieAsync(this ICookieManager cookieManager, string url, Cookie cookie)
//{
// ThrowIfDisposed();
// auto cookieInvoker = gcnew CookieAsyncWrapper(_cookieManager.get(), url, cookie->Name, cookie->Value, cookie->Domain, cookie->Path, cookie->Secure, cookie->HttpOnly, cookie->Expires.HasValue, cookie->Expires.HasValue ? cookie->Expires.Value : DateTime());
// if (CefCurrentlyOn(TID_IO))
// {
// auto source = gcnew TaskCompletionSource<bool>();
// CefSharp::Internals::TaskExtensions::TrySetResultAsync<bool>(source, cookieInvoker->SetCookie());
// return source->Task;
// }
// return Cef::IOThreadTaskFactory->StartNew(gcnew Func<bool>(cookieInvoker, &CookieAsyncWrapper::SetCookie));
//}
/// <summary>
/// Visits all cookies. The returned cookies are sorted by longest path, then by earliest creation date.
/// </summary>
/// <return>A task that represents the VisitAllCookies operation. The value of the TResult parameter contains a List of cookies.</return>
public static Task<List<Cookie>> VisitAllCookiesAsync(this ICookieManager cookieManager)
{
var cookieVisitor = new TaskCookieVisitor();
if(cookieManager.VisitAllCookies(cookieVisitor))
{
return cookieVisitor.Task;
}
return null;
}
/// <summary>
/// Visits a subset of the cookies. The results are filtered by the given url scheme, host, domain and path.
/// If <paramref name="includeHttpOnly"/> is true, HTTP-only cookies will also be included in the results. The returned cookies
/// are sorted by longest path, then by earliest creation date.
/// </summary>
/// <param name="url">The URL to use for filtering a subset of the cookies available.</param>
/// <param name="includeHttpOnly">A flag that determines whether HTTP-only cookies will be shown in results.</param>
/// <return>A task that represents the VisitUrlCookies operation. The value of the TResult parameter contains a List of cookies.</return>
public static Task<List<Cookie>> VisitUrlCookiesAsync(this ICookieManager cookieManager, string url, bool includeHttpOnly)
{
var cookieVisitor = new TaskCookieVisitor();
if(cookieManager.VisitUrlCookies(url, includeHttpOnly, cookieVisitor))
{
return cookieVisitor.Task;
}
return null;
}
/// <summary>
/// Flush the backing store (if any) to disk.
/// </summary>
/// <param name="cookieManager">cookieManager instance</param>
/// <returns>A task that represents the FlushStore operation. Result indicates if the flush completed successfully.
/// Will return null if the cookikes cannot be accessed.</returns>
public static Task<bool> FlushStoreAsync(this ICookieManager cookieManager)
{
var handler = new TaskCompletionHandler();
if (cookieManager.FlushStore(handler))
{
return handler.Task;
}
//returns null if cookies cannot be accessed.
return null;
}
}
}
@@ -0,0 +1,27 @@
// Copyright © 2010-2016 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
{
/// <summary>
/// Interface to implement to be notified of asynchronous completion via ICookieManager.DeleteCookies().
/// It will be executed asnychronously on the CEF IO thread after the cookie has been deleted
/// </summary>
public interface IDeleteCookiesCallback : IDisposable
{
/// <summary>
/// Method that will be called upon completion.
/// </summary>
/// <param name="numDeleted">will be the number of cookies that were deleted or -1 if unknown.</param>
void OnComplete(int numDeleted);
/// <summary>
/// Gets a value indicating whether the callback has been disposed of.
/// </summary>
bool IsDisposed { get; }
}
}
+27
View File
@@ -0,0 +1,27 @@
// Copyright © 2010-2016 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
{
/// <summary>
/// Interface to implement to be notified of asynchronous completion via ICookieManager.SetCookie().
/// It will be executed asnychronously on the CEF IO thread after the cookie has been set
/// </summary>
public interface ISetCookieCallback : IDisposable
{
/// <summary>
/// Method that will be called upon completion.
/// </summary>
/// <param name="success">success will be true if the cookie was set successfully.</param>
void OnComplete(bool success);
/// <summary>
/// Gets a value indicating whether the callback has been disposed of.
/// </summary>
bool IsDisposed { get; }
}
}
+3
View File
@@ -70,7 +70,10 @@
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<Compile Include="AsyncExtensions.cs" />
<Compile Include="BindingOptions.cs" />
<Compile Include="Callback\IDeleteCookiesCallback.cs" />
<Compile Include="Callback\ISetCookieCallback.cs" />
<Compile Include="CdmRegistration.cs" />
<Compile Include="CdmRegistrationErrorCode.cs" />
<Compile Include="CefDirtyRect.cs" />
+24 -27
View File
@@ -2,6 +2,7 @@
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
@@ -10,15 +11,17 @@ namespace CefSharp
/// <summary>
/// Used for managing cookies. The methods may be called on any thread unless otherwise indicated.
/// </summary>
public interface ICookieManager
public interface ICookieManager : IDisposable
{
/// <summary>
/// Deletes all cookies that matches all the provided parameters asynchronously. If both <paramref name="url"/> and <paramref name="name"/> are empty, all cookies will be deleted.
/// Deletes all cookies that matches all the provided parameters. If both <paramref name="url"/> and <paramref name="name"/> are empty, all cookies will be deleted.
/// Must be run on the CEF IO Thread
/// </summary>
/// <param name="url">The cookie URL. If an empty string is provided, any URL will be matched.</param>
/// <param name="name">The name of the cookie. If an empty string is provided, any URL will be matched.</param>
/// <return>A task that represents the delete operation. The value of the TResult parameter contains false if a non-empty invalid URL is specified, or if cookies cannot be accessed; otherwise, true.</return>
Task<bool> DeleteCookiesAsync(string url, string name);
/// <param name="callback">If non-NULL it will be executed asnychronously on the CEF IO thread after the cookies have been deleted.</param>
/// <return>Returns false if a non-empty invalid URL is specified, or if cookies cannot be accessed; otherwise, true.</return>
bool DeleteCookies(string url, string name, IDeleteCookiesCallback callback = null);
/// <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
@@ -27,8 +30,9 @@ namespace CefSharp
/// </summary>
/// <param name="url">The cookie URL</param>
/// <param name="cookie">The cookie</param>
/// <return>A task that represents the cookie set operation. The value of the TResult parameter contains false if the cookie cannot be set (e.g. if illegal charecters such as ';' are used); otherwise true.</return>
Task<bool> SetCookieAsync(string url, Cookie cookie);
/// <param name="callback">If non-NULL it will be executed asnychronously on the CEF IO thread after the cookie has been set.</param>
/// <return>returns false if the cookie cannot be set (e.g. if illegal charecters such as ';' are used); otherwise true.</return>
bool SetCookie(string url, Cookie cookie, ISetCookieCallback callback = null);
/// <summary>
/// Sets the directory path that will be used for storing cookie data. If <paramref name="path"/> is empty data will be stored in
@@ -38,20 +42,17 @@ namespace CefSharp
/// </summary>
/// <param name="path">The file path to write cookies to.</param>
/// <param name="persistSessionCookies">A flag that determines whether session cookies will be persisted or not.</param>
/// <return> false if a non-empty invalid URL is specified; otherwise, true.</return>
bool SetStoragePath(string path, bool persistSessionCookies);
/// <param name="callback">If non-NULL it will be executed asnychronously on the CEF IO thread after the
/// manager's storage has been initialized</param>
/// <return>Returns false if cookies cannot be accessed</return>
bool SetStoragePath(string path, bool persistSessionCookies, ICompletionCallback callback = null);
/// <summary>
/// Set the schemes supported by this manager. By default only "http" and "https" schemes are supported. Must be called before any cookies are accessed.
/// </summary>
/// <param name="schemes">The list of supported schemes.</param>
void SetSupportedSchemes(params string[] schemes);
/// <summary>
/// Visits all cookies. The returned cookies are sorted by longest path, then by earliest creation date.
/// </summary>
/// <return>A task that represents the VisitAllCookies operation. The value of the TResult parameter contains a List of cookies.</return>
Task<List<Cookie>> VisitAllCookiesAsync();
/// <param name="callback">If non-NULL it will be executed asnychronously on the CEF IO thread after the change has been applied.</param>
void SetSupportedSchemes(string[] schemes, ICompletionCallback callback = null);
/// <summary>
/// Visits all cookies using the provided Cookie Visitor. The returned cookies are sorted by longest path, then by earliest creation date.
@@ -60,16 +61,6 @@ namespace CefSharp
/// <return>Returns false if cookies cannot be accessed; otherwise, true.</return>
bool VisitAllCookies(ICookieVisitor visitor);
/// <summary>
/// Visits a subset of the cookies. The results are filtered by the given url scheme, host, domain and path.
/// If <paramref name="includeHttpOnly"/> is true, HTTP-only cookies will also be included in the results. The returned cookies
/// are sorted by longest path, then by earliest creation date.
/// </summary>
/// <param name="url">The URL to use for filtering a subset of the cookies available.</param>
/// <param name="includeHttpOnly">A flag that determines whether HTTP-only cookies will be shown in results.</param>
/// <return>A task that represents the VisitUrlCookies operation. The value of the TResult parameter contains a List of cookies.</return>
Task<List<Cookie>> VisitUrlCookiesAsync(string url, bool includeHttpOnly);
/// <summary>
/// Visits a subset of the cookies. The results are filtered by the given url scheme, host, domain and path.
/// If <paramref name="includeHttpOnly"/> is true, HTTP-only cookies will also be included in the results. The returned cookies
@@ -84,7 +75,13 @@ namespace CefSharp
/// <summary>
/// Flush the backing store (if any) to disk
/// </summary>
/// <return>A task that represents the Flush operation. The value of the TResult parameter contains false if cookies cannot be accessed; otherwise, true.</return>
Task<bool> FlushStoreAsync();
/// <param name="callback">If non-NULL it willbe executed asnychronously on the CEF IO thread after the flush is complete.</param>
/// <return>Returns false if cookies cannot be accessed.</return>
bool FlushStore(ICompletionCallback callback);
/// <summary>
/// Returns true if disposed
/// </summary>
bool IsDisposed { get; }
}
}
+1 -2
View File
@@ -15,7 +15,7 @@ namespace CefSharp
/// </summary>
public class TaskCookieVisitor : ICookieVisitor
{
private TaskCompletionSource<List<Cookie>> taskCompletionSource;
private readonly TaskCompletionSource<List<Cookie>> taskCompletionSource;
private List<Cookie> list;
/// <summary>
@@ -49,7 +49,6 @@ namespace CefSharp
}
list = null;
taskCompletionSource = null;
}
/// <summary>