+2019-02-18 Dean Jackson <dino@apple.com>
+
+ iOS Safari will not load USDZ in QLPreview when opening as BLOB
+ https://bugs.webkit.org/show_bug.cgi?id=194766
+ <rdar://problem/42769186>
+
+ Reviewed by Wenson Hsieh.
+
+ A download from a Blob URL can happen effectively instantly, which means
+ that the loadHandler on the registerItemForTypeIdentifier method might not have
+ been called yet, and we haven't been told what the completionHandler is.
+ In this case, keep a record of the URL we finished with, and call the completionHandler
+ right away.
+
+ * UIProcess/Cocoa/SystemPreviewControllerCocoa.mm: Add a new private member variable: _downloadedURL.
+ (-[_WKPreviewControllerDataSource previewController:previewItemAtIndex:]): Call the completionHandler
+ right away if we've finished.
+ (-[_WKPreviewControllerDataSource finish:]): Remember that we've finished by recording the URL.
+
2019-02-18 Alex Christensen <achristensen@webkit.org>
Disable safe browsing in WKWebView and remove its WKPreferences API
@interface _WKPreviewControllerDataSource : NSObject <QLPreviewControllerDataSource> {
RetainPtr<NSItemProvider> _itemProvider;
RetainPtr<QLItem> _item;
+ URL _downloadedURL;
};
@property (strong) NSItemProviderCompletionHandler completionHandler;
WeakObjCPtr<_WKPreviewControllerDataSource> weakSelf { self };
[_itemProvider registerItemForTypeIdentifier:contentType loadHandler:[weakSelf = WTFMove(weakSelf)] (NSItemProviderCompletionHandler completionHandler, Class expectedValueClass, NSDictionary * options) {
- if (auto strongSelf = weakSelf.get())
- [strongSelf setCompletionHandler:completionHandler];
+ if (auto strongSelf = weakSelf.get()) {
+ // If the download happened instantly, the call to finish might have come before this
+ // loadHandler. In that case, call the completionHandler here.
+ if (!strongSelf->_downloadedURL.isEmpty())
+ completionHandler((NSURL*)strongSelf->_downloadedURL, nil);
+ else
+ [strongSelf setCompletionHandler:completionHandler];
+ }
}];
return _item.get();
}
- (void)finish:(URL)url
{
+ _downloadedURL = url;
+
if (self.completionHandler)
self.completionHandler((NSURL*)url, nil);
}