[WK2] Support data interaction of files into file inputs
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 15 Apr 2017 09:37:01 +0000 (09:37 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 15 Apr 2017 09:37:01 +0000 (09:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=170803
<rdar://problem/31286130>

Reviewed by Tim Horton.

Source/WebCore:

Adds remaining support to allow data interaction of files onto inputs of type file. See per-change annotations
for more details. Unit tests to be added in the next patch.

* platform/PasteboardStrategy.h:
* platform/PlatformPasteboard.h:
* platform/ios/AbstractPasteboard.h:
* platform/ios/PlatformPasteboardIOS.mm:
(WebCore::PlatformPasteboard::numberOfFiles):
* platform/ios/WebItemProviderPasteboard.mm:

Implements numberOfFiles by counting the number of item providers that may be represented as a file, which
includes all item providers that contain at least one content UTI type.

(-[WebItemProviderPasteboard numberOfFiles]):

Adds boilerplate plumbing to fetch the number of files available on the pasteboard. On Mac, logic that
previously existed in DragData::numberOfFiles to query the number of files available in the pasteboard is now
on PlatformPasteboard instead, which both makes the implementation of DragData::numberOfFiles platform-invariant,
and also saves us one synchronous IPC call to the UI process in the WebKit2 implementation.

* platform/mac/DragDataMac.mm:
(WebCore::DragData::containsFiles):
(WebCore::DragData::numberOfFiles):
(WebCore::DragData::asFilenames):

Add support for recognizing objects in the pasteboard that may be represented by files, and therefore may be
uploaded via file input. Following suit with behavior elsewhere on the platform, we consider item providers able
to be represented by a file if they contain at least one content UTI type.

* platform/mac/PlatformPasteboardMac.mm:

Logic previously in DragData::numberOfFiles to get and then count all file path names in the pasteboard has been
moved here instead, and no longer needs to go through the pasteboard proxy.

(WebCore::PlatformPasteboard::numberOfFiles):

Source/WebKit/mac:

Add boilerplate plumbing for fetching the number of files in the pasteboard.

* WebCoreSupport/WebPlatformStrategies.h:
* WebCoreSupport/WebPlatformStrategies.mm:
(WebPlatformStrategies::getNumberOfFiles):

Source/WebKit2:

Implements remaining support for performing data interaction onto file inputs. There are two main changes at
this layer: plumbing the number of files in the pasteboard to the web process, and pulling the implementation of
createSandboxExtensionsIfNeeded out of Mac-specific WebViewImpl::createSandboxExtensionsIfNeeded and into
WebPageProxy::createSandboxExtensionsIfNeeded.

* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<DragData>::encode):
(IPC::ArgumentCoder<DragData>::decode):

Relax special-casing of encoding and decoding filenames to be PLATFORM(COCOA) rather than PLATFORM(MAC).

* UIProcess/Cocoa/WebPageProxyCocoa.mm:
(WebKit::WebPageProxy::createSandboxExtensionsIfNeeded):
* UIProcess/Cocoa/WebPasteboardProxyCocoa.mm:
(WebKit::WebPasteboardProxy::getNumberOfFiles):

More boilerplate plumbing to deliver the number of files in the pasteboard to the web process.

* UIProcess/Cocoa/WebViewImpl.h:
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::performDragOperation):
(WebKit::WebViewImpl::createSandboxExtensionsIfNeeded): Deleted.

Move the logic in WebViewImpl::createSandboxExtensionsIfNeeded over to WebPageProxy::createSandboxExtensionsIfNeeded.

* UIProcess/WebPageProxy.h:
* UIProcess/WebPasteboardProxy.h:
* UIProcess/WebPasteboardProxy.messages.in:
* WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
(WebKit::WebPlatformStrategies::getNumberOfFiles):
* WebProcess/WebCoreSupport/WebPlatformStrategies.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@215392 268f45cc-cd09-0410-ab3c-d52691b4dbfc

22 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/PasteboardStrategy.h
Source/WebCore/platform/PlatformPasteboard.h
Source/WebCore/platform/ios/AbstractPasteboard.h
Source/WebCore/platform/ios/PlatformPasteboardIOS.mm
Source/WebCore/platform/ios/WebItemProviderPasteboard.mm
Source/WebCore/platform/mac/DragDataMac.mm
Source/WebCore/platform/mac/PlatformPasteboardMac.mm
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.h
Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.mm
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebCoreArgumentCoders.cpp
Source/WebKit2/UIProcess/Cocoa/WebPageProxyCocoa.mm
Source/WebKit2/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm
Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h
Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPasteboardProxy.h
Source/WebKit2/UIProcess/WebPasteboardProxy.messages.in
Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h

