Update to Chromium revision 61327.

- Enable accelerated 2D canvas and compositing.
- Add support for request.download_to_file behavior.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@108 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2010-10-03 20:35:06 +00:00
parent 4fd793f802
commit 5fc6307a6f
14 changed files with 353 additions and 13 deletions

View File

@ -53,3 +53,4 @@ Date | CEF Revision | Chromium Revision
2010-06-21 | /trunk@82 | /trunk@50325
2010-08-09 | /trunk@93 | /trunk@55388
2010-09-12 | /trunk@102 | /trunk@59193
2010-10-03 | /trunk@108 | /trunk@61327

View File

@ -153,6 +153,7 @@
'../webkit/support/webkit_support.gyp:appcache',
'../webkit/support/webkit_support.gyp:blob',
'../webkit/support/webkit_support.gyp:database',
'../webkit/support/webkit_support.gyp:fileapi',
'../webkit/support/webkit_support.gyp:glue',
'../webkit/support/webkit_support.gyp:webkit_resources',
'../webkit/support/webkit_support.gyp:webkit_strings',
@ -327,6 +328,7 @@
'../webkit/support/webkit_support.gyp:appcache',
'../webkit/support/webkit_support.gyp:blob',
'../webkit/support/webkit_support.gyp:database',
'../webkit/support/webkit_support.gyp:fileapi',
'../webkit/support/webkit_support.gyp:glue',
'../webkit/support/webkit_support.gyp:webkit_resources',
'../webkit/support/webkit_support.gyp:webkit_strings',
@ -350,6 +352,8 @@
'libcef/browser_drag_delegate.h',
'libcef/browser_drop_delegate.cc',
'libcef/browser_drop_delegate.h',
'libcef/browser_file_system.cc',
'libcef/browser_file_system.h',
'libcef/browser_impl.cc',
'libcef/browser_impl.h',
'libcef/browser_impl_win.cc',

View File

