[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)
commit9f785bed88e99b15d4110333c02b30314c30b54e
tree639550101dfa8bd5e820228007eeca91dd65d21b
parent84b3f55c9eb2d85d853bc3cc265f90d9f55f08b9
[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.

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