index be7157b..15ff38e 100644 (file)
@@ -1,5 +1,49 @@
 2017-04-15  Wenson Hsieh  <wenson_hsieh@apple.com>
 
+        [WK2] Support data interaction of files into file inputs
+        https://bugs.webkit.org/show_bug.cgi?id=170803
+        <rdar://problem/31286130>
+
+        Reviewed by Tim Horton.
+
+        Adds remaining support to allow data interaction of files onto inputs of type file. See per-change annotations
+        for more details. Unit tests to be added in the next patch.
+
+        * platform/PasteboardStrategy.h:
+        * platform/PlatformPasteboard.h:
+        * platform/ios/AbstractPasteboard.h:
+        * platform/ios/PlatformPasteboardIOS.mm:
+        (WebCore::PlatformPasteboard::numberOfFiles):
+        * platform/ios/WebItemProviderPasteboard.mm:
+
+        Implements numberOfFiles by counting the number of item providers that may be represented as a file, which
+        includes all item providers that contain at least one content UTI type.
+
+        (-[WebItemProviderPasteboard numberOfFiles]):
+
+        Adds boilerplate plumbing to fetch the number of files available on the pasteboard. On Mac, logic that
+        previously existed in DragData::numberOfFiles to query the number of files available in the pasteboard is now
+        on PlatformPasteboard instead, which both makes the implementation of DragData::numberOfFiles platform-invariant,
+        and also saves us one synchronous IPC call to the UI process in the WebKit2 implementation.
+
+        * platform/mac/DragDataMac.mm:
+        (WebCore::DragData::containsFiles):
+        (WebCore::DragData::numberOfFiles):
+        (WebCore::DragData::asFilenames):
+
+        Add support for recognizing objects in the pasteboard that may be represented by files, and therefore may be
+        uploaded via file input. Following suit with behavior elsewhere on the platform, we consider item providers able
+        to be represented by a file if they contain at least one content UTI type.
+
+        * platform/mac/PlatformPasteboardMac.mm:
+
+        Logic previously in DragData::numberOfFiles to get and then count all file path names in the pasteboard has been
+        moved here instead, and no longer needs to go through the pasteboard proxy.
+
+        (WebCore::PlatformPasteboard::numberOfFiles):
+
+2017-04-15  Wenson Hsieh  <wenson_hsieh@apple.com>
+
         Unreviewed, fix the build after r215389
 
         Use WebCore::createTemporaryDirectory instead of -_webkit_createTemporaryDirectoryWithTemplatePrefix:.
index 1ac4842..e6aacc2 100644 (file)
@@ -59,6 +59,7 @@ public:
     virtual String uniqueName() = 0;
     virtual Color color(const String& pasteboardName) = 0;
     virtual URL url(const String& pasteboardName) = 0;
+    virtual int getNumberOfFiles(const String& pasteboardName) = 0;
 
     virtual long addTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) = 0;
     virtual long setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) = 0;
index 3430118..1d6d4cb 100644 (file)
@@ -81,6 +81,7 @@ public:
     WEBCORE_EXPORT String readString(int index, const String& pasteboardType);
     WEBCORE_EXPORT URL readURL(int index, const String& pasteboardType);
     WEBCORE_EXPORT int count();
+    WEBCORE_EXPORT int numberOfFiles();
 
 #if PLATFORM(GTK)
     WEBCORE_EXPORT void writeToClipboard(const SelectionData&, std::function<void()>&& primarySelectionCleared);
index 6e69fc8..1f5d996 100644 (file)
@@ -49,6 +49,7 @@ WEBCORE_EXPORT @interface WebPasteboardItemData : NSObject
 @optional
 - (void)setItemsFromObjectRepresentations:(NSArray<WebPasteboardItemData *> *)itemData;
 - (void)setItems:(NSArray<NSDictionary *> *)items;
+@property (readonly, nonatomic) NSInteger numberOfFiles;
 
 @end
 
index 55c9c17..a745744 100644 (file)
@@ -86,6 +86,11 @@ void PlatformPasteboard::getPathnamesForType(Vector<String>&, const String&)
 {
 }
 