@ -0,0 +1,195 @@
// Copyright (c) 2010 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.
#include "browser_file_system.h"
#include "base/file_path.h"
#include "base/message_loop_proxy.h"
#include "base/time.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFileInfo.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFileSystemEntry.h"
#include "third_party/WebKit/WebKit/chromium/public/WebVector.h"
#include "webkit/fileapi/file_system_callback_dispatcher.h"
#include "webkit/glue/webkit_glue.h"
using WebKit::WebFileInfo;
using WebKit::WebFileSystemCallbacks;
using WebKit::WebFileSystemEntry;
using WebKit::WebString;
using WebKit::WebVector;
namespace {
WebKit::WebFileError PlatformFileErrorToWebFileError(
base::PlatformFileError error_code) {
switch (error_code) {
case base::PLATFORM_FILE_ERROR_NOT_FOUND:
return WebKit::WebFileErrorNotFound;
case base::PLATFORM_FILE_ERROR_INVALID_OPERATION:
case base::PLATFORM_FILE_ERROR_EXISTS:
case base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY:
return WebKit::WebFileErrorInvalidModification;
case base::PLATFORM_FILE_ERROR_ACCESS_DENIED:
return WebKit::WebFileErrorNoModificationAllowed;
case base::PLATFORM_FILE_ERROR_FAILED:
return WebKit::WebFileErrorInvalidState;
case base::PLATFORM_FILE_ERROR_ABORT:
return WebKit::WebFileErrorAbort;
default:
return WebKit::WebFileErrorInvalidModification;
}
}
class TestShellFileSystemCallbackDispatcher
: public fileapi::FileSystemCallbackDispatcher {
public:
TestShellFileSystemCallbackDispatcher(
BrowserFileSystem* file_system,
WebFileSystemCallbacks* callbacks)
: file_system_(file_system),
callbacks_(callbacks),
request_id_(-1) {
}
void set_request_id(int request_id) { request_id_ = request_id; }
virtual void DidSucceed() {
callbacks_->didSucceed();
file_system_->RemoveCompletedOperation(request_id_);
}
virtual void DidReadMetadata(const base::PlatformFileInfo& info) {
WebFileInfo web_file_info;
web_file_info.modificationTime = info.last_modified.ToDoubleT();
callbacks_->didReadMetadata(web_file_info);
file_system_->RemoveCompletedOperation(request_id_);
}
virtual void DidReadDirectory(
const std::vector<base::file_util_proxy::Entry>& entries,
bool has_more) {
std::vector<WebFileSystemEntry> web_entries_vector;
for (std::vector<base::file_util_proxy::Entry>::const_iterator it =
entries.begin(); it != entries.end(); ++it) {
WebFileSystemEntry entry;
entry.name = webkit_glue::FilePathStringToWebString(it->name);
entry.isDirectory = it->is_directory;
web_entries_vector.push_back(entry);
}
WebVector<WebKit::WebFileSystemEntry> web_entries =
web_entries_vector;
callbacks_->didReadDirectory(web_entries, has_more);
file_system_->RemoveCompletedOperation(request_id_);
}
virtual void DidOpenFileSystem(const std::string&, const FilePath&) {
NOTREACHED();
}
virtual void DidFail(base::PlatformFileError error_code) {
callbacks_->didFail(PlatformFileErrorToWebFileError(error_code));
file_system_->RemoveCompletedOperation(request_id_);
}
virtual void DidWrite(int64, bool, fileapi::FileSystemOperation*) {
NOTREACHED();
}
private:
BrowserFileSystem* file_system_;
WebFileSystemCallbacks* callbacks_;
int request_id_;
};
} // namespace
BrowserFileSystem::~BrowserFileSystem() {
// Drop all the operations.
for (OperationsMap::const_iterator iter(&operations_);
!iter.IsAtEnd(); iter.Advance())
operations_.Remove(iter.GetCurrentKey());
}
void BrowserFileSystem::move(
const WebString& src_path,
const WebString& dest_path, WebFileSystemCallbacks* callbacks) {
FilePath dest_filepath(webkit_glue::WebStringToFilePath(dest_path));
FilePath src_filepath(webkit_glue::WebStringToFilePath(src_path));
GetNewOperation(callbacks)->Move(src_filepath, dest_filepath);
}
void BrowserFileSystem::copy(
const WebString& src_path, const WebString& dest_path,
WebFileSystemCallbacks* callbacks) {
FilePath dest_filepath(webkit_glue::WebStringToFilePath(dest_path));
FilePath src_filepath(webkit_glue::WebStringToFilePath(src_path));
GetNewOperation(callbacks)->Copy(src_filepath, dest_filepath);
}
void BrowserFileSystem::remove(
const WebString& path, WebFileSystemCallbacks* callbacks) {
FilePath filepath(webkit_glue::WebStringToFilePath(path));
GetNewOperation(callbacks)->Remove(filepath);
}
void BrowserFileSystem::readMetadata(
const WebString& path, WebFileSystemCallbacks* callbacks) {
FilePath filepath(webkit_glue::WebStringToFilePath(path));
GetNewOperation(callbacks)->GetMetadata(filepath);
}
void BrowserFileSystem::createFile(
const WebString& path, bool exclusive, WebFileSystemCallbacks* callbacks) {
FilePath filepath(webkit_glue::WebStringToFilePath(path));
GetNewOperation(callbacks)->CreateFile(filepath, exclusive);
}
void BrowserFileSystem::createDirectory(
const WebString& path, bool exclusive, WebFileSystemCallbacks* callbacks) {
FilePath filepath(webkit_glue::WebStringToFilePath(path));
GetNewOperation(callbacks)->CreateDirectory(filepath, exclusive, false);
}
void BrowserFileSystem::fileExists(
const WebString& path, WebFileSystemCallbacks* callbacks) {
FilePath filepath(webkit_glue::WebStringToFilePath(path));
GetNewOperation(callbacks)->FileExists(filepath);
}
void BrowserFileSystem::directoryExists(
const WebString& path, WebFileSystemCallbacks* callbacks) {
FilePath filepath(webkit_glue::WebStringToFilePath(path));
GetNewOperation(callbacks)->DirectoryExists(filepath);
}
void BrowserFileSystem::readDirectory(
const WebString& path, WebFileSystemCallbacks* callbacks) {
FilePath filepath(webkit_glue::WebStringToFilePath(path));
GetNewOperation(callbacks)->ReadDirectory(filepath);
}
fileapi::FileSystemOperation* BrowserFileSystem::GetNewOperation(
WebFileSystemCallbacks* callbacks) {
// This pointer will be owned by |operation|.
TestShellFileSystemCallbackDispatcher* dispatcher =
new TestShellFileSystemCallbackDispatcher(this, callbacks);
fileapi::FileSystemOperation* operation = new fileapi::FileSystemOperation(
dispatcher, base::MessageLoopProxy::CreateForCurrentThread());
int32 request_id = operations_.Add(operation);
dispatcher->set_request_id(request_id);
return operation;
}
void BrowserFileSystem::RemoveCompletedOperation(int request_id) {
operations_.Remove(request_id);
}

