+2012-04-05 Kinuko Yasuda <kinuko@chromium.org>
+
+ Expose DataTransferItem.getAsEntry() to allow users access dropped files as FileEntry
+ https://bugs.webkit.org/show_bug.cgi?id=82592
+
+ Reviewed by David Levin.
+
+ * editing/pasteboard/data-transfer-items-drag-drop-entry-expected.txt: Added.
+ * editing/pasteboard/data-transfer-items-drag-drop-entry.html: Added.
+ * editing/pasteboard/resources/test_directory/test.txt: Added.
+ * platform/gtk/Skipped:
+ * platform/mac/Skipped:
+ * platform/qt/Skipped:
+ * platform/win/Skipped:
+
2012-04-05 Philippe Normand <pnormand@igalia.com>
Unreviewed, GTK rebaseline after r113279.
--- /dev/null
+This tests the basic functionality and properties of DataTransferItems for files with drag and drop. This test requires DRT.
+Drop files here if you test this manually
+Dragging file: resources/mozilla.gif
+Dragging file: resources/drop-file-svg.svg
+Dragging file: resources/copy-backslash-euc.html
+Dragging file: resources/test_directory
+Verifying contents of DataTransferItems...
+PASS: "4" == "4"
+PASS: "file" == "file"
+PASS: "file" == "file"
+PASS: "file" == "file"
+PASS: "file" == "file"
+entry: /mozilla.gif [file]
+PASS: "/mozilla.gif" == "/mozilla.gif"
+PASS: "false" == "false"
+entry: /drop-file-svg.svg [file]
+PASS: "/drop-file-svg.svg" == "/drop-file-svg.svg"
+PASS: "false" == "false"
+entry: /copy-backslash-euc.html [file]
+PASS: "/copy-backslash-euc.html" == "/copy-backslash-euc.html"
+PASS: "false" == "false"
+entry: /test_directory [dir]
+PASS: "/test_directory" == "/test_directory"
+PASS: "true" == "true"
+PASS: "2593" == "2593"
+PASS: "109" == "109"
+PASS: "478" == "478"
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<body>
+<div>This tests the basic functionality and properties of DataTransferItems for files with drag and drop. This test requires DRT.</div>
+
+<div id="destination" style="min-height:100px; border: solid 1px black">Drop files here if you test this manually</div>
+
+<div id="console"></div>
+
+<script>
+var testFiles = [
+ { path: 'resources/mozilla.gif',
+ directory: false,
+ size: 2593 },
+ { path: 'resources/drop-file-svg.svg',
+ directory: false,
+ size: 109 },
+ { path: 'resources/copy-backslash-euc.html',
+ directory: false,
+ size: 478 },
+ { path: 'resources/test_directory',
+ directory: true,
+ size: 0 }
+];
+
+function log(text)
+{
+ var console = document.getElementById('console');
+ console.appendChild(document.createTextNode(text));
+ console.appendChild(document.createElement('br'));
+}
+
+function test(expect, actual)
+{
+ log((expect == actual ? 'PASS' : 'FAIL') + ': "' + expect + '" == "' + actual + '"');
+}
+
+function startTest()
+{
+ var destination = document.getElementById('destination');
+ destination.addEventListener('dragover', handleDragOver, false);
+ destination.addEventListener('drop', handleDrop, false);
+
+ if (!window.layoutTestController)
+ return;
+ layoutTestController.waitUntilDone();
+ layoutTestController.dumpAsText();
+
+ var files = [];
+ for (var i = 0; i < testFiles.length; ++i) {
+ log('Dragging file: ' + testFiles[i].path);
+ files.push(testFiles[i].path);
+ }
+
+ // Perform drag-and-drop with the testFiles.
+ eventSender.beginDragWithFiles(files);
+ eventSender.leapForward(100);
+ eventSender.mouseMoveTo(destination.offsetLeft + 10, destination.offsetTop + destination.offsetHeight / 2);
+ eventSender.mouseUp();
+}
+
+function handleDragOver(e)
+{
+ e.stopPropagation();
+ e.preventDefault();
+}
+
+function handleDrop(e)
+{
+ e.stopPropagation();
+ e.preventDefault();
+
+ log('Verifying contents of DataTransferItems...');
+ var items = e.dataTransfer.items;
+ var files = [];
+ test(testFiles.length, items.length);
+ for (var i = 0; i < items.length; ++i) {
+ // The items should be in the same order as we added.
+ var expected = testFiles[i];
+ var file = items[i].getAsFile();
+ files.push(file);
+
+ test('file', items[i].kind);
+ with ({last: i + 1 == items.length, expected: expected}) {
+ items[i].webkitGetAsEntry(function(entry) {
+ log('entry: ' + entry.fullPath + (entry.isDirectory ? ' [dir]' : ' [file]'));
+ var components = expected.path.split('/');
+ var name = components[components.length - 1];
+ test('/' + name, entry.fullPath);
+ test(expected.directory, entry.isDirectory);
+
+ entry.getMetadata(function(metadata) {
+ if (!expected.directory)
+ test(expected.size, metadata.size);
+ if (last && window.layoutTestController)
+ layoutTestController.notifyDone();
+ });
+ });
+ }
+ }
+}
+
+startTest();
+
+</script>
+</body>
+</html>
--- /dev/null
+Lorem ipsum.
editing/pasteboard/data-transfer-items.html
editing/pasteboard/data-transfer-items-image-png.html
editing/pasteboard/data-transfer-items-drag-drop-file.html
+editing/pasteboard/data-transfer-items-drag-drop-entry.html
editing/pasteboard/data-transfer-items-drag-drop-string.html
fast/events/clipboard-dataTransferItemList.html
fast/events/drag-dataTransferItemList.html
editing/pasteboard/data-transfer-items.html
editing/pasteboard/data-transfer-items-image-png.html
editing/pasteboard/data-transfer-items-drag-drop-file.html
+editing/pasteboard/data-transfer-items-drag-drop-entry.html
editing/pasteboard/data-transfer-items-drag-drop-string.html
fast/events/clipboard-dataTransferItemList.html
fast/events/drag-dataTransferItemList.html
# See bug https://bugs.webkit.org/show_bug.cgi?id=60068
editing/pasteboard/data-transfer-items.html
editing/pasteboard/data-transfer-items-drag-drop-file.html
+editing/pasteboard/data-transfer-items-drag-drop-entry.html
editing/pasteboard/data-transfer-items-drag-drop-string.html
fast/events/clipboard-dataTransferItemList.html
fast/events/drag-dataTransferItemList.html
editing/pasteboard/data-transfer-items.html
editing/pasteboard/data-transfer-items-image-png.html
editing/pasteboard/data-transfer-items-drag-drop-file.html
+editing/pasteboard/data-transfer-items-drag-drop-entry.html
editing/pasteboard/data-transfer-items-drag-drop-string.html
fast/events/clipboard-dataTransferItemList.html
fast/events/drag-dataTransferItemList.html
+2012-04-05 Kinuko Yasuda <kinuko@chromium.org>
+
+ Expose DataTransferItem.getAsEntry() to allow users access dropped files as FileEntry
+ https://bugs.webkit.org/show_bug.cgi?id=82592
+
+ Reviewed by David Levin.
+
+ For now the method is prefixed thus it is to be exposed as 'webkitGetAsEntry'.
+
+ The API is proposed and discussed in the following whatwg thread:
+ http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2011-November/033814.html
+
+ Add DataTransferItemFilesystem under Modules/filesystem and implemented the bridging part for chromium.
+
+ Test: editing/pasteboard/data-transfer-items-drag-drop-entry.html
+
+ * Modules/filesystem/DataTransferItemFileSystem.h: Added.
+ (DataTransferItemFileSystem):
+ * Modules/filesystem/DataTransferItemFileSystem.idl: Added for DataTransferItem.getAsEntry which is only exposed if filesystem is enabled.
+ * Modules/filesystem/chromium/DataTransferItemFileSystemChromium.cpp: Added for chromium implementation.
+ * Modules/filesystem/chromium/DataTransferItemFileSystemChromium.h: Added.
+ * Modules/filesystem/chromium/DraggedIsolatedFileSystem.cpp: Added.
+ * Modules/filesystem/chromium/DraggedIsolatedFileSystem.h: Added.
+ * WebCore.gypi:
+ * platform/chromium/ChromiumDataObject.cpp:
+ * platform/chromium/ChromiumDataObject.h:
+ (WebCore::ChromiumDataObject::filesystemId): Added.
+ (WebCore::ChromiumDataObject::setFilesystemId): Added.
+ * platform/chromium/ClipboardChromium.cpp:
+
2012-04-04 Patrick Gansterer <paroga@webkit.org>
Add WTF::getCurrentLocalTime()
--- /dev/null
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DataTransferItemFileSystem_h
+#define DataTransferItemFileSystem_h
+
+#if ENABLE(FILE_SYSTEM)
+
+#include <wtf/PassRefPtr.h>
+
+namespace WebCore {
+
+class DataTransferItem;
+class EntryCallback;
+class ScriptExecutionContext;
+
+class DataTransferItemFileSystem {
+public:
+ static void webkitGetAsEntry(DataTransferItem*, ScriptExecutionContext*, PassRefPtr<EntryCallback>);
+
+private:
+ DataTransferItemFileSystem();
+ ~DataTransferItemFileSystem();
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(FILE_SYSTEM)
+
+#endif // DataTransferItemFileSystem_h
--- /dev/null
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module core {
+
+ interface [
+ Conditional=DATA_TRANSFER_ITEMS&FILE_SYSTEM,
+ Supplemental=DataTransferItem
+ ] DataTransferItemFileSystem {
+ [CallWith=ScriptExecutionContext] void webkitGetAsEntry(in [Callback,Optional=DefaultIsUndefined] EntryCallback callback);
+ };
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DataTransferItemFileSystem.h"
+
+#if ENABLE(FILE_SYSTEM)
+
+#include "AsyncFileSystem.h"
+#include "AsyncFileSystemCallbacks.h"
+#include "ChromiumDataObject.h"
+#include "ClipboardChromium.h"
+#include "DOMFilePath.h"
+#include "DOMFileSystem.h"
+#include "DirectoryEntry.h"
+#include "DraggedIsolatedFileSystem.h"
+#include "Entry.h"
+#include "EntryCallback.h"
+#include "File.h"
+#include "FileEntry.h"
+#include "FileMetadata.h"
+#include "ScriptExecutionContext.h"
+
+namespace WebCore {
+
+namespace {
+
+class GetAsEntryCallbacks : public AsyncFileSystemCallbacks {
+ WTF_MAKE_NONCOPYABLE(GetAsEntryCallbacks);
+public:
+ static PassOwnPtr<GetAsEntryCallbacks> create(PassRefPtr<DOMFileSystem> filesystem, const String& virtualPath, PassRefPtr<EntryCallback> callback)
+ {
+ return adoptPtr(new GetAsEntryCallbacks(filesystem, virtualPath, callback));
+ }
+
+ virtual ~GetAsEntryCallbacks()
+ {
+ }
+
+ virtual void didReadMetadata(const FileMetadata& metadata)
+ {
+ if (metadata.type == FileMetadata::TypeDirectory)
+ m_callback->handleEvent(DirectoryEntry::create(m_filesystem, m_virtualPath).get());
+ else
+ m_callback->handleEvent(FileEntry::create(m_filesystem, m_virtualPath).get());
+ }
+
+ virtual void didFail(int error)
+ {
+ // FIXME: Return a special FileEntry which will let any succeeding operations fail with the error code.
+ m_callback->handleEvent(0);
+ }
+
+private:
+ GetAsEntryCallbacks(PassRefPtr<DOMFileSystem> filesystem, const String& virtualPath, PassRefPtr<EntryCallback> callback)
+ : m_filesystem(filesystem)
+ , m_virtualPath(virtualPath)
+ , m_callback(callback)
+ {
+ }
+
+ RefPtr<DOMFileSystem> m_filesystem;
+ String m_virtualPath;
+ RefPtr<EntryCallback> m_callback;
+};
+
+} // namespace
+
+// static
+void DataTransferItemFileSystem::webkitGetAsEntry(DataTransferItem* item, ScriptExecutionContext* scriptExecutionContext, PassRefPtr<EntryCallback> callback)
+{
+ DataTransferItemPolicyWrapper* itemPolicyWrapper = static_cast<DataTransferItemPolicyWrapper*>(item);
+
+ if (!callback || !itemPolicyWrapper->dataObjectItem()->isFilename())
+ return;
+
+ // For dragged files getAsFile must be pretty lightweight.
+ Blob* file = itemPolicyWrapper->getAsFile().get();
+ // The clipboard may not be in a readable state.
+ if (!file)
+ return;
+ ASSERT(file->isFile());
+
+ DraggedIsolatedFileSystem* filesystem = DraggedIsolatedFileSystem::from(itemPolicyWrapper->clipboard()->dataObject().get());
+ DOMFileSystem* domFileSystem = filesystem ? filesystem->getDOMFileSystem(scriptExecutionContext) : 0;
+ if (!filesystem) {
+ // IsolatedFileSystem may not be enabled.
+ DOMFileSystem::scheduleCallback(scriptExecutionContext, callback, adoptRef(static_cast<Entry*>(0)));
+ return;
+ }
+
+ ASSERT(domFileSystem);
+
+ // The dropped entries are mapped as top-level entries in the isolated filesystem.
+ String virtualPath = DOMFilePath::append("/", static_cast<File*>(file)->name());
+ domFileSystem->asyncFileSystem()->readMetadata(virtualPath, GetAsEntryCallbacks::create(domFileSystem, virtualPath, callback));
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(FILE_SYSTEM)
--- /dev/null
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DraggedIsolatedFileSystem.h"
+
+#if ENABLE(FILE_SYSTEM)
+
+#include "DOMFileSystem.h"
+#include "PlatformSupport.h"
+#include "ScriptExecutionContext.h"
+#include "SecurityOrigin.h"
+#include "Supplementable.h"
+#include <wtf/MainThread.h>
+
+namespace WebCore {
+
+DraggedIsolatedFileSystem::~DraggedIsolatedFileSystem()
+{
+}
+
+DOMFileSystem* DraggedIsolatedFileSystem::getDOMFileSystem(ScriptExecutionContext* scriptExecutionContext)
+{
+ ASSERT(!m_filesystemId.isEmpty());
+ if (!m_filesystem) {
+ ASSERT(scriptExecutionContext);
+ SecurityOrigin* securityOrigin = scriptExecutionContext->securityOrigin();
+ String filesystemName = PlatformSupport::createIsolatedFileSystemName(securityOrigin->databaseIdentifier(), m_filesystemId);
+ m_filesystem = DOMFileSystem::create(scriptExecutionContext, filesystemName, PlatformSupport::createIsolatedFileSystem(securityOrigin->toString(), m_filesystemId));
+ }
+ return m_filesystem.get();
+}
+
+// static
+const AtomicString& DraggedIsolatedFileSystem::supplementName()
+{
+ ASSERT(isMainThread());
+ DEFINE_STATIC_LOCAL(AtomicString, name, ("DraggedIsolatedFileSystem"));
+ return name;
+}
+
+DraggedIsolatedFileSystem::DraggedIsolatedFileSystem(const String& filesystemId)
+ : m_filesystemId(filesystemId)
+{
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(FILE_SYSTEM)
--- /dev/null
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DraggedIsolatedFileSystem_h
+#define DraggedIsolatedFileSystem_h
+
+#if ENABLE(FILE_SYSTEM)
+
+#include "ChromiumDataObject.h"
+#include <wtf/Forward.h>
+#include <wtf/text/AtomicString.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class DOMFileSystem;
+
+class DraggedIsolatedFileSystem : public Supplement<ChromiumDataObject> {
+public:
+ ~DraggedIsolatedFileSystem();
+
+ static PassOwnPtr<DraggedIsolatedFileSystem> create(const String& filesystemId)
+ {
+ return adoptPtr(new DraggedIsolatedFileSystem(filesystemId));
+ }
+
+ const String& filesystemId() const { return m_filesystemId; }
+ DOMFileSystem* getDOMFileSystem(ScriptExecutionContext*);
+
+ static const AtomicString& supplementName();
+ static DraggedIsolatedFileSystem* from(ChromiumDataObject* dataObject) { return static_cast<DraggedIsolatedFileSystem*>(Supplement<ChromiumDataObject>::from(dataObject, supplementName())); }
+
+private:
+ DraggedIsolatedFileSystem(const String& filesystemId);
+ RefPtr<DOMFileSystem> m_filesystem;
+ String m_filesystemId;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(FILE_SYSTEM)
+
+#endif // DraggedIsolatedFileSystem_h
'../',
'../..',
'../Modules/filesystem',
+ '../Modules/filesystem/chromium',
'../Modules/gamepad',
'../Modules/geolocation',
'../Modules/intents',
'Modules/filesystem/DOMFileSystem.idl',
'Modules/filesystem/DOMFileSystemSync.idl',
'Modules/filesystem/DOMWindowFileSystem.idl',
+ 'Modules/filesystem/DataTransferItemFileSystem.idl',
'Modules/filesystem/DirectoryEntry.idl',
'Modules/filesystem/DirectoryEntrySync.idl',
'Modules/filesystem/DirectoryReader.idl',
'Modules/filesystem/DOMFileSystemSync.h',
'Modules/filesystem/DOMWindowFileSystem.cpp',
'Modules/filesystem/DOMWindowFileSystem.h',
+ 'Modules/filesystem/DataTransferItemFileSystem.h',
'Modules/filesystem/DirectoryEntry.cpp',
'Modules/filesystem/DirectoryEntry.h',
'Modules/filesystem/DirectoryEntrySync.cpp',
'Modules/filesystem/WebKitFlags.h',
'Modules/filesystem/WorkerContextFileSystem.cpp',
'Modules/filesystem/WorkerContextFileSystem.h',
+ 'Modules/filesystem/chromium/DataTransferItemFileSystemChromium.cpp',
+ 'Modules/filesystem/chromium/DraggedIsolatedFileSystem.cpp',
+ 'Modules/filesystem/chromium/DraggedIsolatedFileSystem.h',
'Modules/gamepad/Gamepad.cpp',
'Modules/gamepad/Gamepad.h',
'Modules/gamepad/GamepadList.cpp',
/*
- * Copyright (c) 2008, 2009, Google Inc. All rights reserved.
+ * Copyright (c) 2008, 2009, 2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
#include "ChromiumDataObjectItem.h"
#include "PlatformString.h"
+#include "Supplementable.h"
#include <wtf/HashSet.h>
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
// A data object for holding data that would be in a clipboard or moved
// during a drag-n-drop operation. This is the data that WebCore is aware
// of and is not specific to a platform.
-class ChromiumDataObject : public RefCounted<ChromiumDataObject> {
+class ChromiumDataObject : public RefCounted<ChromiumDataObject>, public Supplementable<ChromiumDataObject> {
public:
static PassRefPtr<ChromiumDataObject> createFromPasteboard();
static PassRefPtr<ChromiumDataObject> create();
#include "ChromiumDataObjectItem.h"
#include "ClipboardMimeTypes.h"
#include "ClipboardUtilitiesChromium.h"
-#include "DataTransferItem.h"
#include "DataTransferItemList.h"
#include "Document.h"
#include "DragData.h"
namespace {
-// These wrapper classes invalidate a DataTransferItem/DataTransferItemList when the associated
-// Clipboard object goes out of scope.
+// A wrapper class that invalidates a DataTransferItemList when the associated Clipboard object goes out of scope.
class DataTransferItemListPolicyWrapper : public DataTransferItemList {
public:
- static PassRefPtr<DataTransferItemListPolicyWrapper> create(
- PassRefPtr<ClipboardChromium>, PassRefPtr<ChromiumDataObject>);
+ static PassRefPtr<DataTransferItemListPolicyWrapper> create(PassRefPtr<ClipboardChromium>, PassRefPtr<ChromiumDataObject>);
+ virtual ~DataTransferItemListPolicyWrapper();
virtual size_t length() const;
- virtual PassRefPtr<DataTransferItem> item(unsigned long index);
- virtual void deleteItem(unsigned long index, ExceptionCode&);
- virtual void clear();
- virtual void add(const String& data, const String& type, ExceptionCode&);
- virtual void add(PassRefPtr<File>);
+ virtual PassRefPtr<DataTransferItem> item(unsigned long index) OVERRIDE;
+ virtual void deleteItem(unsigned long index, ExceptionCode&) OVERRIDE;
+ virtual void clear() OVERRIDE;
+ virtual void add(const String& data, const String& type, ExceptionCode&) OVERRIDE;
+ virtual void add(PassRefPtr<File>) OVERRIDE;
private:
DataTransferItemListPolicyWrapper(PassRefPtr<ClipboardChromium>, PassRefPtr<ChromiumDataObject>);
RefPtr<ChromiumDataObject> m_dataObject;
};
-class DataTransferItemPolicyWrapper : public DataTransferItem {
-public:
- static PassRefPtr<DataTransferItemPolicyWrapper> create(
- PassRefPtr<ClipboardChromium>, PassRefPtr<ChromiumDataObjectItem>);
-
- virtual String kind() const;
- virtual String type() const;
-
- virtual void getAsString(PassRefPtr<StringCallback>) const;
- virtual PassRefPtr<Blob> getAsFile() const;
-
-private:
- DataTransferItemPolicyWrapper(PassRefPtr<ClipboardChromium>, PassRefPtr<ChromiumDataObjectItem>);
-
- RefPtr<ClipboardChromium> m_clipboard;
- RefPtr<ChromiumDataObjectItem> m_item;
-};
PassRefPtr<DataTransferItemListPolicyWrapper> DataTransferItemListPolicyWrapper::create(
PassRefPtr<ClipboardChromium> clipboard, PassRefPtr<ChromiumDataObject> list)
return adoptRef(new DataTransferItemListPolicyWrapper(clipboard, list));
}
+DataTransferItemListPolicyWrapper::~DataTransferItemListPolicyWrapper()
+{
+}
+
size_t DataTransferItemListPolicyWrapper::length() const
{
if (m_clipboard->policy() == ClipboardNumb)
RefPtr<ChromiumDataObjectItem> item = m_dataObject->item(index);
if (!item)
return 0;
+
return DataTransferItemPolicyWrapper::create(m_clipboard, item);
}
{
}
+} // namespace
+
PassRefPtr<DataTransferItemPolicyWrapper> DataTransferItemPolicyWrapper::create(
PassRefPtr<ClipboardChromium> clipboard, PassRefPtr<ChromiumDataObjectItem> item)
{
return adoptRef(new DataTransferItemPolicyWrapper(clipboard, item));
}
+DataTransferItemPolicyWrapper::~DataTransferItemPolicyWrapper()
+{
+}
+
String DataTransferItemPolicyWrapper::kind() const
{
if (m_clipboard->policy() == ClipboardNumb)
{
}
-} // namespace
-
using namespace HTMLNames;
// We provide the IE clipboard types (URL and Text), and the clipboard types specified in the WHATWG Web Applications 1.0 draft
#include "CachedImage.h"
#include "ChromiumDataObject.h"
#include "Clipboard.h"
+#include "DataTransferItem.h"
namespace WebCore {
class CachedImage;
+ class ChromiumDataObjectItem;
+ class ClipboardChromium;
class Frame;
class IntPoint;
+ // A wrapper class that invalidates a DataTransferItem when the associated Clipboard object goes out of scope.
+ class DataTransferItemPolicyWrapper : public DataTransferItem {
+ public:
+ static PassRefPtr<DataTransferItemPolicyWrapper> create(PassRefPtr<ClipboardChromium>, PassRefPtr<ChromiumDataObjectItem>);
+ virtual ~DataTransferItemPolicyWrapper();
+
+ virtual String kind() const OVERRIDE;
+ virtual String type() const OVERRIDE;
+ virtual void getAsString(PassRefPtr<StringCallback>) const OVERRIDE;
+ virtual PassRefPtr<Blob> getAsFile() const OVERRIDE;
+
+ ClipboardChromium* clipboard() { return m_clipboard.get(); }
+ ChromiumDataObjectItem* dataObjectItem() { return m_item.get(); }
+
+ private:
+ DataTransferItemPolicyWrapper(PassRefPtr<ClipboardChromium>, PassRefPtr<ChromiumDataObjectItem>);
+
+ RefPtr<ClipboardChromium> m_clipboard;
+ RefPtr<ChromiumDataObjectItem> m_item;
+ };
+
class ClipboardChromium : public Clipboard, public CachedImageClient {
WTF_MAKE_FAST_ALLOCATED;
public:
+2012-04-05 Kinuko Yasuda <kinuko@chromium.org>
+
+ Expose DataTransferItem.getAsEntry() to allow users access dropped files as FileEntry
+ https://bugs.webkit.org/show_bug.cgi?id=82592
+
+ Reviewed by David Levin.
+
+ * src/WebDragData.cpp:
+ (WebKit::WebDragData::filesystemId): Added implementation.
+ (WebKit::WebDragData::setFilesystemId): Added implementation.
+
2012-04-04 Kent Tamura <tkent@chromium.org>
[Chromium] Calendar Picker: Add localization functions
#include "ChromiumDataObject.h"
#include "ClipboardMimeTypes.h"
#include "DataTransferItem.h"
+#include "DraggedIsolatedFileSystem.h"
#include "platform/WebData.h"
#include "platform/WebString.h"
#include "platform/WebURL.h"
WebString WebDragData::filesystemId() const
{
- // FIXME: Should return the ID set by setFileSystemId().
+#if ENABLE(FILE_SYSTEM)
+ ASSERT(!isNull());
+ DraggedIsolatedFileSystem* filesystem = DraggedIsolatedFileSystem::from(m_private);
+ if (filesystem)
+ return filesystem->filesystemId();
+#endif
return WebString();
}
void WebDragData::setFilesystemId(const WebString& filesystemId)
{
- // FIXME: The given value should be stored internally and is to be used
- // to instantiate an isolated filesystem for providing FileSystem Entry
- // access to the dragged files/directories.
+#if ENABLE(FILE_SYSTEM)
// The ID is an opaque string, given by and validated by chromium port.
+ ensureMutable();
+ DraggedIsolatedFileSystem::provideTo(m_private, DraggedIsolatedFileSystem::supplementName(), DraggedIsolatedFileSystem::create(filesystemId));
+#endif
}
WebDragData::WebDragData(const WTF::PassRefPtr<WebCore::ChromiumDataObject>& data)
+2012-04-05 Kinuko Yasuda <kinuko@chromium.org>
+
+ Expose DataTransferItem.getAsEntry() to allow users access dropped files as FileEntry
+ https://bugs.webkit.org/show_bug.cgi?id=82592
+
+ Reviewed by David Levin.
+
+ Added filesystem hook support in EventSender.beginDragWithFiles() for DumpRenderTree.
+
+ * DumpRenderTree/chromium/EventSender.cpp:
+ (EventSender::beginDragWithFiles):
+
2012-04-04 Tim Horton <timothy_horton@apple.com>
[mac] WKTR should always keep its windows offscreen
{
currentDragData.initialize();
Vector<string> files = arguments[0].toStringVector();
+ Vector<WebString> absoluteFilenames;
for (size_t i = 0; i < files.size(); ++i) {
WebDragData::Item item;
item.storageType = WebDragData::Item::StorageTypeFilename;
item.filenameData = webkit_support::GetAbsoluteWebStringFromUTF8Path(files[i]);
currentDragData.addItem(item);
+ absoluteFilenames.append(item.filenameData);
}
+ currentDragData.setFilesystemId(webkit_support::RegisterIsolatedFileSystem(absoluteFilenames));
currentDragEffectsAllowed = WebKit::WebDragOperationCopy;
// Provide a drag source.