libcef: Update due to underlying chromium changes.

- Database and AppCache changes.
- New cookie policy class.
- Add StdStringToWebString and WebStringToStdString to browser_webkit_glue.{h,cc} because webkit/glue/glue_util.{h,cc} have been deleted.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@71 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2010-02-11 18:33:33 +00:00
parent 606b342147
commit a46069c097
16 changed files with 96 additions and 41 deletions

View File

@ -48,3 +48,4 @@ Date | CEF Revision | Chromium Revision
2009-11-02 | /trunk@63 | /trunk@30778
2009-11-04 | /trunk@64 | /trunk@31062
2010-01-11 | /trunk@65 | /trunk@35902
2010-02-11 | /trunk@71 | /trunk@38776

View File

@ -280,16 +280,28 @@ BrowserAppCacheSystem::BrowserAppCacheSystem()
instance_ = this;
}
static void SignalEvent(base::WaitableEvent* event) {
event->Signal();
}
BrowserAppCacheSystem::~BrowserAppCacheSystem() {
DCHECK(!io_message_loop_ && !backend_impl_ && !service_);
frontend_proxy_->clear_appcache_system(); // in case a task is in transit
instance_ = NULL;
if (db_thread_.IsRunning()) {
// We pump a task thru the db thread to ensure any tasks previously
// scheduled on that thread have been performed prior to return.
base::WaitableEvent event(false, false);
db_thread_.message_loop()->PostTask(FROM_HERE,
NewRunnableFunction(&SignalEvent, &event));
event.Wait();
}
}
void BrowserAppCacheSystem::InitOnUIThread(
const FilePath& cache_directory) {
DCHECK(!ui_message_loop_);
DCHECK(!cache_directory.empty());
AppCacheThread::InitIDs(DB_THREAD_ID, IO_THREAD_ID);
ui_message_loop_ = MessageLoop::current();
cache_directory_ = cache_directory;

View File

@ -126,7 +126,7 @@ class BrowserAppCacheSystem : public MessageLoop::DestructionObserver {
return io_message_loop_ && is_initailized_on_ui_thread();
}
bool is_initailized_on_ui_thread() {
return ui_message_loop_ && !cache_directory_.empty();
return ui_message_loop_ ? true : false;
}
static MessageLoop* GetMessageLoop(int id) {
if (instance_) {

View File

@ -10,7 +10,9 @@
#include "third_party/sqlite/preprocessed/sqlite3.h"
#endif
#include "base/auto_reset.h"
#include "base/file_util.h"
#include "base/message_loop.h"
#include "base/platform_thread.h"
#include "base/process_util.h"
#include "third_party/WebKit/WebKit/chromium/public/WebDatabase.h"
@ -29,14 +31,17 @@ BrowserDatabaseSystem* BrowserDatabaseSystem::GetInstance() {
return instance_;
}
BrowserDatabaseSystem::BrowserDatabaseSystem() {
BrowserDatabaseSystem::BrowserDatabaseSystem()
: waiting_for_dbs_to_close_(false) {
temp_dir_.CreateUniqueTempDir();
db_tracker_ = new DatabaseTracker(temp_dir_.path());
db_tracker_->AddObserver(this);
DCHECK(!instance_);
instance_ = this;
}
BrowserDatabaseSystem::~BrowserDatabaseSystem() {
db_tracker_->RemoveObserver(this);
instance_ = NULL;
}
@ -113,6 +118,9 @@ void BrowserDatabaseSystem::DatabaseClosed(const string16& origin_identifier,
origin_identifier, database_name));
db_tracker_->DatabaseClosed(origin_identifier, database_name);
database_connections_.RemoveConnection(origin_identifier, database_name);
if (waiting_for_dbs_to_close_ && database_connections_.IsEmpty())
MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask());
}
void BrowserDatabaseSystem::OnDatabaseSizeChanged(
@ -144,13 +152,22 @@ void BrowserDatabaseSystem::databaseClosed(const WebKit::WebDatabase& database)
}
void BrowserDatabaseSystem::ClearAllDatabases() {
db_tracker_->CloseDatabases(database_connections_);
database_connections_.RemoveAllConnections();
// Wait for all databases to be closed.
if (!database_connections_.IsEmpty()) {
AutoReset waiting_for_dbs_auto_reset(&waiting_for_dbs_to_close_, true);
MessageLoop::ScopedNestableTaskAllower nestable(MessageLoop::current());
MessageLoop::current()->Run();
}
db_tracker_->CloseTrackerDatabaseAndClearCaches();
file_util::Delete(db_tracker_->DatabaseDirectory(), true);
file_names_.clear();
}
void BrowserDatabaseSystem::SetDatabaseQuota(int64 quota) {
db_tracker_->SetDefaultQuota(quota);
}
void BrowserDatabaseSystem::SetFullFilePathsForVfsFile(
const string16& origin_identifier,
const string16& database_name) {

View File

@ -53,6 +53,7 @@ class BrowserDatabaseSystem : public webkit_database::DatabaseTracker::Observer,
virtual void databaseClosed(const WebKit::WebDatabase& database);
void ClearAllDatabases();
void SetDatabaseQuota(int64 quota);
private:
// The calls that come from the database tracker run on the main thread.
@ -68,6 +69,8 @@ class BrowserDatabaseSystem : public webkit_database::DatabaseTracker::Observer,
static BrowserDatabaseSystem* instance_;
bool waiting_for_dbs_to_close_;
ScopedTempDir temp_dir_;
scoped_refptr<webkit_database::DatabaseTracker> db_tracker_;

View File

@ -5,6 +5,7 @@
#include "context.h"
#include "browser_impl.h"
#include "browser_webkit_glue.h"
#include "request_impl.h"
#include "base/string_util.h"
@ -16,7 +17,6 @@
#include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h"
#include "third_party/WebKit/WebKit/chromium/public/WebView.h"
#include "webkit/glue/glue_serialize.h"
#include "webkit/glue/glue_util.h"
using WebKit::WebFrame;
using WebKit::WebHTTPBody;

View File

@ -11,6 +11,7 @@
#include "net/base/cookie_monster.h"
#include "net/base/host_resolver.h"
#include "net/base/ssl_config_service.h"
#include "net/base/static_cookie_policy.h"
#include "net/ftp/ftp_network_layer.h"
#include "net/proxy/proxy_config_service.h"
#include "net/proxy/proxy_config_service_fixed.h"
@ -32,7 +33,8 @@ void BrowserRequestContext::Init(
const FilePath& cache_path,
net::HttpCache::Mode cache_mode,
bool no_proxy) {
cookie_store_ = new net::CookieMonster();
cookie_store_ = new net::CookieMonster(NULL);
cookie_policy_ = new net::StaticCookiePolicy();
// hard-code A-L and A-C for test shells
accept_language_ = "en-us,en";
@ -41,17 +43,17 @@ void BrowserRequestContext::Init(
// Use the system proxy settings.
scoped_ptr<net::ProxyConfigService> proxy_config_service(
net::ProxyService::CreateSystemProxyConfigService(NULL, NULL));
host_resolver_ = net::CreateSystemHostResolver();
host_resolver_ = net::CreateSystemHostResolver(NULL);
proxy_service_ = net::ProxyService::Create(proxy_config_service.release(),
false, NULL, NULL, NULL);
ssl_config_service_ = net::SSLConfigService::CreateSystemSSLConfigService();
net::HttpCache *cache;
if (cache_path.empty()) {
cache = new net::HttpCache(host_resolver_, proxy_service_,
cache = new net::HttpCache(NULL, host_resolver_, proxy_service_,
ssl_config_service_, 0);
} else {
cache = new net::HttpCache(host_resolver_, proxy_service_,
cache = new net::HttpCache(NULL, host_resolver_, proxy_service_,
ssl_config_service_, cache_path, 0);
}
cache->set_mode(cache_mode);
@ -63,6 +65,7 @@ void BrowserRequestContext::Init(
BrowserRequestContext::~BrowserRequestContext() {
delete ftp_transaction_factory_;
delete http_transaction_factory_;
delete static_cast<net::StaticCookiePolicy*>(cookie_policy_);
}
const std::string& BrowserRequestContext::GetUserAgent(

View File

@ -50,6 +50,7 @@
#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_response_headers.h"
#include "net/http/http_util.h"
@ -61,8 +62,8 @@
#include "webkit/glue/resource_loader_bridge.h"
using webkit_glue::ResourceLoaderBridge;
using net::CookiePolicy;
using net::HttpResponseHeaders;
using net::StaticCookiePolicy;
namespace {
@ -762,7 +763,7 @@ bool FindProxyForUrl(const GURL& url, std::string* proxy_list) {
//-----------------------------------------------------------------------------
// static
void BrowserResourceLoaderBridge::Init(URLRequestContext* context) {
void BrowserResourceLoaderBridge::Init(BrowserRequestContext* context) {
// Make sure to stop any existing IO thread since it may be using the
// current request context.
Shutdown();
@ -836,7 +837,9 @@ bool BrowserResourceLoaderBridge::EnsureIOThread() {
// static
void BrowserResourceLoaderBridge::SetAcceptAllCookies(bool accept_all_cookies) {
CookiePolicy::Type policy_type = accept_all_cookies ?
CookiePolicy::ALLOW_ALL_COOKIES : CookiePolicy::BLOCK_THIRD_PARTY_COOKIES;
request_context->cookie_policy()->set_type(policy_type);
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);
}

View File

@ -9,7 +9,7 @@
#include <string>
class GURL;
class URLRequestContext;
class BrowserRequestContext;
class BrowserResourceLoaderBridge {
public:
@ -23,7 +23,7 @@ class BrowserResourceLoaderBridge {
// NOTE: If this function is not called, then a default request context will
// be initialized lazily.
//
static void Init(URLRequestContext* context);
static void Init(BrowserRequestContext* context);
// Call this function to shutdown the simple resource loader bridge.
static void Shutdown();

View File

@ -20,10 +20,11 @@ MSVC_POP_WARNING();
#include "base/resource_util.h"
#include "base/scoped_ptr.h"
#include "base/string16.h"
#include "base/string_util.h"
#include "base/win_util.h"
#include "net/base/mime_util.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
#include "webkit/glue/glue_util.h"
#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
#include "webkit/glue/webkit_glue.h"
// Generated by GRIT
@ -204,4 +205,15 @@ void ClearCache()
WebCore::cache()->setDisabled(false);
}
WebKit::WebString StdStringToWebString(const std::string& str) {
return WebKit::WebString::fromUTF8(str.data(), str.size());
}
std::string WebStringToStdString(const WebKit::WebString& str) {
std::string ret;
if (!str.isNull())
UTF16ToUTF8(str.data(), str.length(), &ret);
return ret;
}
} // namespace webkit_glue

View File

@ -12,6 +12,7 @@
namespace WebKit {
class WebFrame;
class WebString;
class WebView;
}
@ -38,4 +39,8 @@ v8::Handle<v8::Context> GetV8Context(WebKit::WebFrame* frame);
// Clear all cached data.
void ClearCache();
WebKit::WebString StdStringToWebString(const std::string& str);
std::string WebStringToStdString(const WebKit::WebString& str);
} // namespace webkit_glue

View File

@ -61,8 +61,13 @@ class BrowserWebKitInit : public webkit_glue::WebKitClientImpl {
// Construct and initialize an appcache system for this scope.
// A new empty temp directory is created to house any cached
// content during the run. Upon exit that directory is deleted.
if (appcache_dir_.CreateUniqueTempDir())
BrowserAppCacheSystem::InitializeOnUIThread(appcache_dir_.path());
// If we can't create a tempdir, we'll use in-memory storage.
if (!appcache_dir_.CreateUniqueTempDir()) {
LOG(WARNING) << "Failed to create a temp dir for the appcache, "
"using in-memory storage.";
DCHECK(appcache_dir_.path().empty());
}
BrowserAppCacheSystem::InitializeOnUIThread(appcache_dir_.path());
WebKit::WebDatabase::setObserver(&database_system_);
}
@ -177,24 +182,11 @@ class BrowserWebKitInit : public webkit_glue::WebKitClientImpl {
quota);
}
virtual WebKit::WebStorageNamespace* createSessionStorageNamespace() {
return WebKit::WebStorageNamespace::createSessionStorageNamespace();
}
void dispatchStorageEvent(const WebKit::WebString& key,
const WebKit::WebString& old_value, const WebKit::WebString& new_value,
const WebKit::WebString& origin, const WebKit::WebURL& url,
bool is_local_storage) {
// TODO(jorlow): Implement
if (!is_local_storage)
return;
if (!dom_storage_event_dispatcher_.get()) {
dom_storage_event_dispatcher_.reset(
WebKit::WebStorageEventDispatcher::create());
}
dom_storage_event_dispatcher_->dispatchStorageEvent(
key, old_value, new_value, origin, url, is_local_storage);
// The event is dispatched by the proxy.
}
virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost(
@ -212,7 +204,6 @@ class BrowserWebKitInit : public webkit_glue::WebKitClientImpl {
ScopedTempDir appcache_dir_;
BrowserAppCacheSystem appcache_system_;
BrowserDatabaseSystem database_system_;
scoped_ptr<WebKit::WebStorageEventDispatcher> dom_storage_event_dispatcher_;
};
#endif // _BROWSER_WEBKIT_INIT_H

View File

@ -37,6 +37,7 @@
#include "third_party/WebKit/WebKit/chromium/public/WebPopupMenu.h"
#include "third_party/WebKit/WebKit/chromium/public/WebRange.h"
#include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h"
#include "third_party/WebKit/WebKit/chromium/public/WebStorageNamespace.h"
#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
#include "third_party/WebKit/WebKit/chromium/public/WebURL.h"
#include "third_party/WebKit/WebKit/chromium/public/WebURLError.h"
@ -44,9 +45,8 @@
#include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h"
#include "third_party/WebKit/WebKit/chromium/public/WebVector.h"
#include "third_party/WebKit/WebKit/chromium/public/WebView.h"
#include "webkit/appcache/appcache_interfaces.h"
#include "webkit/appcache/web_application_cache_host_impl.h"
#include "webkit/glue/glue_serialize.h"
#include "webkit/glue/glue_util.h"
#include "webkit/glue/media/buffered_data_source.h"
#include "webkit/glue/media/media_resource_loader_bridge_factory.h"
#include "webkit/glue/media/simple_data_source.h"
@ -66,6 +66,7 @@
#include "browser_drop_delegate.h"
#endif
using appcache::WebApplicationCacheHostImpl;
using WebKit::WebConsoleMessage;
using WebKit::WebContextMenuData;
using WebKit::WebData;
@ -90,6 +91,7 @@ using WebKit::WebRect;
using WebKit::WebScreenInfo;
using WebKit::WebSecurityOrigin;
using WebKit::WebSize;
using WebKit::WebStorageNamespace;
using WebKit::WebString;
using WebKit::WebTextAffinity;
using WebKit::WebTextDirection;
@ -139,6 +141,10 @@ WebWidget* BrowserWebViewDelegate::createPopupMenu(
return browser_->UIT_CreatePopupWidget();
}
WebStorageNamespace* BrowserWebViewDelegate::createSessionStorageNamespace() {
return WebKit::WebStorageNamespace::createSessionStorageNamespace();
}
void BrowserWebViewDelegate::didAddMessageToConsole(
const WebConsoleMessage& message, const WebString& source_name,
unsigned source_line) {
@ -452,6 +458,9 @@ WebMediaPlayer* BrowserWebViewDelegate::createMediaPlayer(
scoped_refptr<media::FilterFactoryCollection> factory =
new media::FilterFactoryCollection();
WebApplicationCacheHostImpl* appcache_host =
WebApplicationCacheHostImpl::FromFrame(frame);
// TODO(hclam): this is the same piece of code as in RenderView, maybe they
// should be grouped together.
webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory =
@ -460,7 +469,7 @@ WebMediaPlayer* BrowserWebViewDelegate::createMediaPlayer(
"null", // frame origin
"null", // main_frame_origin
base::GetCurrentProcId(),
appcache::kNoHostId,
appcache_host ? appcache_host->host_id() : appcache::kNoHostId,
0);
// A simple data source that keeps all data in memory.
media::FilterFactory* simple_data_source_factory =

View File

@ -49,6 +49,7 @@ class BrowserWebViewDelegate : public WebKit::WebViewClient,
virtual WebKit::WebWidget* createPopupMenu(bool activatable);
virtual WebKit::WebWidget* createPopupMenu(
const WebKit::WebPopupMenuInfo& info);
virtual WebKit::WebStorageNamespace* createSessionStorageNamespace();
virtual void didAddMessageToConsole(
const WebKit::WebConsoleMessage& message,
const WebKit::WebString& source_name, unsigned source_line);

View File

@ -3,6 +3,7 @@
// can be found in the LICENSE file.
#include "request_impl.h"
#include "browser_webkit_glue.h"
#include "base/logging.h"
#include "base/string_util.h"
@ -10,7 +11,6 @@
#include "net/http/http_util.h"
#include "net/url_request/url_request.h"
#include "third_party/WebKit/WebKit/chromium/public/WebHTTPHeaderVisitor.h"
#include "webkit/glue/glue_util.h"
using net::HttpResponseHeaders;

View File

@ -15,12 +15,10 @@
// Clipboard glue
#if defined(OS_WIN)
void ScopedClipboardWriterGlue::WriteBitmapFromPixels(
const void* pixels, const gfx::Size& size) {
ScopedClipboardWriter::WriteBitmapFromPixels(pixels, size);
}
#endif
ScopedClipboardWriterGlue::~ScopedClipboardWriterGlue() {
}