+int PlatformPasteboard::numberOfFiles()
+{
+    return [m_pasteboard respondsToSelector:@selector(numberOfFiles)] ? [m_pasteboard numberOfFiles] : 0;
+}
+
 String PlatformPasteboard::stringForType(const String& type)
 {
     NSArray *values = [m_pasteboard valuesForPasteboardType:type inItemSet:[NSIndexSet indexSetWithIndex:0]];
index 4ee577e..9e6a7f7 100644 (file)
@@ -254,6 +254,20 @@ static BOOL isImageType(NSString *type)
     return _changeCount;
 }
 
+- (NSInteger)numberOfFiles
+{
+    NSInteger numberOfFiles = 0;
+    for (UIItemProvider *itemProvider in _itemProviders.get()) {
+        for (NSString *identifier in itemProvider.registeredTypeIdentifiers) {
+            if (!UTTypeConformsTo((__bridge CFStringRef)identifier, kUTTypeContent))
+                continue;
+            ++numberOfFiles;
+            break;
+        }
+    }
+    return numberOfFiles;
+}
+
 static NSURL *temporaryFileURLForDataInteractionContent(NSString *fileExtension, NSString *suggestedName)
 {
     static NSString *defaultDataInteractionFileName = @"file";
index cf78b4a..ea5fc30 100644 (file)
@@ -123,30 +123,31 @@ bool DragData::containsColor() const
 
 bool DragData::containsFiles() const
 {
-#if PLATFORM(MAC)
     Vector<String> types;
     platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName);
-    return types.contains(String(NSFilenamesPboardType)) || types.contains(String(NSFilesPromisePboardType));
+    for (auto& type : types) {
+#if PLATFORM(MAC)
+        if (type == String(NSFilesPromisePboardType) || type == String(NSFilenamesPboardType))
+            return true;
 #else
-    return false;
+        if (UTTypeConformsTo(type.createCFString().autorelease(), kUTTypeContent))
+            return true;
 #endif
+    }
+    return false;
 }
 
 unsigned DragData::numberOfFiles() const
 {
-    Vector<String> files;
-#if PLATFORM(MAC)
-    platformStrategies()->pasteboardStrategy()->getPathnamesForType(files, String(NSFilenamesPboardType), m_pasteboardName);
-    if (!files.size())
-        platformStrategies()->pasteboardStrategy()->getPathnamesForType(files, String(NSFilesPromisePboardType), m_pasteboardName);
-#endif
-    return files.size();
+    return platformStrategies()->pasteboardStrategy()->getNumberOfFiles(m_pasteboardName);
 }
 
 void DragData::asFilenames(Vector<String>& result) const
 {
 #if PLATFORM(MAC)
     platformStrategies()->pasteboardStrategy()->getPathnamesForType(result, String(NSFilenamesPboardType), m_pasteboardName);
+#endif
+#if PLATFORM(MAC) || ENABLE(DATA_INTERACTION)
     if (!result.size())
         result = fileNames();
 #else
index 10db3db..daff4fc 100644 (file)
@@ -53,6 +53,15 @@ RefPtr<SharedBuffer> PlatformPasteboard::bufferForType(const String& pasteboardT
     return SharedBuffer::wrapNSData([[data copy] autorelease]);
 }
 
+int PlatformPasteboard::numberOfFiles()
+{
+    Vector<String> files;
+    getPathnamesForType(files, String(NSFilenamesPboardType));
+    if (!files.size())
+        getPathnamesForType(files, String(NSFilesPromisePboardType));
+    return files.size();
+}
+
 void PlatformPasteboard::getPathnamesForType(Vector<String>& pathnames, const String& pasteboardType)
 {
     NSArray* paths = [m_pasteboard.get() propertyListForType:pasteboardType];
index cfce5d2..c4ba332 100644 (file)
@@ -1,3 +1,17 @@
+2017-04-15  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [WK2] Support data interaction of files into file inputs
+        https://bugs.webkit.org/show_bug.cgi?id=170803
+        <rdar://problem/31286130>
+
+        Reviewed by Tim Horton.
+
+        Add boilerplate plumbing for fetching the number of files in the pasteboard.
+
+        * WebCoreSupport/WebPlatformStrategies.h:
+        * WebCoreSupport/WebPlatformStrategies.mm:
+        (WebPlatformStrategies::getNumberOfFiles):
+
 2017-04-14  Mark Lam  <mark.lam@apple.com>
 
         Update architectures in xcconfig files.
index ca938be..30c471d 100644 (file)
@@ -66,6 +66,7 @@ private:
     RefPtr<WebCore::SharedBuffer> readBufferFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName) override;
     WebCore::URL readURLFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName) override;
 #endif
