[iOS][WK2] PDFs never load inline again after the Web process crashes
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 28 Jun 2014 22:39:31 +0000 (22:39 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 28 Jun 2014 22:39:31 +0000 (22:39 +0000)
https://bugs.webkit.org/show_bug.cgi?id=134432
<rdar://problem/17484205>

Reviewed by Dan Bernstein.

After a crash, the WebPage never gets mimeTypesWithCustomContentProviders filled back in.

* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode):
(WebKit::WebPageCreationParameters::decode):
* Shared/WebPageCreationParameters.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::creationParameters):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage):
Add mimeTypesWithCustomContentProviders to WebPageCreationParameters.

* UIProcess/Cocoa/WKWebViewContentProviderRegistry.h:
* UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm:
(-[WKWebViewContentProviderRegistry addPage:]):
We don't need to send the MIME types across when a page is added, because it already got them in its creation parameters.

(-[WKWebViewContentProviderRegistry removePage:]):
(-[WKWebViewContentProviderRegistry _mimeTypesWithCustomContentProviders]):
Return a vector of all registered MIME types.

* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::mimeTypesWithCustomContentProviders):
* UIProcess/PageClient.h:
Add (iOS only for now) mimeTypesWithCustomContentProviders to PageClient.

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

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebPageCreationParameters.cpp
Source/WebKit2/Shared/WebPageCreationParameters.h
Source/WebKit2/UIProcess/Cocoa/WKWebViewContentProviderRegistry.h
Source/WebKit2/UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm
Source/WebKit2/UIProcess/PageClient.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/ios/PageClientImplIOS.h
Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm
Source/WebKit2/WebProcess/WebPage/WebPage.cpp

index 155ca78..a8bde8b 100644 (file)
@@ -1,3 +1,38 @@
+2014-06-28  Tim Horton  <timothy_horton@apple.com>
+
+        [iOS][WK2] PDFs never load inline again after the Web process crashes
+        https://bugs.webkit.org/show_bug.cgi?id=134432
+        <rdar://problem/17484205>
+
+        Reviewed by Dan Bernstein.
+
+        After a crash, the WebPage never gets mimeTypesWithCustomContentProviders filled back in.
+
+        * Shared/WebPageCreationParameters.cpp:
+        (WebKit::WebPageCreationParameters::encode):
+        (WebKit::WebPageCreationParameters::decode):
+        * Shared/WebPageCreationParameters.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::creationParameters):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::WebPage):
+        Add mimeTypesWithCustomContentProviders to WebPageCreationParameters.
+
+        * UIProcess/Cocoa/WKWebViewContentProviderRegistry.h:
+        * UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm:
+        (-[WKWebViewContentProviderRegistry addPage:]):
+        We don't need to send the MIME types across when a page is added, because it already got them in its creation parameters.
+
+        (-[WKWebViewContentProviderRegistry removePage:]):
+        (-[WKWebViewContentProviderRegistry _mimeTypesWithCustomContentProviders]):
+        Return a vector of all registered MIME types.
+
+        * UIProcess/ios/PageClientImplIOS.h:
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::mimeTypesWithCustomContentProviders):
+        * UIProcess/PageClient.h:
+        Add (iOS only for now) mimeTypesWithCustomContentProviders to PageClient.
+
 2014-06-28  Dan Bernstein  <mitz@apple.com>
 
         REGRESSION: WebPageProxy::attributedSubstringForCharacterRangeAsync never calls its callback function
index 5c0a214..8a1e968 100644 (file)
@@ -64,6 +64,7 @@ void WebPageCreationParameters::encode(IPC::ArgumentEncoder& encoder) const
     encoder.encodeEnum(scrollPinningBehavior);
     encoder << backgroundExtendsBeyondPage;
     encoder.encodeEnum(layerHostingMode);
+    encoder << mimeTypesWithCustomContentProviders;
 
 #if ENABLE(REMOTE_INSPECTOR)
     encoder << allowsRemoteInspection;
