Blank viewer comes up and then auto-dismisses when device is not connected to Internet
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Jun 2018 00:26:17 +0000 (00:26 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Jun 2018 00:26:17 +0000 (00:26 +0000)
https://bugs.webkit.org/show_bug.cgi?id=186825
<rdar://problem/40294170>

Reviewed by Tim Horton.

Source/WebCore:

Export isSuccessful() to WebKit.

* platform/network/ResourceResponseBase.h:

Source/WebKit:

Handle the case where the network load fails, and send that
error onto QuickLook.

* UIProcess/Cocoa/DownloadClient.mm:
(WebKit::DownloadClient::didReceiveResponse): Check for success.
(WebKit::DownloadClient::processDidCrash): Cancel in the case of a crash.
(WebKit::DownloadClient::didFail): Propagate the error onto QuickLook.
* UIProcess/Cocoa/SystemPreviewControllerCocoa.mm:
(-[_WKPreviewControllerDataSource failWithError:]): New method that calls
the completion handler with the error data.
(WebKit::SystemPreviewController::fail): New API method.
* UIProcess/SystemPreviewController.h:

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

Source/WebCore/ChangeLog
Source/WebCore/platform/network/ResourceResponseBase.h
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/Cocoa/DownloadClient.mm
Source/WebKit/UIProcess/Cocoa/SystemPreviewControllerCocoa.mm
Source/WebKit/UIProcess/SystemPreviewController.h

index f22ee77..a7ecae8 100644 (file)
@@ -1,3 +1,15 @@
+2018-06-19  Dean Jackson  <dino@apple.com>
+
+        Blank viewer comes up and then auto-dismisses when device is not connected to Internet
+        https://bugs.webkit.org/show_bug.cgi?id=186825
+        <rdar://problem/40294170>
+
+        Reviewed by Tim Horton.
+
+        Export isSuccessful() to WebKit.
+
+        * platform/network/ResourceResponseBase.h:
+
 2018-06-19  Basuke Suzuki  <Basuke.Suzuki@sony.com>
 
         [Curl] Enable Proxy Authentication.
index af695b7..3f7435a 100644 (file)
@@ -75,7 +75,7 @@ public:
 
     bool isNull() const { return m_isNull; }
     WEBCORE_EXPORT bool isHTTP() const;
-    bool isSuccessful() const;
+    WEBCORE_EXPORT bool isSuccessful() const;
 
     WEBCORE_EXPORT const URL& url() const;
     WEBCORE_EXPORT void setURL(const URL&);
index b3bfc1c..74119bb 100644 (file)
@@ -1,3 +1,24 @@
+2018-06-19  Dean Jackson  <dino@apple.com>
+
+        Blank viewer comes up and then auto-dismisses when device is not connected to Internet
+        https://bugs.webkit.org/show_bug.cgi?id=186825
+        <rdar://problem/40294170>
+
+        Reviewed by Tim Horton.
+
+        Handle the case where the network load fails, and send that
+        error onto QuickLook.
+
+        * UIProcess/Cocoa/DownloadClient.mm:
+        (WebKit::DownloadClient::didReceiveResponse): Check for success.
+        (WebKit::DownloadClient::processDidCrash): Cancel in the case of a crash.
+        (WebKit::DownloadClient::didFail): Propagate the error onto QuickLook.
+        * UIProcess/Cocoa/SystemPreviewControllerCocoa.mm:
+        (-[_WKPreviewControllerDataSource failWithError:]): New method that calls
+        the completion handler with the error data.
+        (WebKit::SystemPreviewController::fail): New API method.
+        * UIProcess/SystemPreviewController.h:
+
 2018-06-19  Chris Dumez  <cdumez@apple.com>
 
         Implement IPC throttling to keep the main thread responsive when a process misbehaves
index 9eeabe1..31c1321 100644 (file)
@@ -92,7 +92,7 @@ void DownloadClient::didStart(WebProcessPool&, DownloadProxy& downloadProxy)
 void DownloadClient::didReceiveResponse(WebProcessPool&, DownloadProxy& downloadProxy, const WebCore::ResourceResponse& response)
 {
 #if USE(SYSTEM_PREVIEW)
-    if (downloadProxy.isSystemPreviewDownload()) {
+    if (downloadProxy.isSystemPreviewDownload() && response.isSuccessful()) {
         downloadProxy.setExpectedContentLength(response.expectedContentLength());
         downloadProxy.setBytesLoaded(0);
         if (auto* webPage = downloadProxy.originatingPage())
@@ -177,6 +177,8 @@ void DownloadClient::processDidCrash(WebProcessPool&, DownloadProxy& downloadPro
 {
 #if USE(SYSTEM_PREVIEW)
     if (downloadProxy.isSystemPreviewDownload()) {
+        if (auto* webPage = downloadProxy.originatingPage())
+            webPage->systemPreviewController()->cancel();
         releaseActivityTokenIfNecessary(downloadProxy);
         return;
     }
@@ -239,7 +241,7 @@ void DownloadClient::didFail(WebProcessPool&, DownloadProxy& downloadProxy, cons
 #if USE(SYSTEM_PREVIEW)
     if (downloadProxy.isSystemPreviewDownload()) {
         if (auto* webPage = downloadProxy.originatingPage())
-            webPage->systemPreviewController()->cancel();
+            webPage->systemPreviewController()->fail(error);
         releaseActivityTokenIfNecessary(downloadProxy);
         return;
     }
index 429fb0c..dfc828e 100644 (file)
@@ -114,6 +114,12 @@ SOFT_LINK_CLASS(QuickLook, QLItem);
         self.completionHandler((NSURL*)url, nil);
 }
 
+- (void)failWithError:(NSError *)error
+{
+    if (self.completionHandler)
+        self.completionHandler(nil, error);
+}
+
 @end
 
 @interface _WKPreviewControllerDelegate : NSObject <QLPreviewControllerDelegate> {
@@ -234,6 +240,12 @@ void SystemPreviewController::cancel()
     m_qlPreviewController = nullptr;
 }
 
+void SystemPreviewController::fail(const WebCore::ResourceError& error)
+{
+    if (m_qlPreviewControllerDataSource)
+        [m_qlPreviewControllerDataSource failWithError:error.nsError()];
+}
+
 }
 
 #endif
index b8a6849..949c8df 100644 (file)
@@ -28,6 +28,7 @@
 #if USE(SYSTEM_PREVIEW)
 
 #include <WebCore/IntRect.h>
+#include <WebCore/ResourceError.h>
 #include <WebCore/URL.h>
 #include <wtf/RetainPtr.h>
 
@@ -51,6 +52,7 @@ public:
     void updateProgress(float);
     void finish(WebCore::URL);
     void cancel();
+    void fail(const WebCore::ResourceError&);
 
     WebPageProxy& page() { return m_webPageProxy; }