+    int getNumberOfFiles(const String& pasteboardName) override;
     void getTypes(Vector<String>& types, const String& pasteboardName) override;
     RefPtr<WebCore::SharedBuffer> bufferForType(const String& pasteboardType, const String& pasteboardName) override;
     void getPathnamesForType(Vector<String>& pathnames, const String& pasteboardType, const String& pasteboardName) override;
index ac2fb44..236cb2d 100644 (file)
@@ -180,6 +180,11 @@ long WebPlatformStrategies::setStringForType(const String& string, const String&
     return PlatformPasteboard(pasteboardName).setStringForType(string, pasteboardType);
 }
 
+int WebPlatformStrategies::getNumberOfFiles(const String& pasteboardName)
+{
+    return PlatformPasteboard(pasteboardName).numberOfFiles();
+}
+
 #if PLATFORM(IOS)
 void WebPlatformStrategies::writeToPasteboard(const WebCore::PasteboardWebContent& content, const String& pasteboardName)
 {
index 6213799..224d83a 100644 (file)
@@ -1,3 +1,43 @@
+2017-04-15  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [WK2] Support data interaction of files into file inputs
+        https://bugs.webkit.org/show_bug.cgi?id=170803
+        <rdar://problem/31286130>
+
+        Reviewed by Tim Horton.
+
+        Implements remaining support for performing data interaction onto file inputs. There are two main changes at
+        this layer: plumbing the number of files in the pasteboard to the web process, and pulling the implementation of
+        createSandboxExtensionsIfNeeded out of Mac-specific WebViewImpl::createSandboxExtensionsIfNeeded and into
+        WebPageProxy::createSandboxExtensionsIfNeeded.
+
+        * Shared/WebCoreArgumentCoders.cpp:
+        (IPC::ArgumentCoder<DragData>::encode):
+        (IPC::ArgumentCoder<DragData>::decode):
+
+        Relax special-casing of encoding and decoding filenames to be PLATFORM(COCOA) rather than PLATFORM(MAC).
+
+        * UIProcess/Cocoa/WebPageProxyCocoa.mm:
+        (WebKit::WebPageProxy::createSandboxExtensionsIfNeeded):
+        * UIProcess/Cocoa/WebPasteboardProxyCocoa.mm:
+        (WebKit::WebPasteboardProxy::getNumberOfFiles):
+
+        More boilerplate plumbing to deliver the number of files in the pasteboard to the web process.
+
+        * UIProcess/Cocoa/WebViewImpl.h:
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::WebViewImpl::performDragOperation):
+        (WebKit::WebViewImpl::createSandboxExtensionsIfNeeded): Deleted.
+
+        Move the logic in WebViewImpl::createSandboxExtensionsIfNeeded over to WebPageProxy::createSandboxExtensionsIfNeeded.
+
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPasteboardProxy.h:
+        * UIProcess/WebPasteboardProxy.messages.in:
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
+        (WebKit::WebPlatformStrategies::getNumberOfFiles):
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.h:
+
 2017-04-14  Mark Lam  <mark.lam@apple.com>
 
         Update architectures in xcconfig files.
index 71e7e7d..b84131c 100644 (file)
@@ -1219,8 +1219,6 @@ void ArgumentCoder<DragData>::encode(Encoder& encoder, const DragData& dragData)
     encoder.encodeEnum(dragData.flags());
 #if PLATFORM(COCOA)
     encoder << dragData.pasteboardName();
-#endif
-#if PLATFORM(MAC)
     encoder << dragData.fileNames();
 #endif
     encoder.encodeEnum(dragData.dragDestinationAction());
@@ -1245,12 +1243,11 @@ bool ArgumentCoder<DragData>::decode(Decoder& decoder, DragData& dragData)
         return false;
 
     String pasteboardName;
+    Vector<String> fileNames;
 #if PLATFORM(COCOA)
     if (!decoder.decode(pasteboardName))
         return false;
