mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
libcef: Update due to underlying chromium changes.
- webkit/webkit.gyp moved to webkit/support/webkit_support.gyp. - Classes moved from base/gfx moved to gfx. - Changes to plugin creation code path. - Changes to BrowserResourceLoaderBridge, BrowserAppCacheSystem and BrowserDatabaseSystem. - Enable push state, notifications, touch and indexed database. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@82 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2008 The Chromium Embedded Framework Authors.
|
||||
// Copyright (c) 2010 The Chromium Embedded Framework Authors.
|
||||
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
@@ -38,26 +38,31 @@
|
||||
#include "browser_impl.h"
|
||||
#include "request_impl.h"
|
||||
|
||||
#include "base/file_path.h"
|
||||
#include "base/message_loop.h"
|
||||
#if defined(OS_MACOSX) || defined(OS_WIN)
|
||||
#include "base/nss_util.h"
|
||||
#endif
|
||||
#include "base/ref_counted.h"
|
||||
#include "base/time.h"
|
||||
#include "base/timer.h"
|
||||
#include "base/thread.h"
|
||||
#include "base/utf_string_conversions.h"
|
||||
#include "base/waitable_event.h"
|
||||
#include "net/base/cookie_policy.h"
|
||||
#include "net/base/io_buffer.h"
|
||||
#include "net/base/load_flags.h"
|
||||
#include "net/base/net_errors.h"
|
||||
#include "net/base/net_util.h"
|
||||
#include "net/base/static_cookie_policy.h"
|
||||
#include "net/base/upload_data.h"
|
||||
#include "net/http/http_cache.h"
|
||||
#include "net/http/http_request_headers.h"
|
||||
#include "net/http/http_response_headers.h"
|
||||
#include "net/http/http_util.h"
|
||||
#include "net/proxy/proxy_service.h"
|
||||
#if defined(OS_WIN)
|
||||
#include "net/socket/ssl_client_socket_nss_factory.h"
|
||||
#endif
|
||||
#include "net/url_request/url_request.h"
|
||||
#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
|
||||
#include "third_party/WebKit/WebKit/chromium/public/WebView.h"
|
||||
#include "webkit/appcache/appcache_interfaces.h"
|
||||
#include "webkit/glue/resource_loader_bridge.h"
|
||||
|
||||
@@ -65,12 +70,30 @@ using webkit_glue::ResourceLoaderBridge;
|
||||
using net::HttpResponseHeaders;
|
||||
using net::StaticCookiePolicy;
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
struct BrowserRequestContextParams {
|
||||
BrowserRequestContextParams(
|
||||
const FilePath& in_cache_path,
|
||||
net::HttpCache::Mode in_cache_mode,
|
||||
bool in_no_proxy)
|
||||
: cache_path(in_cache_path),
|
||||
cache_mode(in_cache_mode),
|
||||
no_proxy(in_no_proxy),
|
||||
accept_all_cookies(false) {}
|
||||
|
||||
URLRequestContext* request_context = NULL;
|
||||
base::Thread* io_thread = NULL;
|
||||
FilePath cache_path;
|
||||
net::HttpCache::Mode cache_mode;
|
||||
bool no_proxy;
|
||||
bool accept_all_cookies;
|
||||
};
|
||||
|
||||
BrowserRequestContextParams* g_request_context_params = NULL;
|
||||
URLRequestContext* g_request_context = NULL;
|
||||
base::Thread* g_cache_thread = NULL;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class IOThread : public base::Thread {
|
||||
public:
|
||||
@@ -84,19 +107,44 @@ class IOThread : public base::Thread {
|
||||
}
|
||||
|
||||
virtual void Init() {
|
||||
BrowserAppCacheSystem::InitializeOnIOThread(request_context);
|
||||
BrowserSocketStreamBridge::InitializeOnIOThread(request_context);
|
||||
if (g_request_context_params) {
|
||||
g_request_context = new BrowserRequestContext(
|
||||
g_request_context_params->cache_path,
|
||||
g_request_context_params->cache_mode,
|
||||
g_request_context_params->no_proxy);
|
||||
SetAcceptAllCookies(g_request_context_params->accept_all_cookies);
|
||||
delete g_request_context_params;
|
||||
g_request_context_params = NULL;
|
||||
} else {
|
||||
g_request_context = new BrowserRequestContext();
|
||||
SetAcceptAllCookies(false);
|
||||
}
|
||||
|
||||
g_request_context->AddRef();
|
||||
|
||||
BrowserAppCacheSystem::InitializeOnIOThread(g_request_context);
|
||||
BrowserSocketStreamBridge::InitializeOnIOThread(g_request_context);
|
||||
}
|
||||
|
||||
virtual void CleanUp() {
|
||||
BrowserSocketStreamBridge::Cleanup();
|
||||
if (request_context) {
|
||||
request_context->Release();
|
||||
request_context = NULL;
|
||||
if (g_request_context) {
|
||||
g_request_context->Release();
|
||||
g_request_context = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void SetAcceptAllCookies(bool accept_all_cookies) {
|
||||
StaticCookiePolicy::Type policy_type = accept_all_cookies ?
|
||||
StaticCookiePolicy::ALLOW_ALL_COOKIES :
|
||||
StaticCookiePolicy::BLOCK_THIRD_PARTY_COOKIES;
|
||||
static_cast<StaticCookiePolicy*>(g_request_context->cookie_policy())->
|
||||
set_type(policy_type);
|
||||
}
|
||||
};
|
||||
|
||||
IOThread* g_io_thread = NULL;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
struct RequestParams {
|
||||
@@ -137,13 +185,13 @@ class RequestProxy : public URLRequest::Delegate,
|
||||
owner_loop_ = MessageLoop::current();
|
||||
|
||||
// proxy over to the io thread
|
||||
io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
|
||||
g_io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
|
||||
this, &RequestProxy::AsyncStart, params));
|
||||
}
|
||||
|
||||
void Cancel() {
|
||||
// proxy over to the io thread
|
||||
io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
|
||||
g_io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
|
||||
this, &RequestProxy::AsyncCancel));
|
||||
}
|
||||
|
||||
@@ -153,7 +201,7 @@ class RequestProxy : public URLRequest::Delegate,
|
||||
virtual ~RequestProxy() {
|
||||
// If we have a request, then we'd better be on the io thread!
|
||||
DCHECK(!request_.get() ||
|
||||
MessageLoop::current() == io_thread->message_loop());
|
||||
MessageLoop::current() == g_io_thread->message_loop());
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
@@ -161,11 +209,6 @@ class RequestProxy : public URLRequest::Delegate,
|
||||
// various URLRequest callbacks. The event hooks, defined below, trigger
|
||||
// these methods asynchronously.
|
||||
|
||||
void NotifyUploadProgress(uint64 position, uint64 size) {
|
||||
if (peer_)
|
||||
peer_->OnUploadProgress(position, size);
|
||||
}
|
||||
|
||||
void NotifyReceivedRedirect(const GURL& new_url,
|
||||
const ResourceLoaderBridge::ResponseInfo& info) {
|
||||
bool has_new_first_party_for_cookies = false;
|
||||
@@ -173,7 +216,7 @@ class RequestProxy : public URLRequest::Delegate,
|
||||
if (peer_ && peer_->OnReceivedRedirect(new_url, info,
|
||||
&has_new_first_party_for_cookies,
|
||||
&new_first_party_for_cookies)) {
|
||||
io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
|
||||
g_io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
|
||||
this, &RequestProxy::AsyncFollowDeferredRedirect,
|
||||
has_new_first_party_for_cookies, new_first_party_for_cookies));
|
||||
} else {
|
||||
@@ -202,7 +245,7 @@ class RequestProxy : public URLRequest::Delegate,
|
||||
// peer could generate new requests in reponse to the received data, which
|
||||
// when run on the io thread, could race against this function in doing
|
||||
// another InvokeLater. See bug 769249.
|
||||
io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
|
||||
g_io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
|
||||
this, &RequestProxy::AsyncReadData));
|
||||
|
||||
peer_->OnReceivedData(buf_copy.get(), bytes_read);
|
||||
@@ -216,6 +259,11 @@ class RequestProxy : public URLRequest::Delegate,
|
||||
}
|
||||
}
|
||||
|
||||
void NotifyUploadProgress(uint64 position, uint64 size) {
|
||||
if (peer_)
|
||||
peer_->OnUploadProgress(position, size);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// The following methods are called on the io thread. They correspond to
|
||||
// actions performed on the owner's thread.
|
||||
@@ -295,10 +343,12 @@ class RequestProxy : public URLRequest::Delegate,
|
||||
request_->set_method(params->method);
|
||||
request_->set_first_party_for_cookies(params->first_party_for_cookies);
|
||||
request_->set_referrer(params->referrer.spec());
|
||||
request_->SetExtraRequestHeaders(params->headers);
|
||||
net::HttpRequestHeaders headers;
|
||||
headers.AddHeadersFromString(params->headers);
|
||||
request_->SetExtraRequestHeaders(headers);
|
||||
request_->set_load_flags(params->load_flags);
|
||||
request_->set_upload(params->upload.get());
|
||||
request_->set_context(request_context);
|
||||
request_->set_context(g_request_context);
|
||||
BrowserAppCacheSystem::SetExtraRequestInfo(
|
||||
request_.get(), params->appcache_host_id, params->request_type);
|
||||
|
||||
@@ -448,7 +498,7 @@ class RequestProxy : public URLRequest::Delegate,
|
||||
MaybeUpdateUploadProgress();
|
||||
upload_progress_timer_.Stop();
|
||||
}
|
||||
|
||||
DCHECK(request_.get());
|
||||
OnCompletedRequest(request_->status(), std::string());
|
||||
request_.reset(); // destroy on the io thread
|
||||
}
|
||||
@@ -606,7 +656,7 @@ class ResourceLoaderBridgeImpl : public ResourceLoaderBridge {
|
||||
if (proxy_) {
|
||||
proxy_->DropPeer();
|
||||
// Let the proxy die on the IO thread
|
||||
io_thread->message_loop()->ReleaseSoon(FROM_HERE, proxy_);
|
||||
g_io_thread->message_loop()->ReleaseSoon(FROM_HERE, proxy_);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -695,8 +745,8 @@ class ResourceLoaderBridgeImpl : public ResourceLoaderBridge {
|
||||
class CookieSetter : public base::RefCountedThreadSafe<CookieSetter> {
|
||||
public:
|
||||
void Set(const GURL& url, const std::string& cookie) {
|
||||
DCHECK(MessageLoop::current() == io_thread->message_loop());
|
||||
request_context->cookie_store()->SetCookie(url, cookie);
|
||||
DCHECK(MessageLoop::current() == g_io_thread->message_loop());
|
||||
g_request_context->cookie_store()->SetCookie(url, cookie);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -711,7 +761,7 @@ class CookieGetter : public base::RefCountedThreadSafe<CookieGetter> {
|
||||
}
|
||||
|
||||
void Get(const GURL& url) {
|
||||
result_ = request_context->cookie_store()->GetCookies(url);
|
||||
result_ = g_request_context->cookie_store()->GetCookies(url);
|
||||
event_.Signal();
|
||||
}
|
||||
|
||||
@@ -747,14 +797,15 @@ ResourceLoaderBridge* ResourceLoaderBridge::Create(
|
||||
// Issue the proxy resolve request on the io thread, and wait
|
||||
// for the result.
|
||||
bool FindProxyForUrl(const GURL& url, std::string* proxy_list) {
|
||||
DCHECK(request_context);
|
||||
DCHECK(g_request_context);
|
||||
|
||||
scoped_refptr<net::SyncProxyServiceHelper> sync_proxy_service(
|
||||
new net::SyncProxyServiceHelper(io_thread->message_loop(),
|
||||
request_context->proxy_service()));
|
||||
new net::SyncProxyServiceHelper(g_io_thread->message_loop(),
|
||||
g_request_context->proxy_service()));
|
||||
|
||||
net::ProxyInfo proxy_info;
|
||||
int rv = sync_proxy_service->ResolveProxy(url, &proxy_info, NULL);
|
||||
int rv = sync_proxy_service->ResolveProxy(url, &proxy_info,
|
||||
net::BoundNetLog());
|
||||
if (rv == net::OK) {
|
||||
*proxy_list = proxy_info.ToPacString();
|
||||
}
|
||||
@@ -767,34 +818,43 @@ bool FindProxyForUrl(const GURL& url, std::string* proxy_list) {
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// static
|
||||
void BrowserResourceLoaderBridge::Init(BrowserRequestContext* context) {
|
||||
void BrowserResourceLoaderBridge::Init(
|
||||
const FilePath& cache_path,
|
||||
net::HttpCache::Mode cache_mode,
|
||||
bool no_proxy) {
|
||||
// Make sure to stop any existing IO thread since it may be using the
|
||||
// current request context.
|
||||
Shutdown();
|
||||
|
||||
if (context) {
|
||||
request_context = context;
|
||||
} else {
|
||||
request_context = new BrowserRequestContext();
|
||||
}
|
||||
request_context->AddRef();
|
||||
BrowserResourceLoaderBridge::SetAcceptAllCookies(false);
|
||||
DCHECK(!g_request_context_params);
|
||||
DCHECK(!g_request_context);
|
||||
DCHECK(!g_io_thread);
|
||||
|
||||
g_request_context_params = new BrowserRequestContextParams(
|
||||
cache_path, cache_mode, no_proxy);
|
||||
}
|
||||
|
||||
// static
|
||||
void BrowserResourceLoaderBridge::Shutdown() {
|
||||
if (io_thread) {
|
||||
delete io_thread;
|
||||
io_thread = NULL;
|
||||
if (g_io_thread) {
|
||||
delete g_io_thread;
|
||||
g_io_thread = NULL;
|
||||
|
||||
DCHECK(!request_context) << "should have been nulled by thread dtor";
|
||||
DCHECK(g_cache_thread);
|
||||
delete g_cache_thread;
|
||||
g_cache_thread = NULL;
|
||||
|
||||
DCHECK(!g_request_context) << "should have been nulled by thread dtor";
|
||||
} else {
|
||||
delete g_request_context_params;
|
||||
g_request_context_params = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void BrowserResourceLoaderBridge::SetCookie(const GURL& url,
|
||||
const GURL& first_party_for_cookies,
|
||||
const std::string& cookie) {
|
||||
const GURL& first_party_for_cookies,
|
||||
const std::string& cookie) {
|
||||
// Proxy to IO thread to synchronize w/ network loading.
|
||||
|
||||
if (!EnsureIOThread()) {
|
||||
@@ -803,7 +863,7 @@ void BrowserResourceLoaderBridge::SetCookie(const GURL& url,
|
||||
}
|
||||
|
||||
scoped_refptr<CookieSetter> cookie_setter = new CookieSetter();
|
||||
io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
|
||||
g_io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
|
||||
cookie_setter.get(), &CookieSetter::Set, url, cookie));
|
||||
}
|
||||
|
||||
@@ -819,7 +879,7 @@ std::string BrowserResourceLoaderBridge::GetCookies(
|
||||
|
||||
scoped_refptr<CookieGetter> getter = new CookieGetter();
|
||||
|
||||
io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
|
||||
g_io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
|
||||
getter.get(), &CookieGetter::Get, url));
|
||||
|
||||
return getter->GetResult();
|
||||
@@ -827,23 +887,46 @@ std::string BrowserResourceLoaderBridge::GetCookies(
|
||||
|
||||
// static
|
||||
bool BrowserResourceLoaderBridge::EnsureIOThread() {
|
||||
if (io_thread)
|
||||
if (g_io_thread)
|
||||
return true;
|
||||
|
||||
if (!request_context)
|
||||
BrowserResourceLoaderBridge::Init(NULL);
|
||||
#if defined(OS_WIN)
|
||||
// Use NSS for SSL on Windows. TODO(wtc): this should eventually be hidden
|
||||
// inside DefaultClientSocketFactory::CreateSSLClientSocket.
|
||||
net::ClientSocketFactory::SetSSLClientSocketFactory(
|
||||
net::SSLClientSocketNSSFactory);
|
||||
#endif
|
||||
#if defined(OS_MACOSX) || defined(OS_WIN)
|
||||
// We want to be sure to init NSPR on the main thread.
|
||||
base::EnsureNSPRInit();
|
||||
#endif
|
||||
|
||||
io_thread = new IOThread();
|
||||
// Create the cache thread. We want the cache thread to outlive the IO thread,
|
||||
// so its lifetime is bonded to the IO thread lifetime.
|
||||
DCHECK(!g_cache_thread);
|
||||
g_cache_thread = new base::Thread("cache");
|
||||
CHECK(g_cache_thread->StartWithOptions(
|
||||
base::Thread::Options(MessageLoop::TYPE_IO, 0)));
|
||||
|
||||
g_io_thread = new IOThread();
|
||||
base::Thread::Options options;
|
||||
options.message_loop_type = MessageLoop::TYPE_IO;
|
||||
return io_thread->StartWithOptions(options);
|
||||
return g_io_thread->StartWithOptions(options);
|
||||
}
|
||||
|
||||
// static
|
||||
void BrowserResourceLoaderBridge::SetAcceptAllCookies(bool accept_all_cookies) {
|
||||
StaticCookiePolicy::Type policy_type = accept_all_cookies ?
|
||||
StaticCookiePolicy::ALLOW_ALL_COOKIES :
|
||||
StaticCookiePolicy::BLOCK_THIRD_PARTY_COOKIES;
|
||||
static_cast<StaticCookiePolicy*>(request_context->cookie_policy())->
|
||||
set_type(policy_type);
|
||||
if (g_request_context_params) {
|
||||
g_request_context_params->accept_all_cookies = accept_all_cookies;
|
||||
DCHECK(!g_request_context);
|
||||
DCHECK(!g_io_thread);
|
||||
} else {
|
||||
g_io_thread->SetAcceptAllCookies(accept_all_cookies);
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
scoped_refptr<base::MessageLoopProxy>
|
||||
BrowserResourceLoaderBridge::GetCacheThread() {
|
||||
return g_cache_thread->message_loop_proxy();
|
||||
}
|
||||
|
Reference in New Issue
Block a user