<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[210360] trunk/Source</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/210360">210360</a></dd>
<dt>Author</dt> <dd>enrica@apple.com</dd>
<dt>Date</dt> <dd>2017-01-05 10:29:00 -0800 (Thu, 05 Jan 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>Support File Promise during drag for macOS.
https://bugs.webkit.org/show_bug.cgi?id=165204
rdar://problem/19595567
Reviewed by Tim Horton.
Source/WebCore:
Adds the support for handling File Promise type during
drag. DragData now has the knowledge of the NSFilesPromisePboardType and
checks for the data type during drag.
* page/mac/DragControllerMac.mm:
(WebCore::DragController::dragOperation):
* platform/DragData.h:
(WebCore::DragData::setFileNames):
(WebCore::DragData::fileNames):
* platform/mac/DragDataMac.mm:
(WebCore::DragData::containsFiles):
(WebCore::DragData::numberOfFiles):
(WebCore::DragData::asFilenames):
(WebCore::DragData::containsCompatibleContent):
(WebCore::DragData::containsPromise):
(WebCore::DragData::asURL):
Source/WebKit/mac:
Adds support for dropping a File Promise in a WebView.
The implementation uses new File Promise API available in Sierra.
* Misc/WebNSPasteboardExtras.mm:
(+[NSPasteboard _web_dragTypesForURL]):
* WebView/WebView.mm:
(-[WebView performDragOperation:]):
Source/WebKit2:
Adds support for dropping a File Promise in a WKWebView.
The implementation uses new File Promise API available in Sierra.
* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<DragData>::encode):
(IPC::ArgumentCoder<DragData>::decode):
* Shared/mac/PasteboardTypes.mm:
(WebKit::PasteboardTypes::forURL):
* UIProcess/Cocoa/WebViewImpl.h:
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::createSandboxExtensionsIfNeeded):
(WebKit::WebViewImpl::performDragOperation):
(WebKit::maybeCreateSandboxExtensionFromPasteboard): Deleted.
(WebKit::createSandboxExtensionsForFileUpload): Deleted.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorepagemacDragControllerMacmm">trunk/Source/WebCore/page/mac/DragControllerMac.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformDragDatah">trunk/Source/WebCore/platform/DragData.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmacDragDataMacmm">trunk/Source/WebCore/platform/mac/DragDataMac.mm</a></li>
<li><a href="#trunkSourceWebKitmacChangeLog">trunk/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitmacMiscWebNSPasteboardExtrasmm">trunk/Source/WebKit/mac/Misc/WebNSPasteboardExtras.mm</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebViewmm">trunk/Source/WebKit/mac/WebView/WebView.mm</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedWebCoreArgumentCoderscpp">trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharedmacPasteboardTypesmm">trunk/Source/WebKit2/Shared/mac/PasteboardTypes.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWebViewImplh">trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWebViewImplmm">trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (210359 => 210360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-01-05 18:05:29 UTC (rev 210359)
+++ trunk/Source/WebCore/ChangeLog        2017-01-05 18:29:00 UTC (rev 210360)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2017-01-05 Enrica Casucci <enrica@apple.com>
+
+ Support File Promise during drag for macOS.
+ https://bugs.webkit.org/show_bug.cgi?id=165204
+ rdar://problem/19595567
+
+ Reviewed by Tim Horton.
+
+ Adds the support for handling File Promise type during
+ drag. DragData now has the knowledge of the NSFilesPromisePboardType and
+ checks for the data type during drag.
+
+ * page/mac/DragControllerMac.mm:
+ (WebCore::DragController::dragOperation):
+ * platform/DragData.h:
+ (WebCore::DragData::setFileNames):
+ (WebCore::DragData::fileNames):
+ * platform/mac/DragDataMac.mm:
+ (WebCore::DragData::containsFiles):
+ (WebCore::DragData::numberOfFiles):
+ (WebCore::DragData::asFilenames):
+ (WebCore::DragData::containsCompatibleContent):
+ (WebCore::DragData::containsPromise):
+ (WebCore::DragData::asURL):
+
</ins><span class="cx"> 2017-01-05 Per Arne Vollan <pvollan@apple.com>
</span><span class="cx">
</span><span class="cx"> [Win] Compile error.
</span></span></pre></div>
<a id="trunkSourceWebCorepagemacDragControllerMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/mac/DragControllerMac.mm (210359 => 210360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/mac/DragControllerMac.mm        2017-01-05 18:05:29 UTC (rev 210359)
+++ trunk/Source/WebCore/page/mac/DragControllerMac.mm        2017-01-05 18:29:00 UTC (rev 210360)
</span><span class="lines">@@ -61,7 +61,7 @@
</span><span class="cx">
</span><span class="cx"> DragOperation DragController::dragOperation(const DragData& dragData)
</span><span class="cx"> {
</span><del>- if ((dragData.flags() & DragApplicationIsModal) || !dragData.containsURL())
</del><ins>+ if ((dragData.flags() & DragApplicationIsModal) || !(dragData.containsURL() || dragData.containsPromise()))
</ins><span class="cx"> return DragOperationNone;
</span><span class="cx">
</span><span class="cx"> if (!m_documentUnderMouse || (!(dragData.flags() & (DragApplicationHasAttachedSheet | DragApplicationIsSource))))
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformDragDatah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/DragData.h (210359 => 210360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/DragData.h        2017-01-05 18:05:29 UTC (rev 210359)
+++ trunk/Source/WebCore/platform/DragData.h        2017-01-05 18:29:00 UTC (rev 210360)
</span><span class="lines">@@ -105,8 +105,11 @@
</span><span class="cx"> bool containsColor() const;
</span><span class="cx"> bool containsFiles() const;
</span><span class="cx"> unsigned numberOfFiles() const;
</span><ins>+ void setFileNames(Vector<String>& fileNames) { m_fileNames = WTFMove(fileNames); }
+ const Vector<String>& fileNames() const { return m_fileNames; }
</ins><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx"> const String& pasteboardName() const { return m_pasteboardName; }
</span><ins>+ bool containsPromise() const;
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(GTK)
</span><span class="lines">@@ -128,6 +131,7 @@
</span><span class="cx"> DragDataRef m_platformDragData;
</span><span class="cx"> DragOperation m_draggingSourceOperationMask;
</span><span class="cx"> DragApplicationFlags m_applicationFlags;
</span><ins>+ Vector<String> m_fileNames;
</ins><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx"> String m_pasteboardName;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmacDragDataMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/DragDataMac.mm (210359 => 210360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/DragDataMac.mm        2017-01-05 18:05:29 UTC (rev 210359)
+++ trunk/Source/WebCore/platform/mac/DragDataMac.mm        2017-01-05 18:29:00 UTC (rev 210360)
</span><span class="lines">@@ -73,7 +73,7 @@
</span><span class="cx"> {
</span><span class="cx"> Vector<String> types;
</span><span class="cx"> platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName);
</span><del>- return types.contains(String(NSFilenamesPboardType));
</del><ins>+ return types.contains(String(NSFilenamesPboardType)) || types.contains(String(NSFilesPromisePboardType));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> unsigned DragData::numberOfFiles() const
</span><span class="lines">@@ -80,6 +80,8 @@
</span><span class="cx"> {
</span><span class="cx"> Vector<String> files;
</span><span class="cx"> platformStrategies()->pasteboardStrategy()->getPathnamesForType(files, String(NSFilenamesPboardType), m_pasteboardName);
</span><ins>+ if (!files.size())
+ platformStrategies()->pasteboardStrategy()->getPathnamesForType(files, String(NSFilesPromisePboardType), m_pasteboardName);
</ins><span class="cx"> return files.size();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -86,6 +88,8 @@
</span><span class="cx"> void DragData::asFilenames(Vector<String>& result) const
</span><span class="cx"> {
</span><span class="cx"> platformStrategies()->pasteboardStrategy()->getPathnamesForType(result, String(NSFilenamesPboardType), m_pasteboardName);
</span><ins>+ if (!result.size())
+ result = fileNames();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool DragData::containsPlainText() const
</span><span class="lines">@@ -128,6 +132,7 @@
</span><span class="cx"> return types.contains(String(WebArchivePboardType))
</span><span class="cx"> || types.contains(String(NSHTMLPboardType))
</span><span class="cx"> || types.contains(String(NSFilenamesPboardType))
</span><ins>+ || types.contains(String(NSFilesPromisePboardType))
</ins><span class="cx"> || types.contains(String(NSTIFFPboardType))
</span><span class="cx"> || types.contains(String(NSPDFPboardType))
</span><span class="cx"> || types.contains(String(NSURLPboardType))
</span><span class="lines">@@ -137,7 +142,14 @@
</span><span class="cx"> || types.contains(String(NSColorPboardType))
</span><span class="cx"> || types.contains(String(kUTTypePNG));
</span><span class="cx"> }
</span><del>-
</del><ins>+
+bool DragData::containsPromise() const
+{
+ Vector<String> files;
+ platformStrategies()->pasteboardStrategy()->getPathnamesForType(files, String(NSFilesPromisePboardType), m_pasteboardName);
+ return files.size() == 1;
+}
+
</ins><span class="cx"> bool DragData::containsURL(FilenameConversionPolicy filenamePolicy) const
</span><span class="cx"> {
</span><span class="cx"> return !asURL(filenamePolicy).isEmpty();
</span><span class="lines">@@ -184,7 +196,10 @@
</span><span class="cx"> return [URLByCanonicalizingURL([NSURL fileURLWithPath:files[0]]) absoluteString];
</span><span class="cx"> }
</span><span class="cx"> }
</span><del>-
</del><ins>+
+ if (types.contains(String(NSFilesPromisePboardType)) && fileNames().size() == 1)
+ return [URLByCanonicalizingURL([NSURL fileURLWithPath:fileNames()[0]]) absoluteString];
+
</ins><span class="cx"> return String();
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (210359 => 210360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2017-01-05 18:05:29 UTC (rev 210359)
+++ trunk/Source/WebKit/mac/ChangeLog        2017-01-05 18:29:00 UTC (rev 210360)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2017-01-05 Enrica Casucci <enrica@apple.com>
+
+ Support File Promise during drag for macOS.
+ https://bugs.webkit.org/show_bug.cgi?id=165204
+ rdar://problem/19595567
+
+ Reviewed by Tim Horton.
+
+ Adds support for dropping a File Promise in a WebView.
+ The implementation uses new File Promise API available in Sierra.
+
+ * Misc/WebNSPasteboardExtras.mm:
+ (+[NSPasteboard _web_dragTypesForURL]):
+ * WebView/WebView.mm:
+ (-[WebView performDragOperation:]):
+
</ins><span class="cx"> 2017-01-05 Andreas Kling <akling@apple.com>
</span><span class="cx">
</span><span class="cx"> Remove ChromeClient::needTouchEvents().
</span></span></pre></div>
<a id="trunkSourceWebKitmacMiscWebNSPasteboardExtrasmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/Misc/WebNSPasteboardExtras.mm (210359 => 210360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/Misc/WebNSPasteboardExtras.mm        2017-01-05 18:05:29 UTC (rev 210359)
+++ trunk/Source/WebKit/mac/Misc/WebNSPasteboardExtras.mm        2017-01-05 18:29:00 UTC (rev 210360)
</span><span class="lines">@@ -113,6 +113,9 @@
</span><span class="cx"> WebURLNamePboardType,
</span><span class="cx"> NSStringPboardType,
</span><span class="cx"> NSFilenamesPboardType,
</span><ins>+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+ NSFilesPromisePboardType,
+#endif
</ins><span class="cx"> nil];
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (210359 => 210360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebView.mm        2017-01-05 18:05:29 UTC (rev 210359)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm        2017-01-05 18:29:00 UTC (rev 210360)
</span><span class="lines">@@ -40,6 +40,7 @@
</span><span class="cx"> #import "StorageThread.h"
</span><span class="cx"> #import "WebAlternativeTextClient.h"
</span><span class="cx"> #import "WebApplicationCacheInternal.h"
</span><ins>+#import "WebArchive.h"
</ins><span class="cx"> #import "WebBackForwardListInternal.h"
</span><span class="cx"> #import "WebBaseNetscapePluginView.h"
</span><span class="cx"> #import "WebCache.h"
</span><span class="lines">@@ -6517,8 +6518,46 @@
</span><span class="cx"> {
</span><span class="cx"> IntPoint client([draggingInfo draggingLocation]);
</span><span class="cx"> IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
</span><del>- DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
- return core(self)->dragController().performDragOperation(dragData);
</del><ins>+ DragData *dragData = new DragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
+
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+ NSArray* types = draggingInfo.draggingPasteboard.types;
+ if (![types containsObject:WebArchivePboardType] && ![types containsObject:NSFilenamesPboardType] && [types containsObject:NSFilesPromisePboardType]) {
+ NSArray *files = [draggingInfo.draggingPasteboard propertyListForType:NSFilesPromisePboardType];
+ if (![files isKindOfClass:[NSArray class]]) {
+ delete dragData;
+ return false;
+ }
+ size_t fileCount = files.count;
+ Vector<String> *fileNames = new Vector<String>;
+ NSURL *dropLocation = [NSURL fileURLWithPath:NSTemporaryDirectory() isDirectory:YES];
+ [draggingInfo enumerateDraggingItemsWithOptions:0 forView:self classes:@[[NSFilePromiseReceiver class]] searchOptions:@{ } usingBlock:^(NSDraggingItem * __nonnull draggingItem, NSInteger idx, BOOL * __nonnull stop) {
+ NSFilePromiseReceiver *item = draggingItem.item;
+ NSDictionary *options = @{ };
+
+ [item receivePromisedFilesAtDestination:dropLocation options:options operationQueue:[NSOperationQueue new] reader:^(NSURL * _Nonnull fileURL, NSError * _Nullable errorOrNil) {
+ if (errorOrNil)
+ return;
+
+ dispatch_async(dispatch_get_main_queue(), [self, path = RetainPtr<NSString>(fileURL.path), fileNames, fileCount, dragData] {
+ fileNames->append(path.get());
+ if (fileNames->size() == fileCount) {
+ dragData->setFileNames(*fileNames);
+ core(self)->dragController().performDragOperation(*dragData);
+ delete dragData;
+ delete fileNames;
+ }
+ });
+ }];
+ }];
+
+ return true;
+ }
+#endif
+ bool returnValue = core(self)->dragController().performDragOperation(*dragData);
+ delete dragData;
+
+ return returnValue;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (NSView *)_hitTest:(NSPoint *)point dragTypes:(NSSet *)types
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (210359 => 210360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2017-01-05 18:05:29 UTC (rev 210359)
+++ trunk/Source/WebKit2/ChangeLog        2017-01-05 18:29:00 UTC (rev 210360)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2017-01-05 Enrica Casucci <enrica@apple.com>
+
+ Support File Promise during drag for macOS.
+ https://bugs.webkit.org/show_bug.cgi?id=165204
+ rdar://problem/19595567
+
+ Reviewed by Tim Horton.
+
+ Adds support for dropping a File Promise in a WKWebView.
+ The implementation uses new File Promise API available in Sierra.
+
+ * Shared/WebCoreArgumentCoders.cpp:
+ (IPC::ArgumentCoder<DragData>::encode):
+ (IPC::ArgumentCoder<DragData>::decode):
+ * Shared/mac/PasteboardTypes.mm:
+ (WebKit::PasteboardTypes::forURL):
+ * UIProcess/Cocoa/WebViewImpl.h:
+ * UIProcess/Cocoa/WebViewImpl.mm:
+ (WebKit::WebViewImpl::createSandboxExtensionsIfNeeded):
+ (WebKit::WebViewImpl::performDragOperation):
+ (WebKit::maybeCreateSandboxExtensionFromPasteboard): Deleted.
+ (WebKit::createSandboxExtensionsForFileUpload): Deleted.
+
</ins><span class="cx"> 2017-01-05 Andreas Kling <akling@apple.com>
</span><span class="cx">
</span><span class="cx"> Remove ChromeClient::needTouchEvents().
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebCoreArgumentCoderscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp (210359 => 210360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp        2017-01-05 18:05:29 UTC (rev 210359)
+++ trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp        2017-01-05 18:29:00 UTC (rev 210360)
</span><span class="lines">@@ -1225,6 +1225,7 @@
</span><span class="cx"> encoder.encodeEnum(dragData.flags());
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx"> encoder << dragData.pasteboardName();
</span><ins>+ encoder << dragData.fileNames();
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1251,8 +1252,12 @@
</span><span class="cx"> if (!decoder.decode(pasteboardName))
</span><span class="cx"> return false;
</span><span class="cx"> #endif
</span><ins>+ Vector<String> fileNames;
+ if (!decoder.decode(fileNames))
+ return false;
</ins><span class="cx">
</span><span class="cx"> dragData = DragData(pasteboardName, clientPosition, globalPosition, draggingSourceOperationMask, applicationFlags);
</span><ins>+ dragData.setFileNames(fileNames);
</ins><span class="cx">
</span><span class="cx"> return true;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedmacPasteboardTypesmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/mac/PasteboardTypes.mm (210359 => 210360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/PasteboardTypes.mm        2017-01-05 18:05:29 UTC (rev 210359)
+++ trunk/Source/WebKit2/Shared/mac/PasteboardTypes.mm        2017-01-05 18:29:00 UTC (rev 210360)
</span><span class="lines">@@ -53,7 +53,11 @@
</span><span class="cx">
</span><span class="cx"> NSArray* PasteboardTypes::forURL()
</span><span class="cx"> {
</span><del>- static NSArray *types = retain([NSArray arrayWithObjects:WebURLsWithTitlesPboardType, NSURLPboardType, WebURLPboardType, WebURLNamePboardType, NSStringPboardType, NSFilenamesPboardType, nil]);
</del><ins>+ static NSArray *types = retain([NSArray arrayWithObjects:WebURLsWithTitlesPboardType, NSURLPboardType, WebURLPboardType, WebURLNamePboardType, NSStringPboardType, NSFilenamesPboardType,
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+ NSFilesPromisePboardType,
+#endif
+ nil]);
</ins><span class="cx"> return types;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebViewImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h (210359 => 210360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h        2017-01-05 18:05:29 UTC (rev 210359)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h        2017-01-05 18:29:00 UTC (rev 210360)
</span><span class="lines">@@ -582,6 +582,7 @@
</span><span class="cx">
</span><span class="cx"> bool mightBeginDragWhileInactive();
</span><span class="cx"> bool mightBeginScrollWhileInactive();
</span><ins>+ void createSandboxExtensionsIfNeeded(const Vector<String>& files, SandboxExtension::Handle&, SandboxExtension::HandleArray& handles);
</ins><span class="cx">
</span><span class="cx"> #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
</span><span class="cx"> void handleRequestedCandidates(NSInteger sequenceNumber, NSArray<NSTextCheckingResult *> *candidates);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebViewImplmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm (210359 => 210360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm        2017-01-05 18:05:29 UTC (rev 210359)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm        2017-01-05 18:29:00 UTC (rev 210360)
</span><span class="lines">@@ -3616,43 +3616,24 @@
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-// FIXME: This code is more or less copied from Pasteboard::getBestURL.
-// It would be nice to be able to share the code somehow.
-static bool maybeCreateSandboxExtensionFromPasteboard(NSPasteboard *pasteboard, SandboxExtension::Handle& sandboxExtensionHandle)
</del><ins>+void WebViewImpl::createSandboxExtensionsIfNeeded(const Vector<String>& files, SandboxExtension::Handle& handle, SandboxExtension::HandleArray& handles)
</ins><span class="cx"> {
</span><del>- NSArray *types = pasteboard.types;
- if (![types containsObject:NSFilenamesPboardType])
- return false;
</del><ins>+ if (!files.size())
+ return;
</ins><span class="cx">
</span><del>- NSArray *files = [pasteboard propertyListForType:NSFilenamesPboardType];
- if (files.count != 1)
- return false;
</del><ins>+ if (files.size() == 1) {
+ BOOL isDirectory;
+ if ([[NSFileManager defaultManager] fileExistsAtPath:files[0] isDirectory:&isDirectory] && !isDirectory) {
+ SandboxExtension::createHandle("/", SandboxExtension::ReadOnly, handle);
+ m_page->process().willAcquireUniversalFileReadSandboxExtension();
+ }
+ }
</ins><span class="cx">
</span><del>- NSString *file = [files objectAtIndex:0];
- BOOL isDirectory;
- if (![[NSFileManager defaultManager] fileExistsAtPath:file isDirectory:&isDirectory])
- return false;
-
- if (isDirectory)
- return false;
-
- SandboxExtension::createHandle("/", SandboxExtension::ReadOnly, sandboxExtensionHandle);
- return true;
-}
-
-static void createSandboxExtensionsForFileUpload(NSPasteboard *pasteboard, SandboxExtension::HandleArray& handles)
-{
- NSArray *types = pasteboard.types;
- if (![types containsObject:NSFilenamesPboardType])
- return;
-
- NSArray *files = [pasteboard propertyListForType:NSFilenamesPboardType];
- handles.allocate(files.count);
- for (unsigned i = 0; i < files.count; i++) {
- NSString *file = [files objectAtIndex:i];
</del><ins>+ handles.allocate(files.size());
+ for (size_t i = 0; i< files.size(); i++) {
+ NSString *file = files[i];
</ins><span class="cx"> if (![[NSFileManager defaultManager] fileExistsAtPath:file])
</span><span class="cx"> continue;
</span><del>- SandboxExtension::Handle handle;
</del><span class="cx"> SandboxExtension::createHandle(file, SandboxExtension::ReadOnly, handles[i]);
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -3661,18 +3642,67 @@
</span><span class="cx"> {
</span><span class="cx"> WebCore::IntPoint client([m_view convertPoint:draggingInfo.draggingLocation fromView:nil]);
</span><span class="cx"> WebCore::IntPoint global(WebCore::globalPoint(draggingInfo.draggingLocation, m_view.window));
</span><del>- WebCore::DragData dragData(draggingInfo, client, global, static_cast<WebCore::DragOperation>(draggingInfo.draggingSourceOperationMask), applicationFlagsForDrag(m_view, draggingInfo));
</del><ins>+ WebCore::DragData *dragData = new WebCore::DragData(draggingInfo, client, global, static_cast<WebCore::DragOperation>(draggingInfo.draggingSourceOperationMask), applicationFlagsForDrag(m_view, draggingInfo));
</ins><span class="cx">
</span><ins>+ NSArray *types = draggingInfo.draggingPasteboard.types;
</ins><span class="cx"> SandboxExtension::Handle sandboxExtensionHandle;
</span><del>- bool createdExtension = maybeCreateSandboxExtensionFromPasteboard(draggingInfo.draggingPasteboard, sandboxExtensionHandle);
- if (createdExtension)
- m_page->process().willAcquireUniversalFileReadSandboxExtension();
-
</del><span class="cx"> SandboxExtension::HandleArray sandboxExtensionForUpload;
</span><del>- createSandboxExtensionsForFileUpload(draggingInfo.draggingPasteboard, sandboxExtensionForUpload);
</del><span class="cx">
</span><del>- m_page->performDragOperation(dragData, draggingInfo.draggingPasteboard.name, sandboxExtensionHandle, sandboxExtensionForUpload);
</del><ins>+ if ([types containsObject:NSFilenamesPboardType]) {
+ NSArray *files = [draggingInfo.draggingPasteboard propertyListForType:NSFilenamesPboardType];
+ if (![files isKindOfClass:[NSArray class]]) {
+ delete dragData;
+ return false;
+ }
</ins><span class="cx">
</span><ins>+ Vector<String> fileNames;
+
+ for (NSString *file in files)
+ fileNames.append(file);
+ createSandboxExtensionsIfNeeded(fileNames, sandboxExtensionHandle, sandboxExtensionForUpload);
+ }
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+ else if (![types containsObject:WebArchivePboardType] && [types containsObject:NSFilesPromisePboardType]) {
+ NSArray *files = [draggingInfo.draggingPasteboard propertyListForType:NSFilesPromisePboardType];
+ if (![files isKindOfClass:[NSArray class]]) {
+ delete dragData;
+ return false;
+ }
+ size_t fileCount = files.count;
+ Vector<String> *fileNames = new Vector<String>;
+ NSURL *dropLocation = [NSURL fileURLWithPath:NSTemporaryDirectory() isDirectory:YES];
+ String pasteboardName = draggingInfo.draggingPasteboard.name;
+ [draggingInfo enumerateDraggingItemsWithOptions:0 forView:m_view classes:@[[NSFilePromiseReceiver class]] searchOptions:@{ } usingBlock:^(NSDraggingItem * __nonnull draggingItem, NSInteger idx, BOOL * __nonnull stop) {
+ NSFilePromiseReceiver *item = draggingItem.item;
+ NSDictionary *options = @{ };
+
+ [item receivePromisedFilesAtDestination:dropLocation options:options operationQueue:[NSOperationQueue new] reader:^(NSURL * _Nonnull fileURL, NSError * _Nullable errorOrNil) {
+ if (errorOrNil)
+ return;
+
+ dispatch_async(dispatch_get_main_queue(), [this, path = RetainPtr<NSString>(fileURL.path), fileNames, fileCount, dragData, pasteboardName] {
+ fileNames->append(path.get());
+ if (fileNames->size() == fileCount) {
+ SandboxExtension::Handle sandboxExtensionHandle;
+ SandboxExtension::HandleArray sandboxExtensionForUpload;
+
+ createSandboxExtensionsIfNeeded(*fileNames, sandboxExtensionHandle, sandboxExtensionForUpload);
+ dragData->setFileNames(*fileNames);
+ m_page->performDragOperation(*dragData, pasteboardName, sandboxExtensionHandle, sandboxExtensionForUpload);
+ delete dragData;
+ delete fileNames;
+ }
+ });
+ }];
+ }];
+
+ return true;
+ }
+#endif
+
+ m_page->performDragOperation(*dragData, draggingInfo.draggingPasteboard.name, sandboxExtensionHandle, sandboxExtensionForUpload);
+ delete dragData;
+
</ins><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>