Show the web page URL when sharing an AR model
authorgraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Jun 2019 05:57:09 +0000 (05:57 +0000)
committergraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Jun 2019 05:57:09 +0000 (05:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=198812
<rdar://problem/48689498>

Reviewed by Dean Jackson.

Source/WebCore/PAL:

* pal/spi/ios/SystemPreviewSPI.h:

Source/WebKit:

* UIProcess/Cocoa/DownloadClient.mm:
(WebKit::DownloadClient::didStart):
* UIProcess/Cocoa/SystemPreviewControllerCocoa.mm:
(-[_WKPreviewControllerDataSource initWithMIMEType:originatingPageURL:]):
(-[_WKPreviewControllerDataSource previewController:previewItemAtIndex:]):
(WebKit::SystemPreviewController::start):
(-[_WKPreviewControllerDataSource initWithMIMEType:]): Deleted.
* UIProcess/SystemPreviewController.h:

Source/WTF:

* wtf/Platform.h:

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

Source/WTF/ChangeLog
Source/WTF/wtf/Platform.h
Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/pal/spi/ios/SystemPreviewSPI.h
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/Cocoa/DownloadClient.mm
Source/WebKit/UIProcess/Cocoa/SystemPreviewControllerCocoa.mm
Source/WebKit/UIProcess/SystemPreviewController.h

index 72eea33..edf2cef 100644 (file)
@@ -1,3 +1,13 @@
+2019-06-12  Antoine Quint  <graouts@apple.com>
+
+        Show the web page URL when sharing an AR model
+        https://bugs.webkit.org/show_bug.cgi?id=198812
+        <rdar://problem/48689498>
+
+        Reviewed by Dean Jackson.
+
+        * wtf/Platform.h:
+
 2019-06-12  Youenn Fablet  <youenn@apple.com>
 
         Use NSURLSession for WebSocket
index 9d43bff..d56b0b2 100644 (file)
 #endif
 
 #if PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000
+#define HAVE_ARKIT_QUICK_LOOK_PREVIEW_ITEM 1
+#endif
+
+#if PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000
 #define HAVE_UI_WK_DOCUMENT_CONTEXT 1
 #endif
 
index 96691b2..7d873f5 100644 (file)
@@ -1,3 +1,13 @@
+2019-06-12  Antoine Quint  <graouts@apple.com>
+
+        Show the web page URL when sharing an AR model
+        https://bugs.webkit.org/show_bug.cgi?id=198812
+        <rdar://problem/48689498>
+
+        Reviewed by Dean Jackson.
+
+        * pal/spi/ios/SystemPreviewSPI.h:
+
 2019-06-10  Sam Weinig  <weinig@apple.com>
 
         Remove Dashboard support
index 39e7518..bec7f90 100644 (file)
 
 #if USE(APPLE_INTERNAL_SDK)
 
+#if HAVE(ARKIT_QUICK_LOOK_PREVIEW_ITEM)
+#import <AssetViewer/ARQuickLookWebKitItem.h>
+#endif
+
 #import <AssetViewer/ASVThumbnailView.h>
 
 #else
 @property (nonatomic) CGSize maxThumbnailSize;
 @end
 
+#if HAVE(ARKIT_QUICK_LOOK_PREVIEW_ITEM)
+#import <ARKit/ARKit.h>
+
+@class ARQuickLookWebKitItem;
+
+@interface ARQuickLookWebKitItem : QLItem
+- (instancetype)initWithPreviewItemProvider:(NSItemProvider *_Nonnull)itemProvider contentType:(NSString *_Nonnull)contentType previewTitle:(NSString *_Nonnull)previewTitle fileSize:(NSNumber *_Nonnull)fileSize previewItem:(ARQuickLookPreviewItem *)previewItem;
+@end
+#endif
+
 #endif
 
index c2540a3..0d99009 100644 (file)
@@ -1,3 +1,20 @@
+2019-06-12  Antoine Quint  <graouts@apple.com>
+
+        Show the web page URL when sharing an AR model
+        https://bugs.webkit.org/show_bug.cgi?id=198812
+        <rdar://problem/48689498>
+
+        Reviewed by Dean Jackson.
+
+        * UIProcess/Cocoa/DownloadClient.mm:
+        (WebKit::DownloadClient::didStart):
+        * UIProcess/Cocoa/SystemPreviewControllerCocoa.mm:
+        (-[_WKPreviewControllerDataSource initWithMIMEType:originatingPageURL:]):
+        (-[_WKPreviewControllerDataSource previewController:previewItemAtIndex:]):
+        (WebKit::SystemPreviewController::start):
+        (-[_WKPreviewControllerDataSource initWithMIMEType:]): Deleted.
+        * UIProcess/SystemPreviewController.h:
+
 2019-06-12  Antti Koivisto  <antti@apple.com>
 
         Try to fix iOS build.
index a640f98..36ede72 100644 (file)
@@ -71,7 +71,7 @@ void DownloadClient::didStart(WebProcessPool&, DownloadProxy& downloadProxy)
     if (downloadProxy.isSystemPreviewDownload()) {
         if (auto* webPage = downloadProxy.originatingPage()) {
             // FIXME: Update the MIME-type once it is known in the ResourceResponse.
-            webPage->systemPreviewController()->start("application/octet-stream"_s, downloadProxy.systemPreviewDownloadRect());
+            webPage->systemPreviewController()->start(URL(URL(), webPage->currentURL()), "application/octet-stream"_s, downloadProxy.systemPreviewDownloadRect());
         }
         takeActivityToken(downloadProxy);
         return;
index 58834e9..8e01cc5 100644 (file)
 #import <pal/spi/ios/QuickLookSPI.h>
 #import <wtf/WeakObjCPtr.h>
 
+#if HAVE(ARKIT_QUICK_LOOK_PREVIEW_ITEM)
+#import <pal/spi/ios/SystemPreviewSPI.h>
+SOFT_LINK_PRIVATE_FRAMEWORK(ARKit);
+SOFT_LINK_CLASS(ARKit, ARQuickLookPreviewItem);
+SOFT_LINK_PRIVATE_FRAMEWORK(AssetViewer);
+SOFT_LINK_CLASS(AssetViewer, ARQuickLookWebKitItem);
+#endif
+
 @interface _WKPreviewControllerDataSource : NSObject <QLPreviewControllerDataSource> {
     RetainPtr<NSItemProvider> _itemProvider;
+#if HAVE(ARKIT_QUICK_LOOK_PREVIEW_ITEM)
+    RetainPtr<ARQuickLookWebKitItem> _item;
+#else
     RetainPtr<QLItem> _item;
+#endif
+    URL _originatingPageURL;
     URL _downloadedURL;
 };
 
 
 @implementation _WKPreviewControllerDataSource
 
-- (instancetype)initWithMIMEType:(NSString*)mimeType
+- (instancetype)initWithMIMEType:(NSString*)mimeType originatingPageURL:(URL)url
 {
     if (!(self = [super init]))
         return nil;
 
+    _originatingPageURL = url;
     _mimeType = [mimeType copy];
 
     return self;
     // means we don't actually know the real MIME type yet.
     NSString *contentType = WebCore::UTIFromMIMEType("model/vnd.usdz+zip"_s);
 
+#if HAVE(ARKIT_QUICK_LOOK_PREVIEW_ITEM)
+    ARQuickLookPreviewItem *previewItem = [allocARQuickLookPreviewItemInstance() initWithFileAtURL:_downloadedURL];
+    previewItem.canonicalWebPageURL = _originatingPageURL;
+
+    _item = [allocARQuickLookWebKitItemInstance() initWithPreviewItemProvider:_itemProvider.get() contentType:contentType previewTitle:@"Preview" fileSize:@(0) previewItem:previewItem];
+#else
     _item = adoptNS([PAL::allocQLItemInstance() initWithPreviewItemProvider:_itemProvider.get() contentType:contentType previewTitle:@"Preview" fileSize:@(0)]);
+#endif
     [_item setUseLoadingTimeout:NO];
 
     WeakObjCPtr<_WKPreviewControllerDataSource> weakSelf { self };
 
 namespace WebKit {
 
-void SystemPreviewController::start(const String& mimeType, const WebCore::IntRect& fromRect)
+void SystemPreviewController::start(URL originatingPageURL, const String& mimeType, const WebCore::IntRect& fromRect)
 {
     ASSERT(!m_qlPreviewController);
     if (m_qlPreviewController)
@@ -213,7 +234,7 @@ void SystemPreviewController::start(const String& mimeType, const WebCore::IntRe
     m_qlPreviewControllerDelegate = adoptNS([[_WKPreviewControllerDelegate alloc] initWithSystemPreviewController:this fromRect:fromRect]);
     [m_qlPreviewController setDelegate:m_qlPreviewControllerDelegate.get()];
 
-    m_qlPreviewControllerDataSource = adoptNS([[_WKPreviewControllerDataSource alloc] initWithMIMEType:mimeType]);
+    m_qlPreviewControllerDataSource = adoptNS([[_WKPreviewControllerDataSource alloc] initWithMIMEType:mimeType originatingPageURL:originatingPageURL]);
     [m_qlPreviewController setDataSource:m_qlPreviewControllerDataSource.get()];
 
     [presentingViewController presentViewController:m_qlPreviewController.get() animated:YES completion:nullptr];
index 269d0c3..f261f52 100644 (file)
@@ -48,7 +48,7 @@ public:
 
     bool canPreview(const String& mimeType) const;
 
-    void start(const String& mimeType, const WebCore::IntRect&);
+    void start(URL originatingPageURL, const String& mimeType, const WebCore::IntRect&);
     void updateProgress(float);
     void finish(URL);
     void cancel();