mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Update to Chromium revision 122508.
- CefDragData::GetFileExtension() has been removed. - Audio playback no longer works (issue #530). git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@509 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@ -17,5 +17,5 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
'chromium_url': 'http://src.chromium.org/svn/trunk/src',
|
'chromium_url': 'http://src.chromium.org/svn/trunk/src',
|
||||||
'chromium_revision': '119867',
|
'chromium_revision': '122508',
|
||||||
}
|
}
|
||||||
|
9
cef.gyp
9
cef.gyp
@ -825,7 +825,7 @@
|
|||||||
'libcef/web_drag_utils_mac.mm',
|
'libcef/web_drag_utils_mac.mm',
|
||||||
'libcef/web_drop_target_mac.h',
|
'libcef/web_drop_target_mac.h',
|
||||||
'libcef/web_drop_target_mac.mm',
|
'libcef/web_drop_target_mac.mm',
|
||||||
# Build necessary Mozilla sources
|
# Include necessary Mozilla sources.
|
||||||
'<(DEPTH)/third_party/mozilla/NSPasteboard+Utils.h',
|
'<(DEPTH)/third_party/mozilla/NSPasteboard+Utils.h',
|
||||||
'<(DEPTH)/third_party/mozilla/NSPasteboard+Utils.mm',
|
'<(DEPTH)/third_party/mozilla/NSPasteboard+Utils.mm',
|
||||||
'<(DEPTH)/third_party/mozilla/NSString+Utils.h',
|
'<(DEPTH)/third_party/mozilla/NSString+Utils.h',
|
||||||
@ -847,6 +847,13 @@
|
|||||||
'libcef/web_drag_source_gtk.h',
|
'libcef/web_drag_source_gtk.h',
|
||||||
'libcef/web_drop_target_gtk.cc',
|
'libcef/web_drop_target_gtk.cc',
|
||||||
'libcef/web_drop_target_gtk.h',
|
'libcef/web_drop_target_gtk.h',
|
||||||
|
# Include the files needed for drag&drop that are otherwise excluded
|
||||||
|
# by 'toolkit_views=0' in ui/ui.gyp.
|
||||||
|
'<(DEPTH)/ui/base/dragdrop/drag_drop_types_gtk.cc',
|
||||||
|
'<(DEPTH)/ui/base/dragdrop/os_exchange_data.cc',
|
||||||
|
'<(DEPTH)/ui/base/dragdrop/os_exchange_data.h',
|
||||||
|
'<(DEPTH)/ui/base/dragdrop/os_exchange_data_provider_gtk.cc',
|
||||||
|
'<(DEPTH)/ui/base/dragdrop/os_exchange_data_provider_gtk.h',
|
||||||
],
|
],
|
||||||
}],
|
}],
|
||||||
],
|
],
|
||||||
|
@ -113,13 +113,6 @@ typedef struct _cef_drag_data_t {
|
|||||||
cef_string_userfree_t (CEF_CALLBACK *get_fragment_base_url)(
|
cef_string_userfree_t (CEF_CALLBACK *get_fragment_base_url)(
|
||||||
struct _cef_drag_data_t* self);
|
struct _cef_drag_data_t* self);
|
||||||
|
|
||||||
///
|
|
||||||
// Return the extension of the file being dragged out of the browser window.
|
|
||||||
///
|
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
|
||||||
cef_string_userfree_t (CEF_CALLBACK *get_file_extension)(
|
|
||||||
struct _cef_drag_data_t* self);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the name of the file being dragged out of the browser window.
|
// Return the name of the file being dragged out of the browser window.
|
||||||
///
|
///
|
||||||
|
@ -103,12 +103,6 @@ class CefDragData : public virtual CefBase {
|
|||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual CefString GetFragmentBaseURL() =0;
|
virtual CefString GetFragmentBaseURL() =0;
|
||||||
|
|
||||||
///
|
|
||||||
// Return the extension of the file being dragged out of the browser window.
|
|
||||||
///
|
|
||||||
/*--cef()--*/
|
|
||||||
virtual CefString GetFileExtension() =0;
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the name of the file being dragged out of the browser window.
|
// Return the name of the file being dragged out of the browser window.
|
||||||
///
|
///
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
#ifdef __OBJC__
|
#ifdef __OBJC__
|
||||||
@class NSView;
|
@class NSView;
|
||||||
#else
|
#else
|
||||||
class NSView;
|
struct NSView;
|
||||||
#endif
|
#endif
|
||||||
#define cef_window_handle_t NSView*
|
#define cef_window_handle_t NSView*
|
||||||
#else
|
#else
|
||||||
|
@ -229,21 +229,22 @@ void BrowserDragDelegate::PrepareDragForDownload(
|
|||||||
|
|
||||||
void BrowserDragDelegate::PrepareDragForFileContents(
|
void BrowserDragDelegate::PrepareDragForFileContents(
|
||||||
const WebDropData& drop_data, ui::OSExchangeData* data) {
|
const WebDropData& drop_data, ui::OSExchangeData* data) {
|
||||||
|
static const int kMaxFilenameLength = 255; // FAT and NTFS
|
||||||
|
FilePath file_name(drop_data.file_description_filename);
|
||||||
|
string16 extension = file_name.Extension();
|
||||||
|
file_name = file_name.BaseName().RemoveExtension();
|
||||||
// Images without ALT text will only have a file extension so we need to
|
// Images without ALT text will only have a file extension so we need to
|
||||||
// synthesize one from the provided extension and URL.
|
// synthesize one from the provided extension and URL.
|
||||||
FilePath file_name(drop_data.file_description_filename);
|
|
||||||
file_name = file_name.BaseName().RemoveExtension();
|
|
||||||
if (file_name.value().empty()) {
|
if (file_name.value().empty()) {
|
||||||
// Retrieve the name from the URL.
|
// Retrieve the name from the URL.
|
||||||
file_name = FilePath(
|
file_name = FilePath(
|
||||||
net::GetSuggestedFilename(drop_data.url, "", "", "", "", ""));
|
net::GetSuggestedFilename(drop_data.url, "", "", "", "", ""));
|
||||||
if (file_name.value().size() + drop_data.file_extension.size() + 1 >
|
if (file_name.value().size() + extension.size() > kMaxFilenameLength) {
|
||||||
MAX_PATH) {
|
|
||||||
file_name = FilePath(file_name.value().substr(
|
file_name = FilePath(file_name.value().substr(
|
||||||
0, MAX_PATH - drop_data.file_extension.size() - 2));
|
0, kMaxFilenameLength - extension.size()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_name = file_name.ReplaceExtension(drop_data.file_extension);
|
file_name = file_name.ReplaceExtension(extension);
|
||||||
data->SetFileContents(file_name, drop_data.file_contents);
|
data->SetFileContents(file_name, drop_data.file_contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "libcef/browser_file_writer.h"
|
#include "libcef/browser_file_writer.h"
|
||||||
#include "libcef/cef_thread.h"
|
#include "libcef/cef_thread.h"
|
||||||
|
|
||||||
|
#include "base/bind.h"
|
||||||
#include "base/file_path.h"
|
#include "base/file_path.h"
|
||||||
#include "base/message_loop.h"
|
#include "base/message_loop.h"
|
||||||
#include "base/message_loop_proxy.h"
|
#include "base/message_loop_proxy.h"
|
||||||
@ -20,10 +21,6 @@
|
|||||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
|
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
|
||||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h"
|
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h"
|
||||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h"
|
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h"
|
||||||
#include "webkit/fileapi/file_system_callback_dispatcher.h"
|
|
||||||
#include "webkit/fileapi/file_system_context.h"
|
|
||||||
#include "webkit/fileapi/file_system_operation_interface.h"
|
|
||||||
#include "webkit/fileapi/file_system_types.h"
|
|
||||||
#include "webkit/fileapi/mock_file_system_options.h"
|
#include "webkit/fileapi/mock_file_system_options.h"
|
||||||
#include "webkit/glue/webkit_glue.h"
|
#include "webkit/glue/webkit_glue.h"
|
||||||
#include "webkit/tools/test_shell/simple_file_writer.h"
|
#include "webkit/tools/test_shell/simple_file_writer.h"
|
||||||
@ -42,95 +39,9 @@ using WebKit::WebString;
|
|||||||
using WebKit::WebURL;
|
using WebKit::WebURL;
|
||||||
using WebKit::WebVector;
|
using WebKit::WebVector;
|
||||||
|
|
||||||
using fileapi::FileSystemCallbackDispatcher;
|
|
||||||
using fileapi::FileSystemContext;
|
using fileapi::FileSystemContext;
|
||||||
using fileapi::FileSystemOperationInterface;
|
using fileapi::FileSystemOperationInterface;
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
class BrowserFileSystemCallbackDispatcher
|
|
||||||
: public FileSystemCallbackDispatcher {
|
|
||||||
public:
|
|
||||||
// An instance of this class must be created by Create()
|
|
||||||
// (so that we do not leak ownerships).
|
|
||||||
static scoped_ptr<FileSystemCallbackDispatcher> Create(
|
|
||||||
const WeakPtr<BrowserFileSystem>& file_system,
|
|
||||||
WebFileSystemCallbacks* callbacks) {
|
|
||||||
return scoped_ptr<FileSystemCallbackDispatcher>(
|
|
||||||
new BrowserFileSystemCallbackDispatcher(file_system, callbacks));
|
|
||||||
}
|
|
||||||
|
|
||||||
~BrowserFileSystemCallbackDispatcher() {
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void DidSucceed() {
|
|
||||||
DCHECK(file_system_);
|
|
||||||
callbacks_->didSucceed();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void DidReadMetadata(const base::PlatformFileInfo& info,
|
|
||||||
const FilePath& platform_path) {
|
|
||||||
DCHECK(file_system_);
|
|
||||||
WebFileInfo web_file_info;
|
|
||||||
web_file_info.length = info.size;
|
|
||||||
web_file_info.modificationTime = info.last_modified.ToDoubleT();
|
|
||||||
web_file_info.type = info.is_directory ?
|
|
||||||
WebFileInfo::TypeDirectory : WebFileInfo::TypeFile;
|
|
||||||
web_file_info.platformPath =
|
|
||||||
webkit_glue::FilePathToWebString(platform_path);
|
|
||||||
callbacks_->didReadMetadata(web_file_info);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void DidReadDirectory(
|
|
||||||
const std::vector<base::FileUtilProxy::Entry>& entries,
|
|
||||||
bool has_more) {
|
|
||||||
DCHECK(file_system_);
|
|
||||||
std::vector<WebFileSystemEntry> web_entries_vector;
|
|
||||||
for (std::vector<base::FileUtilProxy::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);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void DidOpenFileSystem(
|
|
||||||
const std::string& name, const GURL& root) {
|
|
||||||
DCHECK(file_system_);
|
|
||||||
if (!root.is_valid())
|
|
||||||
callbacks_->didFail(WebKit::WebFileErrorSecurity);
|
|
||||||
else
|
|
||||||
callbacks_->didOpenFileSystem(WebString::fromUTF8(name), root);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void DidFail(base::PlatformFileError error_code) {
|
|
||||||
DCHECK(file_system_);
|
|
||||||
callbacks_->didFail(
|
|
||||||
webkit_glue::PlatformFileErrorToWebFileError(error_code));
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void DidWrite(int64, bool) {
|
|
||||||
NOTREACHED();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
BrowserFileSystemCallbackDispatcher(
|
|
||||||
const WeakPtr<BrowserFileSystem>& file_system,
|
|
||||||
WebFileSystemCallbacks* callbacks)
|
|
||||||
: file_system_(file_system),
|
|
||||||
callbacks_(callbacks) {
|
|
||||||
}
|
|
||||||
|
|
||||||
WeakPtr<BrowserFileSystem> file_system_;
|
|
||||||
WebFileSystemCallbacks* callbacks_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
BrowserFileSystem::BrowserFileSystem() {
|
BrowserFileSystem::BrowserFileSystem() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,60 +96,64 @@ void BrowserFileSystem::OpenFileSystem(
|
|||||||
|
|
||||||
GURL origin_url(frame->document().securityOrigin().toString());
|
GURL origin_url(frame->document().securityOrigin().toString());
|
||||||
file_system_context_->OpenFileSystem(
|
file_system_context_->OpenFileSystem(
|
||||||
origin_url, type, create,
|
origin_url, type, create, OpenFileSystemHandler(callbacks));
|
||||||
BrowserFileSystemCallbackDispatcher::Create(AsWeakPtr(), callbacks));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserFileSystem::move(
|
void BrowserFileSystem::move(
|
||||||
const WebURL& src_path,
|
const WebURL& src_path,
|
||||||
const WebURL& dest_path, WebFileSystemCallbacks* callbacks) {
|
const WebURL& dest_path, WebFileSystemCallbacks* callbacks) {
|
||||||
GetNewOperation(src_path, callbacks)->Move(GURL(src_path), GURL(dest_path));
|
GetNewOperation(src_path)->Move(GURL(src_path), GURL(dest_path),
|
||||||
|
FinishHandler(callbacks));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserFileSystem::copy(
|
void BrowserFileSystem::copy(
|
||||||
const WebURL& src_path, const WebURL& dest_path,
|
const WebURL& src_path, const WebURL& dest_path,
|
||||||
WebFileSystemCallbacks* callbacks) {
|
WebFileSystemCallbacks* callbacks) {
|
||||||
GetNewOperation(src_path, callbacks)->Copy(GURL(src_path), GURL(dest_path));
|
GetNewOperation(src_path)->Copy(GURL(src_path), GURL(dest_path),
|
||||||
|
FinishHandler(callbacks));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserFileSystem::remove(
|
void BrowserFileSystem::remove(
|
||||||
const WebURL& path, WebFileSystemCallbacks* callbacks) {
|
const WebURL& path, WebFileSystemCallbacks* callbacks) {
|
||||||
GetNewOperation(path, callbacks)->Remove(path, false /* recursive */);
|
GetNewOperation(path)->Remove(path, false /* recursive */,
|
||||||
|
FinishHandler(callbacks));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserFileSystem::removeRecursively(
|
void BrowserFileSystem::removeRecursively(
|
||||||
const WebURL& path, WebFileSystemCallbacks* callbacks) {
|
const WebURL& path, WebFileSystemCallbacks* callbacks) {
|
||||||
GetNewOperation(path, callbacks)->Remove(path, true /* recursive */);
|
GetNewOperation(path)->Remove(path, true /* recursive */,
|
||||||
|
FinishHandler(callbacks));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserFileSystem::readMetadata(
|
void BrowserFileSystem::readMetadata(
|
||||||
const WebURL& path, WebFileSystemCallbacks* callbacks) {
|
const WebURL& path, WebFileSystemCallbacks* callbacks) {
|
||||||
GetNewOperation(path, callbacks)->GetMetadata(path);
|
GetNewOperation(path)->GetMetadata(path, GetMetadataHandler(callbacks));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserFileSystem::createFile(
|
void BrowserFileSystem::createFile(
|
||||||
const WebURL& path, bool exclusive, WebFileSystemCallbacks* callbacks) {
|
const WebURL& path, bool exclusive, WebFileSystemCallbacks* callbacks) {
|
||||||
GetNewOperation(path, callbacks)->CreateFile(path, exclusive);
|
GetNewOperation(path)->CreateFile(path, exclusive, FinishHandler(callbacks));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserFileSystem::createDirectory(
|
void BrowserFileSystem::createDirectory(
|
||||||
const WebURL& path, bool exclusive, WebFileSystemCallbacks* callbacks) {
|
const WebURL& path, bool exclusive, WebFileSystemCallbacks* callbacks) {
|
||||||
GetNewOperation(path, callbacks)->CreateDirectory(path, exclusive, false);
|
GetNewOperation(path)->CreateDirectory(path, exclusive, false,
|
||||||
|
FinishHandler(callbacks));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserFileSystem::fileExists(
|
void BrowserFileSystem::fileExists(
|
||||||
const WebURL& path, WebFileSystemCallbacks* callbacks) {
|
const WebURL& path, WebFileSystemCallbacks* callbacks) {
|
||||||
GetNewOperation(path, callbacks)->FileExists(path);
|
GetNewOperation(path)->FileExists(path, FinishHandler(callbacks));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserFileSystem::directoryExists(
|
void BrowserFileSystem::directoryExists(
|
||||||
const WebURL& path, WebFileSystemCallbacks* callbacks) {
|
const WebURL& path, WebFileSystemCallbacks* callbacks) {
|
||||||
GetNewOperation(path, callbacks)->DirectoryExists(path);
|
GetNewOperation(path)->DirectoryExists(path, FinishHandler(callbacks));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserFileSystem::readDirectory(
|
void BrowserFileSystem::readDirectory(
|
||||||
const WebURL& path, WebFileSystemCallbacks* callbacks) {
|
const WebURL& path, WebFileSystemCallbacks* callbacks) {
|
||||||
GetNewOperation(path, callbacks)->ReadDirectory(path);
|
GetNewOperation(path)->ReadDirectory(path, ReadDirectoryHandler(callbacks));
|
||||||
}
|
}
|
||||||
|
|
||||||
WebFileWriter* BrowserFileSystem::createFileWriter(
|
WebFileWriter* BrowserFileSystem::createFileWriter(
|
||||||
@ -247,9 +162,93 @@ WebFileWriter* BrowserFileSystem::createFileWriter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
FileSystemOperationInterface* BrowserFileSystem::GetNewOperation(
|
FileSystemOperationInterface* BrowserFileSystem::GetNewOperation(
|
||||||
const WebURL& url, WebFileSystemCallbacks* callbacks) {
|
const WebURL& url) {
|
||||||
return file_system_context_->CreateFileSystemOperation(
|
return file_system_context_->CreateFileSystemOperation(
|
||||||
GURL(url),
|
GURL(url),
|
||||||
BrowserFileSystemCallbackDispatcher::Create(AsWeakPtr(), callbacks),
|
|
||||||
base::MessageLoopProxy::current());
|
base::MessageLoopProxy::current());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FileSystemOperationInterface::StatusCallback
|
||||||
|
BrowserFileSystem::FinishHandler(WebFileSystemCallbacks* callbacks) {
|
||||||
|
return base::Bind(&BrowserFileSystem::DidFinish,
|
||||||
|
AsWeakPtr(), base::Unretained(callbacks));
|
||||||
|
}
|
||||||
|
|
||||||
|
FileSystemOperationInterface::ReadDirectoryCallback
|
||||||
|
BrowserFileSystem::ReadDirectoryHandler(WebFileSystemCallbacks* callbacks) {
|
||||||
|
return base::Bind(&BrowserFileSystem::DidReadDirectory,
|
||||||
|
AsWeakPtr(), base::Unretained(callbacks));
|
||||||
|
}
|
||||||
|
|
||||||
|
FileSystemOperationInterface::GetMetadataCallback
|
||||||
|
BrowserFileSystem::GetMetadataHandler(WebFileSystemCallbacks* callbacks) {
|
||||||
|
return base::Bind(&BrowserFileSystem::DidGetMetadata,
|
||||||
|
AsWeakPtr(), base::Unretained(callbacks));
|
||||||
|
}
|
||||||
|
|
||||||
|
FileSystemContext::OpenFileSystemCallback
|
||||||
|
BrowserFileSystem::OpenFileSystemHandler(WebFileSystemCallbacks* callbacks) {
|
||||||
|
return base::Bind(&BrowserFileSystem::DidOpenFileSystem,
|
||||||
|
AsWeakPtr(), base::Unretained(callbacks));
|
||||||
|
}
|
||||||
|
|
||||||
|
void BrowserFileSystem::DidFinish(WebFileSystemCallbacks* callbacks,
|
||||||
|
base::PlatformFileError result) {
|
||||||
|
if (result == base::PLATFORM_FILE_OK)
|
||||||
|
callbacks->didSucceed();
|
||||||
|
else
|
||||||
|
callbacks->didFail(webkit_glue::PlatformFileErrorToWebFileError(result));
|
||||||
|
}
|
||||||
|
|
||||||
|
void BrowserFileSystem::DidGetMetadata(WebFileSystemCallbacks* callbacks,
|
||||||
|
base::PlatformFileError result,
|
||||||
|
const base::PlatformFileInfo& info,
|
||||||
|
const FilePath& platform_path) {
|
||||||
|
if (result == base::PLATFORM_FILE_OK) {
|
||||||
|
WebFileInfo web_file_info;
|
||||||
|
web_file_info.length = info.size;
|
||||||
|
web_file_info.modificationTime = info.last_modified.ToDoubleT();
|
||||||
|
web_file_info.type = info.is_directory ?
|
||||||
|
WebFileInfo::TypeDirectory : WebFileInfo::TypeFile;
|
||||||
|
web_file_info.platformPath =
|
||||||
|
webkit_glue::FilePathToWebString(platform_path);
|
||||||
|
callbacks->didReadMetadata(web_file_info);
|
||||||
|
} else {
|
||||||
|
callbacks->didFail(webkit_glue::PlatformFileErrorToWebFileError(result));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BrowserFileSystem::DidReadDirectory(
|
||||||
|
WebFileSystemCallbacks* callbacks,
|
||||||
|
base::PlatformFileError result,
|
||||||
|
const std::vector<base::FileUtilProxy::Entry>& entries,
|
||||||
|
bool has_more) {
|
||||||
|
if (result == base::PLATFORM_FILE_OK) {
|
||||||
|
std::vector<WebFileSystemEntry> web_entries_vector;
|
||||||
|
for (std::vector<base::FileUtilProxy::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);
|
||||||
|
} else {
|
||||||
|
callbacks->didFail(webkit_glue::PlatformFileErrorToWebFileError(result));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BrowserFileSystem::DidOpenFileSystem(
|
||||||
|
WebFileSystemCallbacks* callbacks,
|
||||||
|
base::PlatformFileError result,
|
||||||
|
const std::string& name, const GURL& root) {
|
||||||
|
if (result == base::PLATFORM_FILE_OK) {
|
||||||
|
if (!root.is_valid())
|
||||||
|
callbacks->didFail(WebKit::WebFileErrorSecurity);
|
||||||
|
else
|
||||||
|
callbacks->didOpenFileSystem(WebString::fromUTF8(name), root);
|
||||||
|
} else {
|
||||||
|
callbacks->didFail(webkit_glue::PlatformFileErrorToWebFileError(result));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
#include "base/memory/weak_ptr.h"
|
#include "base/memory/weak_ptr.h"
|
||||||
#include "base/scoped_temp_dir.h"
|
#include "base/scoped_temp_dir.h"
|
||||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFileSystem.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_types.h"
|
#include "webkit/fileapi/file_system_types.h"
|
||||||
|
|
||||||
namespace WebKit {
|
namespace WebKit {
|
||||||
@ -23,7 +25,6 @@ class WebURL;
|
|||||||
|
|
||||||
namespace fileapi {
|
namespace fileapi {
|
||||||
class FileSystemContext;
|
class FileSystemContext;
|
||||||
class FileSystemOperationInterface;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class BrowserFileSystem
|
class BrowserFileSystem
|
||||||
@ -86,7 +87,31 @@ class BrowserFileSystem
|
|||||||
private:
|
private:
|
||||||
// Helpers.
|
// Helpers.
|
||||||
fileapi::FileSystemOperationInterface* GetNewOperation(
|
fileapi::FileSystemOperationInterface* GetNewOperation(
|
||||||
const WebKit::WebURL& path, WebKit::WebFileSystemCallbacks* callbacks);
|
const WebKit::WebURL& path);
|
||||||
|
|
||||||
|
// Callback Handlers
|
||||||
|
fileapi::FileSystemOperationInterface::StatusCallback FinishHandler(
|
||||||
|
WebKit::WebFileSystemCallbacks* callbacks);
|
||||||
|
fileapi::FileSystemOperationInterface::GetMetadataCallback GetMetadataHandler(
|
||||||
|
WebKit::WebFileSystemCallbacks* callbacks);
|
||||||
|
fileapi::FileSystemOperationInterface::ReadDirectoryCallback
|
||||||
|
ReadDirectoryHandler(WebKit::WebFileSystemCallbacks* callbacks);
|
||||||
|
fileapi::FileSystemContext::OpenFileSystemCallback OpenFileSystemHandler(
|
||||||
|
WebKit::WebFileSystemCallbacks* callbacks);
|
||||||
|
void DidFinish(WebKit::WebFileSystemCallbacks* callbacks,
|
||||||
|
base::PlatformFileError result);
|
||||||
|
void DidGetMetadata(WebKit::WebFileSystemCallbacks* callbacks,
|
||||||
|
base::PlatformFileError result,
|
||||||
|
const base::PlatformFileInfo& info,
|
||||||
|
const FilePath& platform_path);
|
||||||
|
void DidReadDirectory(
|
||||||
|
WebKit::WebFileSystemCallbacks* callbacks,
|
||||||
|
base::PlatformFileError result,
|
||||||
|
const std::vector<base::FileUtilProxy::Entry>& entries,
|
||||||
|
bool has_more);
|
||||||
|
void DidOpenFileSystem(WebKit::WebFileSystemCallbacks* callbacks,
|
||||||
|
base::PlatformFileError result,
|
||||||
|
const std::string& name, const GURL& root);
|
||||||
|
|
||||||
// A temporary directory for FileSystem API.
|
// A temporary directory for FileSystem API.
|
||||||
ScopedTempDir file_system_dir_;
|
ScopedTempDir file_system_dir_;
|
||||||
|
@ -9,12 +9,10 @@
|
|||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/message_loop_proxy.h"
|
#include "base/message_loop_proxy.h"
|
||||||
#include "net/url_request/url_request_context.h"
|
#include "net/url_request/url_request_context.h"
|
||||||
#include "webkit/fileapi/file_system_callback_dispatcher.h"
|
|
||||||
#include "webkit/fileapi/file_system_context.h"
|
#include "webkit/fileapi/file_system_context.h"
|
||||||
#include "webkit/fileapi/file_system_operation_interface.h"
|
#include "webkit/fileapi/file_system_operation_interface.h"
|
||||||
#include "webkit/glue/webkit_glue.h"
|
#include "webkit/glue/webkit_glue.h"
|
||||||
|
|
||||||
using fileapi::FileSystemCallbackDispatcher;
|
|
||||||
using fileapi::FileSystemContext;
|
using fileapi::FileSystemContext;
|
||||||
using fileapi::FileSystemOperationInterface;
|
using fileapi::FileSystemOperationInterface;
|
||||||
using fileapi::WebFileWriterBase;
|
using fileapi::WebFileWriterBase;
|
||||||
@ -51,7 +49,8 @@ class BrowserFileWriter::IOThreadProxy
|
|||||||
}
|
}
|
||||||
DCHECK(!operation_);
|
DCHECK(!operation_);
|
||||||
operation_ = GetNewOperation(path);
|
operation_ = GetNewOperation(path);
|
||||||
operation_->Truncate(path, offset);
|
operation_->Truncate(path, offset,
|
||||||
|
base::Bind(&IOThreadProxy::DidFinish, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Write(const GURL& path, const GURL& blob_url, int64 offset) {
|
void Write(const GURL& path, const GURL& blob_url, int64 offset) {
|
||||||
@ -64,7 +63,8 @@ class BrowserFileWriter::IOThreadProxy
|
|||||||
DCHECK(request_context_);
|
DCHECK(request_context_);
|
||||||
DCHECK(!operation_);
|
DCHECK(!operation_);
|
||||||
operation_ = GetNewOperation(path);
|
operation_ = GetNewOperation(path);
|
||||||
operation_->Write(request_context_, path, blob_url, offset);
|
operation_->Write(request_context_, path, blob_url, offset,
|
||||||
|
base::Bind(&IOThreadProxy::DidWrite, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cancel() {
|
void Cancel() {
|
||||||
@ -75,96 +75,45 @@ class BrowserFileWriter::IOThreadProxy
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!operation_) {
|
if (!operation_) {
|
||||||
DidFail(base::PLATFORM_FILE_ERROR_INVALID_OPERATION);
|
DidFailOnMainThread(base::PLATFORM_FILE_ERROR_INVALID_OPERATION);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
operation_->Cancel(CallbackDispatcher::Create(this));
|
operation_->Cancel(base::Bind(&IOThreadProxy::DidFinish, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Inner class to receive callbacks from FileSystemOperation.
|
|
||||||
class CallbackDispatcher : public FileSystemCallbackDispatcher {
|
|
||||||
public:
|
|
||||||
// An instance of this class must be created by Create()
|
|
||||||
// (so that we do not leak ownerships).
|
|
||||||
static scoped_ptr<FileSystemCallbackDispatcher> Create(
|
|
||||||
IOThreadProxy* proxy) {
|
|
||||||
return scoped_ptr<FileSystemCallbackDispatcher>(
|
|
||||||
new CallbackDispatcher(proxy));
|
|
||||||
}
|
|
||||||
|
|
||||||
~CallbackDispatcher() {
|
|
||||||
proxy_->ClearOperation();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void DidSucceed() {
|
|
||||||
proxy_->DidSucceed();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void DidFail(base::PlatformFileError error_code) {
|
|
||||||
proxy_->DidFail(error_code);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void DidWrite(int64 bytes, bool complete) {
|
|
||||||
proxy_->DidWrite(bytes, complete);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void DidReadMetadata(
|
|
||||||
const base::PlatformFileInfo&,
|
|
||||||
const FilePath&) {
|
|
||||||
NOTREACHED();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void DidReadDirectory(
|
|
||||||
const std::vector<base::FileUtilProxy::Entry>& entries,
|
|
||||||
bool has_more) {
|
|
||||||
NOTREACHED();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void DidOpenFileSystem(
|
|
||||||
const std::string& name,
|
|
||||||
const GURL& root) {
|
|
||||||
NOTREACHED();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
explicit CallbackDispatcher(IOThreadProxy* proxy) : proxy_(proxy) {}
|
|
||||||
scoped_refptr<IOThreadProxy> proxy_;
|
|
||||||
};
|
|
||||||
|
|
||||||
FileSystemOperationInterface* GetNewOperation(const GURL& path) {
|
FileSystemOperationInterface* GetNewOperation(const GURL& path) {
|
||||||
// The FileSystemOperation takes ownership of the CallbackDispatcher.
|
return file_system_context_->CreateFileSystemOperation(path, io_thread_);
|
||||||
return file_system_context_->CreateFileSystemOperation(
|
|
||||||
path, CallbackDispatcher::Create(this), io_thread_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DidSucceed() {
|
void DidSucceedOnMainThread() {
|
||||||
if (!main_thread_->BelongsToCurrentThread()) {
|
if (!main_thread_->BelongsToCurrentThread()) {
|
||||||
main_thread_->PostTask(
|
main_thread_->PostTask(
|
||||||
FROM_HERE,
|
FROM_HERE,
|
||||||
base::Bind(&IOThreadProxy::DidSucceed, this));
|
base::Bind(&IOThreadProxy::DidSucceedOnMainThread, this));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (simple_writer_)
|
if (simple_writer_)
|
||||||
simple_writer_->DidSucceed();
|
simple_writer_->DidSucceed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DidFail(base::PlatformFileError error_code) {
|
void DidFailOnMainThread(base::PlatformFileError error_code) {
|
||||||
if (!main_thread_->BelongsToCurrentThread()) {
|
if (!main_thread_->BelongsToCurrentThread()) {
|
||||||
main_thread_->PostTask(
|
main_thread_->PostTask(
|
||||||
FROM_HERE,
|
FROM_HERE,
|
||||||
base::Bind(&IOThreadProxy::DidFail, this, error_code));
|
base::Bind(&IOThreadProxy::DidFailOnMainThread, this, error_code));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (simple_writer_)
|
if (simple_writer_)
|
||||||
simple_writer_->DidFail(error_code);
|
simple_writer_->DidFail(error_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DidWrite(int64 bytes, bool complete) {
|
void DidWriteOnMainThread(int64 bytes, bool complete) {
|
||||||
if (!main_thread_->BelongsToCurrentThread()) {
|
if (!main_thread_->BelongsToCurrentThread()) {
|
||||||
main_thread_->PostTask(
|
main_thread_->PostTask(
|
||||||
FROM_HERE,
|
FROM_HERE,
|
||||||
base::Bind(&IOThreadProxy::DidWrite, this, bytes, complete));
|
base::Bind(&IOThreadProxy::DidWriteOnMainThread,
|
||||||
|
this, bytes, complete));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (simple_writer_)
|
if (simple_writer_)
|
||||||
@ -176,6 +125,25 @@ class BrowserFileWriter::IOThreadProxy
|
|||||||
operation_ = NULL;
|
operation_ = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DidFinish(base::PlatformFileError result) {
|
||||||
|
if (result == base::PLATFORM_FILE_OK)
|
||||||
|
DidSucceedOnMainThread();
|
||||||
|
else
|
||||||
|
DidFailOnMainThread(result);
|
||||||
|
ClearOperation();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DidWrite(base::PlatformFileError result, int64 bytes, bool complete) {
|
||||||
|
if (result == base::PLATFORM_FILE_OK) {
|
||||||
|
DidWriteOnMainThread(bytes, complete);
|
||||||
|
if (complete)
|
||||||
|
ClearOperation();
|
||||||
|
} else {
|
||||||
|
DidFailOnMainThread(result);
|
||||||
|
ClearOperation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
scoped_refptr<base::MessageLoopProxy> io_thread_;
|
scoped_refptr<base::MessageLoopProxy> io_thread_;
|
||||||
scoped_refptr<base::MessageLoopProxy> main_thread_;
|
scoped_refptr<base::MessageLoopProxy> main_thread_;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2011 The Chromium Embedded Framework Authors.
|
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
|
||||||
// Portions copyright (c) 2011 The Chromium Authors. All rights reserved.
|
// Portions copyright (c) 2011 The Chromium Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
@ -345,8 +345,9 @@ bool BrowserPersistentCookieStore::Backend::InitializeDatabase() {
|
|||||||
sql::Statement smt(db_->GetUniqueStatement(
|
sql::Statement smt(db_->GetUniqueStatement(
|
||||||
"SELECT DISTINCT host_key FROM cookies"));
|
"SELECT DISTINCT host_key FROM cookies"));
|
||||||
|
|
||||||
if (!smt) {
|
if (!smt.is_valid()) {
|
||||||
NOTREACHED() << "select statement prep failed";
|
NOTREACHED() << "select statement prep failed";
|
||||||
|
smt.Clear(); // Disconnect smt_ref from db_.
|
||||||
db_.reset();
|
db_.reset();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -398,7 +399,7 @@ void BrowserPersistentCookieStore::Backend::ChainLoadCookies(
|
|||||||
CefThread::IO, FROM_HERE,
|
CefThread::IO, FROM_HERE,
|
||||||
base::Bind(&BrowserPersistentCookieStore::Backend::NotifyOnIOThread,
|
base::Bind(&BrowserPersistentCookieStore::Backend::NotifyOnIOThread,
|
||||||
this, loaded_callback, load_success));
|
this, loaded_callback, load_success));
|
||||||
if (!restore_old_session_cookies_)
|
if (load_success && !restore_old_session_cookies_)
|
||||||
DeleteSessionCookies();
|
DeleteSessionCookies();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -421,8 +422,9 @@ bool BrowserPersistentCookieStore::Backend::LoadCookiesForDomains(
|
|||||||
"secure, httponly, last_access_utc, has_expires, persistent "
|
"secure, httponly, last_access_utc, has_expires, persistent "
|
||||||
"FROM cookies WHERE host_key = ? AND persistent = 1"));
|
"FROM cookies WHERE host_key = ? AND persistent = 1"));
|
||||||
}
|
}
|
||||||
if (!smt) {
|
if (!smt.is_valid()) {
|
||||||
NOTREACHED() << "select statement prep failed";
|
NOTREACHED() << "select statement prep failed";
|
||||||
|
smt.Clear(); // Disconnect smt_ref from db_.
|
||||||
db_.reset();
|
db_.reset();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ struct RequestParams {
|
|||||||
// The interval for calls to RequestProxy::MaybeUpdateUploadProgress
|
// The interval for calls to RequestProxy::MaybeUpdateUploadProgress
|
||||||
static const int kUpdateUploadProgressIntervalMsec = 100;
|
static const int kUpdateUploadProgressIntervalMsec = 100;
|
||||||
|
|
||||||
class ExtraRequestInfo : public net::URLRequest::UserData {
|
class ExtraRequestInfo : public net::URLRequest::Data {
|
||||||
public:
|
public:
|
||||||
ExtraRequestInfo(CefBrowser* browser, ResourceType::Type resource_type)
|
ExtraRequestInfo(CefBrowser* browser, ResourceType::Type resource_type)
|
||||||
: browser_(browser),
|
: browser_(browser),
|
||||||
@ -197,6 +197,7 @@ class RequestProxy : public net::URLRequest::Delegate,
|
|||||||
// Takes ownership of the params.
|
// Takes ownership of the params.
|
||||||
explicit RequestProxy(CefRefPtr<CefBrowser> browser)
|
explicit RequestProxy(CefRefPtr<CefBrowser> browser)
|
||||||
: download_to_file_(false),
|
: download_to_file_(false),
|
||||||
|
file_stream_(NULL),
|
||||||
buf_(new net::IOBuffer(kDataSize)),
|
buf_(new net::IOBuffer(kDataSize)),
|
||||||
browser_(browser),
|
browser_(browser),
|
||||||
last_upload_position_(0),
|
last_upload_position_(0),
|
||||||
@ -584,7 +585,7 @@ class RequestProxy : public net::URLRequest::Delegate,
|
|||||||
if (file_util::CreateTemporaryFile(&path)) {
|
if (file_util::CreateTemporaryFile(&path)) {
|
||||||
downloaded_file_ = DeletableFileReference::GetOrCreate(
|
downloaded_file_ = DeletableFileReference::GetOrCreate(
|
||||||
path, base::MessageLoopProxy::current());
|
path, base::MessageLoopProxy::current());
|
||||||
file_stream_.Open(
|
file_stream_.OpenSync(
|
||||||
path, base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE);
|
path, base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -706,7 +707,7 @@ class RequestProxy : public net::URLRequest::Delegate,
|
|||||||
|
|
||||||
virtual void OnReceivedData(int bytes_read) {
|
virtual void OnReceivedData(int bytes_read) {
|
||||||
if (download_to_file_) {
|
if (download_to_file_) {
|
||||||
file_stream_.Write(buf_->data(), bytes_read, net::CompletionCallback());
|
file_stream_.WriteSync(buf_->data(), bytes_read);
|
||||||
owner_loop_->PostTask(FROM_HERE, base::Bind(
|
owner_loop_->PostTask(FROM_HERE, base::Bind(
|
||||||
&RequestProxy::NotifyDownloadedData, this, bytes_read));
|
&RequestProxy::NotifyDownloadedData, this, bytes_read));
|
||||||
return;
|
return;
|
||||||
@ -720,7 +721,7 @@ class RequestProxy : public net::URLRequest::Delegate,
|
|||||||
const std::string& security_info,
|
const std::string& security_info,
|
||||||
const base::TimeTicks& complete_time) {
|
const base::TimeTicks& complete_time) {
|
||||||
if (download_to_file_)
|
if (download_to_file_)
|
||||||
file_stream_.Close();
|
file_stream_.CloseSync();
|
||||||
|
|
||||||
owner_loop_->PostTask(FROM_HERE, base::Bind(
|
owner_loop_->PostTask(FROM_HERE, base::Bind(
|
||||||
&RequestProxy::NotifyCompletedRequest, this, status, security_info,
|
&RequestProxy::NotifyCompletedRequest, this, status, security_info,
|
||||||
@ -849,7 +850,9 @@ class RequestProxy : public net::URLRequest::Delegate,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64 size = request_->get_upload()->GetContentLength();
|
// GetContentLengthSync() may perform file IO, but it's ok here, as file
|
||||||
|
// IO is not prohibited in IOThread defined in the file.
|
||||||
|
uint64 size = request_->get_upload()->GetContentLengthSync();
|
||||||
uint64 position = request_->GetUploadProgress();
|
uint64 position = request_->GetUploadProgress();
|
||||||
if (position == last_upload_position_)
|
if (position == last_upload_position_)
|
||||||
return; // no progress made since last time
|
return; // no progress made since last time
|
||||||
@ -969,7 +972,7 @@ class SyncRequestProxy : public RequestProxy {
|
|||||||
|
|
||||||
virtual void OnReceivedData(int bytes_read) {
|
virtual void OnReceivedData(int bytes_read) {
|
||||||
if (download_to_file_)
|
if (download_to_file_)
|
||||||
file_stream_.Write(buf_->data(), bytes_read, net::CompletionCallback());
|
file_stream_.WriteSync(buf_->data(), bytes_read);
|
||||||
else
|
else
|
||||||
result_->data.append(buf_->data(), bytes_read);
|
result_->data.append(buf_->data(), bytes_read);
|
||||||
AsyncReadData(); // read more (may recurse)
|
AsyncReadData(); // read more (may recurse)
|
||||||
@ -979,7 +982,7 @@ class SyncRequestProxy : public RequestProxy {
|
|||||||
const std::string& security_info,
|
const std::string& security_info,
|
||||||
const base::TimeTicks& complete_time) {
|
const base::TimeTicks& complete_time) {
|
||||||
if (download_to_file_)
|
if (download_to_file_)
|
||||||
file_stream_.Close();
|
file_stream_.CloseSync();
|
||||||
|
|
||||||
result_->status = status;
|
result_->status = status;
|
||||||
event_.Signal();
|
event_.Signal();
|
||||||
|
@ -23,6 +23,8 @@ MSVC_POP_WARNING();
|
|||||||
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
|
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
|
||||||
#include "webkit/glue/user_agent.h"
|
#include "webkit/glue/user_agent.h"
|
||||||
#include "webkit/glue/webkit_glue.h"
|
#include "webkit/glue/webkit_glue.h"
|
||||||
|
#include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h"
|
||||||
|
#include "webkit/gpu/webgraphicscontext3d_in_process_impl.h"
|
||||||
#include "webkit/plugins/npapi/plugin_list.h"
|
#include "webkit/plugins/npapi/plugin_list.h"
|
||||||
|
|
||||||
// Generated by GRIT
|
// Generated by GRIT
|
||||||
@ -132,4 +134,30 @@ bool IsPluginEnabled(const webkit::WebPluginInfo& plugin) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebKit::WebGraphicsContext3D* CreateGraphicsContext3D(
|
||||||
|
cef_graphics_implementation_t graphics_implementation,
|
||||||
|
const WebKit::WebGraphicsContext3D::Attributes& attributes,
|
||||||
|
bool renderDirectlyToWebView) {
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
bool use_command_buffer =
|
||||||
|
(graphics_implementation == ANGLE_IN_PROCESS_COMMAND_BUFFER ||
|
||||||
|
graphics_implementation == DESKTOP_IN_PROCESS_COMMAND_BUFFER);
|
||||||
|
#else
|
||||||
|
bool use_command_buffer =
|
||||||
|
(graphics_implementation == DESKTOP_IN_PROCESS_COMMAND_BUFFER);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (use_command_buffer) {
|
||||||
|
scoped_ptr<webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl>
|
||||||
|
context(
|
||||||
|
new webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl());
|
||||||
|
if (!context->initialize(attributes, NULL, renderDirectlyToWebView))
|
||||||
|
return NULL;
|
||||||
|
return context.release();
|
||||||
|
} else {
|
||||||
|
return webkit::gpu::WebGraphicsContext3DInProcessImpl::CreateForWebView(
|
||||||
|
attributes, NULL, renderDirectlyToWebView);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace webkit_glue
|
} // namespace webkit_glue
|
||||||
|
@ -8,7 +8,10 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "include/internal/cef_types.h"
|
||||||
|
|
||||||
#include "base/compiler_specific.h"
|
#include "base/compiler_specific.h"
|
||||||
|
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsContext3D.h"
|
||||||
#include "v8/include/v8.h"
|
#include "v8/include/v8.h"
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
@ -51,6 +54,12 @@ bool ShouldDownload(const std::string& content_disposition,
|
|||||||
// Checks whether a plugin is enabled either by the user or by policy.
|
// Checks whether a plugin is enabled either by the user or by policy.
|
||||||
bool IsPluginEnabled(const webkit::WebPluginInfo& plugin);
|
bool IsPluginEnabled(const webkit::WebPluginInfo& plugin);
|
||||||
|
|
||||||
|
// Create a new WebGraphicsContext3D object.
|
||||||
|
WebKit::WebGraphicsContext3D* CreateGraphicsContext3D(
|
||||||
|
cef_graphics_implementation_t graphics_implementation,
|
||||||
|
const WebKit::WebGraphicsContext3D::Attributes& attributes,
|
||||||
|
bool renderDirectlyToWebView);
|
||||||
|
|
||||||
} // namespace webkit_glue
|
} // namespace webkit_glue
|
||||||
|
|
||||||
#endif // CEF_LIBCEF_BROWSER_WEBKIT_GLUE_H_
|
#endif // CEF_LIBCEF_BROWSER_WEBKIT_GLUE_H_
|
||||||
|
@ -21,8 +21,6 @@
|
|||||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKey.h"
|
#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKey.h"
|
||||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyPath.h"
|
#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyPath.h"
|
||||||
#include "v8/include/v8.h"
|
#include "v8/include/v8.h"
|
||||||
#include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h"
|
|
||||||
#include "webkit/gpu/webgraphicscontext3d_in_process_impl.h"
|
|
||||||
#include "webkit/plugins/npapi/plugin_list.h"
|
#include "webkit/plugins/npapi/plugin_list.h"
|
||||||
|
|
||||||
|
|
||||||
@ -174,18 +172,6 @@ void BrowserWebKitInit::histogramEnumeration(const char* name, int sample,
|
|||||||
int boundary_value) {
|
int boundary_value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BrowserWebKitInit::isTraceEventEnabled() const {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BrowserWebKitInit::traceEventBegin(const char* name, void* id,
|
|
||||||
const char* extra) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void BrowserWebKitInit::traceEventEnd(const char* name, void* id,
|
|
||||||
const char* extra) {
|
|
||||||
}
|
|
||||||
|
|
||||||
WebKit::WebData BrowserWebKitInit::loadResource(const char* name) {
|
WebKit::WebData BrowserWebKitInit::loadResource(const char* name) {
|
||||||
if (!strcmp(name, "deleteButton")) {
|
if (!strcmp(name, "deleteButton")) {
|
||||||
// Create a red 30x30 square.
|
// Create a red 30x30 square.
|
||||||
@ -247,23 +233,12 @@ BrowserWebKitInit::injectIDBKeyIntoSerializedValue(
|
|||||||
key, value, WebKit::WebIDBKeyPath::create(keyPath));
|
key, value, WebKit::WebIDBKeyPath::create(keyPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
WebKit::WebGraphicsContext3D* BrowserWebKitInit::createGraphicsContext3D() {
|
WebKit::WebGraphicsContext3D*
|
||||||
|
BrowserWebKitInit::createOffscreenGraphicsContext3D(
|
||||||
|
const WebKit::WebGraphicsContext3D::Attributes& attributes) {
|
||||||
const CefSettings& settings = _Context->settings();
|
const CefSettings& settings = _Context->settings();
|
||||||
#if defined(OS_WIN)
|
return webkit_glue::CreateGraphicsContext3D(settings.graphics_implementation,
|
||||||
bool use_command_buffer =
|
attributes, false);
|
||||||
(settings.graphics_implementation == ANGLE_IN_PROCESS_COMMAND_BUFFER ||
|
|
||||||
settings.graphics_implementation == DESKTOP_IN_PROCESS_COMMAND_BUFFER);
|
|
||||||
#else
|
|
||||||
bool use_command_buffer =
|
|
||||||
(settings.graphics_implementation == DESKTOP_IN_PROCESS_COMMAND_BUFFER);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (use_command_buffer) {
|
|
||||||
return new webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl();
|
|
||||||
} else {
|
|
||||||
return new webkit::gpu::WebGraphicsContext3DInProcessImpl(
|
|
||||||
gfx::kNullPluginWindow, NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserWebKitInit::GetPlugins(
|
void BrowserWebKitInit::GetPlugins(
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "libcef/simple_clipboard_impl.h"
|
#include "libcef/simple_clipboard_impl.h"
|
||||||
|
|
||||||
#include "base/scoped_temp_dir.h"
|
#include "base/scoped_temp_dir.h"
|
||||||
|
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsContext3D.h"
|
||||||
#include "webkit/glue/simple_webmimeregistry_impl.h"
|
#include "webkit/glue/simple_webmimeregistry_impl.h"
|
||||||
#include "webkit/glue/webclipboard_impl.h"
|
#include "webkit/glue/webclipboard_impl.h"
|
||||||
#include "webkit/glue/webfileutilities_impl.h"
|
#include "webkit/glue/webfileutilities_impl.h"
|
||||||
@ -58,11 +59,6 @@ class BrowserWebKitInit : public webkit_glue::WebKitPlatformSupportImpl {
|
|||||||
int max, int bucket_count) OVERRIDE;
|
int max, int bucket_count) OVERRIDE;
|
||||||
virtual void histogramEnumeration(const char* name, int sample,
|
virtual void histogramEnumeration(const char* name, int sample,
|
||||||
int boundary_value) OVERRIDE;
|
int boundary_value) OVERRIDE;
|
||||||
virtual bool isTraceEventEnabled() const OVERRIDE;
|
|
||||||
virtual void traceEventBegin(const char* name, void* id,
|
|
||||||
const char* extra) OVERRIDE;
|
|
||||||
virtual void traceEventEnd(const char* name, void* id,
|
|
||||||
const char* extra) OVERRIDE;
|
|
||||||
virtual WebKit::WebData loadResource(const char* name) OVERRIDE;
|
virtual WebKit::WebData loadResource(const char* name) OVERRIDE;
|
||||||
virtual WebKit::WebString defaultLocale() OVERRIDE;
|
virtual WebKit::WebString defaultLocale() OVERRIDE;
|
||||||
virtual WebKit::WebStorageNamespace* createLocalStorageNamespace(
|
virtual WebKit::WebStorageNamespace* createLocalStorageNamespace(
|
||||||
@ -80,7 +76,8 @@ class BrowserWebKitInit : public webkit_glue::WebKitPlatformSupportImpl {
|
|||||||
const WebKit::WebIDBKey& key,
|
const WebKit::WebIDBKey& key,
|
||||||
const WebKit::WebSerializedScriptValue& value,
|
const WebKit::WebSerializedScriptValue& value,
|
||||||
const WebKit::WebString& keyPath) OVERRIDE;
|
const WebKit::WebString& keyPath) OVERRIDE;
|
||||||
virtual WebKit::WebGraphicsContext3D* createGraphicsContext3D() OVERRIDE;
|
virtual WebKit::WebGraphicsContext3D* createOffscreenGraphicsContext3D(
|
||||||
|
const WebKit::WebGraphicsContext3D::Attributes& attributes) OVERRIDE;
|
||||||
virtual string16 GetLocalizedString(int message_id) OVERRIDE;
|
virtual string16 GetLocalizedString(int message_id) OVERRIDE;
|
||||||
virtual base::StringPiece GetDataResource(int resource_id) OVERRIDE;
|
virtual base::StringPiece GetDataResource(int resource_id) OVERRIDE;
|
||||||
virtual void GetPlugins(bool refresh,
|
virtual void GetPlugins(bool refresh,
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
#include "media/base/filter_collection.h"
|
#include "media/base/filter_collection.h"
|
||||||
#include "media/base/media_log.h"
|
#include "media/base/media_log.h"
|
||||||
#include "media/base/message_loop_factory_impl.h"
|
#include "media/base/message_loop_factory_impl.h"
|
||||||
#include "media/filters/reference_audio_renderer.h"
|
#include "media/filters/null_audio_renderer.h"
|
||||||
#include "net/base/net_errors.h"
|
#include "net/base/net_errors.h"
|
||||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h"
|
#include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h"
|
||||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h"
|
#include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h"
|
||||||
@ -192,6 +192,14 @@ WebStorageNamespace* BrowserWebViewDelegate::createSessionStorageNamespace(
|
|||||||
kLocalStorageNamespaceId + 1);
|
kLocalStorageNamespaceId + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebKit::WebGraphicsContext3D* BrowserWebViewDelegate::createGraphicsContext3D(
|
||||||
|
const WebKit::WebGraphicsContext3D::Attributes& attributes,
|
||||||
|
bool renderDirectlyToWebView) {
|
||||||
|
const CefSettings& settings = _Context->settings();
|
||||||
|
return webkit_glue::CreateGraphicsContext3D(settings.graphics_implementation,
|
||||||
|
attributes, renderDirectlyToWebView);
|
||||||
|
}
|
||||||
|
|
||||||
void BrowserWebViewDelegate::didAddMessageToConsole(
|
void BrowserWebViewDelegate::didAddMessageToConsole(
|
||||||
const WebConsoleMessage& message, const WebString& source_name,
|
const WebConsoleMessage& message, const WebString& source_name,
|
||||||
unsigned source_line) {
|
unsigned source_line) {
|
||||||
@ -661,8 +669,8 @@ WebMediaPlayer* BrowserWebViewDelegate::createMediaPlayer(
|
|||||||
new media::FilterCollection());
|
new media::FilterCollection());
|
||||||
|
|
||||||
// Add the audio renderer.
|
// Add the audio renderer.
|
||||||
collection->AddAudioRenderer(new media::ReferenceAudioRenderer(
|
// TODO(vrk): Re-enable audio. (crbug.com/112159)
|
||||||
_Context->process()->ui_thread()->audio_manager()));
|
collection->AddAudioRenderer(new media::NullAudioRenderer());
|
||||||
|
|
||||||
return new webkit_media::WebMediaPlayerImpl(
|
return new webkit_media::WebMediaPlayerImpl(
|
||||||
frame,
|
frame,
|
||||||
|
@ -74,6 +74,9 @@ class BrowserWebViewDelegate : public WebKit::WebViewClient,
|
|||||||
WebKit::WebExternalPopupMenuClient* client) OVERRIDE;
|
WebKit::WebExternalPopupMenuClient* client) OVERRIDE;
|
||||||
virtual WebKit::WebStorageNamespace* createSessionStorageNamespace(
|
virtual WebKit::WebStorageNamespace* createSessionStorageNamespace(
|
||||||
unsigned quota) OVERRIDE;
|
unsigned quota) OVERRIDE;
|
||||||
|
virtual WebKit::WebGraphicsContext3D* createGraphicsContext3D(
|
||||||
|
const WebKit::WebGraphicsContext3D::Attributes& attributes,
|
||||||
|
bool renderDirectlyToWebView) OVERRIDE;
|
||||||
virtual void didAddMessageToConsole(
|
virtual void didAddMessageToConsole(
|
||||||
const WebKit::WebConsoleMessage& message,
|
const WebKit::WebConsoleMessage& message,
|
||||||
const WebKit::WebString& source_name, unsigned source_line) OVERRIDE;
|
const WebKit::WebString& source_name, unsigned source_line) OVERRIDE;
|
||||||
|
@ -197,7 +197,7 @@ void BrowserWebViewDelegate::show(WebNavigationPolicy policy) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BrowserWebViewDelegate::didChangeCursor(const WebCursorInfo& cursor_info) {
|
void BrowserWebViewDelegate::didChangeCursor(const WebCursorInfo& cursor_info) {
|
||||||
NSCursor* ns_cursor = WebCursor(cursor_info).GetCursor();
|
NSCursor* ns_cursor = WebCursor(cursor_info).GetNativeCursor();
|
||||||
[ns_cursor set];
|
[ns_cursor set];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,14 +213,6 @@ void CefProcessUIThread::CleanUp() {
|
|||||||
_Context->CleanupResourceBundle();
|
_Context->CleanupResourceBundle();
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioManager* CefProcessUIThread::audio_manager() {
|
|
||||||
DCHECK(CefThread::CurrentlyOn(CefThread::UI));
|
|
||||||
if (!audio_manager_)
|
|
||||||
audio_manager_ = AudioManager::Create();
|
|
||||||
|
|
||||||
return audio_manager_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefProcessUIThread::OnOnlineStateChanged(bool online) {
|
void CefProcessUIThread::OnOnlineStateChanged(bool online) {
|
||||||
DCHECK(CefThread::CurrentlyOn(CefThread::UI));
|
DCHECK(CefThread::CurrentlyOn(CefThread::UI));
|
||||||
WebKit::WebNetworkStateNotifier::setOnLine(online);
|
WebKit::WebNetworkStateNotifier::setOnLine(online);
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
#include "base/basictypes.h"
|
#include "base/basictypes.h"
|
||||||
#include "base/memory/scoped_ptr.h"
|
#include "base/memory/scoped_ptr.h"
|
||||||
#include "media/audio/audio_manager.h"
|
|
||||||
#include "net/base/network_change_notifier.h"
|
#include "net/base/network_change_notifier.h"
|
||||||
|
|
||||||
class BrowserWebKitInit;
|
class BrowserWebKitInit;
|
||||||
@ -39,8 +38,6 @@ class CefProcessUIThread
|
|||||||
virtual void Init();
|
virtual void Init();
|
||||||
virtual void CleanUp();
|
virtual void CleanUp();
|
||||||
|
|
||||||
AudioManager* audio_manager();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void PlatformInit();
|
void PlatformInit();
|
||||||
void PlatformCleanUp();
|
void PlatformCleanUp();
|
||||||
@ -54,7 +51,6 @@ class CefProcessUIThread
|
|||||||
BrowserWebKitInit* webkit_init_;
|
BrowserWebKitInit* webkit_init_;
|
||||||
|
|
||||||
scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_;
|
scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_;
|
||||||
scoped_refptr<AudioManager> audio_manager_;
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(CefProcessUIThread);
|
DISALLOW_COPY_AND_ASSIGN(CefProcessUIThread);
|
||||||
};
|
};
|
||||||
|
@ -10,15 +10,12 @@
|
|||||||
#include "libcef/browser_webkit_glue.h"
|
#include "libcef/browser_webkit_glue.h"
|
||||||
#include "libcef/cef_context.h"
|
#include "libcef/cef_context.h"
|
||||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
|
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
|
||||||
#include "third_party/WebKit/Source/WebKit/mac/WebCoreSupport/WebSystemInterface.h"
|
|
||||||
|
|
||||||
void CefProcessUIThread::PlatformInit() {
|
void CefProcessUIThread::PlatformInit() {
|
||||||
// The NSApplication instance must implement the CefAppProtocol protocol.
|
// The NSApplication instance must implement the CefAppProtocol protocol.
|
||||||
DCHECK([[NSApplication sharedApplication]
|
DCHECK([[NSApplication sharedApplication]
|
||||||
conformsToProtocol:@protocol(CefAppProtocol)]);
|
conformsToProtocol:@protocol(CefAppProtocol)]);
|
||||||
|
|
||||||
InitWebCoreSystemInterface();
|
|
||||||
|
|
||||||
// On Mac, the select popup menus are rendered by the browser.
|
// On Mac, the select popup menus are rendered by the browser.
|
||||||
WebKit::WebView::setUseExternalPopupMenus(true);
|
WebKit::WebView::setUseExternalPopupMenus(true);
|
||||||
}
|
}
|
||||||
|
@ -31,22 +31,12 @@ class CefThreadMessageLoopProxy : public MessageLoopProxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MessageLoopProxy implementation.
|
// MessageLoopProxy implementation.
|
||||||
virtual bool PostTask(const tracked_objects::Location& from_here,
|
|
||||||
const base::Closure& task) OVERRIDE {
|
|
||||||
return CefThread::PostTask(id_, from_here, task);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
|
virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
|
||||||
const base::Closure& task,
|
const base::Closure& task,
|
||||||
int64 delay_ms) OVERRIDE {
|
int64 delay_ms) OVERRIDE {
|
||||||
return CefThread::PostDelayedTask(id_, from_here, task, delay_ms);
|
return CefThread::PostDelayedTask(id_, from_here, task, delay_ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool PostNonNestableTask(const tracked_objects::Location& from_here,
|
|
||||||
const base::Closure& task) OVERRIDE {
|
|
||||||
return CefThread::PostNonNestableTask(id_, from_here, task);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool PostNonNestableDelayedTask(
|
virtual bool PostNonNestableDelayedTask(
|
||||||
const tracked_objects::Location& from_here,
|
const tracked_objects::Location& from_here,
|
||||||
const base::Closure& task,
|
const base::Closure& task,
|
||||||
@ -55,7 +45,7 @@ class CefThreadMessageLoopProxy : public MessageLoopProxy {
|
|||||||
delay_ms);
|
delay_ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool BelongsToCurrentThread() OVERRIDE {
|
virtual bool RunsTasksOnCurrentThread() const OVERRIDE {
|
||||||
return CefThread::CurrentlyOn(id_);
|
return CefThread::CurrentlyOn(id_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,22 +3,23 @@
|
|||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
#include "libcef/drag_data_impl.h"
|
#include "libcef/drag_data_impl.h"
|
||||||
|
#include "base/file_path.h"
|
||||||
|
|
||||||
CefDragDataImpl::CefDragDataImpl(const WebDropData& data)
|
CefDragDataImpl::CefDragDataImpl(const WebDropData& data)
|
||||||
: data_(data) {
|
: data_(data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CefDragDataImpl::IsLink() {
|
bool CefDragDataImpl::IsLink() {
|
||||||
return (data_.url.is_valid() && data_.file_extension.empty());
|
return (data_.url.is_valid() && data_.file_description_filename.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CefDragDataImpl::IsFragment() {
|
bool CefDragDataImpl::IsFragment() {
|
||||||
return (!data_.url.is_valid() && data_.file_extension.empty() &&
|
return (!data_.url.is_valid() && data_.file_description_filename.empty() &&
|
||||||
data_.filenames.empty());
|
data_.filenames.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CefDragDataImpl::IsFile() {
|
bool CefDragDataImpl::IsFile() {
|
||||||
return (!data_.file_extension.empty() || !data_.filenames.empty());
|
return (!data_.file_description_filename.empty() || !data_.filenames.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
CefString CefDragDataImpl::GetLinkURL() {
|
CefString CefDragDataImpl::GetLinkURL() {
|
||||||
@ -45,10 +46,6 @@ CefString CefDragDataImpl::GetFragmentBaseURL() {
|
|||||||
return data_.html_base_url.spec();
|
return data_.html_base_url.spec();
|
||||||
}
|
}
|
||||||
|
|
||||||
CefString CefDragDataImpl::GetFileExtension() {
|
|
||||||
return data_.file_extension;
|
|
||||||
}
|
|
||||||
|
|
||||||
CefString CefDragDataImpl::GetFileName() {
|
CefString CefDragDataImpl::GetFileName() {
|
||||||
return data_.file_description_filename;
|
return data_.file_description_filename;
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@ class CefDragDataImpl : public CefDragData {
|
|||||||
virtual CefString GetFragmentText();
|
virtual CefString GetFragmentText();
|
||||||
virtual CefString GetFragmentHtml();
|
virtual CefString GetFragmentHtml();
|
||||||
virtual CefString GetFragmentBaseURL();
|
virtual CefString GetFragmentBaseURL();
|
||||||
virtual CefString GetFileExtension();
|
|
||||||
virtual CefString GetFileName();
|
virtual CefString GetFileName();
|
||||||
virtual bool GetFileNames(std::vector<CefString>& names);
|
virtual bool GetFileNames(std::vector<CefString>& names);
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ bool ParseDownloadMetadata(const string16& metadata,
|
|||||||
FileStream* CreateFileStreamForDrop(FilePath* file_path) {
|
FileStream* CreateFileStreamForDrop(FilePath* file_path) {
|
||||||
DCHECK(file_path && !file_path->empty());
|
DCHECK(file_path && !file_path->empty());
|
||||||
|
|
||||||
scoped_ptr<FileStream> file_stream(new FileStream);
|
scoped_ptr<FileStream> file_stream(new FileStream(NULL));
|
||||||
const int kMaxSeq = 99;
|
const int kMaxSeq = 99;
|
||||||
for (int seq = 0; seq <= kMaxSeq; seq++) {
|
for (int seq = 0; seq <= kMaxSeq; seq++) {
|
||||||
FilePath new_file_path;
|
FilePath new_file_path;
|
||||||
@ -76,7 +76,7 @@ FileStream* CreateFileStreamForDrop(FilePath* file_path) {
|
|||||||
// Explicitly (and redundantly check) for file -- despite the fact that our
|
// Explicitly (and redundantly check) for file -- despite the fact that our
|
||||||
// open won't overwrite -- just to avoid log spew.
|
// open won't overwrite -- just to avoid log spew.
|
||||||
if (!file_util::PathExists(new_file_path) &&
|
if (!file_util::PathExists(new_file_path) &&
|
||||||
file_stream->Open(new_file_path, base::PLATFORM_FILE_CREATE |
|
file_stream->OpenSync(new_file_path, base::PLATFORM_FILE_CREATE |
|
||||||
base::PLATFORM_FILE_WRITE) == net::OK) {
|
base::PLATFORM_FILE_WRITE) == net::OK) {
|
||||||
*file_path = new_file_path;
|
*file_path = new_file_path;
|
||||||
return file_stream.release();
|
return file_stream.release();
|
||||||
|
@ -9,7 +9,11 @@
|
|||||||
#include "base/string16.h"
|
#include "base/string16.h"
|
||||||
#include "googleurl/src/gurl.h"
|
#include "googleurl/src/gurl.h"
|
||||||
#include "third_party/skia/include/core/SkBitmap.h"
|
#include "third_party/skia/include/core/SkBitmap.h"
|
||||||
|
#if defined(USE_SYSTEM_ZLIB)
|
||||||
|
#include <zlib.h>
|
||||||
|
#else
|
||||||
#include "third_party/zlib/zlib.h"
|
#include "third_party/zlib/zlib.h"
|
||||||
|
#endif
|
||||||
#include "ui/base/clipboard/clipboard.h"
|
#include "ui/base/clipboard/clipboard.h"
|
||||||
#include "ui/gfx/codec/png_codec.h"
|
#include "ui/gfx/codec/png_codec.h"
|
||||||
#include "ui/gfx/size.h"
|
#include "ui/gfx/size.h"
|
||||||
|
@ -45,6 +45,9 @@ struct WebDropData;
|
|||||||
|
|
||||||
// The URL to download from for a drag-out download.
|
// The URL to download from for a drag-out download.
|
||||||
GURL downloadURL_;
|
GURL downloadURL_;
|
||||||
|
|
||||||
|
// The file extension associated with the file drag, if any.
|
||||||
|
NSString* fileExtension_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize a WebDragSource object for a drag (originating on the given
|
// Initialize a WebDragSource object for a drag (originating on the given
|
||||||
|
@ -56,11 +56,12 @@ FilePath FilePathFromFilename(const string16& filename) {
|
|||||||
// TODO(viettrungluu): Refactor to make it common across platforms,
|
// TODO(viettrungluu): Refactor to make it common across platforms,
|
||||||
// and move it somewhere sensible.
|
// and move it somewhere sensible.
|
||||||
FilePath GetFileNameFromDragData(const WebDropData& drop_data) {
|
FilePath GetFileNameFromDragData(const WebDropData& drop_data) {
|
||||||
// Images without ALT text will only have a file extension so we need to
|
|
||||||
// synthesize one from the provided extension and URL.
|
|
||||||
FilePath file_name(FilePathFromFilename(drop_data.file_description_filename));
|
FilePath file_name(FilePathFromFilename(drop_data.file_description_filename));
|
||||||
|
std::string extension = file_name.Extension();
|
||||||
file_name = file_name.BaseName().RemoveExtension();
|
file_name = file_name.BaseName().RemoveExtension();
|
||||||
|
|
||||||
|
// Images without ALT text will only have a file extension so we need to
|
||||||
|
// synthesize one from the provided extension and URL.
|
||||||
if (file_name.empty()) {
|
if (file_name.empty()) {
|
||||||
// Retrieve the name from the URL.
|
// Retrieve the name from the URL.
|
||||||
string16 suggested_filename =
|
string16 suggested_filename =
|
||||||
@ -68,9 +69,7 @@ FilePath GetFileNameFromDragData(const WebDropData& drop_data) {
|
|||||||
file_name = FilePathFromFilename(suggested_filename);
|
file_name = FilePathFromFilename(suggested_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
file_name = file_name.ReplaceExtension(UTF16ToUTF8(drop_data.file_extension));
|
return file_name.ReplaceExtension(extension);
|
||||||
|
|
||||||
return file_name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This helper's sole task is to write out data for a promised file; the caller
|
// This helper's sole task is to write out data for a promised file; the caller
|
||||||
@ -79,11 +78,10 @@ FilePath GetFileNameFromDragData(const WebDropData& drop_data) {
|
|||||||
void PromiseWriterHelper(const WebDropData& drop_data,
|
void PromiseWriterHelper(const WebDropData& drop_data,
|
||||||
net::FileStream* file_stream) {
|
net::FileStream* file_stream) {
|
||||||
DCHECK(file_stream);
|
DCHECK(file_stream);
|
||||||
file_stream->Write(drop_data.file_contents.data(),
|
file_stream->WriteSync(drop_data.file_contents.data(),
|
||||||
drop_data.file_contents.length(),
|
drop_data.file_contents.length());
|
||||||
net::CompletionCallback());
|
|
||||||
|
|
||||||
file_stream->Close();
|
file_stream->CloseSync();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
@ -128,6 +126,8 @@ void PromiseWriterHelper(const WebDropData& drop_data,
|
|||||||
|
|
||||||
dragOperationMask_ = dragOperationMask;
|
dragOperationMask_ = dragOperationMask;
|
||||||
|
|
||||||
|
fileExtension_ = nil;
|
||||||
|
|
||||||
[self fillPasteboard];
|
[self fillPasteboard];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,8 +177,8 @@ void PromiseWriterHelper(const WebDropData& drop_data,
|
|||||||
|
|
||||||
// File contents.
|
// File contents.
|
||||||
} else if ([type isEqualToString:NSFileContentsPboardType] ||
|
} else if ([type isEqualToString:NSFileContentsPboardType] ||
|
||||||
[type isEqualToString:NSCreateFileContentsPboardType(
|
(fileExtension_ &&
|
||||||
SysUTF16ToNSString(dropData_->file_extension))]) {
|
[type isEqualToString:NSCreateFileContentsPboardType(fileExtension_)])) {
|
||||||
// TODO(viettrungluu: find something which is known to accept
|
// TODO(viettrungluu: find something which is known to accept
|
||||||
// NSFileContentsPboardType to check that this actually works!
|
// NSFileContentsPboardType to check that this actually works!
|
||||||
scoped_nsobject<NSFileWrapper> file_wrapper(
|
scoped_nsobject<NSFileWrapper> file_wrapper(
|
||||||
@ -369,15 +369,13 @@ void PromiseWriterHelper(const WebDropData& drop_data,
|
|||||||
kNSURLTitlePboardType, nil]
|
kNSURLTitlePboardType, nil]
|
||||||
owner:view_];
|
owner:view_];
|
||||||
|
|
||||||
|
std::string fileExtension;
|
||||||
|
|
||||||
// File.
|
// File.
|
||||||
if (!dropData_->file_contents.empty() ||
|
if (!dropData_->file_contents.empty() ||
|
||||||
!dropData_->download_metadata.empty()) {
|
!dropData_->download_metadata.empty()) {
|
||||||
NSString* fileExtension = 0;
|
|
||||||
|
|
||||||
if (dropData_->download_metadata.empty()) {
|
if (dropData_->download_metadata.empty()) {
|
||||||
// |dropData_->file_extension| comes with the '.', which we must strip.
|
fileExtension = GetFileNameFromDragData(*dropData_).Extension();
|
||||||
fileExtension = (dropData_->file_extension.length() > 0) ?
|
|
||||||
SysUTF16ToNSString(dropData_->file_extension.substr(1)) : @"";
|
|
||||||
} else {
|
} else {
|
||||||
string16 mimeType;
|
string16 mimeType;
|
||||||
FilePath fileName;
|
FilePath fileName;
|
||||||
@ -393,24 +391,29 @@ void PromiseWriterHelper(const WebDropData& drop_data,
|
|||||||
UTF16ToUTF8(mimeType),
|
UTF16ToUTF8(mimeType),
|
||||||
fileName.value(),
|
fileName.value(),
|
||||||
&downloadFileName_);
|
&downloadFileName_);
|
||||||
fileExtension = SysUTF8ToNSString(downloadFileName_.Extension());
|
fileExtension = downloadFileName_.Extension();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileExtension) {
|
if (!fileExtension.empty()) {
|
||||||
// File contents (with and without specific type), file (HFS) promise,
|
// Strip the leading dot.
|
||||||
// TIFF.
|
fileExtension_ = SysUTF8ToNSString(fileExtension.substr(1));
|
||||||
|
// File contents (with and without specific type), and file (HFS) promise.
|
||||||
// TODO(viettrungluu): others?
|
// TODO(viettrungluu): others?
|
||||||
[pasteboard_ addTypes:[NSArray arrayWithObjects:
|
NSArray* types = [NSArray arrayWithObjects:
|
||||||
NSFileContentsPboardType,
|
NSFileContentsPboardType,
|
||||||
NSCreateFileContentsPboardType(fileExtension),
|
NSCreateFileContentsPboardType(fileExtension_),
|
||||||
NSFilesPromisePboardType,
|
NSFilesPromisePboardType,
|
||||||
NSTIFFPboardType,
|
nil];
|
||||||
nil]
|
[pasteboard_ addTypes:types owner:view_];
|
||||||
|
|
||||||
|
if (!dropData_->file_contents.empty()) {
|
||||||
|
[pasteboard_ addTypes:[NSArray arrayWithObject:NSTIFFPboardType]
|
||||||
owner:view_];
|
owner:view_];
|
||||||
|
}
|
||||||
|
|
||||||
// For the file promise, we need to specify the extension.
|
// For the file promise, we need to specify the extension.
|
||||||
[pasteboard_ setPropertyList:[NSArray arrayWithObject:fileExtension]
|
[pasteboard_ setPropertyList:[NSArray arrayWithObject:fileExtension_]
|
||||||
forType:NSFilesPromisePboardType];
|
forType:NSFilesPromisePboardType];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,14 @@ DWORD WebDropTarget::OnDragEnter(IDataObject* data_object,
|
|||||||
WebDropData drop_data;
|
WebDropData drop_data;
|
||||||
WebDropData::PopulateWebDropData(data_object, &drop_data);
|
WebDropData::PopulateWebDropData(data_object, &drop_data);
|
||||||
|
|
||||||
|
// Clear the fields that are currently unused when dragging into WebKit.
|
||||||
|
// Remove these lines once PopulateWebDropData() is updated not to set them.
|
||||||
|
// See crbug.com/112255.
|
||||||
|
if (!drop_data.file_contents.empty())
|
||||||
|
drop_data.file_contents.clear();
|
||||||
|
if (!drop_data.file_description_filename.empty())
|
||||||
|
drop_data.file_description_filename.clear();
|
||||||
|
|
||||||
if (drop_data.url.is_empty())
|
if (drop_data.url.is_empty())
|
||||||
ui::OSExchangeDataProviderWin::GetPlainTextURL(data_object, &drop_data.url);
|
ui::OSExchangeDataProviderWin::GetPlainTextURL(data_object, &drop_data.url);
|
||||||
|
|
||||||
|
@ -148,21 +148,6 @@ cef_string_userfree_t CEF_CALLBACK drag_data_get_fragment_base_url(
|
|||||||
return _retval.DetachToUserFree();
|
return _retval.DetachToUserFree();
|
||||||
}
|
}
|
||||||
|
|
||||||
cef_string_userfree_t CEF_CALLBACK drag_data_get_file_extension(
|
|
||||||
struct _cef_drag_data_t* self) {
|
|
||||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
|
||||||
|
|
||||||
DCHECK(self);
|
|
||||||
if (!self)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
// Execute
|
|
||||||
CefString _retval = CefDragDataCppToC::Get(self)->GetFileExtension();
|
|
||||||
|
|
||||||
// Return type: string
|
|
||||||
return _retval.DetachToUserFree();
|
|
||||||
}
|
|
||||||
|
|
||||||
cef_string_userfree_t CEF_CALLBACK drag_data_get_file_name(
|
cef_string_userfree_t CEF_CALLBACK drag_data_get_file_name(
|
||||||
struct _cef_drag_data_t* self) {
|
struct _cef_drag_data_t* self) {
|
||||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
@ -220,7 +205,6 @@ CefDragDataCppToC::CefDragDataCppToC(CefDragData* cls)
|
|||||||
struct_.struct_.get_fragment_text = drag_data_get_fragment_text;
|
struct_.struct_.get_fragment_text = drag_data_get_fragment_text;
|
||||||
struct_.struct_.get_fragment_html = drag_data_get_fragment_html;
|
struct_.struct_.get_fragment_html = drag_data_get_fragment_html;
|
||||||
struct_.struct_.get_fragment_base_url = drag_data_get_fragment_base_url;
|
struct_.struct_.get_fragment_base_url = drag_data_get_fragment_base_url;
|
||||||
struct_.struct_.get_file_extension = drag_data_get_file_extension;
|
|
||||||
struct_.struct_.get_file_name = drag_data_get_file_name;
|
struct_.struct_.get_file_name = drag_data_get_file_name;
|
||||||
struct_.struct_.get_file_names = drag_data_get_file_names;
|
struct_.struct_.get_file_names = drag_data_get_file_names;
|
||||||
}
|
}
|
||||||
|
@ -145,21 +145,6 @@ CefString CefDragDataCToCpp::GetFragmentBaseURL() {
|
|||||||
return _retvalStr;
|
return _retvalStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
CefString CefDragDataCToCpp::GetFileExtension() {
|
|
||||||
if (CEF_MEMBER_MISSING(struct_, get_file_extension))
|
|
||||||
return CefString();
|
|
||||||
|
|
||||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
|
||||||
|
|
||||||
// Execute
|
|
||||||
cef_string_userfree_t _retval = struct_->get_file_extension(struct_);
|
|
||||||
|
|
||||||
// Return type: string
|
|
||||||
CefString _retvalStr;
|
|
||||||
_retvalStr.AttachToUserFree(_retval);
|
|
||||||
return _retvalStr;
|
|
||||||
}
|
|
||||||
|
|
||||||
CefString CefDragDataCToCpp::GetFileName() {
|
CefString CefDragDataCToCpp::GetFileName() {
|
||||||
if (CEF_MEMBER_MISSING(struct_, get_file_name))
|
if (CEF_MEMBER_MISSING(struct_, get_file_name))
|
||||||
return CefString();
|
return CefString();
|
||||||
|
@ -42,7 +42,6 @@ class CefDragDataCToCpp
|
|||||||
virtual CefString GetFragmentText() OVERRIDE;
|
virtual CefString GetFragmentText() OVERRIDE;
|
||||||
virtual CefString GetFragmentHtml() OVERRIDE;
|
virtual CefString GetFragmentHtml() OVERRIDE;
|
||||||
virtual CefString GetFragmentBaseURL() OVERRIDE;
|
virtual CefString GetFragmentBaseURL() OVERRIDE;
|
||||||
virtual CefString GetFileExtension() OVERRIDE;
|
|
||||||
virtual CefString GetFileName() OVERRIDE;
|
virtual CefString GetFileName() OVERRIDE;
|
||||||
virtual bool GetFileNames(std::vector<CefString>& names) OVERRIDE;
|
virtual bool GetFileNames(std::vector<CefString>& names) OVERRIDE;
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
Index: message_loop.cc
|
Index: message_loop.cc
|
||||||
===================================================================
|
===================================================================
|
||||||
--- message_loop.cc (revision 119867)
|
--- message_loop.cc (revision 122508)
|
||||||
+++ message_loop.cc (working copy)
|
+++ message_loop.cc (working copy)
|
||||||
@@ -362,9 +362,13 @@
|
@@ -362,9 +362,13 @@
|
||||||
}
|
}
|
||||||
@ -19,9 +19,9 @@ Index: message_loop.cc
|
|||||||
bool MessageLoop::is_running() const {
|
bool MessageLoop::is_running() const {
|
||||||
Index: message_loop.h
|
Index: message_loop.h
|
||||||
===================================================================
|
===================================================================
|
||||||
--- message_loop.h (revision 119867)
|
--- message_loop.h (revision 122508)
|
||||||
+++ message_loop.h (working copy)
|
+++ message_loop.h (working copy)
|
||||||
@@ -345,6 +345,9 @@
|
@@ -350,6 +350,9 @@
|
||||||
// Asserts that the MessageLoop is "idle".
|
// Asserts that the MessageLoop is "idle".
|
||||||
void AssertIdle() const;
|
void AssertIdle() const;
|
||||||
|
|
||||||
|
@ -265,8 +265,10 @@ bool ClientHandler::OnDragStart(CefRefPtr<CefBrowser> browser,
|
|||||||
|
|
||||||
// Forbid dragging of image files.
|
// Forbid dragging of image files.
|
||||||
if (dragData->IsFile()) {
|
if (dragData->IsFile()) {
|
||||||
std::string fileExt = dragData->GetFileExtension();
|
std::string fileName = dragData->GetFileName();
|
||||||
if (fileExt == ".png" || fileExt == ".jpg" || fileExt == ".gif")
|
if (fileName.find(".png") != std::string::npos ||
|
||||||
|
fileName.find(".jpg") != std::string::npos ||
|
||||||
|
fileName.find(".gif") != std::string::npos)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user