mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add CefCookieManager::GetBlockingManager (issue #2374)
This commit is contained in:
@ -33,7 +33,7 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=e0605a0c9918e225b9282b6d5e6138a7d697945b$
|
// $hash=00e6d1aa80d5998d89cc272dcb199cde0add12fa$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_COOKIE_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_COOKIE_CAPI_H_
|
||||||
@ -159,6 +159,16 @@ typedef struct _cef_cookie_manager_t {
|
|||||||
CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_get_global_manager(
|
CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_get_global_manager(
|
||||||
struct _cef_completion_callback_t* callback);
|
struct _cef_completion_callback_t* callback);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns a cookie manager that neither stores nor retrieves cookies. All usage
|
||||||
|
// of cookies will be blocked including cookies accessed via the network
|
||||||
|
// (request/response headers), via JavaScript (document.cookie), and via
|
||||||
|
// cef_cookie_manager_t functions. No cookies will be displayed in DevTools. If
|
||||||
|
// you wish to only block cookies sent via the network use the
|
||||||
|
// cef_request_tHandler CanGetCookies and CanSetCookie functions instead.
|
||||||
|
///
|
||||||
|
CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_get_blocking_manager();
|
||||||
|
|
||||||
///
|
///
|
||||||
// Creates a new cookie manager. If |path| is NULL data will be stored in memory
|
// Creates a new cookie manager. If |path| is NULL data will be stored in memory
|
||||||
// only. Otherwise, data will be stored at the specified |path|. To persist
|
// only. Otherwise, data will be stored at the specified |path|. To persist
|
||||||
|
@ -64,6 +64,17 @@ class CefCookieManager : public virtual CefBaseRefCounted {
|
|||||||
static CefRefPtr<CefCookieManager> GetGlobalManager(
|
static CefRefPtr<CefCookieManager> GetGlobalManager(
|
||||||
CefRefPtr<CefCompletionCallback> callback);
|
CefRefPtr<CefCompletionCallback> callback);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns a cookie manager that neither stores nor retrieves cookies. All
|
||||||
|
// usage of cookies will be blocked including cookies accessed via the network
|
||||||
|
// (request/response headers), via JavaScript (document.cookie), and via
|
||||||
|
// CefCookieManager methods. No cookies will be displayed in DevTools. If you
|
||||||
|
// wish to only block cookies sent via the network use the CefRequestHandler
|
||||||
|
// CanGetCookies and CanSetCookie methods instead.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
static CefRefPtr<CefCookieManager> GetBlockingManager();
|
||||||
|
|
||||||
///
|
///
|
||||||
// Creates a new cookie manager. If |path| is empty data will be stored in
|
// Creates a new cookie manager. If |path| is empty data will be stored in
|
||||||
// memory only. Otherwise, data will be stored at the specified |path|. To
|
// memory only. Otherwise, data will be stored at the specified |path|. To
|
||||||
|
@ -120,7 +120,8 @@ net::CookieStore* GetExistingCookieStoreHelper(
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
CefCookieManagerImpl::CefCookieManagerImpl() : weak_ptr_factory_(this) {}
|
CefCookieManagerImpl::CefCookieManagerImpl(bool is_blocking)
|
||||||
|
: is_blocking_(is_blocking), weak_ptr_factory_(this) {}
|
||||||
|
|
||||||
CefCookieManagerImpl::~CefCookieManagerImpl() {
|
CefCookieManagerImpl::~CefCookieManagerImpl() {
|
||||||
CEF_REQUIRE_IOT();
|
CEF_REQUIRE_IOT();
|
||||||
@ -131,6 +132,7 @@ void CefCookieManagerImpl::Initialize(
|
|||||||
const CefString& path,
|
const CefString& path,
|
||||||
bool persist_session_cookies,
|
bool persist_session_cookies,
|
||||||
CefRefPtr<CefCompletionCallback> callback) {
|
CefRefPtr<CefCompletionCallback> callback) {
|
||||||
|
CHECK(!is_blocking_);
|
||||||
if (request_context.get()) {
|
if (request_context.get()) {
|
||||||
request_context_ = request_context;
|
request_context_ = request_context;
|
||||||
request_context_->GetRequestContextImpl(
|
request_context_->GetRequestContextImpl(
|
||||||
@ -160,7 +162,7 @@ void CefCookieManagerImpl::GetCookieStore(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DCHECK(cookie_store_.get());
|
DCHECK(is_blocking_ || cookie_store_.get());
|
||||||
|
|
||||||
// Binding ref-counted |this| to CookieStoreGetter may result in
|
// Binding ref-counted |this| to CookieStoreGetter may result in
|
||||||
// heap-use-after-free if (a) the CookieStoreGetter contains the last
|
// heap-use-after-free if (a) the CookieStoreGetter contains the last
|
||||||
@ -192,7 +194,9 @@ net::CookieStore* CefCookieManagerImpl::GetExistingCookieStore() {
|
|||||||
return cookie_store;
|
return cookie_store;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(ERROR) << "Cookie store does not exist";
|
DCHECK(is_blocking_);
|
||||||
|
if (!is_blocking_)
|
||||||
|
LOG(ERROR) << "Cookie store does not exist";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -495,12 +499,11 @@ void CefCookieManagerImpl::SetSupportedSchemesInternal(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DCHECK(cookie_store_.get());
|
DCHECK(is_blocking_ || cookie_store_.get());
|
||||||
if (!cookie_store_.get())
|
if (cookie_store_) {
|
||||||
return;
|
supported_schemes_ = schemes;
|
||||||
|
SetCookieMonsterSchemes(cookie_store_.get(), supported_schemes_);
|
||||||
supported_schemes_ = schemes;
|
}
|
||||||
SetCookieMonsterSchemes(cookie_store_.get(), supported_schemes_);
|
|
||||||
|
|
||||||
RunAsyncCompletionOnIOThread(callback);
|
RunAsyncCompletionOnIOThread(callback);
|
||||||
}
|
}
|
||||||
@ -552,8 +555,13 @@ void CefCookieManagerImpl::SetCookieInternal(
|
|||||||
CEF_REQUIRE_IOT();
|
CEF_REQUIRE_IOT();
|
||||||
|
|
||||||
net::CookieStore* cookie_store = cookie_store_getter.Run();
|
net::CookieStore* cookie_store = cookie_store_getter.Run();
|
||||||
if (!cookie_store)
|
if (!cookie_store) {
|
||||||
|
if (callback.get()) {
|
||||||
|
CEF_POST_TASK(CEF_IOT, base::Bind(&CefSetCookieCallback::OnComplete,
|
||||||
|
callback.get(), false));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
std::string name = CefString(&cookie.name).ToString();
|
std::string name = CefString(&cookie.name).ToString();
|
||||||
std::string value = CefString(&cookie.value).ToString();
|
std::string value = CefString(&cookie.value).ToString();
|
||||||
@ -584,8 +592,13 @@ void CefCookieManagerImpl::DeleteCookiesInternal(
|
|||||||
CEF_REQUIRE_IOT();
|
CEF_REQUIRE_IOT();
|
||||||
|
|
||||||
net::CookieStore* cookie_store = cookie_store_getter.Run();
|
net::CookieStore* cookie_store = cookie_store_getter.Run();
|
||||||
if (!cookie_store)
|
if (!cookie_store) {
|
||||||
|
if (callback.get()) {
|
||||||
|
CEF_POST_TASK(CEF_IOT, base::Bind(&CefDeleteCookiesCallback::OnComplete,
|
||||||
|
callback.get(), 0));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (url.is_empty()) {
|
if (url.is_empty()) {
|
||||||
// Delete all cookies.
|
// Delete all cookies.
|
||||||
@ -610,8 +623,10 @@ void CefCookieManagerImpl::FlushStoreInternal(
|
|||||||
CEF_REQUIRE_IOT();
|
CEF_REQUIRE_IOT();
|
||||||
|
|
||||||
net::CookieStore* cookie_store = cookie_store_getter.Run();
|
net::CookieStore* cookie_store = cookie_store_getter.Run();
|
||||||
if (!cookie_store)
|
if (!cookie_store) {
|
||||||
|
RunAsyncCompletionOnIOThread(callback);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
cookie_store->FlushStore(base::Bind(RunAsyncCompletionOnIOThread, callback));
|
cookie_store->FlushStore(base::Bind(RunAsyncCompletionOnIOThread, callback));
|
||||||
}
|
}
|
||||||
@ -631,6 +646,11 @@ CefRefPtr<CefCookieManager> CefCookieManager::GetGlobalManager(
|
|||||||
callback);
|
callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
CefRefPtr<CefCookieManager> CefCookieManager::GetBlockingManager() {
|
||||||
|
return new CefCookieManagerImpl(true);
|
||||||
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
CefRefPtr<CefCookieManager> CefCookieManager::CreateManager(
|
CefRefPtr<CefCookieManager> CefCookieManager::CreateManager(
|
||||||
const CefString& path,
|
const CefString& path,
|
||||||
@ -642,7 +662,8 @@ CefRefPtr<CefCookieManager> CefCookieManager::CreateManager(
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CefRefPtr<CefCookieManagerImpl> cookie_manager = new CefCookieManagerImpl();
|
CefRefPtr<CefCookieManagerImpl> cookie_manager =
|
||||||
|
new CefCookieManagerImpl(false);
|
||||||
cookie_manager->Initialize(NULL, path, persist_session_cookies, callback);
|
cookie_manager->Initialize(NULL, path, persist_session_cookies, callback);
|
||||||
return cookie_manager.get();
|
return cookie_manager.get();
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,11 @@
|
|||||||
// Implementation of the CefCookieManager interface.
|
// Implementation of the CefCookieManager interface.
|
||||||
class CefCookieManagerImpl : public CefCookieManager {
|
class CefCookieManagerImpl : public CefCookieManager {
|
||||||
public:
|
public:
|
||||||
CefCookieManagerImpl();
|
explicit CefCookieManagerImpl(bool is_blocking);
|
||||||
~CefCookieManagerImpl() override;
|
~CefCookieManagerImpl() override;
|
||||||
|
|
||||||
// Must be called immediately after this object is created.
|
// Must be called immediately after this object is created when |is_blocking|
|
||||||
|
// is false.
|
||||||
void Initialize(CefRefPtr<CefRequestContextImpl> request_context,
|
void Initialize(CefRefPtr<CefRequestContextImpl> request_context,
|
||||||
const CefString& path,
|
const CefString& path,
|
||||||
bool persist_session_cookies,
|
bool persist_session_cookies,
|
||||||
@ -113,6 +114,9 @@ class CefCookieManagerImpl : public CefCookieManager {
|
|||||||
void FlushStoreInternal(CefRefPtr<CefCompletionCallback> callback,
|
void FlushStoreInternal(CefRefPtr<CefCompletionCallback> callback,
|
||||||
const CookieStoreGetter& cookie_store_getter);
|
const CookieStoreGetter& cookie_store_getter);
|
||||||
|
|
||||||
|
// If true all cookies will be blocked.
|
||||||
|
const bool is_blocking_;
|
||||||
|
|
||||||
// Used for cookie monsters owned by the context.
|
// Used for cookie monsters owned by the context.
|
||||||
CefRefPtr<CefRequestContextImpl> request_context_;
|
CefRefPtr<CefRequestContextImpl> request_context_;
|
||||||
scoped_refptr<CefURLRequestContextGetterImpl> request_context_impl_;
|
scoped_refptr<CefURLRequestContextGetterImpl> request_context_impl_;
|
||||||
|
@ -33,6 +33,8 @@ void CefCookieStoreProxy::SetCookieWithOptionsAsync(
|
|||||||
if (cookie_store) {
|
if (cookie_store) {
|
||||||
cookie_store->SetCookieWithOptionsAsync(url, cookie_line, options,
|
cookie_store->SetCookieWithOptionsAsync(url, cookie_line, options,
|
||||||
std::move(callback));
|
std::move(callback));
|
||||||
|
} else if (!callback.is_null()) {
|
||||||
|
std::move(callback).Run(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +48,8 @@ void CefCookieStoreProxy::SetCanonicalCookieAsync(
|
|||||||
cookie_store->SetCanonicalCookieAsync(std::move(cookie), secure_source,
|
cookie_store->SetCanonicalCookieAsync(std::move(cookie), secure_source,
|
||||||
modify_http_only,
|
modify_http_only,
|
||||||
std::move(callback));
|
std::move(callback));
|
||||||
|
} else if (!callback.is_null()) {
|
||||||
|
std::move(callback).Run(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,8 +58,11 @@ void CefCookieStoreProxy::GetCookiesWithOptionsAsync(
|
|||||||
const net::CookieOptions& options,
|
const net::CookieOptions& options,
|
||||||
GetCookiesCallback callback) {
|
GetCookiesCallback callback) {
|
||||||
net::CookieStore* cookie_store = GetCookieStore();
|
net::CookieStore* cookie_store = GetCookieStore();
|
||||||
if (cookie_store)
|
if (cookie_store) {
|
||||||
cookie_store->GetCookiesWithOptionsAsync(url, options, std::move(callback));
|
cookie_store->GetCookiesWithOptionsAsync(url, options, std::move(callback));
|
||||||
|
} else if (!callback.is_null()) {
|
||||||
|
std::move(callback).Run(std::string());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefCookieStoreProxy::GetCookieListWithOptionsAsync(
|
void CefCookieStoreProxy::GetCookieListWithOptionsAsync(
|
||||||
@ -63,31 +70,43 @@ void CefCookieStoreProxy::GetCookieListWithOptionsAsync(
|
|||||||
const net::CookieOptions& options,
|
const net::CookieOptions& options,
|
||||||
GetCookieListCallback callback) {
|
GetCookieListCallback callback) {
|
||||||
net::CookieStore* cookie_store = GetCookieStore();
|
net::CookieStore* cookie_store = GetCookieStore();
|
||||||
if (cookie_store)
|
if (cookie_store) {
|
||||||
cookie_store->GetCookieListWithOptionsAsync(url, options,
|
cookie_store->GetCookieListWithOptionsAsync(url, options,
|
||||||
std::move(callback));
|
std::move(callback));
|
||||||
|
} else if (!callback.is_null()) {
|
||||||
|
std::move(callback).Run(net::CookieList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefCookieStoreProxy::GetAllCookiesAsync(GetCookieListCallback callback) {
|
void CefCookieStoreProxy::GetAllCookiesAsync(GetCookieListCallback callback) {
|
||||||
net::CookieStore* cookie_store = GetCookieStore();
|
net::CookieStore* cookie_store = GetCookieStore();
|
||||||
if (cookie_store)
|
if (cookie_store) {
|
||||||
cookie_store->GetAllCookiesAsync(std::move(callback));
|
cookie_store->GetAllCookiesAsync(std::move(callback));
|
||||||
|
} else if (!callback.is_null()) {
|
||||||
|
std::move(callback).Run(net::CookieList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefCookieStoreProxy::DeleteCookieAsync(const GURL& url,
|
void CefCookieStoreProxy::DeleteCookieAsync(const GURL& url,
|
||||||
const std::string& cookie_name,
|
const std::string& cookie_name,
|
||||||
base::OnceClosure callback) {
|
base::OnceClosure callback) {
|
||||||
net::CookieStore* cookie_store = GetCookieStore();
|
net::CookieStore* cookie_store = GetCookieStore();
|
||||||
if (cookie_store)
|
if (cookie_store) {
|
||||||
cookie_store->DeleteCookieAsync(url, cookie_name, std::move(callback));
|
cookie_store->DeleteCookieAsync(url, cookie_name, std::move(callback));
|
||||||
|
} else if (!callback.is_null()) {
|
||||||
|
std::move(callback).Run();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefCookieStoreProxy::DeleteCanonicalCookieAsync(
|
void CefCookieStoreProxy::DeleteCanonicalCookieAsync(
|
||||||
const net::CanonicalCookie& cookie,
|
const net::CanonicalCookie& cookie,
|
||||||
DeleteCallback callback) {
|
DeleteCallback callback) {
|
||||||
net::CookieStore* cookie_store = GetCookieStore();
|
net::CookieStore* cookie_store = GetCookieStore();
|
||||||
if (cookie_store)
|
if (cookie_store) {
|
||||||
cookie_store->DeleteCanonicalCookieAsync(cookie, std::move(callback));
|
cookie_store->DeleteCanonicalCookieAsync(cookie, std::move(callback));
|
||||||
|
} else if (!callback.is_null()) {
|
||||||
|
std::move(callback).Run(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefCookieStoreProxy::DeleteAllCreatedBetweenAsync(
|
void CefCookieStoreProxy::DeleteAllCreatedBetweenAsync(
|
||||||
@ -98,6 +117,8 @@ void CefCookieStoreProxy::DeleteAllCreatedBetweenAsync(
|
|||||||
if (cookie_store) {
|
if (cookie_store) {
|
||||||
cookie_store->DeleteAllCreatedBetweenAsync(delete_begin, delete_end,
|
cookie_store->DeleteAllCreatedBetweenAsync(delete_begin, delete_end,
|
||||||
std::move(callback));
|
std::move(callback));
|
||||||
|
} else if (!callback.is_null()) {
|
||||||
|
std::move(callback).Run(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,19 +131,27 @@ void CefCookieStoreProxy::DeleteAllCreatedBetweenWithPredicateAsync(
|
|||||||
if (cookie_store) {
|
if (cookie_store) {
|
||||||
cookie_store->DeleteAllCreatedBetweenWithPredicateAsync(
|
cookie_store->DeleteAllCreatedBetweenWithPredicateAsync(
|
||||||
delete_begin, delete_end, predicate, std::move(callback));
|
delete_begin, delete_end, predicate, std::move(callback));
|
||||||
|
} else if (!callback.is_null()) {
|
||||||
|
std::move(callback).Run(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefCookieStoreProxy::DeleteSessionCookiesAsync(DeleteCallback callback) {
|
void CefCookieStoreProxy::DeleteSessionCookiesAsync(DeleteCallback callback) {
|
||||||
net::CookieStore* cookie_store = GetCookieStore();
|
net::CookieStore* cookie_store = GetCookieStore();
|
||||||
if (cookie_store)
|
if (cookie_store) {
|
||||||
cookie_store->DeleteSessionCookiesAsync(std::move(callback));
|
cookie_store->DeleteSessionCookiesAsync(std::move(callback));
|
||||||
|
} else if (!callback.is_null()) {
|
||||||
|
std::move(callback).Run(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefCookieStoreProxy::FlushStore(base::OnceClosure callback) {
|
void CefCookieStoreProxy::FlushStore(base::OnceClosure callback) {
|
||||||
net::CookieStore* cookie_store = GetCookieStore();
|
net::CookieStore* cookie_store = GetCookieStore();
|
||||||
if (cookie_store)
|
if (cookie_store) {
|
||||||
cookie_store->FlushStore(std::move(callback));
|
cookie_store->FlushStore(std::move(callback));
|
||||||
|
} else if (!callback.is_null()) {
|
||||||
|
std::move(callback).Run();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<net::CookieStore::CookieChangedSubscription>
|
std::unique_ptr<net::CookieStore::CookieChangedSubscription>
|
||||||
@ -131,8 +160,9 @@ CefCookieStoreProxy::AddCallbackForCookie(
|
|||||||
const std::string& name,
|
const std::string& name,
|
||||||
const CookieChangedCallback& callback) {
|
const CookieChangedCallback& callback) {
|
||||||
net::CookieStore* cookie_store = GetCookieStore();
|
net::CookieStore* cookie_store = GetCookieStore();
|
||||||
if (cookie_store)
|
if (cookie_store) {
|
||||||
return cookie_store->AddCallbackForCookie(url, name, callback);
|
return cookie_store->AddCallbackForCookie(url, name, callback);
|
||||||
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,8 +170,9 @@ std::unique_ptr<net::CookieStore::CookieChangedSubscription>
|
|||||||
CefCookieStoreProxy::AddCallbackForAllChanges(
|
CefCookieStoreProxy::AddCallbackForAllChanges(
|
||||||
const CookieChangedCallback& callback) {
|
const CookieChangedCallback& callback) {
|
||||||
net::CookieStore* cookie_store = GetCookieStore();
|
net::CookieStore* cookie_store = GetCookieStore();
|
||||||
if (cookie_store)
|
if (cookie_store) {
|
||||||
return cookie_store->AddCallbackForAllChanges(callback);
|
return cookie_store->AddCallbackForAllChanges(callback);
|
||||||
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,25 +186,23 @@ bool CefCookieStoreProxy::IsEphemeral() {
|
|||||||
net::CookieStore* CefCookieStoreProxy::GetCookieStore() {
|
net::CookieStore* CefCookieStoreProxy::GetCookieStore() {
|
||||||
CEF_REQUIRE_IOT();
|
CEF_REQUIRE_IOT();
|
||||||
|
|
||||||
net::CookieStore* cookie_store = nullptr;
|
|
||||||
|
|
||||||
CefRefPtr<CefCookieManager> manager = handler_->GetCookieManager();
|
CefRefPtr<CefCookieManager> manager = handler_->GetCookieManager();
|
||||||
if (manager.get()) {
|
if (manager.get()) {
|
||||||
// Use the cookie store provided by the manager.
|
// Use the cookie store provided by the manager. May be nullptr if the
|
||||||
cookie_store = reinterpret_cast<CefCookieManagerImpl*>(manager.get())
|
// cookie manager is blocking.
|
||||||
->GetExistingCookieStore();
|
return reinterpret_cast<CefCookieManagerImpl*>(manager.get())
|
||||||
DCHECK(cookie_store);
|
->GetExistingCookieStore();
|
||||||
return cookie_store;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DCHECK(parent_);
|
DCHECK(parent_);
|
||||||
if (parent_) {
|
if (parent_) {
|
||||||
// Use the cookie store from the parent.
|
// Use the cookie store from the parent.
|
||||||
cookie_store = parent_->cookie_store();
|
net::CookieStore* cookie_store = parent_->cookie_store();
|
||||||
DCHECK(cookie_store);
|
DCHECK(cookie_store);
|
||||||
if (!cookie_store)
|
if (!cookie_store)
|
||||||
LOG(ERROR) << "Cookie store does not exist";
|
LOG(ERROR) << "Cookie store does not exist";
|
||||||
|
return cookie_store;
|
||||||
}
|
}
|
||||||
|
|
||||||
return cookie_store;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -293,7 +293,8 @@ CefString CefRequestContextImpl::GetCachePath() {
|
|||||||
|
|
||||||
CefRefPtr<CefCookieManager> CefRequestContextImpl::GetDefaultCookieManager(
|
CefRefPtr<CefCookieManager> CefRequestContextImpl::GetDefaultCookieManager(
|
||||||
CefRefPtr<CefCompletionCallback> callback) {
|
CefRefPtr<CefCompletionCallback> callback) {
|
||||||
CefRefPtr<CefCookieManagerImpl> cookie_manager = new CefCookieManagerImpl();
|
CefRefPtr<CefCookieManagerImpl> cookie_manager =
|
||||||
|
new CefCookieManagerImpl(false);
|
||||||
cookie_manager->Initialize(this, CefString(), false, callback);
|
cookie_manager->Initialize(this, CefString(), false, callback);
|
||||||
return cookie_manager.get();
|
return cookie_manager.get();
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// implementations. See the translator.README.txt file in the tools directory
|
// implementations. See the translator.README.txt file in the tools directory
|
||||||
// for more information.
|
// for more information.
|
||||||
//
|
//
|
||||||
// $hash=0b1ea8f0568d1fbbf7359429d1cab3d0df845e93$
|
// $hash=807ba668c5bc70deae472558afa6e7026ca54de5$
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "libcef_dll/cpptoc/cookie_manager_cpptoc.h"
|
#include "libcef_dll/cpptoc/cookie_manager_cpptoc.h"
|
||||||
@ -35,6 +35,16 @@ CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_get_global_manager(
|
|||||||
return CefCookieManagerCppToC::Wrap(_retval);
|
return CefCookieManagerCppToC::Wrap(_retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_get_blocking_manager() {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefRefPtr<CefCookieManager> _retval = CefCookieManager::GetBlockingManager();
|
||||||
|
|
||||||
|
// Return type: refptr_same
|
||||||
|
return CefCookieManagerCppToC::Wrap(_retval);
|
||||||
|
}
|
||||||
|
|
||||||
CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_create_manager(
|
CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_create_manager(
|
||||||
const cef_string_t* path,
|
const cef_string_t* path,
|
||||||
int persist_session_cookies,
|
int persist_session_cookies,
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// implementations. See the translator.README.txt file in the tools directory
|
// implementations. See the translator.README.txt file in the tools directory
|
||||||
// for more information.
|
// for more information.
|
||||||
//
|
//
|
||||||
// $hash=5a754788197bd0d5e1e18db5dc1643285baa848f$
|
// $hash=5a5ae9a4567ba338efa8477ba1dc53435ada8c6b$
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "libcef_dll/ctocpp/cookie_manager_ctocpp.h"
|
#include "libcef_dll/ctocpp/cookie_manager_ctocpp.h"
|
||||||
@ -35,6 +35,16 @@ CefRefPtr<CefCookieManager> CefCookieManager::GetGlobalManager(
|
|||||||
return CefCookieManagerCToCpp::Wrap(_retval);
|
return CefCookieManagerCToCpp::Wrap(_retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CefRefPtr<CefCookieManager> CefCookieManager::GetBlockingManager() {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
cef_cookie_manager_t* _retval = cef_cookie_manager_get_blocking_manager();
|
||||||
|
|
||||||
|
// Return type: refptr_same
|
||||||
|
return CefCookieManagerCToCpp::Wrap(_retval);
|
||||||
|
}
|
||||||
|
|
||||||
CefRefPtr<CefCookieManager> CefCookieManager::CreateManager(
|
CefRefPtr<CefCookieManager> CefCookieManager::CreateManager(
|
||||||
const CefString& path,
|
const CefString& path,
|
||||||
bool persist_session_cookies,
|
bool persist_session_cookies,
|
||||||
|
@ -22,7 +22,14 @@ namespace {
|
|||||||
class ClientRequestContextHandler : public CefRequestContextHandler,
|
class ClientRequestContextHandler : public CefRequestContextHandler,
|
||||||
public CefExtensionHandler {
|
public CefExtensionHandler {
|
||||||
public:
|
public:
|
||||||
ClientRequestContextHandler() {}
|
ClientRequestContextHandler() {
|
||||||
|
CefRefPtr<CefCommandLine> command_line =
|
||||||
|
CefCommandLine::GetGlobalCommandLine();
|
||||||
|
if (command_line->HasSwitch(switches::kRequestContextBlockCookies)) {
|
||||||
|
// Use a cookie manager that neither stores nor retrieves cookies.
|
||||||
|
cookie_manager_ = CefCookieManager::GetBlockingManager();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// CefRequestContextHandler methods:
|
// CefRequestContextHandler methods:
|
||||||
bool OnBeforePluginLoad(const CefString& mime_type,
|
bool OnBeforePluginLoad(const CefString& mime_type,
|
||||||
@ -73,6 +80,10 @@ class ClientRequestContextHandler : public CefRequestContextHandler,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CefRefPtr<CefCookieManager> GetCookieManager() OVERRIDE {
|
||||||
|
return cookie_manager_;
|
||||||
|
}
|
||||||
|
|
||||||
// CefExtensionHandler methods:
|
// CefExtensionHandler methods:
|
||||||
void OnExtensionLoaded(CefRefPtr<CefExtension> extension) OVERRIDE {
|
void OnExtensionLoaded(CefRefPtr<CefExtension> extension) OVERRIDE {
|
||||||
CEF_REQUIRE_UI_THREAD();
|
CEF_REQUIRE_UI_THREAD();
|
||||||
@ -99,6 +110,8 @@ class ClientRequestContextHandler : public CefRequestContextHandler,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
CefRefPtr<CefCookieManager> cookie_manager_;
|
||||||
|
|
||||||
IMPLEMENT_REFCOUNTING(ClientRequestContextHandler);
|
IMPLEMENT_REFCOUNTING(ClientRequestContextHandler);
|
||||||
DISALLOW_COPY_AND_ASSIGN(ClientRequestContextHandler);
|
DISALLOW_COPY_AND_ASSIGN(ClientRequestContextHandler);
|
||||||
};
|
};
|
||||||
|
@ -2180,14 +2180,46 @@ class CookieAccessTestHandler : public RoutingTestHandler {
|
|||||||
ALLOW = 0,
|
ALLOW = 0,
|
||||||
BLOCK_READ = 1 << 0,
|
BLOCK_READ = 1 << 0,
|
||||||
BLOCK_WRITE = 1 << 1,
|
BLOCK_WRITE = 1 << 1,
|
||||||
BLOCK_ALL = BLOCK_READ | BLOCK_WRITE,
|
BLOCK_READ_WRITE = BLOCK_READ | BLOCK_WRITE,
|
||||||
|
BLOCK_ALL = 1 << 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
class RequestContextHandler : public CefRequestContextHandler {
|
||||||
|
public:
|
||||||
|
explicit RequestContextHandler(CookieAccessTestHandler* handler)
|
||||||
|
: handler_(handler) {}
|
||||||
|
|
||||||
|
CefRefPtr<CefCookieManager> GetCookieManager() override {
|
||||||
|
EXPECT_TRUE(handler_);
|
||||||
|
EXPECT_TRUE(CefCurrentlyOn(TID_IO));
|
||||||
|
|
||||||
|
handler_->got_cookie_manager_.yes();
|
||||||
|
return handler_->cookie_manager_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Detach() { handler_ = NULL; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
CookieAccessTestHandler* handler_;
|
||||||
|
|
||||||
|
IMPLEMENT_REFCOUNTING(RequestContextHandler);
|
||||||
};
|
};
|
||||||
|
|
||||||
CookieAccessTestHandler(TestMode test_mode, bool server_backend)
|
CookieAccessTestHandler(TestMode test_mode, bool server_backend)
|
||||||
: test_mode_(test_mode), server_backend_(server_backend) {}
|
: test_mode_(test_mode), server_backend_(server_backend) {}
|
||||||
|
|
||||||
void RunTest() override {
|
void RunTest() override {
|
||||||
cookie_manager_ = CefCookieManager::GetGlobalManager(nullptr);
|
if (test_mode_ == BLOCK_ALL) {
|
||||||
|
cookie_manager_ = CefCookieManager::GetBlockingManager();
|
||||||
|
context_handler_ = new RequestContextHandler(this);
|
||||||
|
|
||||||
|
// Create a request context that uses |context_handler_|.
|
||||||
|
CefRequestContextSettings settings;
|
||||||
|
context_ =
|
||||||
|
CefRequestContext::CreateContext(settings, context_handler_.get());
|
||||||
|
} else {
|
||||||
|
cookie_manager_ = CefCookieManager::GetGlobalManager(nullptr);
|
||||||
|
}
|
||||||
SetTestTimeout();
|
SetTestTimeout();
|
||||||
|
|
||||||
CefPostTask(TID_UI,
|
CefPostTask(TID_UI,
|
||||||
@ -2204,88 +2236,130 @@ class CookieAccessTestHandler : public RoutingTestHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cookie_manager_ = NULL;
|
cookie_manager_ = NULL;
|
||||||
|
if (context_)
|
||||||
// Always get a call to CanSetCookie for the 1st network request due to the
|
context_ = NULL;
|
||||||
// network cookie.
|
if (context_handler_) {
|
||||||
EXPECT_TRUE(got_can_set_cookie1_);
|
context_handler_->Detach();
|
||||||
// Always get a call to CanGetCookies for the 2nd network request due to the
|
context_handler_ = NULL;
|
||||||
// JS cookie.
|
|
||||||
EXPECT_TRUE(got_can_get_cookies2_);
|
|
||||||
|
|
||||||
// Always get the JS cookie via JS.
|
|
||||||
EXPECT_TRUE(got_cookie_js1_);
|
|
||||||
EXPECT_TRUE(got_cookie_js2_);
|
|
||||||
EXPECT_TRUE(got_cookie_js3_);
|
|
||||||
|
|
||||||
// Only get the net cookie via JS if cookie write was allowed.
|
|
||||||
if (test_mode_ & BLOCK_WRITE) {
|
|
||||||
EXPECT_FALSE(got_cookie_net1_);
|
|
||||||
EXPECT_FALSE(got_cookie_net2_);
|
|
||||||
EXPECT_FALSE(got_cookie_net3_);
|
|
||||||
} else {
|
|
||||||
EXPECT_TRUE(got_cookie_net1_);
|
|
||||||
EXPECT_TRUE(got_cookie_net2_);
|
|
||||||
EXPECT_TRUE(got_cookie_net3_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Got both network requests.
|
// Got both network requests.
|
||||||
EXPECT_TRUE(data1_.got_request_);
|
EXPECT_TRUE(data1_.got_request_);
|
||||||
EXPECT_TRUE(data2_.got_request_);
|
EXPECT_TRUE(data2_.got_request_);
|
||||||
|
|
||||||
// No cookies sent for the 1st network request.
|
if (test_mode_ == BLOCK_ALL) {
|
||||||
EXPECT_FALSE(data1_.got_cookie_js_);
|
EXPECT_TRUE(got_cookie_manager_);
|
||||||
EXPECT_FALSE(data1_.got_cookie_net_);
|
|
||||||
|
|
||||||
// 2nd network request...
|
// The callback to set the cookie comes before the actual storage fails.
|
||||||
if (test_mode_ & BLOCK_READ) {
|
EXPECT_TRUE(got_can_set_cookie1_);
|
||||||
// No cookies sent if reading was blocked.
|
|
||||||
EXPECT_FALSE(data2_.got_cookie_js_);
|
|
||||||
EXPECT_FALSE(data2_.got_cookie_net_);
|
|
||||||
} else if (test_mode_ & BLOCK_WRITE) {
|
|
||||||
// Only JS cookie sent if writing was blocked.
|
|
||||||
EXPECT_TRUE(data2_.got_cookie_js_);
|
|
||||||
EXPECT_FALSE(data2_.got_cookie_net_);
|
|
||||||
} else {
|
|
||||||
// All cookies sent.
|
|
||||||
EXPECT_TRUE(data2_.got_cookie_js_);
|
|
||||||
EXPECT_TRUE(data2_.got_cookie_net_);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!server_backend_) {
|
if (!server_backend_) {
|
||||||
// No query to get cookies with the 1st network request because none have
|
// The callback to set the cookie comes before the actual storage fails.
|
||||||
// been set yet.
|
EXPECT_TRUE(data1_.got_can_set_cookie_net_);
|
||||||
|
} else {
|
||||||
|
EXPECT_FALSE(data1_.got_can_set_cookie_net_);
|
||||||
|
}
|
||||||
|
|
||||||
|
// No cookies stored anywhere.
|
||||||
|
EXPECT_FALSE(got_can_get_cookies2_);
|
||||||
|
EXPECT_FALSE(got_cookie_js1_);
|
||||||
|
EXPECT_FALSE(got_cookie_js2_);
|
||||||
|
EXPECT_FALSE(got_cookie_js3_);
|
||||||
|
EXPECT_FALSE(got_cookie_net1_);
|
||||||
|
EXPECT_FALSE(got_cookie_net2_);
|
||||||
|
EXPECT_FALSE(got_cookie_net3_);
|
||||||
|
EXPECT_FALSE(data1_.got_cookie_js_);
|
||||||
|
EXPECT_FALSE(data1_.got_cookie_net_);
|
||||||
EXPECT_FALSE(data1_.got_can_get_cookie_js_);
|
EXPECT_FALSE(data1_.got_can_get_cookie_js_);
|
||||||
EXPECT_FALSE(data1_.got_can_get_cookie_net_);
|
EXPECT_FALSE(data1_.got_can_get_cookie_net_);
|
||||||
|
|
||||||
// JS cookie is not set via a network request.
|
|
||||||
EXPECT_FALSE(data1_.got_can_set_cookie_js_);
|
EXPECT_FALSE(data1_.got_can_set_cookie_js_);
|
||||||
|
EXPECT_FALSE(data2_.got_cookie_js_);
|
||||||
|
EXPECT_FALSE(data2_.got_cookie_net_);
|
||||||
|
EXPECT_FALSE(data2_.got_can_get_cookie_js_);
|
||||||
|
EXPECT_FALSE(data2_.got_can_get_cookie_net_);
|
||||||
EXPECT_FALSE(data2_.got_can_set_cookie_js_);
|
EXPECT_FALSE(data2_.got_can_set_cookie_js_);
|
||||||
|
|
||||||
// No query to set the net cookie for the 1st network request if write was
|
|
||||||
// blocked.
|
|
||||||
if (test_mode_ & BLOCK_WRITE) {
|
|
||||||
EXPECT_FALSE(data1_.got_can_set_cookie_net_);
|
|
||||||
} else {
|
|
||||||
EXPECT_TRUE(data1_.got_can_set_cookie_net_);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Net cookie is not set via the 2nd network request.
|
|
||||||
EXPECT_FALSE(data2_.got_can_set_cookie_net_);
|
EXPECT_FALSE(data2_.got_can_set_cookie_net_);
|
||||||
|
} else {
|
||||||
|
EXPECT_FALSE(got_cookie_manager_);
|
||||||
|
|
||||||
// No query to get the JS cookie for the 2nd network request if read was
|
// Always get a call to CanSetCookie for the 1st network request due to
|
||||||
// blocked.
|
// the network cookie.
|
||||||
if (test_mode_ & BLOCK_READ) {
|
EXPECT_TRUE(got_can_set_cookie1_);
|
||||||
EXPECT_FALSE(data2_.got_can_get_cookie_js_);
|
// Always get a call to CanGetCookies for the 2nd network request due to
|
||||||
|
// the JS cookie.
|
||||||
|
EXPECT_TRUE(got_can_get_cookies2_);
|
||||||
|
|
||||||
|
// Always get the JS cookie via JS.
|
||||||
|
EXPECT_TRUE(got_cookie_js1_);
|
||||||
|
EXPECT_TRUE(got_cookie_js2_);
|
||||||
|
EXPECT_TRUE(got_cookie_js3_);
|
||||||
|
|
||||||
|
// Only get the net cookie via JS if cookie write was allowed.
|
||||||
|
if (test_mode_ & BLOCK_WRITE) {
|
||||||
|
EXPECT_FALSE(got_cookie_net1_);
|
||||||
|
EXPECT_FALSE(got_cookie_net2_);
|
||||||
|
EXPECT_FALSE(got_cookie_net3_);
|
||||||
} else {
|
} else {
|
||||||
EXPECT_TRUE(data2_.got_can_get_cookie_js_);
|
EXPECT_TRUE(got_cookie_net1_);
|
||||||
|
EXPECT_TRUE(got_cookie_net2_);
|
||||||
|
EXPECT_TRUE(got_cookie_net3_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// No query to get the net cookie for the 2nd network request if read or
|
// No cookies sent for the 1st network request.
|
||||||
// write (of the net cookie) was blocked.
|
EXPECT_FALSE(data1_.got_cookie_js_);
|
||||||
if (test_mode_ & (BLOCK_READ | BLOCK_WRITE)) {
|
EXPECT_FALSE(data1_.got_cookie_net_);
|
||||||
EXPECT_FALSE(data2_.got_can_get_cookie_net_);
|
|
||||||
|
// 2nd network request...
|
||||||
|
if (test_mode_ & BLOCK_READ) {
|
||||||
|
// No cookies sent if reading was blocked.
|
||||||
|
EXPECT_FALSE(data2_.got_cookie_js_);
|
||||||
|
EXPECT_FALSE(data2_.got_cookie_net_);
|
||||||
|
} else if (test_mode_ & BLOCK_WRITE) {
|
||||||
|
// Only JS cookie sent if writing was blocked.
|
||||||
|
EXPECT_TRUE(data2_.got_cookie_js_);
|
||||||
|
EXPECT_FALSE(data2_.got_cookie_net_);
|
||||||
} else {
|
} else {
|
||||||
EXPECT_TRUE(data2_.got_can_get_cookie_net_);
|
// All cookies sent.
|
||||||
|
EXPECT_TRUE(data2_.got_cookie_js_);
|
||||||
|
EXPECT_TRUE(data2_.got_cookie_net_);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!server_backend_) {
|
||||||
|
// No query to get cookies with the 1st network request because none
|
||||||
|
// have been set yet.
|
||||||
|
EXPECT_FALSE(data1_.got_can_get_cookie_js_);
|
||||||
|
EXPECT_FALSE(data1_.got_can_get_cookie_net_);
|
||||||
|
|
||||||
|
// JS cookie is not set via a network request.
|
||||||
|
EXPECT_FALSE(data1_.got_can_set_cookie_js_);
|
||||||
|
EXPECT_FALSE(data2_.got_can_set_cookie_js_);
|
||||||
|
|
||||||
|
// No query to set the net cookie for the 1st network request if write
|
||||||
|
// was blocked.
|
||||||
|
if (test_mode_ & BLOCK_WRITE) {
|
||||||
|
EXPECT_FALSE(data1_.got_can_set_cookie_net_);
|
||||||
|
} else {
|
||||||
|
EXPECT_TRUE(data1_.got_can_set_cookie_net_);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Net cookie is not set via the 2nd network request.
|
||||||
|
EXPECT_FALSE(data2_.got_can_set_cookie_net_);
|
||||||
|
|
||||||
|
// No query to get the JS cookie for the 2nd network request if read was
|
||||||
|
// blocked.
|
||||||
|
if (test_mode_ & BLOCK_READ) {
|
||||||
|
EXPECT_FALSE(data2_.got_can_get_cookie_js_);
|
||||||
|
} else {
|
||||||
|
EXPECT_TRUE(data2_.got_can_get_cookie_js_);
|
||||||
|
}
|
||||||
|
|
||||||
|
// No query to get the net cookie for the 2nd network request if read or
|
||||||
|
// write (of the net cookie) was blocked.
|
||||||
|
if (test_mode_ & (BLOCK_READ | BLOCK_WRITE)) {
|
||||||
|
EXPECT_FALSE(data2_.got_can_get_cookie_net_);
|
||||||
|
} else {
|
||||||
|
EXPECT_TRUE(data2_.got_can_get_cookie_net_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2413,8 +2487,13 @@ class CookieAccessTestHandler : public RoutingTestHandler {
|
|||||||
// Add the factory registration.
|
// Add the factory registration.
|
||||||
scheme_factory_ = new CookieAccessSchemeHandlerFactory();
|
scheme_factory_ = new CookieAccessSchemeHandlerFactory();
|
||||||
AddResponses(scheme_factory_.get());
|
AddResponses(scheme_factory_.get());
|
||||||
CefRegisterSchemeHandlerFactory(kCookieAccessScheme, kCookieAccessDomain,
|
if (context_) {
|
||||||
scheme_factory_.get());
|
context_->RegisterSchemeHandlerFactory(
|
||||||
|
kCookieAccessScheme, kCookieAccessDomain, scheme_factory_.get());
|
||||||
|
} else {
|
||||||
|
CefRegisterSchemeHandlerFactory(kCookieAccessScheme, kCookieAccessDomain,
|
||||||
|
scheme_factory_.get());
|
||||||
|
}
|
||||||
|
|
||||||
complete_callback.Run();
|
complete_callback.Run();
|
||||||
}
|
}
|
||||||
@ -2426,7 +2505,7 @@ class CookieAccessTestHandler : public RoutingTestHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateBrowser(GetCookieAccessUrl1(server_backend_));
|
CreateBrowser(GetCookieAccessUrl1(server_backend_), context_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FinishTest() {
|
void FinishTest() {
|
||||||
@ -2487,14 +2566,21 @@ class CookieAccessTestHandler : public RoutingTestHandler {
|
|||||||
void ShutdownSchemeHandler(const base::Closure& complete_callback) {
|
void ShutdownSchemeHandler(const base::Closure& complete_callback) {
|
||||||
EXPECT_TRUE(scheme_factory_);
|
EXPECT_TRUE(scheme_factory_);
|
||||||
|
|
||||||
CefRegisterSchemeHandlerFactory(kCookieAccessScheme, kCookieAccessDomain,
|
if (context_) {
|
||||||
nullptr);
|
context_->RegisterSchemeHandlerFactory(kCookieAccessScheme,
|
||||||
|
kCookieAccessDomain, nullptr);
|
||||||
|
} else {
|
||||||
|
CefRegisterSchemeHandlerFactory(kCookieAccessScheme, kCookieAccessDomain,
|
||||||
|
nullptr);
|
||||||
|
}
|
||||||
scheme_factory_->Shutdown(complete_callback);
|
scheme_factory_->Shutdown(complete_callback);
|
||||||
scheme_factory_ = nullptr;
|
scheme_factory_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
TestMode test_mode_;
|
TestMode test_mode_;
|
||||||
bool server_backend_;
|
bool server_backend_;
|
||||||
|
CefRefPtr<RequestContextHandler> context_handler_;
|
||||||
|
CefRefPtr<CefRequestContext> context_;
|
||||||
CefRefPtr<CefCookieManager> cookie_manager_;
|
CefRefPtr<CefCookieManager> cookie_manager_;
|
||||||
|
|
||||||
CefRefPtr<CookieAccessServerHandler> server_handler_;
|
CefRefPtr<CookieAccessServerHandler> server_handler_;
|
||||||
@ -2503,6 +2589,8 @@ class CookieAccessTestHandler : public RoutingTestHandler {
|
|||||||
CookieAccessData data1_;
|
CookieAccessData data1_;
|
||||||
CookieAccessData data2_;
|
CookieAccessData data2_;
|
||||||
|
|
||||||
|
TrackCallback got_cookie_manager_;
|
||||||
|
|
||||||
// 1st request.
|
// 1st request.
|
||||||
TrackCallback got_can_set_cookie1_;
|
TrackCallback got_can_set_cookie1_;
|
||||||
TrackCallback got_cookie_js1_;
|
TrackCallback got_cookie_js1_;
|
||||||
@ -2548,6 +2636,14 @@ TEST(RequestHandlerTest, CookieAccessServerBlockWrite) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Block reading and writing of cookies with server backend.
|
// Block reading and writing of cookies with server backend.
|
||||||
|
TEST(RequestHandlerTest, CookieAccessServerBlockReadWrite) {
|
||||||
|
CefRefPtr<CookieAccessTestHandler> handler = new CookieAccessTestHandler(
|
||||||
|
CookieAccessTestHandler::BLOCK_READ_WRITE, true);
|
||||||
|
handler->ExecuteTest();
|
||||||
|
ReleaseAndWaitForDestructor(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Block all cookies with server backend.
|
||||||
TEST(RequestHandlerTest, CookieAccessServerBlockAll) {
|
TEST(RequestHandlerTest, CookieAccessServerBlockAll) {
|
||||||
CefRefPtr<CookieAccessTestHandler> handler =
|
CefRefPtr<CookieAccessTestHandler> handler =
|
||||||
new CookieAccessTestHandler(CookieAccessTestHandler::BLOCK_ALL, true);
|
new CookieAccessTestHandler(CookieAccessTestHandler::BLOCK_ALL, true);
|
||||||
@ -2580,6 +2676,14 @@ TEST(RequestHandlerTest, CookieAccessSchemeBlockWrite) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Block reading and writing of cookies with scheme handler backend.
|
// Block reading and writing of cookies with scheme handler backend.
|
||||||
|
TEST(RequestHandlerTest, CookieAccessSchemeBlockReadWrite) {
|
||||||
|
CefRefPtr<CookieAccessTestHandler> handler = new CookieAccessTestHandler(
|
||||||
|
CookieAccessTestHandler::BLOCK_READ_WRITE, false);
|
||||||
|
handler->ExecuteTest();
|
||||||
|
ReleaseAndWaitForDestructor(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Block all cookies with scheme handler backend.
|
||||||
TEST(RequestHandlerTest, CookieAccessSchemeBlockAll) {
|
TEST(RequestHandlerTest, CookieAccessSchemeBlockAll) {
|
||||||
CefRefPtr<CookieAccessTestHandler> handler =
|
CefRefPtr<CookieAccessTestHandler> handler =
|
||||||
new CookieAccessTestHandler(CookieAccessTestHandler::BLOCK_ALL, false);
|
new CookieAccessTestHandler(CookieAccessTestHandler::BLOCK_ALL, false);
|
||||||
|
@ -28,6 +28,7 @@ const char kShowUpdateRect[] = "show-update-rect";
|
|||||||
const char kMouseCursorChangeDisabled[] = "mouse-cursor-change-disabled";
|
const char kMouseCursorChangeDisabled[] = "mouse-cursor-change-disabled";
|
||||||
const char kRequestContextPerBrowser[] = "request-context-per-browser";
|
const char kRequestContextPerBrowser[] = "request-context-per-browser";
|
||||||
const char kRequestContextSharedCache[] = "request-context-shared-cache";
|
const char kRequestContextSharedCache[] = "request-context-shared-cache";
|
||||||
|
const char kRequestContextBlockCookies[] = "request-context-block-cookies";
|
||||||
const char kBackgroundColor[] = "background-color";
|
const char kBackgroundColor[] = "background-color";
|
||||||
const char kEnableGPU[] = "enable-gpu";
|
const char kEnableGPU[] = "enable-gpu";
|
||||||
const char kFilterURL[] = "filter-url";
|
const char kFilterURL[] = "filter-url";
|
||||||
|
@ -22,6 +22,7 @@ extern const char kShowUpdateRect[];
|
|||||||
extern const char kMouseCursorChangeDisabled[];
|
extern const char kMouseCursorChangeDisabled[];
|
||||||
extern const char kRequestContextPerBrowser[];
|
extern const char kRequestContextPerBrowser[];
|
||||||
extern const char kRequestContextSharedCache[];
|
extern const char kRequestContextSharedCache[];
|
||||||
|
extern const char kRequestContextBlockCookies[];
|
||||||
extern const char kBackgroundColor[];
|
extern const char kBackgroundColor[];
|
||||||
extern const char kEnableGPU[];
|
extern const char kEnableGPU[];
|
||||||
extern const char kFilterURL[];
|
extern const char kFilterURL[];
|
||||||
|
Reference in New Issue
Block a user