-#endif
-    Vector<String> fileNames;
-#if PLATFORM(MAC)
+
     if (!decoder.decode(fileNames))
         return false;
 #endif
index 5ff893b..8f04454 100644 (file)
@@ -80,4 +80,26 @@ void WebPageProxy::addPlatformLoadParameters(LoadParameters& loadParameters)
     loadParameters.dataDetectionContext = m_uiClient->dataDetectionContext();
 }
 
+void WebPageProxy::createSandboxExtensionsIfNeeded(const Vector<String>& files, SandboxExtension::Handle& fileReadHandle, SandboxExtension::HandleArray& fileUploadHandles)
+{
+    if (!files.size())
+        return;
+
+    if (files.size() == 1) {
+        BOOL isDirectory;
+        if ([[NSFileManager defaultManager] fileExistsAtPath:files[0] isDirectory:&isDirectory] && !isDirectory) {
+            SandboxExtension::createHandle("/", SandboxExtension::ReadOnly, fileReadHandle);
+            process().willAcquireUniversalFileReadSandboxExtension();
+        }
+    }
+
+    fileUploadHandles.allocate(files.size());
+    for (size_t i = 0; i< files.size(); i++) {
+        NSString *file = files[i];
+        if (![[NSFileManager defaultManager] fileExistsAtPath:file])
+            continue;
+        SandboxExtension::createHandle(file, SandboxExtension::ReadOnly, fileUploadHandles[i]);
+    }
+}
+
 }
index e4f2301..406432d 100644 (file)
@@ -134,6 +134,11 @@ void WebPasteboardProxy::setPasteboardBufferForType(const String& pasteboardName
     newChangeCount = PlatformPasteboard(pasteboardName).setBufferForType(buffer.get(), pasteboardType);
 }
 
+void WebPasteboardProxy::getNumberOfFiles(const String& pasteboardName, uint64_t& numberOfFiles)
+{
+    numberOfFiles = PlatformPasteboard(pasteboardName).numberOfFiles();
+}
+
 #if PLATFORM(IOS)
 void WebPasteboardProxy::writeWebContentToPasteboard(const WebCore::PasteboardWebContent& content, const String& pasteboardName)
 {
index b1929bc..319a362 100644 (file)
@@ -588,7 +588,6 @@ private:
 
     bool mightBeginDragWhileInactive();
     bool mightBeginScrollWhileInactive();
-    void createSandboxExtensionsIfNeeded(const Vector<String>& files, SandboxExtension::Handle&, SandboxExtension::HandleArray& handles);
 
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
     void handleRequestedCandidates(NSInteger sequenceNumber, NSArray<NSTextCheckingResult *> *candidates);
index 46e5a8c..75e7ae2 100644 (file)
@@ -3642,28 +3642,6 @@ bool WebViewImpl::prepareForDragOperation(id <NSDraggingInfo>)
     return true;
 }
 
