mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Update to Chromium revision 0bfd25d4 (#381305)
- Delete include/cef_runnable.h (issue #1336). - Build the cef_unittests target using all Chromium headers. Add a USING_CHROMIUM_INCLUDES define and libcef_dll_wrapper_unittests target to support this. This change avoids compile errors due to the divergence of CEF and Chromium base/ header implementations. The libcef_dll_wrapper sources must now compile successfully with both CEF and Chromium base/ headers (issue #1632). - The onbeforeunload message specified via JavaScript is no longer passed to the client (see http://crbug.com/587940).
This commit is contained in:
@ -11,7 +11,6 @@
|
||||
#include "libcef/browser/content_browser_client.h"
|
||||
#include "libcef/browser/context.h"
|
||||
#include "libcef/browser/net/network_delegate.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/common/time_util.h"
|
||||
|
||||
#include "base/bind.h"
|
||||
@ -33,9 +32,9 @@ namespace {
|
||||
class VisitCookiesCallback : public base::RefCounted<VisitCookiesCallback> {
|
||||
public:
|
||||
explicit VisitCookiesCallback(
|
||||
scoped_refptr<net::CookieMonster> cookie_monster,
|
||||
const CefCookieManagerImpl::CookieStoreGetter& cookie_store_getter,
|
||||
CefRefPtr<CefCookieVisitor> visitor)
|
||||
: cookie_monster_(cookie_monster),
|
||||
: cookie_store_getter_(cookie_store_getter),
|
||||
visitor_(visitor) {
|
||||
}
|
||||
|
||||
@ -53,8 +52,11 @@ class VisitCookiesCallback : public base::RefCounted<VisitCookiesCallback> {
|
||||
bool deleteCookie = false;
|
||||
bool keepLooping = visitor_->Visit(cookie, count, total, deleteCookie);
|
||||
if (deleteCookie) {
|
||||
cookie_monster_->DeleteCanonicalCookieAsync(cc,
|
||||
net::CookieMonster::DeleteCookieCallback());
|
||||
net::CookieStore* cookie_store = cookie_store_getter_.Run();
|
||||
if (cookie_store) {
|
||||
cookie_store->DeleteCanonicalCookieAsync(cc,
|
||||
net::CookieMonster::DeleteCallback());
|
||||
}
|
||||
}
|
||||
if (!keepLooping)
|
||||
break;
|
||||
@ -66,12 +68,12 @@ class VisitCookiesCallback : public base::RefCounted<VisitCookiesCallback> {
|
||||
|
||||
~VisitCookiesCallback() {}
|
||||
|
||||
scoped_refptr<net::CookieMonster> cookie_monster_;
|
||||
CefCookieManagerImpl::CookieStoreGetter cookie_store_getter_;
|
||||
CefRefPtr<CefCookieVisitor> visitor_;
|
||||
};
|
||||
|
||||
|
||||
// Methods extracted from net/cookies/cookie_monster.cc
|
||||
// Methods extracted from net/cookies/cookie_store.cc
|
||||
|
||||
// Determine the cookie domain to use for setting the specified cookie.
|
||||
bool GetCookieDomain(const GURL& url,
|
||||
@ -118,6 +120,7 @@ CefCookieManagerImpl::CefCookieManagerImpl() {
|
||||
}
|
||||
|
||||
CefCookieManagerImpl::~CefCookieManagerImpl() {
|
||||
CEF_REQUIRE_IOT();
|
||||
}
|
||||
|
||||
void CefCookieManagerImpl::Initialize(
|
||||
@ -135,53 +138,54 @@ void CefCookieManagerImpl::Initialize(
|
||||
}
|
||||
}
|
||||
|
||||
void CefCookieManagerImpl::GetCookieMonster(
|
||||
void CefCookieManagerImpl::GetCookieStore(
|
||||
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
|
||||
const CookieMonsterCallback& callback) {
|
||||
const CookieStoreCallback& callback) {
|
||||
if (!task_runner.get())
|
||||
task_runner = base::MessageLoop::current()->task_runner();
|
||||
|
||||
if (!CEF_CURRENTLY_ON_IOT()) {
|
||||
CEF_POST_TASK(CEF_IOT,
|
||||
base::Bind(&CefCookieManagerImpl::GetCookieMonster, this, task_runner,
|
||||
base::Bind(&CefCookieManagerImpl::GetCookieStore, this, task_runner,
|
||||
callback));
|
||||
return;
|
||||
}
|
||||
|
||||
if (HasContext()) {
|
||||
RunMethodWithContext(
|
||||
base::Bind(&CefCookieManagerImpl::GetCookieMonsterWithContext, this,
|
||||
base::Bind(&CefCookieManagerImpl::GetCookieStoreWithContext, this,
|
||||
task_runner, callback));
|
||||
return;
|
||||
}
|
||||
|
||||
DCHECK(cookie_monster_.get());
|
||||
if (cookie_monster_.get()) {
|
||||
if (task_runner->BelongsToCurrentThread()) {
|
||||
// Execute the callback immediately.
|
||||
callback.Run(cookie_monster_);
|
||||
} else {
|
||||
// Execute the callback on the target thread.
|
||||
task_runner->PostTask(FROM_HERE, base::Bind(callback, cookie_monster_));
|
||||
}
|
||||
return;
|
||||
DCHECK(cookie_store_.get());
|
||||
|
||||
const CookieStoreGetter& cookie_store_getter =
|
||||
base::Bind(&CefCookieManagerImpl::GetExistingCookieStore, this);
|
||||
|
||||
if (task_runner->BelongsToCurrentThread()) {
|
||||
// Execute the callback immediately.
|
||||
callback.Run(cookie_store_getter);
|
||||
} else {
|
||||
// Execute the callback on the target thread.
|
||||
task_runner->PostTask(FROM_HERE,
|
||||
base::Bind(callback, cookie_store_getter));
|
||||
}
|
||||
}
|
||||
|
||||
scoped_refptr<net::CookieMonster>
|
||||
CefCookieManagerImpl::GetExistingCookieMonster() {
|
||||
net::CookieStore* CefCookieManagerImpl::GetExistingCookieStore() {
|
||||
CEF_REQUIRE_IOT();
|
||||
if (cookie_monster_.get()) {
|
||||
return cookie_monster_;
|
||||
if (cookie_store_.get()) {
|
||||
return cookie_store_.get();
|
||||
} else if (request_context_impl_.get()) {
|
||||
scoped_refptr<net::CookieMonster> cookie_monster =
|
||||
request_context_impl_->GetCookieMonster();
|
||||
DCHECK(cookie_monster.get());
|
||||
return cookie_monster;
|
||||
net::CookieStore* cookie_store =
|
||||
request_context_impl_->GetExistingCookieStore();
|
||||
DCHECK(cookie_store);
|
||||
return cookie_store;
|
||||
}
|
||||
|
||||
LOG(ERROR) << "Cookie manager backing store does not exist yet";
|
||||
return NULL;
|
||||
LOG(ERROR) << "Cookie store does not exist";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CefCookieManagerImpl::SetSupportedSchemes(
|
||||
@ -204,7 +208,7 @@ void CefCookieManagerImpl::SetSupportedSchemes(
|
||||
|
||||
bool CefCookieManagerImpl::VisitAllCookies(
|
||||
CefRefPtr<CefCookieVisitor> visitor) {
|
||||
GetCookieMonster(
|
||||
GetCookieStore(
|
||||
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
|
||||
base::Bind(&CefCookieManagerImpl::VisitAllCookiesInternal, this,
|
||||
visitor));
|
||||
@ -215,7 +219,7 @@ bool CefCookieManagerImpl::VisitUrlCookies(
|
||||
const CefString& url,
|
||||
bool includeHttpOnly,
|
||||
CefRefPtr<CefCookieVisitor> visitor) {
|
||||
GetCookieMonster(
|
||||
GetCookieStore(
|
||||
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
|
||||
base::Bind(&CefCookieManagerImpl::VisitUrlCookiesInternal, this, url,
|
||||
includeHttpOnly, visitor));
|
||||
@ -230,7 +234,7 @@ bool CefCookieManagerImpl::SetCookie(
|
||||
if (!gurl.is_valid())
|
||||
return false;
|
||||
|
||||
GetCookieMonster(
|
||||
GetCookieStore(
|
||||
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
|
||||
base::Bind(&CefCookieManagerImpl::SetCookieInternal, this, gurl, cookie,
|
||||
callback));
|
||||
@ -246,7 +250,7 @@ bool CefCookieManagerImpl::DeleteCookies(
|
||||
if (!gurl.is_empty() && !gurl.is_valid())
|
||||
return false;
|
||||
|
||||
GetCookieMonster(
|
||||
GetCookieStore(
|
||||
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
|
||||
base::Bind(&CefCookieManagerImpl::DeleteCookiesInternal, this, gurl,
|
||||
cookie_name, callback));
|
||||
@ -275,7 +279,7 @@ bool CefCookieManagerImpl::SetStoragePath(
|
||||
if (!path.empty())
|
||||
new_path = base::FilePath(path);
|
||||
|
||||
if (cookie_monster_.get() && ((storage_path_.empty() && path.empty()) ||
|
||||
if (cookie_store_.get() && ((storage_path_.empty() && path.empty()) ||
|
||||
storage_path_ == new_path)) {
|
||||
// The path has not changed so don't do anything.
|
||||
RunAsyncCompletionOnIOThread(callback);
|
||||
@ -306,9 +310,9 @@ bool CefCookieManagerImpl::SetStoragePath(
|
||||
// Set the new cookie store that will be used for all new requests. The old
|
||||
// cookie store, if any, will be automatically flushed and closed when no
|
||||
// longer referenced.
|
||||
cookie_monster_ = new net::CookieMonster(persistent_store.get(), NULL);
|
||||
cookie_store_.reset(new net::CookieMonster(persistent_store.get(), NULL));
|
||||
if (persistent_store.get() && persist_session_cookies)
|
||||
cookie_monster_->SetPersistSessionCookies(true);
|
||||
cookie_store_->SetPersistSessionCookies(true);
|
||||
storage_path_ = new_path;
|
||||
|
||||
// Restore the previously supported schemes.
|
||||
@ -319,7 +323,7 @@ bool CefCookieManagerImpl::SetStoragePath(
|
||||
|
||||
bool CefCookieManagerImpl::FlushStore(
|
||||
CefRefPtr<CefCompletionCallback> callback) {
|
||||
GetCookieMonster(
|
||||
GetCookieStore(
|
||||
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
|
||||
base::Bind(&CefCookieManagerImpl::FlushStoreInternal, this, callback));
|
||||
return true;
|
||||
@ -457,27 +461,29 @@ void CefCookieManagerImpl::SetSupportedSchemesWithContext(
|
||||
RunAsyncCompletionOnIOThread(callback);
|
||||
}
|
||||
|
||||
void CefCookieManagerImpl::GetCookieMonsterWithContext(
|
||||
void CefCookieManagerImpl::GetCookieStoreWithContext(
|
||||
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
|
||||
const CookieMonsterCallback& callback,
|
||||
const CookieStoreCallback& callback,
|
||||
scoped_refptr<CefURLRequestContextGetterImpl> request_context) {
|
||||
CEF_REQUIRE_IOT();
|
||||
DCHECK(request_context->GetExistingCookieStore());
|
||||
|
||||
scoped_refptr<net::CookieMonster> cookie_monster =
|
||||
request_context->GetCookieMonster();
|
||||
const CookieStoreGetter& cookie_store_getter =
|
||||
base::Bind(&CefURLRequestContextGetterImpl::GetExistingCookieStore,
|
||||
request_context);
|
||||
|
||||
if (task_runner->BelongsToCurrentThread()) {
|
||||
// Execute the callback immediately.
|
||||
callback.Run(cookie_monster);
|
||||
callback.Run(cookie_store_getter);
|
||||
} else {
|
||||
// Execute the callback on the target thread.
|
||||
task_runner->PostTask(FROM_HERE, base::Bind(callback, cookie_monster));
|
||||
task_runner->PostTask(FROM_HERE, base::Bind(callback, cookie_store_getter));
|
||||
}
|
||||
}
|
||||
|
||||
void CefCookieManagerImpl::SetSupportedSchemesInternal(
|
||||
const std::vector<std::string>& schemes,
|
||||
CefRefPtr<CefCompletionCallback> callback){
|
||||
CefRefPtr<CefCompletionCallback> callback) {
|
||||
CEF_REQUIRE_IOT();
|
||||
|
||||
if (HasContext()) {
|
||||
@ -487,25 +493,29 @@ void CefCookieManagerImpl::SetSupportedSchemesInternal(
|
||||
return;
|
||||
}
|
||||
|
||||
DCHECK(cookie_monster_.get());
|
||||
if (!cookie_monster_.get())
|
||||
DCHECK(cookie_store_.get());
|
||||
if (!cookie_store_.get())
|
||||
return;
|
||||
|
||||
supported_schemes_ = schemes;
|
||||
SetCookieMonsterSchemes(cookie_monster_.get(), supported_schemes_);
|
||||
SetCookieMonsterSchemes(cookie_store_.get(), supported_schemes_);
|
||||
|
||||
RunAsyncCompletionOnIOThread(callback);
|
||||
}
|
||||
|
||||
void CefCookieManagerImpl::VisitAllCookiesInternal(
|
||||
CefRefPtr<CefCookieVisitor> visitor,
|
||||
scoped_refptr<net::CookieMonster> cookie_monster) {
|
||||
const CookieStoreGetter& cookie_store_getter) {
|
||||
CEF_REQUIRE_IOT();
|
||||
|
||||
scoped_refptr<VisitCookiesCallback> callback(
|
||||
new VisitCookiesCallback(cookie_monster, visitor));
|
||||
net::CookieStore* cookie_store = cookie_store_getter.Run();
|
||||
if (!cookie_store)
|
||||
return;
|
||||
|
||||
cookie_monster->GetAllCookiesAsync(
|
||||
scoped_refptr<VisitCookiesCallback> callback(
|
||||
new VisitCookiesCallback(cookie_store_getter, visitor));
|
||||
|
||||
cookie_store->GetAllCookiesAsync(
|
||||
base::Bind(&VisitCookiesCallback::Run, callback.get()));
|
||||
}
|
||||
|
||||
@ -513,18 +523,22 @@ void CefCookieManagerImpl::VisitUrlCookiesInternal(
|
||||
const CefString& url,
|
||||
bool includeHttpOnly,
|
||||
CefRefPtr<CefCookieVisitor> visitor,
|
||||
scoped_refptr<net::CookieMonster> cookie_monster) {
|
||||
const CookieStoreGetter& cookie_store_getter) {
|
||||
CEF_REQUIRE_IOT();
|
||||
|
||||
net::CookieStore* cookie_store = cookie_store_getter.Run();
|
||||
if (!cookie_store)
|
||||
return;
|
||||
|
||||
net::CookieOptions options;
|
||||
if (includeHttpOnly)
|
||||
options.set_include_httponly();
|
||||
|
||||
scoped_refptr<VisitCookiesCallback> callback(
|
||||
new VisitCookiesCallback(cookie_monster, visitor));
|
||||
new VisitCookiesCallback(cookie_store_getter, visitor));
|
||||
|
||||
GURL gurl = GURL(url.ToString());
|
||||
cookie_monster->GetAllCookiesForURLWithOptionsAsync(gurl, options,
|
||||
cookie_store->GetCookieListWithOptionsAsync(gurl, options,
|
||||
base::Bind(&VisitCookiesCallback::Run, callback.get()));
|
||||
}
|
||||
|
||||
@ -532,9 +546,13 @@ void CefCookieManagerImpl::SetCookieInternal(
|
||||
const GURL& url,
|
||||
const CefCookie& cookie,
|
||||
CefRefPtr<CefSetCookieCallback> callback,
|
||||
scoped_refptr<net::CookieMonster> cookie_monster) {
|
||||
const CookieStoreGetter& cookie_store_getter) {
|
||||
CEF_REQUIRE_IOT();
|
||||
|
||||
net::CookieStore* cookie_store = cookie_store_getter.Run();
|
||||
if (!cookie_store)
|
||||
return;
|
||||
|
||||
std::string name = CefString(&cookie.name).ToString();
|
||||
std::string value = CefString(&cookie.value).ToString();
|
||||
std::string domain = CefString(&cookie.domain).ToString();
|
||||
@ -544,13 +562,14 @@ void CefCookieManagerImpl::SetCookieInternal(
|
||||
if (cookie.has_expires)
|
||||
cef_time_to_basetime(cookie.expires, expiration_time);
|
||||
|
||||
cookie_monster->SetCookieWithDetailsAsync(
|
||||
cookie_store->SetCookieWithDetailsAsync(
|
||||
url, name, value, domain, path,
|
||||
base::Time(), // Creation time.
|
||||
expiration_time,
|
||||
base::Time(), // Last access time.
|
||||
cookie.secure ? true : false,
|
||||
cookie.httponly ? true : false,
|
||||
false, // First-party only.
|
||||
net::CookieSameSite::DEFAULT_MODE,
|
||||
CefNetworkDelegate::AreStrictSecureCookiesEnabled(),
|
||||
net::COOKIE_PRIORITY_DEFAULT,
|
||||
base::Bind(SetCookieCallbackImpl, callback));
|
||||
@ -560,31 +579,39 @@ void CefCookieManagerImpl::DeleteCookiesInternal(
|
||||
const GURL& url,
|
||||
const CefString& cookie_name,
|
||||
CefRefPtr<CefDeleteCookiesCallback> callback,
|
||||
scoped_refptr<net::CookieMonster> cookie_monster) {
|
||||
const CookieStoreGetter& cookie_store_getter) {
|
||||
CEF_REQUIRE_IOT();
|
||||
|
||||
net::CookieStore* cookie_store = cookie_store_getter.Run();
|
||||
if (!cookie_store)
|
||||
return;
|
||||
|
||||
if (url.is_empty()) {
|
||||
// Delete all cookies.
|
||||
cookie_monster->DeleteAllAsync(
|
||||
cookie_store->DeleteAllAsync(
|
||||
base::Bind(DeleteCookiesCallbackImpl, callback));
|
||||
} else if (cookie_name.empty()) {
|
||||
// Delete all matching host cookies.
|
||||
cookie_monster->DeleteAllCreatedBetweenForHostAsync(
|
||||
cookie_store->DeleteAllCreatedBetweenForHostAsync(
|
||||
base::Time(), base::Time::Max(), url,
|
||||
base::Bind(DeleteCookiesCallbackImpl, callback));
|
||||
} else {
|
||||
// Delete all matching host and domain cookies.
|
||||
cookie_monster->DeleteCookieAsync(url, cookie_name,
|
||||
cookie_store->DeleteCookieAsync(url, cookie_name,
|
||||
base::Bind(DeleteCookiesCallbackImpl, callback, -1));
|
||||
}
|
||||
}
|
||||
|
||||
void CefCookieManagerImpl::FlushStoreInternal(
|
||||
CefRefPtr<CefCompletionCallback> callback,
|
||||
scoped_refptr<net::CookieMonster> cookie_monster) {
|
||||
const CookieStoreGetter& cookie_store_getter) {
|
||||
CEF_REQUIRE_IOT();
|
||||
|
||||
cookie_monster->FlushStore(
|
||||
net::CookieStore* cookie_store = cookie_store_getter.Run();
|
||||
if (!cookie_store)
|
||||
return;
|
||||
|
||||
cookie_store->FlushStore(
|
||||
base::Bind(RunAsyncCompletionOnIOThread, callback));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user