View File

@ -0,0 +1,58 @@
// Copyright (c) 2010 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.
#ifndef BROWSER_FILE_SYSTEM_H_
#define BROWSER_FILE_SYSTEM_H_
#include <vector>
#include "base/file_util_proxy.h"
#include "base/id_map.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFileSystem.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFileSystemCallbacks.h"
#include "webkit/fileapi/file_system_operation.h"
class BrowserFileSystem : public WebKit::WebFileSystem {
public:
BrowserFileSystem() {}
virtual ~BrowserFileSystem();
void RemoveCompletedOperation(int request_id);
// WebKit::WebFileSystem methods.
virtual void move(const WebKit::WebString& src_path,
const WebKit::WebString& dest_path,
WebKit::WebFileSystemCallbacks* callbacks);
virtual void copy(const WebKit::WebString& src_path,
const WebKit::WebString& dest_path,
WebKit::WebFileSystemCallbacks* callbacks);
virtual void remove(const WebKit::WebString& path,
WebKit::WebFileSystemCallbacks* callbacks);
virtual void readMetadata(const WebKit::WebString& path,
WebKit::WebFileSystemCallbacks* callbacks);
virtual void createFile(const WebKit::WebString& path,
bool exclusive,
WebKit::WebFileSystemCallbacks* callbacks);
virtual void createDirectory(const WebKit::WebString& path,
bool exclusive,
WebKit::WebFileSystemCallbacks* callbacks);
virtual void fileExists(const WebKit::WebString& path,
WebKit::WebFileSystemCallbacks* callbacks);
virtual void directoryExists(const WebKit::WebString& path,
WebKit::WebFileSystemCallbacks* callbacks);
virtual void readDirectory(const WebKit::WebString& path,
WebKit::WebFileSystemCallbacks* callbacks);
private:
// Helpers.
fileapi::FileSystemOperation* GetNewOperation(
WebKit::WebFileSystemCallbacks* callbacks);
// Keeps ongoing file system operations.
typedef IDMap<fileapi::FileSystemOperation, IDMapOwnPointer> OperationsMap;
OperationsMap operations_;
DISALLOW_COPY_AND_ASSIGN(BrowserFileSystem);
};
#endif // BROWSER_FILE_SYSTEM_H_

View File

