Changeset 231858 in webkit


Ignore:
Timestamp:
May 16, 2018 11:47:31 AM (6 years ago)
Author:
bshafiei@apple.com
Message:

Cherry-pick r231825. rdar://problem/40278181

Launch System Preview as the download starts, rather than waiting for a response
https://bugs.webkit.org/show_bug.cgi?id=185669
<rdar://problem/40278181>

Reviewed by Tim Horton.

We were waiting for the RequestResponse to get a MIME-type before
launching the system preview. This causes an annoying delay.

Instead, assume that the system preview is one of the handled
mime types and launch the viewer immediately. If it gets something it
didn't expect, it will show an error.

  • UIProcess/Cocoa/DownloadClient.mm: (WebKit::DownloadClient::didStart): (WebKit::DownloadClient::didReceiveResponse):
  • UIProcess/Cocoa/SystemPreviewControllerCocoa.mm: (-[_WKPreviewControllerDataSource previewController:previewItemAtIndex:]): (WebKit::SystemPreviewController::start): Small cleanup to ensure we don't try to present twice (this shouldn't happen).

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

Location:
branches/safari-606.1.17-branch/Source/WebKit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-606.1.17-branch/Source/WebKit/ChangeLog

    r231857 r231858  
     12018-05-16  Babak Shafiei  <bshafiei@apple.com>
     2
     3        Cherry-pick r231825. rdar://problem/40278181
     4
     5    Launch System Preview as the download starts, rather than waiting for a response
     6    https://bugs.webkit.org/show_bug.cgi?id=185669
     7    <rdar://problem/40278181>
     8   
     9    Reviewed by Tim Horton.
     10   
     11    We were waiting for the RequestResponse to get a MIME-type before
     12    launching the system preview. This causes an annoying delay.
     13   
     14    Instead, assume that the system preview is one of the handled
     15    mime types and launch the viewer immediately. If it gets something it
     16    didn't expect, it will show an error.
     17   
     18    * UIProcess/Cocoa/DownloadClient.mm:
     19    (WebKit::DownloadClient::didStart):
     20    (WebKit::DownloadClient::didReceiveResponse):
     21    * UIProcess/Cocoa/SystemPreviewControllerCocoa.mm:
     22    (-[_WKPreviewControllerDataSource previewController:previewItemAtIndex:]):
     23    (WebKit::SystemPreviewController::start): Small cleanup to ensure we
     24    don't try to present twice (this shouldn't happen).
     25   
     26    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231825 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     27
     28    2018-05-15  Dean Jackson  <dino@apple.com>
     29
     30            Launch System Preview as the download starts, rather than waiting for a response
     31            https://bugs.webkit.org/show_bug.cgi?id=185669
     32            <rdar://problem/40278181>
     33
     34            Reviewed by Tim Horton.
     35
     36            We were waiting for the RequestResponse to get a MIME-type before
     37            launching the system preview. This causes an annoying delay.
     38
     39            Instead, assume that the system preview is one of the handled
     40            mime types and launch the viewer immediately. If it gets something it
     41            didn't expect, it will show an error.
     42
     43            * UIProcess/Cocoa/DownloadClient.mm:
     44            (WebKit::DownloadClient::didStart):
     45            (WebKit::DownloadClient::didReceiveResponse):
     46            * UIProcess/Cocoa/SystemPreviewControllerCocoa.mm:
     47            (-[_WKPreviewControllerDataSource previewController:previewItemAtIndex:]):
     48            (WebKit::SystemPreviewController::start): Small cleanup to ensure we
     49            don't try to present twice (this shouldn't happen).
     50
    1512018-05-16  Babak Shafiei  <bshafiei@apple.com>
    252
  • branches/safari-606.1.17-branch/Source/WebKit/UIProcess/Cocoa/DownloadClient.mm

    r231857 r231858  
    7777#if USE(SYSTEM_PREVIEW)
    7878    if (downloadProxy.isSystemPreviewDownload()) {
     79        if (auto* webPage = downloadProxy.originatingPage()) {
     80            // FIXME: Update the MIME-type once it is known in the ResourceResponse.
     81            webPage->systemPreviewController()->start(ASCIILiteral { "application/octet-stream" });
     82        }
    7983        takeActivityToken(downloadProxy);
    8084        return;
     
    9296        downloadProxy.setExpectedContentLength(response.expectedContentLength());
    9397        downloadProxy.setBytesLoaded(0);
    94         if (auto* webPage = downloadProxy.originatingPage()) {
    95             webPage->systemPreviewController()->start(response.mimeType());
     98        if (auto* webPage = downloadProxy.originatingPage())
    9699            webPage->systemPreviewController()->updateProgress(0);
    97         }
    98100        return;
    99101    }
  • branches/safari-606.1.17-branch/Source/WebKit/UIProcess/Cocoa/SystemPreviewControllerCocoa.mm

    r231857 r231858  
    8181    NSString *contentType = @"public.content";
    8282#if USE(APPLE_INTERNAL_SDK)
    83     contentType = WebKit::getUTIForMIMEType(self.mimeType);
     83    // FIXME: We are launching the preview controller before getting a response from the resource, which
     84    // means we don't actually know the real MIME type yet. Assume it is one of those that we registered.
     85    contentType = WebKit::getUTIForMIMEType(*WebKit::getSystemPreviewMIMETypes().begin());
    8486#endif
    8587    _item = adoptNS([allocQLItemInstance() initWithPreviewItemProvider:_itemProvider.get() contentType:contentType previewTitle:@"Preview" fileSize:@(0)]);
     
    159161void SystemPreviewController::start(const String& mimeType)
    160162{
    161     // FIXME: Make sure you can't show a preview if we're already previewing.
     163    ASSERT(!m_qlPreviewController);
     164    if (m_qlPreviewController)
     165        return;
    162166
    163167    UIViewController *presentingViewController = m_webPageProxy.uiClient().presentingViewController();
     
    166170        return;
    167171
    168     if (!m_qlPreviewController) {
    169         m_qlPreviewController = adoptNS([allocQLPreviewControllerInstance() init]);
    170 
    171         m_qlPreviewControllerDelegate = adoptNS([[_WKPreviewControllerDelegate alloc] initWithSystemPreviewController:this]);
    172         [m_qlPreviewController setDelegate:m_qlPreviewControllerDelegate.get()];
    173 
    174         m_qlPreviewControllerDataSource = adoptNS([[_WKPreviewControllerDataSource alloc] initWithMIMEType:mimeType]);
    175         [m_qlPreviewController setDataSource:m_qlPreviewControllerDataSource.get()];
    176 
    177     }
     172    m_qlPreviewController = adoptNS([allocQLPreviewControllerInstance() init]);
     173
     174    m_qlPreviewControllerDelegate = adoptNS([[_WKPreviewControllerDelegate alloc] initWithSystemPreviewController:this]);
     175    [m_qlPreviewController setDelegate:m_qlPreviewControllerDelegate.get()];
     176
     177    m_qlPreviewControllerDataSource = adoptNS([[_WKPreviewControllerDataSource alloc] initWithMIMEType:mimeType]);
     178    [m_qlPreviewController setDataSource:m_qlPreviewControllerDataSource.get()];
    178179
    179180    [presentingViewController presentViewController:m_qlPreviewController.get() animated:YES completion:nullptr];
Note: See TracChangeset for help on using the changeset viewer.