From 30ecc8a4db33ace6b32b67feb80b1411f88ab4be Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Wed, 29 Aug 2012 20:11:26 +0000 Subject: [PATCH] Update to Chromium revision 153668. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@750 5089003a-bbd8-11dd-ad1f-f1f9622dbc98 --- cef1/CHROMIUM_BUILD_COMPATIBILITY.txt | 2 +- cef1/libcef/browser_drag_delegate_win.cc | 75 +++++++++--------- cef1/libcef/browser_drag_delegate_win.h | 5 +- cef1/libcef/browser_file_system.cc | 69 +++++++++++------ cef1/libcef/browser_file_system.h | 19 +++-- cef1/libcef/browser_file_writer.cc | 10 +-- cef1/libcef/browser_network_delegate.cc | 4 +- cef1/libcef/browser_network_delegate.h | 4 +- cef1/libcef/browser_request_context.cc | 4 +- cef1/libcef/browser_resource_loader_bridge.cc | 76 +++++++------------ cef1/libcef/browser_webblobregistry_impl.cc | 45 ++++++++++- cef1/libcef/browser_webkit_glue.cc | 6 +- cef1/libcef/browser_webkit_init.cc | 21 ----- cef1/libcef/browser_webkit_init.h | 8 -- cef1/libcef/browser_webview_delegate.cc | 2 +- cef1/libcef/browser_webview_delegate.h | 2 +- cef1/libcef/request_impl.cc | 21 +++-- cef1/libcef/request_impl.h | 4 +- cef1/libcef/scheme_impl.cc | 24 +++--- cef1/libcef/v8_impl.cc | 29 ++++--- 20 files changed, 231 insertions(+), 199 deletions(-) diff --git a/cef1/CHROMIUM_BUILD_COMPATIBILITY.txt b/cef1/CHROMIUM_BUILD_COMPATIBILITY.txt index 9324c407a..1f6beaeef 100644 --- a/cef1/CHROMIUM_BUILD_COMPATIBILITY.txt +++ b/cef1/CHROMIUM_BUILD_COMPATIBILITY.txt @@ -17,5 +17,5 @@ { 'chromium_url': 'http://src.chromium.org/svn/trunk/src', - 'chromium_revision': '149431', + 'chromium_revision': '153668', } diff --git a/cef1/libcef/browser_drag_delegate_win.cc b/cef1/libcef/browser_drag_delegate_win.cc index dcadee97f..0b567fe8d 100644 --- a/cef1/libcef/browser_drag_delegate_win.cc +++ b/cef1/libcef/browser_drag_delegate_win.cc @@ -19,12 +19,15 @@ #include "libcef/web_drop_target_win.h" #include "base/bind.h" +#include "base/pickle.h" #include "base/utf_string_conversions.h" #include "net/base/file_stream.h" #include "net/base/net_util.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" +#include "ui/base/clipboard/clipboard_util_win.h" +#include "ui/base/clipboard/custom_data_helper.h" #include "ui/base/dragdrop/drag_utils.h" #include "ui/gfx/image/image_skia.h" #include "webkit/glue/webdropdata.h" @@ -101,8 +104,7 @@ class DragDropThread : public base::Thread { BrowserDragDelegate::BrowserDragDelegate(BrowserWebViewDelegate* view) : drag_drop_thread_id_(0), view_(view), - drag_ended_(false), - old_drop_target_suspended_state_(false) { + drag_ended_(false) { } BrowserDragDelegate::~BrowserDragDelegate() { @@ -130,14 +132,10 @@ void BrowserDragDelegate::StartDragging(const WebDropData& drop_data, DoDragging(drop_data, ops, page_url, page_encoding, image, image_offset); CefThread::PostTask( CefThread::UI, FROM_HERE, - base::Bind(&BrowserDragDelegate::EndDragging, this, false)); + base::Bind(&BrowserDragDelegate::EndDragging, this)); return; } - // We do not want to drag and drop the download to itself. - old_drop_target_suspended_state_ = view_->drop_target()->suspended(); - view_->drop_target()->set_suspended(true); - // Start a background thread to do the drag-and-drop. DCHECK(!drag_drop_thread_.get()); drag_drop_thread_.reset(new DragDropThread(this)); @@ -183,7 +181,7 @@ void BrowserDragDelegate::StartBackgroundDragging( DoDragging(drop_data, ops, page_url, page_encoding, image, image_offset); CefThread::PostTask( CefThread::UI, FROM_HERE, - base::Bind(&BrowserDragDelegate::EndDragging, this, true)); + base::Bind(&BrowserDragDelegate::EndDragging, this)); } void BrowserDragDelegate::PrepareDragForDownload( @@ -273,20 +271,26 @@ void BrowserDragDelegate::DoDragging(const WebDropData& drop_data, // Set the observer. ui::OSExchangeDataProviderWin::GetDataObjectImpl(data)->set_observer(this); - } else { - // We set the file contents before the URL because the URL also sets file - // contents (to a .URL shortcut). We want to prefer file content data over - // a shortcut so we add it first. - if (!drop_data.file_contents.empty()) - PrepareDragForFileContents(drop_data, &data); - if (!drop_data.html.is_null() && !drop_data.html.string().empty()) - data.SetHtml(drop_data.html.string(), drop_data.html_base_url); - // We set the text contents before the URL because the URL also sets text - // content. - if (!drop_data.text.is_null() && !drop_data.text.string().empty()) - data.SetString(drop_data.text.string()); - if (drop_data.url.is_valid()) - PrepareDragForUrl(drop_data, &data); + } + + // We set the file contents before the URL because the URL also sets file + // contents (to a .URL shortcut). We want to prefer file content data over + // a shortcut so we add it first. + if (!drop_data.file_contents.empty()) + PrepareDragForFileContents(drop_data, &data); + if (!drop_data.html.string().empty()) + data.SetHtml(drop_data.html.string(), drop_data.html_base_url); + // We set the text contents before the URL because the URL also sets text + // content. + if (!drop_data.text.string().empty()) + data.SetString(drop_data.text.string()); + if (drop_data.url.is_valid()) + PrepareDragForUrl(drop_data, &data); + if (!drop_data.custom_data.empty()) { + Pickle pickle; + ui::WriteCustomDataToPickle(drop_data.custom_data, &pickle); + data.SetPickledData(ui::ClipboardUtil::GetWebCustomDataFormat()->cfFormat, + pickle); } // Set drag image. @@ -298,28 +302,31 @@ void BrowserDragDelegate::DoDragging(const WebDropData& drop_data, // We need to enable recursive tasks on the message loop so we can get // updates while in the system DoDragDrop loop. - bool old_state = MessageLoop::current()->NestableTasksAllowed(); - MessageLoop::current()->SetNestableTasksAllowed(true); DWORD effect; - DoDragDrop(ui::OSExchangeDataProviderWin::GetIDataObject(data), drag_source_, - web_drag_utils_win::WebDragOpMaskToWinDragOpMask(ops), &effect); - MessageLoop::current()->SetNestableTasksAllowed(old_state); + { + MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); + DoDragDrop(ui::OSExchangeDataProviderWin::GetIDataObject(data), + drag_source_, + web_drag_utils_win::WebDragOpMaskToWinDragOpMask(ops), + &effect); + } - // This works because WebDragSource::OnDragSourceDrop uses PostTask to - // dispatch the actual event. + // Normally, the drop and dragend events get dispatched in the system + // DoDragDrop message loop so it'd be too late to set the effect to send back + // to the renderer here. However, we use PostTask to delay the execution of + // WebDragSource::OnDragSourceDrop, which means that the delayed dragend + // callback to the renderer doesn't run until this has been set to the correct + // value. drag_source_->set_effect(effect); } -void BrowserDragDelegate::EndDragging(bool restore_suspended_state) { +void BrowserDragDelegate::EndDragging() { DCHECK(CefThread::CurrentlyOn(CefThread::UI)); if (drag_ended_) return; drag_ended_ = true; - if (restore_suspended_state) - view_->drop_target()->set_suspended(old_drop_target_suspended_state_); - if (msg_hook) { AttachThreadInput(drag_out_thread_id, GetCurrentThreadId(), FALSE); UnhookWindowsHookEx(msg_hook); @@ -349,7 +356,7 @@ void BrowserDragDelegate::OnWaitForData() { // mode so that it can start to process the normal input events. CefThread::PostTask( CefThread::UI, FROM_HERE, - base::Bind(&BrowserDragDelegate::EndDragging, this, true)); + base::Bind(&BrowserDragDelegate::EndDragging, this)); } void BrowserDragDelegate::OnDataObjectDisposed() { diff --git a/cef1/libcef/browser_drag_delegate_win.h b/cef1/libcef/browser_drag_delegate_win.h index 25290d533..c2b104efa 100644 --- a/cef1/libcef/browser_drag_delegate_win.h +++ b/cef1/libcef/browser_drag_delegate_win.h @@ -71,7 +71,7 @@ class BrowserDragDelegate const SkBitmap& image, const gfx::Point& image_offset); // Called on UI thread. - void EndDragging(bool restore_suspended_state); + void EndDragging(); void CloseThread(); // For debug check only. Access only on drag-and-drop thread. @@ -94,9 +94,6 @@ class BrowserDragDelegate // The flag to guard that EndDragging is not called twice. bool drag_ended_; - // Keep track of the old suspended state of the drop target. - bool old_drop_target_suspended_state_; - DISALLOW_COPY_AND_ASSIGN(BrowserDragDelegate); }; diff --git a/cef1/libcef/browser_file_system.cc b/cef1/libcef/browser_file_system.cc index 9ac501d40..eeb64c70d 100644 --- a/cef1/libcef/browser_file_system.cc +++ b/cef1/libcef/browser_file_system.cc @@ -23,6 +23,7 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" #include "webkit/blob/blob_storage_controller.h" +#include "webkit/fileapi/file_system_task_runners.h" #include "webkit/fileapi/file_system_url.h" #include "webkit/fileapi/file_system_util.h" #include "webkit/fileapi/mock_file_system_options.h" @@ -44,9 +45,10 @@ using WebKit::WebVector; using webkit_blob::BlobData; using webkit_blob::BlobStorageController; -using fileapi::FileSystemURL; using fileapi::FileSystemContext; -using fileapi::FileSystemOperationInterface; +using fileapi::FileSystemOperation; +using fileapi::FileSystemTaskRunners; +using fileapi::FileSystemURL; namespace { MessageLoop* g_io_thread; @@ -64,7 +66,7 @@ void RegisterBlob(const GURL& blob_url, const FilePath& file_path) { net::GetWellKnownMimeTypeFromExtension(extension, &mime_type); BlobData::Item item; - item.SetToFile(file_path, 0, -1, base::Time()); + item.SetToFilePathRange(file_path, 0, -1, base::Time()); g_blob_storage_controller->StartBuildingBlob(blob_url); g_blob_storage_controller->AppendBlobDataItem(blob_url, item); g_blob_storage_controller->FinishBuildingBlob(blob_url, mime_type); @@ -83,8 +85,10 @@ void BrowserFileSystem::CreateContext() { additional_allowed_schemes.push_back("file"); file_system_context_ = new FileSystemContext( - CefThread::GetMessageLoopProxyForThread(CefThread::FILE), - CefThread::GetMessageLoopProxyForThread(CefThread::IO), + make_scoped_ptr(new FileSystemTaskRunners( + CefThread::GetMessageLoopProxyForThread(CefThread::IO), + CefThread::GetMessageLoopProxyForThread(CefThread::FILE), + CefThread::GetMessageLoopProxyForThread(CefThread::FILE))), NULL /* special storage policy */, NULL /* quota manager */, file_system_dir_.path(), @@ -101,7 +105,7 @@ BrowserFileSystem::~BrowserFileSystem() { } void BrowserFileSystem::OpenFileSystem( - WebFrame* frame, WebFileSystem::Type web_filesystem_type, + WebFrame* frame, WebFileSystem::Type type, long long, bool create, // NOLINT(runtime/int) WebFileSystemCallbacks* callbacks) { if (!frame || !file_system_context_.get()) { @@ -110,22 +114,24 @@ void BrowserFileSystem::OpenFileSystem( return; } - fileapi::FileSystemType type; - if (web_filesystem_type == WebFileSystem::TypeTemporary) - type = fileapi::kFileSystemTypeTemporary; - else if (web_filesystem_type == WebFileSystem::TypePersistent) - type = fileapi::kFileSystemTypePersistent; - else if (web_filesystem_type == WebFileSystem::TypeExternal) - type = fileapi::kFileSystemTypeExternal; - else { - // Unknown type filesystem is requested. + GURL origin_url(frame->document().securityOrigin().toString()); + file_system_context_->OpenFileSystem( + origin_url, static_cast(type), create, + OpenFileSystemHandler(callbacks)); +} + +void BrowserFileSystem::DeleteFileSystem( + WebFrame* frame, WebFileSystem::Type type, + WebFileSystemCallbacks* callbacks) { + if (!frame || !file_system_context_.get()) { callbacks->didFail(WebKit::WebFileErrorSecurity); return; } GURL origin_url(frame->document().securityOrigin().toString()); - file_system_context_->OpenFileSystem( - origin_url, type, create, OpenFileSystemHandler(callbacks)); + file_system_context_->DeleteFileSystem( + origin_url, static_cast(type), + DeleteFileSystemHandler(callbacks)); } void BrowserFileSystem::move( @@ -272,29 +278,29 @@ void BrowserFileSystem::CleanupOnIOThread() { bool BrowserFileSystem::HasFilePermission( const fileapi::FileSystemURL& url, FilePermission permission) { - // Disallow writing on isolated file system, otherwise return ok. - return (url.type() != fileapi::kFileSystemTypeIsolated || + // Disallow writing on dragged file system, otherwise return ok. + return (url.type() != fileapi::kFileSystemTypeDragged || permission == FILE_PERMISSION_READ); } -FileSystemOperationInterface* BrowserFileSystem::GetNewOperation( +FileSystemOperation* BrowserFileSystem::GetNewOperation( const fileapi::FileSystemURL& url) { return file_system_context_->CreateFileSystemOperation(url); } -FileSystemOperationInterface::StatusCallback +FileSystemOperation::StatusCallback BrowserFileSystem::FinishHandler(WebFileSystemCallbacks* callbacks) { return base::Bind(&BrowserFileSystem::DidFinish, AsWeakPtr(), base::Unretained(callbacks)); } -FileSystemOperationInterface::ReadDirectoryCallback +FileSystemOperation::ReadDirectoryCallback BrowserFileSystem::ReadDirectoryHandler(WebFileSystemCallbacks* callbacks) { return base::Bind(&BrowserFileSystem::DidReadDirectory, AsWeakPtr(), base::Unretained(callbacks)); } -FileSystemOperationInterface::GetMetadataCallback +FileSystemOperation::GetMetadataCallback BrowserFileSystem::GetMetadataHandler(WebFileSystemCallbacks* callbacks) { return base::Bind(&BrowserFileSystem::DidGetMetadata, AsWeakPtr(), base::Unretained(callbacks)); @@ -306,7 +312,13 @@ BrowserFileSystem::OpenFileSystemHandler(WebFileSystemCallbacks* callbacks) { AsWeakPtr(), base::Unretained(callbacks)); } -FileSystemOperationInterface::SnapshotFileCallback +FileSystemContext::DeleteFileSystemCallback +BrowserFileSystem::DeleteFileSystemHandler(WebFileSystemCallbacks* callbacks) { + return base::Bind(&BrowserFileSystem::DidDeleteFileSystem, + AsWeakPtr(), callbacks); +} + +FileSystemOperation::SnapshotFileCallback BrowserFileSystem::SnapshotFileHandler(const GURL& blob_url, WebFileSystemCallbacks* callbacks) { return base::Bind(&BrowserFileSystem::DidCreateSnapshotFile, @@ -374,6 +386,15 @@ void BrowserFileSystem::DidOpenFileSystem( } } +void BrowserFileSystem::DidDeleteFileSystem( + WebFileSystemCallbacks* callbacks, + base::PlatformFileError result) { + if (result == base::PLATFORM_FILE_OK) + callbacks->didSucceed(); + else + callbacks->didFail(fileapi::PlatformFileErrorToWebFileError(result)); +} + void BrowserFileSystem::DidCreateSnapshotFile( const GURL& blob_url, WebFileSystemCallbacks* callbacks, diff --git a/cef1/libcef/browser_file_system.h b/cef1/libcef/browser_file_system.h index be27631f5..d63c9ed15 100644 --- a/cef1/libcef/browser_file_system.h +++ b/cef1/libcef/browser_file_system.h @@ -14,7 +14,7 @@ #include "base/scoped_temp_dir.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFileSystem.h" #include "webkit/fileapi/file_system_context.h" -#include "webkit/fileapi/file_system_operation_interface.h" +#include "webkit/fileapi/file_system_operation.h" #include "webkit/fileapi/file_system_types.h" namespace WebKit { @@ -46,6 +46,9 @@ class BrowserFileSystem long long size, // NOLINT(runtime/int) bool create, WebKit::WebFileSystemCallbacks* callbacks); + void DeleteFileSystem(WebKit::WebFrame* frame, + WebKit::WebFileSystem::Type type, + WebKit::WebFileSystemCallbacks* callbacks); fileapi::FileSystemContext* file_system_context() { return file_system_context_.get(); @@ -107,19 +110,21 @@ class BrowserFileSystem // Helpers. bool HasFilePermission(const fileapi::FileSystemURL& url, FilePermission permission); - fileapi::FileSystemOperationInterface* GetNewOperation( + fileapi::FileSystemOperation* GetNewOperation( const fileapi::FileSystemURL& url); // Callback Handlers - fileapi::FileSystemOperationInterface::StatusCallback FinishHandler( + fileapi::FileSystemOperation::StatusCallback FinishHandler( WebKit::WebFileSystemCallbacks* callbacks); - fileapi::FileSystemOperationInterface::GetMetadataCallback GetMetadataHandler( + fileapi::FileSystemOperation::GetMetadataCallback GetMetadataHandler( WebKit::WebFileSystemCallbacks* callbacks); - fileapi::FileSystemOperationInterface::ReadDirectoryCallback + fileapi::FileSystemOperation::ReadDirectoryCallback ReadDirectoryHandler(WebKit::WebFileSystemCallbacks* callbacks); fileapi::FileSystemContext::OpenFileSystemCallback OpenFileSystemHandler( WebKit::WebFileSystemCallbacks* callbacks); - fileapi::FileSystemOperationInterface::SnapshotFileCallback + fileapi::FileSystemContext::DeleteFileSystemCallback DeleteFileSystemHandler( + WebKit::WebFileSystemCallbacks* callbacks); + fileapi::FileSystemOperation::SnapshotFileCallback SnapshotFileHandler(const GURL& blob_url, WebKit::WebFileSystemCallbacks* callbacks); void DidFinish(WebKit::WebFileSystemCallbacks* callbacks, @@ -136,6 +141,8 @@ class BrowserFileSystem void DidOpenFileSystem(WebKit::WebFileSystemCallbacks* callbacks, base::PlatformFileError result, const std::string& name, const GURL& root); + void DidDeleteFileSystem(WebKit::WebFileSystemCallbacks* callbacks, + base::PlatformFileError result); void DidCreateSnapshotFile( const GURL& blob_url, WebKit::WebFileSystemCallbacks* callbacks, diff --git a/cef1/libcef/browser_file_writer.cc b/cef1/libcef/browser_file_writer.cc index 2adfdeea1..117aeb267 100644 --- a/cef1/libcef/browser_file_writer.cc +++ b/cef1/libcef/browser_file_writer.cc @@ -11,14 +11,14 @@ #include "base/message_loop_proxy.h" #include "net/url_request/url_request_context.h" #include "webkit/fileapi/file_system_context.h" -#include "webkit/fileapi/file_system_operation_interface.h" +#include "webkit/fileapi/file_system_operation.h" #include "webkit/fileapi/file_system_types.h" #include "webkit/fileapi/file_system_url.h" #include "webkit/glue/webkit_glue.h" using fileapi::FileSystemURL; using fileapi::FileSystemContext; -using fileapi::FileSystemOperationInterface; +using fileapi::FileSystemOperation; using fileapi::WebFileWriterBase; using WebKit::WebFileWriterClient; using WebKit::WebString; @@ -90,13 +90,13 @@ class BrowserFileWriter::IOThreadProxy friend class base::RefCountedThreadSafe; virtual ~IOThreadProxy() {} - FileSystemOperationInterface* GetNewOperation( const FileSystemURL& url) { + FileSystemOperation* GetNewOperation( const FileSystemURL& url) { return file_system_context_->CreateFileSystemOperation(url); } // Returns true if it is not writable. bool FailIfNotWritable(const FileSystemURL& url) { - if (url.type() == fileapi::kFileSystemTypeIsolated) { + if (url.type() == fileapi::kFileSystemTypeDragged) { // Write is not allowed in isolate file system in BrowserFileWriter. DidFailOnMainThread(base::PLATFORM_FILE_ERROR_SECURITY); return true; @@ -169,7 +169,7 @@ class BrowserFileWriter::IOThreadProxy base::WeakPtr simple_writer_; // Only used on the io thread. - FileSystemOperationInterface* operation_; + FileSystemOperation* operation_; scoped_refptr file_system_context_; }; diff --git a/cef1/libcef/browser_network_delegate.cc b/cef1/libcef/browser_network_delegate.cc index 43326efc3..7e4ce562a 100644 --- a/cef1/libcef/browser_network_delegate.cc +++ b/cef1/libcef/browser_network_delegate.cc @@ -116,7 +116,7 @@ int BrowserNetworkDelegate::OnBeforeSocketStreamConnect( return net::OK; } -void BrowserNetworkDelegate::OnCacheWaitStateChange( +void BrowserNetworkDelegate::OnRequestWaitStateChange( const net::URLRequest& request, - CacheWaitState state) { + RequestWaitState state) { } diff --git a/cef1/libcef/browser_network_delegate.h b/cef1/libcef/browser_network_delegate.h index d9eb09985..085166a5e 100644 --- a/cef1/libcef/browser_network_delegate.h +++ b/cef1/libcef/browser_network_delegate.h @@ -56,8 +56,8 @@ class BrowserNetworkDelegate : public net::NetworkDelegate { virtual int OnBeforeSocketStreamConnect( net::SocketStream* stream, const net::CompletionCallback& callback) OVERRIDE; - virtual void OnCacheWaitStateChange(const net::URLRequest& request, - CacheWaitState state) OVERRIDE; + virtual void OnRequestWaitStateChange(const net::URLRequest& request, + RequestWaitState state) OVERRIDE; bool accept_all_cookies_; }; diff --git a/cef1/libcef/browser_request_context.cc b/cef1/libcef/browser_request_context.cc index 6e3d28308..2383f31b9 100644 --- a/cef1/libcef/browser_request_context.cc +++ b/cef1/libcef/browser_request_context.cc @@ -34,7 +34,7 @@ #include "net/proxy/proxy_config_service_fixed.h" #include "net/proxy/proxy_resolver.h" #include "net/proxy/proxy_service.h" -#include "net/url_request/url_request_job_factory.h" +#include "net/url_request/url_request_job_factory_impl.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebKitPlatformSupport.h" #include "webkit/blob/blob_storage_controller.h" @@ -254,7 +254,7 @@ void BrowserRequestContext::Init( storage_.set_ftp_transaction_factory( new net::FtpNetworkLayer(host_resolver())); - net::URLRequestJobFactory* job_factory = new net::URLRequestJobFactory; + net::URLRequestJobFactory* job_factory = new net::URLRequestJobFactoryImpl(); blob_storage_controller_.reset(new webkit_blob::BlobStorageController()); job_factory->SetProtocolHandler( diff --git a/cef1/libcef/browser_resource_loader_bridge.cc b/cef1/libcef/browser_resource_loader_bridge.cc index 280568ae4..7efbbb860 100644 --- a/cef1/libcef/browser_resource_loader_bridge.cc +++ b/cef1/libcef/browser_resource_loader_bridge.cc @@ -73,6 +73,7 @@ #include "webkit/fileapi/file_system_dir_url_request_job.h" #include "webkit/fileapi/file_system_url_request_job.h" #include "webkit/glue/resource_loader_bridge.h" +#include "webkit/glue/resource_request_body.h" #include "webkit/glue/webkit_glue.h" #if defined(OS_MACOSX) || defined(OS_WIN) @@ -84,6 +85,7 @@ using net::StaticCookiePolicy; using net::URLRequestStatus; using webkit_blob::ShareableFileReference; using webkit_glue::ResourceLoaderBridge; +using webkit_glue::ResourceRequestBody; using webkit_glue::ResourceResponseInfo; @@ -102,7 +104,7 @@ struct RequestParams { ResourceType::Type request_type; int appcache_host_id; bool download_to_file; - scoped_refptr upload; + scoped_refptr request_body; net::RequestPriority priority; }; @@ -146,12 +148,16 @@ class RequestInterceptor : public net::URLRequest::Interceptor { UnregisterRequestInterceptor(this); } - virtual net::URLRequestJob* MaybeIntercept(net::URLRequest* request) + virtual net::URLRequestJob* MaybeIntercept( + net::URLRequest* request, + net::NetworkDelegate* network_delegate) OVERRIDE { return NULL; } - virtual net::URLRequestJob* MaybeInterceptRedirect(net::URLRequest* request, + virtual net::URLRequestJob* MaybeInterceptRedirect( + net::URLRequest* request, + net::NetworkDelegate* network_delegate, const GURL& location) OVERRIDE { REQUIRE_IOT(); @@ -175,7 +181,9 @@ class RequestInterceptor : public net::URLRequest::Interceptor { if (newUrlStr != location.spec()) { GURL new_url = GURL(std::string(newUrlStr)); if (!new_url.is_empty() && new_url.is_valid()) - return new net::URLRequestRedirectJob(request, new_url); + return new net::URLRequestRedirectJob(request, + network_delegate, + new_url); } return NULL; @@ -443,6 +451,12 @@ class RequestProxy : public net::URLRequest::Delegate, bool handled = false; + scoped_refptr upload_data; + if (params->request_body) { + upload_data = params->request_body->ResolveElementsAndCreateUploadData( + _Context->request_context()->blob_storage_controller()); + } + if (browser_.get()) { CefRefPtr client = browser_->GetClient(); CefRefPtr handler; @@ -466,10 +480,10 @@ class RequestProxy : public net::URLRequest::Delegate, requestimpl->SetHeaderMap(headerMap); // Transfer post data, if any - scoped_refptr upload = params->upload; - if (upload.get()) { + if (upload_data.get()) { CefRefPtr postdata(new CefPostDataImpl()); - static_cast(postdata.get())->Set(*upload.get()); + static_cast(postdata.get())->Set( + *upload_data.get()); requestimpl->SetPostData(postdata); } @@ -510,8 +524,8 @@ class RequestProxy : public net::URLRequest::Delegate, // Observe post data from request. CefRefPtr postData = request->GetPostData(); if (postData.get()) { - params->upload = new net::UploadData(); - static_cast(postData.get())->Get(*params->upload); + upload_data = new net::UploadData(); + static_cast(postData.get())->Get(*upload_data); } } @@ -574,12 +588,6 @@ class RequestProxy : public net::URLRequest::Delegate, } if (!handled) { - // Might need to resolve the blob references in the upload data. - if (params->upload) { - _Context->request_context()->blob_storage_controller()-> - ResolveBlobReferencesInUploadData(params->upload.get()); - } - net::URLRequestContext* context = browser_.get() ? browser_->request_context_proxy() : _Context->request_context(); @@ -594,7 +602,7 @@ class RequestProxy : public net::URLRequest::Delegate, headers.AddHeadersFromString(params->headers); request_->SetExtraRequestHeaders(headers); request_->set_load_flags(params->load_flags); - request_->set_upload(params->upload.get()); + request_->set_upload(upload_data); request_->SetUserData(kCefUserData, new ExtraRequestInfo(browser_.get(), params->request_type)); BrowserAppCacheSystem::SetExtraRequestInfo( @@ -1067,41 +1075,11 @@ class ResourceLoaderBridgeImpl : public ResourceLoaderBridge, // -------------------------------------------------------------------------- // ResourceLoaderBridge implementation: - virtual void AppendDataToUpload(const char* data, int data_len) OVERRIDE { + virtual void SetRequestBody(ResourceRequestBody* request_body) OVERRIDE { DCHECK(CalledOnValidThread()); DCHECK(params_.get()); - if (!params_->upload) - params_->upload = new net::UploadData(); - params_->upload->AppendBytes(data, data_len); - } - - virtual void AppendFileRangeToUpload( - const FilePath& file_path, - uint64 offset, - uint64 length, - const base::Time& expected_modification_time) OVERRIDE { - DCHECK(CalledOnValidThread()); - DCHECK(params_.get()); - if (!params_->upload) - params_->upload = new net::UploadData(); - params_->upload->AppendFileRange(file_path, offset, length, - expected_modification_time); - } - - virtual void AppendBlobToUpload(const GURL& blob_url) OVERRIDE { - DCHECK(CalledOnValidThread()); - DCHECK(params_.get()); - if (!params_->upload) - params_->upload = new net::UploadData(); - params_->upload->AppendBlob(blob_url); - } - - virtual void SetUploadIdentifier(int64 identifier) OVERRIDE { - DCHECK(CalledOnValidThread()); - DCHECK(params_.get()); - if (!params_->upload) - params_->upload = new net::UploadData(); - params_->upload->set_identifier(identifier); + DCHECK(!params_->request_body); + params_->request_body = request_body; } virtual bool Start(Peer* peer) OVERRIDE { diff --git a/cef1/libcef/browser_webblobregistry_impl.cc b/cef1/libcef/browser_webblobregistry_impl.cc index 626f64b82..52fae0155 100644 --- a/cef1/libcef/browser_webblobregistry_impl.cc +++ b/cef1/libcef/browser_webblobregistry_impl.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -11,6 +11,7 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" #include "webkit/blob/blob_data.h" #include "webkit/blob/blob_storage_controller.h" +#include "webkit/glue/webkit_glue.h" using WebKit::WebBlobData; using WebKit::WebURL; @@ -21,6 +22,46 @@ namespace { MessageLoop* g_io_thread; webkit_blob::BlobStorageController* g_blob_storage_controller; +// Creates a new BlobData from WebBlobData. +BlobData* NewBlobData(const WebBlobData& data) { + BlobData* blob = new BlobData; + size_t i = 0; + WebBlobData::Item item; + while (data.itemAt(i++, item)) { + switch (item.type) { + case WebBlobData::Item::TypeData: + if (!item.data.isEmpty()) { + // WebBlobData does not allow partial data. + DCHECK(!item.offset && item.length == -1); + blob->AppendData(item.data); + } + break; + case WebBlobData::Item::TypeFile: + if (item.length) { + blob->AppendFile( + webkit_glue::WebStringToFilePath(item.filePath), + static_cast(item.offset), + static_cast(item.length), + base::Time::FromDoubleT(item.expectedModificationTime)); + } + break; + case WebBlobData::Item::TypeBlob: + if (item.length) { + blob->AppendBlob( + item.blobURL, + static_cast(item.offset), + static_cast(item.length)); + } + break; + default: + NOTREACHED(); + } + } + blob->set_content_type(data.contentType().utf8().data()); + blob->set_content_disposition(data.contentDisposition().utf8().data()); + return blob; +} + } // namespace /* static */ @@ -45,7 +86,7 @@ void BrowserWebBlobRegistryImpl::registerBlobURL( GURL thread_safe_url = url; // WebURL uses refcounted strings. g_io_thread->PostTask(FROM_HERE, base::Bind( &BrowserWebBlobRegistryImpl::AddFinishedBlob, this, - thread_safe_url, make_scoped_refptr(new BlobData(data)))); + thread_safe_url, make_scoped_refptr(NewBlobData(data)))); } void BrowserWebBlobRegistryImpl::registerBlobURL( diff --git a/cef1/libcef/browser_webkit_glue.cc b/cef1/libcef/browser_webkit_glue.cc index e4505f120..0978552cd 100644 --- a/cef1/libcef/browser_webkit_glue.cc +++ b/cef1/libcef/browser_webkit_glue.cc @@ -11,6 +11,7 @@ MSVC_PUSH_WARNING_LEVEL(0); #include "CrossOriginPreflightResultCache.h" // NOLINT(build/include) #include "DocumentLoader.h" // NOLINT(build/include) #include "MemoryCache.h" // NOLINT(build/include) +#include "ScriptController.h" // NOLINT(build/include) #include "TextEncoding.h" // NOLINT(build/include) #include "third_party/WebKit/Source/WebKit/chromium/src/WebFrameImpl.h" MSVC_POP_WARNING(); @@ -44,9 +45,8 @@ void InitializeTextEncoding() { } v8::Handle GetV8Context(WebKit::WebFrame* frame) { - WebFrameImpl* webFrameImpl = static_cast(frame); - WebCore::Frame* core_frame = webFrameImpl->frame(); - return WebCore::V8Proxy::context(core_frame); + WebFrameImpl* impl = static_cast(frame); + return WebCore::ScriptController::mainWorldContext(impl->frame()); } void ClearCache() { diff --git a/cef1/libcef/browser_webkit_init.cc b/cef1/libcef/browser_webkit_init.cc index 7174a8720..e4de6ed13 100644 --- a/cef1/libcef/browser_webkit_init.cc +++ b/cef1/libcef/browser_webkit_init.cc @@ -18,8 +18,6 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBFactory.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKey.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyPath.h" #include "v8/include/v8.h" #include "webkit/plugins/npapi/plugin_list.h" @@ -221,25 +219,6 @@ WebKit::WebIDBFactory* BrowserWebKitInit::idbFactory() { return WebKit::WebIDBFactory::create(); } -void BrowserWebKitInit::createIDBKeysFromSerializedValuesAndKeyPath( - const WebKit::WebVector& values, - const WebKit::WebIDBKeyPath& keyPath, - WebKit::WebVector& keys_out) { - WebKit::WebVector keys(values.size()); - for (size_t i = 0; i < values.size(); ++i) - keys[i] = WebKit::WebIDBKey::createFromValueAndKeyPath(values[i], keyPath); - keys_out.swap(keys); -} - -WebKit::WebSerializedScriptValue -BrowserWebKitInit::injectIDBKeyIntoSerializedValue( - const WebKit::WebIDBKey& key, - const WebKit::WebSerializedScriptValue& value, - const WebKit::WebIDBKeyPath& keyPath) { - return WebKit::WebIDBKey::injectIDBKeyIntoSerializedValue( - key, value, keyPath); -} - WebKit::WebGraphicsContext3D* BrowserWebKitInit::createOffscreenGraphicsContext3D( const WebKit::WebGraphicsContext3D::Attributes& attributes) { diff --git a/cef1/libcef/browser_webkit_init.h b/cef1/libcef/browser_webkit_init.h index 3f0c1c439..d88075931 100644 --- a/cef1/libcef/browser_webkit_init.h +++ b/cef1/libcef/browser_webkit_init.h @@ -67,14 +67,6 @@ class BrowserWebKitInit : public webkit_glue::WebKitPlatformSupportImpl { virtual WebKit::WebStorageNamespace* createLocalStorageNamespace( const WebKit::WebString& path, unsigned quota) OVERRIDE; virtual WebKit::WebIDBFactory* idbFactory() OVERRIDE; - virtual void createIDBKeysFromSerializedValuesAndKeyPath( - const WebKit::WebVector& values, - const WebKit::WebIDBKeyPath& keyPath, - WebKit::WebVector& keys_out) OVERRIDE; - virtual WebKit::WebSerializedScriptValue injectIDBKeyIntoSerializedValue( - const WebKit::WebIDBKey& key, - const WebKit::WebSerializedScriptValue& value, - const WebKit::WebIDBKeyPath& keyPath) OVERRIDE; virtual WebKit::WebGraphicsContext3D* createOffscreenGraphicsContext3D( const WebKit::WebGraphicsContext3D::Attributes& attributes) OVERRIDE; virtual string16 GetLocalizedString(int message_id) OVERRIDE; diff --git a/cef1/libcef/browser_webview_delegate.cc b/cef1/libcef/browser_webview_delegate.cc index b94ac3455..72a4386d7 100644 --- a/cef1/libcef/browser_webview_delegate.cc +++ b/cef1/libcef/browser_webview_delegate.cc @@ -688,7 +688,7 @@ WebPlugin* BrowserWebViewDelegate::createPlugin( } WebMediaPlayer* BrowserWebViewDelegate::createMediaPlayer( - WebFrame* frame, WebMediaPlayerClient* client) { + WebFrame* frame, const WebKit::WebURL&, WebMediaPlayerClient* client) { scoped_ptr message_loop_factory( new media::MessageLoopFactory()); diff --git a/cef1/libcef/browser_webview_delegate.h b/cef1/libcef/browser_webview_delegate.h index 2893e1618..aad923278 100644 --- a/cef1/libcef/browser_webview_delegate.h +++ b/cef1/libcef/browser_webview_delegate.h @@ -156,7 +156,7 @@ class BrowserWebViewDelegate : public WebKit::WebViewClient, virtual WebKit::WebPlugin* createPlugin( WebKit::WebFrame*, const WebKit::WebPluginParams&) OVERRIDE; virtual WebKit::WebMediaPlayer* createMediaPlayer( - WebKit::WebFrame*, WebKit::WebMediaPlayerClient*) OVERRIDE; + WebKit::WebFrame*, const WebKit::WebURL&, WebKit::WebMediaPlayerClient*) OVERRIDE; virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost( WebKit::WebFrame* frame, WebKit::WebApplicationCacheHostClient* client) OVERRIDE; diff --git a/cef1/libcef/request_impl.cc b/cef1/libcef/request_impl.cc index 80b45bb67..b71d36d0b 100644 --- a/cef1/libcef/request_impl.cc +++ b/cef1/libcef/request_impl.cc @@ -296,8 +296,8 @@ void CefPostDataImpl::Set(const net::UploadData& data) { CefRefPtr postelem; - const std::vector* elements = data.elements(); - std::vector::const_iterator it = elements->begin(); + const std::vector* elements = data.elements(); + std::vector::const_iterator it = elements->begin(); for (; it != elements->end(); ++it) { postelem = CefPostDataElement::CreatePostDataElement(); static_cast(postelem.get())->Set(*it); @@ -308,8 +308,8 @@ void CefPostDataImpl::Set(const net::UploadData& data) { void CefPostDataImpl::Get(net::UploadData& data) { AutoLock lock_scope(this); - net::UploadData::Element element; - std::vector data_elements; + net::UploadElement element; + std::vector data_elements; ElementVector::iterator it = elements_.begin(); for (; it != elements_.end(); ++it) { static_cast(it->get())->Get(element); @@ -436,22 +436,19 @@ size_t CefPostDataElementImpl::GetBytes(size_t size, void* bytes) { return rv; } -void CefPostDataElementImpl::Set(const net::UploadData::Element& element) { +void CefPostDataElementImpl::Set(const net::UploadElement& element) { AutoLock lock_scope(this); - if (element.type() == net::UploadData::TYPE_BYTES) { - SetToBytes(element.bytes().size(), - static_cast( - std::string(element.bytes().begin(), - element.bytes().end()).c_str())); - } else if (element.type() == net::UploadData::TYPE_FILE) { + if (element.type() == net::UploadElement::TYPE_BYTES) { + SetToBytes(element.bytes_length(), element.bytes()); + } else if (element.type() == net::UploadElement::TYPE_FILE) { SetToFile(element.file_path().value()); } else { NOTREACHED(); } } -void CefPostDataElementImpl::Get(net::UploadData::Element& element) { +void CefPostDataElementImpl::Get(net::UploadElement& element) { AutoLock lock_scope(this); if (type_ == PDE_TYPE_BYTES) { diff --git a/cef1/libcef/request_impl.h b/cef1/libcef/request_impl.h index 9761c7cf4..0d5245a92 100644 --- a/cef1/libcef/request_impl.h +++ b/cef1/libcef/request_impl.h @@ -104,8 +104,8 @@ class CefPostDataElementImpl : public CefPostDataElement { void* GetBytes() { return data_.bytes.bytes; } - void Set(const net::UploadData::Element& element); - void Get(net::UploadData::Element& element); + void Set(const net::UploadElement& element); + void Get(net::UploadElement& element); void Set(const WebKit::WebHTTPBody::Element& element); void Get(WebKit::WebHTTPBody::Element& element); diff --git a/cef1/libcef/scheme_impl.cc b/cef1/libcef/scheme_impl.cc index 7c009b1a6..ad1bd86da 100644 --- a/cef1/libcef/scheme_impl.cc +++ b/cef1/libcef/scheme_impl.cc @@ -80,12 +80,15 @@ bool IsBuiltinScheme(const std::string& scheme) { return false; } -net::URLRequestJob* GetBuiltinSchemeRequestJob(net::URLRequest* request, - const std::string& scheme) { +net::URLRequestJob* GetBuiltinSchemeRequestJob( + net::URLRequest* request, + net::NetworkDelegate* network_delegate, + const std::string& scheme) { // See if the request should be handled by a built-in protocol factory. for (size_t i = 0; i < arraysize(kBuiltinFactories); ++i) { if (scheme == kBuiltinFactories[i].scheme) { - net::URLRequestJob* job = (kBuiltinFactories[i].factory)(request, scheme); + net::URLRequestJob* job = + (kBuiltinFactories[i].factory)(request, network_delegate, scheme); DCHECK(job); // The built-in factories are not expected to fail! return job; } @@ -106,8 +109,9 @@ std::string ToLower(const std::string& str) { class CefUrlRequestJob : public net::URLRequestJob { public: CefUrlRequestJob(net::URLRequest* request, + net::NetworkDelegate* network_delegate, CefRefPtr handler) - : net::URLRequestJob(request, request->context()->network_delegate()), + : net::URLRequestJob(request, network_delegate), handler_(handler), remaining_bytes_(0), response_cookies_save_index_(0), @@ -574,10 +578,11 @@ class CefUrlRequestManager { // From net::URLRequestJobFactory::ProtocolHandler virtual net::URLRequestJob* MaybeCreateJob( - net::URLRequest* request) const OVERRIDE { + net::URLRequest* request, + net::NetworkDelegate* network_delegate) const OVERRIDE { REQUIRE_IOT(); - return CefUrlRequestManager::GetInstance()->GetRequestJob(request, - scheme_); + return CefUrlRequestManager::GetInstance()->GetRequestJob( + request, network_delegate, scheme_); } private: @@ -732,6 +737,7 @@ class CefUrlRequestManager { // Create the job that will handle the request. |scheme| will already be in // lower case. net::URLRequestJob* GetRequestJob(net::URLRequest* request, + net::NetworkDelegate* network_delegate, const std::string& scheme) { net::URLRequestJob* job = NULL; CefRefPtr factory = @@ -745,12 +751,12 @@ class CefUrlRequestManager { CefRefPtr handler = factory->Create(browser.get(), scheme, requestPtr); if (handler.get()) - job = new CefUrlRequestJob(request, handler); + job = new CefUrlRequestJob(request, network_delegate, handler); } if (!job && IsBuiltinScheme(scheme)) { // Give the built-in scheme handler a chance to handle the request. - job = GetBuiltinSchemeRequestJob(request, scheme); + job = GetBuiltinSchemeRequestJob(request, network_delegate, scheme); } #ifndef NDEBUG diff --git a/cef1/libcef/v8_impl.cc b/cef1/libcef/v8_impl.cc index 5bc9910d6..b2fe82be4 100644 --- a/cef1/libcef/v8_impl.cc +++ b/cef1/libcef/v8_impl.cc @@ -8,7 +8,10 @@ #include "third_party/WebKit/Source/WebCore/config.h" MSVC_PUSH_WARNING_LEVEL(0); -#include "V8Proxy.h" // NOLINT(build/include) +#include "Frame.h" // NOLINT(build/include) +#include "ScriptController.h" // NOLINT(build/include) +#include "ScriptControllerBase.h" // NOLINT(build/include) +#include "V8Binding.h" // NOLINT(build/include) #include "V8RecursionScope.h" // NOLINT(build/include) MSVC_POP_WARNING(); #undef LOG @@ -597,12 +600,14 @@ bool CefV8ContextImpl::Eval(const CefString& code, retval = NULL; exception = NULL; - // Execute the function call using the V8Proxy so that inspector + // Execute the function call using the ScriptController so that inspector // instrumentation works. - WebCore::V8Proxy* proxy = WebCore::V8Proxy::retrieve(); - DCHECK(proxy); - if (proxy) - func_rv = proxy->callFunction(func, obj, 1, &code_val); + RefPtr frame = WebCore::toFrameIfNotDetached(GetHandle()); + DCHECK(frame); + if (frame && + frame->script()->canExecuteScripts(WebCore::AboutToExecuteScript)) { + func_rv = frame->script()->callFunction(func, obj, 1, &code_val); + } if (try_catch.HasCaught()) { exception = new CefV8ExceptionImpl(try_catch.Message()); @@ -1342,12 +1347,14 @@ CefRefPtr CefV8ValueImpl::ExecuteFunctionWithContext( try_catch.SetVerbose(true); v8::Local func_rv; - // Execute the function call using the V8Proxy so that inspector + // Execute the function call using the ScriptController so that inspector // instrumentation works. - WebCore::V8Proxy* proxy = WebCore::V8Proxy::retrieve(); - DCHECK(proxy); - if (proxy) - func_rv = proxy->callFunction(func, recv, argc, argv); + RefPtr frame = WebCore::toFrameIfNotDetached(context_local); + DCHECK(frame); + if (frame && + frame->script()->canExecuteScripts(WebCore::AboutToExecuteScript)) { + func_rv = frame->script()->callFunction(func, recv, argc, argv); + } if (!HasCaught(try_catch) && !func_rv.IsEmpty()) retval = new CefV8ValueImpl(func_rv);