-void WebViewImpl::createSandboxExtensionsIfNeeded(const Vector<String>& files, SandboxExtension::Handle& handle, SandboxExtension::HandleArray& handles)
-{
-    if (!files.size())
-        return;
-
-    if (files.size() == 1) {
-        BOOL isDirectory;
-        if ([[NSFileManager defaultManager] fileExistsAtPath:files[0] isDirectory:&isDirectory] && !isDirectory) {
-            SandboxExtension::createHandle("/", SandboxExtension::ReadOnly, handle);
-            m_page->process().willAcquireUniversalFileReadSandboxExtension();
-        }
-    }
-
-    handles.allocate(files.size());
-    for (size_t i = 0; i< files.size(); i++) {
-        NSString *file = files[i];
-        if (![[NSFileManager defaultManager] fileExistsAtPath:file])
-            continue;
-        SandboxExtension::createHandle(file, SandboxExtension::ReadOnly, handles[i]);
-    }
-}
-
 bool WebViewImpl::performDragOperation(id <NSDraggingInfo> draggingInfo)
 {
     WebCore::IntPoint client([m_view convertPoint:draggingInfo.draggingLocation fromView:nil]);
@@ -3685,7 +3663,7 @@ bool WebViewImpl::performDragOperation(id <NSDraggingInfo> draggingInfo)
 
         for (NSString *file in files)
             fileNames.append(file);
-        createSandboxExtensionsIfNeeded(fileNames, sandboxExtensionHandle, sandboxExtensionForUpload);
+        m_page->createSandboxExtensionsIfNeeded(fileNames, sandboxExtensionHandle, sandboxExtensionForUpload);
     }
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
     else if (![types containsObject:PasteboardTypes::WebArchivePboardType] && [types containsObject:NSFilesPromisePboardType]) {
@@ -3712,7 +3690,7 @@ bool WebViewImpl::performDragOperation(id <NSDraggingInfo> draggingInfo)
                         SandboxExtension::Handle sandboxExtensionHandle;
                         SandboxExtension::HandleArray sandboxExtensionForUpload;
 
-                        createSandboxExtensionsIfNeeded(*fileNames, sandboxExtensionHandle, sandboxExtensionForUpload);
+                        m_page->createSandboxExtensionsIfNeeded(*fileNames, sandboxExtensionHandle, sandboxExtensionForUpload);
                         dragData->setFileNames(*fileNames);
                         m_page->performDragOperation(*dragData, pasteboardName, sandboxExtensionHandle, sandboxExtensionForUpload);
                         delete dragData;
index 058c59b..b1cb846 100644 (file)
@@ -1191,6 +1191,10 @@ public:
     void setURLSchemeHandlerForScheme(Ref<WebURLSchemeHandler>&&, const String& scheme);
     WebURLSchemeHandler* urlSchemeHandlerForScheme(const String& scheme);
 
+#if PLATFORM(COCOA)
+    void createSandboxExtensionsIfNeeded(const Vector<String>& files, SandboxExtension::Handle& fileReadHandle, SandboxExtension::HandleArray& fileUploadHandles);
+#endif
+
 private:
     WebPageProxy(PageClient&, WebProcessProxy&, uint64_t pageID, Ref<API::PageConfiguration>&&);
     void platformInitialize();
index f156e4b..e43d1a1 100644 (file)
@@ -77,6 +77,7 @@ private:
     void getPasteboardItemsCount(const String& pasteboardName, uint64_t& itemsCount);
 #endif
 #if PLATFORM(COCOA)
+    void getNumberOfFiles(const String& pasteboardName, uint64_t& numberOfFiles);
     void getPasteboardTypes(const String& pasteboardName, Vector<String>& pasteboardTypes);
     void getPasteboardPathnamesForType(const String& pasteboardName, const String& pasteboardType, Vector<String>& pathnames);
     void getPasteboardStringForType(const String& pasteboardName, const String& pasteboardType, String&);
index c267922..c1e99ff 100644 (file)
@@ -33,6 +33,7 @@ messages -> WebPasteboardProxy {
 
 #if PLATFORM(COCOA)
     # Pasteboard messages.
+    GetNumberOfFiles(String pasteboardName) -> (uint64_t numberOfFiles)
     GetPasteboardTypes(String pasteboardName) -> (Vector<String> types)
     GetPasteboardPathnamesForType(String pasteboardName, String pasteboardType) -> (Vector<String> pathnames)
     GetPasteboardStringForType(String pasteboardName, String pasteboardType) -> (String string)
index bd48979..050563f 100644 (file)
@@ -279,6 +279,13 @@ long WebPlatformStrategies::setStringForType(const String& string, const String&
     return newChangeCount;
 }
 
+int WebPlatformStrategies::getNumberOfFiles(const String& pasteboardName)
+{
+    uint64_t numberOfFiles;
+    WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::GetNumberOfFiles(pasteboardName), Messages::WebPasteboardProxy::GetNumberOfFiles::Reply(numberOfFiles), 0);
+    return numberOfFiles;
+}
+
 #if PLATFORM(IOS)
 void WebPlatformStrategies::writeToPasteboard(const WebCore::PasteboardWebContent& content, const String& pasteboardName)
 {
index 355d8a6..2d7d8a5 100644 (file)
@@ -68,6 +68,7 @@ private:
     WebCore::URL readURLFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName) override;
 #endif
 #if PLATFORM(COCOA)
+    int getNumberOfFiles(const String& pasteboardName) override;
     void getTypes(Vector<String>& types, const String& pasteboardName) override;
     RefPtr<WebCore::SharedBuffer> bufferForType(const String& pasteboardType, const String& pasteboardName) override;
     void getPathnamesForType(Vector<String>& pathnames, const String& pasteboardType, const String& pasteboardName) override;