@ -53,7 +53,8 @@ void BrowserRequestContext::Init(
false, NULL, NULL, NULL, NULL);
ssl_config_service_ = net::SSLConfigService::CreateSystemSSLConfigService();
http_auth_handler_factory_ = net::HttpAuthHandlerFactory::CreateDefault();
http_auth_handler_factory_ =
net::HttpAuthHandlerFactory::CreateDefault(host_resolver_);
net::HttpCache::DefaultBackend* backend = new net::HttpCache::DefaultBackend(
cache_path.empty() ? net::MEMORY_CACHE : net::DISK_CACHE,
@ -76,6 +77,7 @@ BrowserRequestContext::~BrowserRequestContext() {
delete http_transaction_factory_;
delete http_auth_handler_factory_;
delete static_cast<net::StaticCookiePolicy*>(cookie_policy_);
delete host_resolver_;
}
void BrowserRequestContext::SetAcceptAllCookies(bool accept_all_cookies) {

View File

@ -42,7 +42,9 @@
#include "request_impl.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/message_loop.h"
#include "base/message_loop_proxy.h"
#if defined(OS_MACOSX) || defined(OS_WIN)
#include "base/nss_util.h"
#endif
@ -53,6 +55,7 @@
#include "base/utf_string_conversions.h"
#include "base/waitable_event.h"
#include "net/base/cookie_store.h"
#include "net/base/file_stream.h"
#include "net/base/io_buffer.h"
#include "net/base/load_flags.h"
#include "net/base/net_errors.h"
@ -69,11 +72,13 @@
#include "net/url_request/url_request.h"
#include "webkit/appcache/appcache_interfaces.h"
#include "webkit/blob/blob_storage_controller.h"
#include "webkit/blob/deletable_file_reference.h"
#include "webkit/glue/resource_loader_bridge.h"
using webkit_glue::ResourceLoaderBridge;
using net::HttpResponseHeaders;
using net::StaticCookiePolicy;
using webkit_blob::DeletableFileReference;
using webkit_glue::ResourceLoaderBridge;
namespace {
@ -87,6 +92,7 @@ struct RequestParams {
int load_flags;
ResourceType::Type request_type;
int appcache_host_id;
bool download_to_file;
scoped_refptr<net::UploadData> upload;
};
@ -102,6 +108,7 @@ class RequestProxy : public URLRequest::Delegate,
// Takes ownership of the params.
RequestProxy(CefRefPtr<CefBrowser> browser)
: browser_(browser),
download_to_file_(false),
buf_(new net::IOBuffer(kDataSize)),
last_upload_position_(0)
{
@ -181,10 +188,22 @@ class RequestProxy : public URLRequest::Delegate,
peer_->OnReceivedData(buf_copy.get(), bytes_read);
}
void NotifyDownloadedData(int bytes_read) {
if (!peer_)
return;
// Continue reading more data, see the comment in NotifyReceivedData.
CefThread::PostTask(CefThread::IO, FROM_HERE, NewRunnableMethod(
this, &RequestProxy::AsyncReadData));
peer_->OnDownloadedData(bytes_read);
}
void NotifyCompletedRequest(const URLRequestStatus& status,
const std::string& security_info) {
const std::string& security_info,
const base::Time& complete_time) {
if (peer_) {
peer_->OnCompletedRequest(status, security_info);
peer_->OnCompletedRequest(status, security_info, complete_time);
DropPeer(); // ensure no further notifications
}
}
@ -271,7 +290,7 @@ class RequestProxy : public URLRequest::Delegate,
handled = true;
OnCompletedRequest(
URLRequestStatus(URLRequestStatus::CANCELED, net::ERR_ABORTED),
std::string());
std::string(), base::Time());
} else if(!redirectUrl.empty()) {
// redirect to the specified URL
params->url = GURL(WideToUTF8(redirectUrl));
@ -319,6 +338,17 @@ class RequestProxy : public URLRequest::Delegate,
BrowserAppCacheSystem::SetExtraRequestInfo(
request_.get(), params->appcache_host_id, params->request_type);
download_to_file_ = params->download_to_file;
if (download_to_file_) {
FilePath path;
if (file_util::CreateTemporaryFile(&path)) {
downloaded_file_ = DeletableFileReference::GetOrCreate(
path, base::MessageLoopProxy::CreateForCurrentThread());
file_stream_.Open(
path, base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE);
}
}
request_->Start();
if (request_->has_upload() &&
@ -403,14 +433,26 @@ class RequestProxy : public URLRequest::Delegate,
}
virtual void OnReceivedData(int bytes_read) {
if (download_to_file_) {
file_stream_.Write(buf_->data(), bytes_read, NULL);
owner_loop_->PostTask(FROM_HERE, NewRunnableMethod(
this, &RequestProxy::NotifyDownloadedData, bytes_read));
return;
}
owner_loop_->PostTask(FROM_HERE, NewRunnableMethod(
this, &RequestProxy::NotifyReceivedData, bytes_read));
}
virtual void OnCompletedRequest(const URLRequestStatus& status,
const std::string& security_info) {
const std::string& security_info,
const base::Time& complete_time) {
if (download_to_file_)
file_stream_.Close();
owner_loop_->PostTask(FROM_HERE, NewRunnableMethod(
this, &RequestProxy::NotifyCompletedRequest, status, security_info));
this, &RequestProxy::NotifyCompletedRequest, status, security_info,
complete_time));
}
// --------------------------------------------------------------------------
@ -458,7 +500,7 @@ class RequestProxy : public URLRequest::Delegate,
if(resource_stream_.get()) {
// Resource stream reads always complete successfully
OnCompletedRequest(URLRequestStatus(URLRequestStatus::SUCCESS, 0),
std::string());
std::string(), base::Time());
resource_stream_ = NULL;
} else if(request_.get()) {
if (upload_progress_timer_.IsRunning()) {
@ -466,7 +508,7 @@ class RequestProxy : public URLRequest::Delegate,
upload_progress_timer_.Stop();
}
DCHECK(request_.get());
OnCompletedRequest(request_->status(), std::string());
OnCompletedRequest(request_->status(), std::string(), base::Time());
request_.reset(); // destroy on the io thread
}
}
@ -514,6 +556,8 @@ class RequestProxy : public URLRequest::Delegate,
request->GetMimeType(&info->mime_type);
request->GetCharset(&info->charset);
info->content_length = request->GetExpectedContentSize();
if (downloaded_file_)
info->download_file_path = downloaded_file_->path();
BrowserAppCacheSystem::GetExtraResponseInfo(
request,
&info->appcache_id,
@ -523,6 +567,11 @@ class RequestProxy : public URLRequest::Delegate,
scoped_ptr<URLRequest> request_;
CefRefPtr<CefStreamReader> resource_stream_;
// Support for request.download_to_file behavior.
bool download_to_file_;
net::FileStream file_stream_;
scoped_refptr<DeletableFileReference> downloaded_file_;
// Size of our async IO data buffers
static const int kDataSize = 16*1024;
@ -585,12 +634,19 @@ class SyncRequestProxy : public RequestProxy {
}
virtual void OnReceivedData(int bytes_read) {
result_->data.append(buf_->data(), bytes_read);
if (download_to_file_)
file_stream_.Write(buf_->data(), bytes_read, NULL);
else
result_->data.append(buf_->data(), bytes_read);
AsyncReadData(); // read more (may recurse)
}
virtual void OnCompletedRequest(const URLRequestStatus& status,
const std::string& security_info) {
const std::string& security_info,
const base::Time& complete_time) {
if (download_to_file_)
file_stream_.Close();
result_->status = status;
event_.Signal();
}
@ -617,6 +673,7 @@ class ResourceLoaderBridgeImpl : public ResourceLoaderBridge {
params_->load_flags = request_info.load_flags;
params_->request_type = request_info.request_type;
params_->appcache_host_id = request_info.appcache_host_id;
params_->download_to_file = request_info.download_to_file;
}
virtual ~ResourceLoaderBridgeImpl() {

View File

@ -7,7 +7,6 @@
#include "base/message_loop.h"
#include "googleurl/src/gurl.h"
#include "third_party/WebKit/WebKit/chromium/public/WebBlobData.h"
#include "third_party/WebKit/WebKit/chromium/public/WebBlobStorageData.h"
#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
#include "third_party/WebKit/WebKit/chromium/public/WebURL.h"
#include "webkit/blob/blob_data.h"

View File

@ -36,6 +36,7 @@
#include "webkit/glue/webkitclient_impl.h"
#include "browser_appcache_system.h"
#include "browser_database_system.h"
#include "browser_file_system.h"
#include "browser_resource_loader_bridge.h"
#include "browser_webblobregistry_impl.h"
#include "browser_webcookiejar_impl.h"
@ -118,6 +119,10 @@ class BrowserWebKitInit : public webkit_glue::WebKitClientImpl {
return &cookie_jar_;
}
virtual WebKit::WebFileSystem* fileSystem() {
return &file_system_;
}
virtual bool sandboxEnabled() {
return true;
}
@ -216,6 +221,7 @@ class BrowserWebKitInit : public webkit_glue::WebKitClientImpl {
BrowserDatabaseSystem database_system_;
BrowserWebCookieJarImpl cookie_jar_;
scoped_refptr<BrowserWebBlobRegistryImpl> blob_registry_;
BrowserFileSystem file_system_;
};
#endif // _BROWSER_WEBKIT_INIT_H

View File

@ -485,6 +485,11 @@ void BrowserWebViewDelegate::didScrollRect(int dx, int dy,
host->DidScrollRect(dx, dy, clip_rect);
}
void BrowserWebViewDelegate::scheduleComposite() {
if (WebWidgetHost* host = GetWidgetHost())
host->ScheduleComposite();
}
void BrowserWebViewDelegate::didFocus() {
if (WebWidgetHost* host = GetWidgetHost()) {
CefRefPtr<CefHandler> handler = browser_->GetHandler();

View File

@ -113,6 +113,7 @@ class BrowserWebViewDelegate : public WebKit::WebViewClient,
virtual void didInvalidateRect(const WebKit::WebRect& rect);
virtual void didScrollRect(int dx, int dy,
const WebKit::WebRect& clip_rect);
virtual void scheduleComposite();
virtual void didFocus();
virtual void didBlur();
virtual void didChangeCursor(const WebKit::WebCursorInfo& cursor);

View File

@ -225,6 +225,8 @@ bool CefContext::Initialize(bool multi_threaded_message_loop,
webprefs_->application_cache_enabled = true;
webprefs_->databases_enabled = true;
webprefs_->allow_file_access_from_file_urls = true;
webprefs_->accelerated_2d_canvas_enabled = true;
webprefs_->accelerated_compositing_enabled = true;
#if defined(OS_MACOSX) || defined(OS_WIN)
// We want to be sure to init NSPR on the main thread.

View File

@ -179,6 +179,15 @@ void WebWidgetHost::DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect) {
InvalidateRect(view_, &r, FALSE);
}
void WebWidgetHost::ScheduleComposite() {
if (!webwidget_)
return;
WebSize size = webwidget_->size();
gfx::Rect rect(0, 0, size.width, size.height);
RECT r = rect.ToRECT();
InvalidateRect(view_, &r, FALSE);
}
void WebWidgetHost::SetCursor(HCURSOR cursor) {
SetClassLong(view_, GCL_HCURSOR,
static_cast<LONG>(reinterpret_cast<LONG_PTR>(cursor)));

View File

@ -41,6 +41,7 @@ class WebWidgetHost {
void DidInvalidateRect(const gfx::Rect& rect);
void DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect);
void ScheduleComposite();
#if defined(OS_WIN)
void SetCursor(HCURSOR cursor);
#endif

View File

@ -21,7 +21,7 @@
#include "ctocpp/task_ctocpp.h"
#include "ctocpp/v8handler_ctocpp.h"
#include "ctocpp/write_handler_ctocpp.h"
#include "base/string_util.h"
#include "base/string_split.h"
CEF_EXPORT int cef_initialize(int multi_threaded_message_loop,