@@ -142,6 +143,8 @@ bool WebPageCreationParameters::decode(IPC::ArgumentDecoder& decoder, WebPageCre
         return false;
     if (!decoder.decodeEnum(parameters.layerHostingMode))
         return false;
+    if (!decoder.decode(parameters.mimeTypesWithCustomContentProviders))
+        return false;
 
 #if ENABLE(REMOTE_INSPECTOR)
     if (!decoder.decode(parameters.allowsRemoteInspection))
index ece5035..5c7f209 100644 (file)
@@ -106,6 +106,8 @@ struct WebPageCreationParameters {
 
     LayerHostingMode layerHostingMode;
 
+    Vector<String> mimeTypesWithCustomContentProviders;
+
 #if ENABLE(REMOTE_INSPECTOR)
     bool allowsRemoteInspection;
 #endif
index a78ebb7..59b6e3b 100644 (file)
@@ -45,6 +45,8 @@ class WebPageProxy;
 - (void)registerProvider:(Class <WKWebViewContentProvider>)contentProvider forMIMEType:(const String&)mimeType;
 - (Class <WKWebViewContentProvider>)providerForMIMEType:(const String&)mimeType;
 
+- (Vector<String>)_mimeTypesWithCustomContentProviders;
+
 @end
 
 #endif // PLATFORM(IOS)
index 7227e7d..00ff15c 100644 (file)
@@ -61,15 +61,11 @@ using namespace WebKit;
 {
     ASSERT(!_pages.contains(&page));
     _pages.add(&page);
-
-    for (auto& mimeType : _contentProviderForMIMEType.keys())
-        page.addMIMETypeWithCustomContentProvider(mimeType);
 }
 
 - (void)removePage:(WebPageProxy&)page
 {
     ASSERT(_pages.contains(&page));
-
     _pages.remove(&page);
 }
 
@@ -91,6 +87,13 @@ using namespace WebKit;
     return representation->value;
 }
 
+- (Vector<String>)_mimeTypesWithCustomContentProviders
+{
+    Vector<String> mimeTypes;
+    copyKeysToVector(_contentProviderForMIMEType, mimeTypes);
+    return mimeTypes;
+}
+
 @end
 
 #endif // PLATFORM(IOS)
index 6b6d69b..c8330f0 100644 (file)
@@ -273,6 +273,7 @@ public:
     virtual void overflowScrollViewWillStartPanGesture() = 0;
     virtual void overflowScrollViewDidScroll() = 0;
     virtual void didFinishDrawingPagesToPDF(const IPC::DataReference&) = 0;
+    virtual Vector<String> mimeTypesWithCustomContentProviders() = 0;
 
 #if ENABLE(INSPECTOR)
     virtual void showInspectorHighlight(const WebCore::Highlight&) = 0;
index b9e99cd..835b6f8 100644 (file)
@@ -4393,6 +4393,7 @@ WebPageCreationParameters WebPageProxy::creationParameters()
     parameters.screenSize = screenSize();
     parameters.availableScreenSize = availableScreenSize();
     parameters.textAutosizingWidth = textAutosizingWidth();
+    parameters.mimeTypesWithCustomContentProviders = m_pageClient.mimeTypesWithCustomContentProviders();
 #endif
 
     return parameters;
index 110d6a5..37cea0a 100644 (file)
@@ -164,6 +164,8 @@ private:
 
     virtual void didFinishLoadingDataForCustomContentProvider(const String& suggestedFilename, const IPC::DataReference&) override;
 
+    virtual Vector<String> mimeTypesWithCustomContentProviders() override;
+
     WKContentView *m_contentView;
     WKWebView *m_webView;
 };
index f176823..367098a 100644 (file)
@@ -37,6 +37,8 @@
 #import "ViewSnapshotStore.h"
 #import "WKContentView.h"
 #import "WKContentViewInteraction.h"
+#import "WKWebViewConfigurationInternal.h"
+#import "WKWebViewContentProviderRegistry.h"
 #import "WKWebViewInternal.h"
 #import "WebContextMenuProxy.h"
 #import "WebEditCommandProxy.h"
@@ -587,6 +589,11 @@ void PageClientImpl::didFinishDrawingPagesToPDF(const IPC::DataReference& pdfDat
     m_webView._printedDocument = adoptCF(CGPDFDocumentCreateWithProvider(dataProvider.get())).get();
 }
 
+Vector<String> PageClientImpl::mimeTypesWithCustomContentProviders()
+{
+    return m_webView.configuration._contentProviderRegistry._mimeTypesWithCustomContentProviders;
+}
+
 } // namespace WebKit
 
 #endif // PLATFORM(IOS)
index 4b4ee36..aa346b6 100644 (file)
@@ -470,6 +470,9 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
     if (m_useAsyncScrolling)
         WebProcess::shared().eventDispatcher().addScrollingTreeForPage(this);
 #endif
+
+    for (auto& mimeType : parameters.mimeTypesWithCustomContentProviders)
+        m_mimeTypesWithCustomContentProviders.add(mimeType);
 }
 
 void WebPage::reinitializeWebPage(const WebPageCreationParameters& parameters)