<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[165303] trunk/Source/WebKit2</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/165303">165303</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2014-03-07 17:06:31 -0800 (Fri, 07 Mar 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[WebKit2][iOS] Main-frame custom content providers
https://bugs.webkit.org/show_bug.cgi?id=129809

Reviewed by Dan Bernstein.

Re-introduce custom content providers to WebKit2 (removed in <a href="http://trac.webkit.org/projects/webkit/changeset/152841">r152841</a>), but
for iOS this time.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView initWithFrame:configuration:]):
Send the initial MIME types that have custom content providers to the WebProcess.

(-[WKWebView dealloc]):
Unregister our page from the content provider registry.

(-[WKWebView _setHasCustomContentView:loadedMIMEType:]):
Install/uninstall the custom content provider. Create a view, if needed,
based on the class that the registry has associated with the given MIME type.
We unparent the WKContentView while the custom content provider is active,
and re-use the existing WKScrollView to contain the custom content provider.

(-[WKWebView _didFinishLoadingDataForCustomContentProviderWithSuggestedFilename:dataReference:]):
Forward loaded data on to the custom content provider for display.

(-[WKWebView _didCommitLayerTree:WebKit::]):
Assert that we aren't getting layer tree commits while using a custom content provider.

(-[WKWebView viewForZoomingInScrollView:]):
If we're using a custom content provider, its view should be used for zooming
instead of the (unparented) web content view.

(-[WKWebView hasContentView]):
(-[WKWebView scrollViewWillBeginZooming:withView:]):
(-[WKWebView scrollViewWillBeginDragging:]):
(-[WKWebView _didFinishScrolling]):
(-[WKWebView _updateVisibleContentRects]):
If we do not have a parented WKContentView because we are using a custom
content provider, we should not forward scroll view related changes to it.

(-[WKWebView _frameOrBoundsChanged]):
Update the minimum size of the custom content provider if the web view size changes.

* UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
(-[WKWebViewConfiguration copyWithZone:]):
(-[WKWebViewConfiguration _contentProviderRegistry]):
(-[WKWebViewConfiguration _setContentProviderRegistry:]):
* UIProcess/API/Cocoa/WKWebViewConfigurationInternal.h: Added.
Add an internal WKWebViewConfiguration property, the WKWebViewContentProviderRegistry.

* UIProcess/API/Cocoa/WKWebViewInternal.h:

* UIProcess/Cocoa/WKWebViewContentProvider.h: Added.
A minimal protocol for informing custom content providers of changes to
the size of the view, the represented data, and the owning scroll view.

* UIProcess/Cocoa/WKWebViewContentProviderRegistry.h: Added.
* UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm: Added.
(-[WKWebViewContentProviderRegistry addPage:]):
(-[WKWebViewContentProviderRegistry removePage:]):
(-[WKWebViewContentProviderRegistry registerProvider:forMIMEType:]):
(-[WKWebViewContentProviderRegistry providerForMIMEType:]):
(-[WKWebViewContentProviderRegistry mimeTypesWithContentProviders]):
New class, keeps track of a mapping from MIME types to UIViews that
conform to the WKWebViewContentProvider protocol.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::didCommitLoadForFrame):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:

* UIProcess/PageClient.h:
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::PageClientImpl):
(WebKit::PageClientImpl::didCommitLoadForMainFrame):
(WebKit::PageClientImpl::didFinishLoadingDataForCustomContentProvider):
* UIProcess/mac/PageClientImpl.h:
* UIProcess/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::didCommitLoadForMainFrame):
(WebKit::PageClientImpl::didFinishLoadingDataForCustomContentProvider):
Add parameters to didCommitLoadForMainFrame, indicating if we should use
a custom content provider to display the main frame, and what MIME type
was loaded in said frame, and add didFinishLoadingDataForCustomContentProvider.
On iOS, forward these to the WKWebView.
Also, give PageClientImplIOS a reference to the WKWebView.

* UIProcess/ios/WKContentView.mm:
(-[WKContentView initWithFrame:context:WebKit::configuration:WebKit::webView:]):

* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm:
(-[WKWebProcessPlugInFrame _hasCustomContentProvider]):
* WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFramePrivate.h:
Expose whether or not a given frame has a custom content provider to the plug-in.

* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::WebFrameLoaderClient):
(WebKit::WebFrameLoaderClient::hasHTMLView):
(WebKit::WebFrameLoaderClient::dispatchDidCommitLoad):
(WebKit::WebFrameLoaderClient::committedLoad):
(WebKit::WebFrameLoaderClient::finishedLoading):
(WebKit::WebFrameLoaderClient::transitionToCommittedFromCachedFrame):
(WebKit::WebFrameLoaderClient::transitionToCommittedForNewPage):
(WebKit::WebFrameLoaderClient::canCachePage):
* WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
(WebKit::WebFrameLoaderClient::frameHasCustomContentProvider):
Restore WebFrameLoaderClient custom representation code, which ensures
that data is routed correctly (to the UI process, and not to WebCore) and
that we don't try to use the page cache for frames with content providers.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::mainFrameHasCustomContentProvider):
(WebKit::WebPage::addMIMETypeWithCustomContentProvider):
(WebKit::WebPage::shouldUseCustomContentProviderForResponse):
(WebKit::WebPage::canShowMIMEType):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
Keep a list of MIME types which can be displayed via custom content providers
in WebPage, which will be pushed down from the registry as new providers
are added. Plug-ins still take precendence over custom content providers.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewConfigurationmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewInternalh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessPageClienth">trunk/Source/WebKit2/UIProcess/PageClient.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxycpp">trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxyh">trunk/Source/WebKit2/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxymessagesin">trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosPageClientImplIOSh">trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosPageClientImplIOSmm">trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKContentViewmm">trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacPageClientImplh">trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacPageClientImplmm">trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm</a></li>
<li><a href="#trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj">trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebKit2WebProcessInjectedBundleAPICocoaWKWebProcessPlugInFramemm">trunk/Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessInjectedBundleAPICocoaWKWebProcessPlugInFramePrivateh">trunk/Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFramePrivate.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebFrameLoaderClientcpp">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebFrameLoaderClienth">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagecpp">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPageh">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagemessagesin">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewConfigurationInternalh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfigurationInternal.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWKWebViewContentProviderh">trunk/Source/WebKit2/UIProcess/Cocoa/WKWebViewContentProvider.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWKWebViewContentProviderRegistryh">trunk/Source/WebKit2/UIProcess/Cocoa/WKWebViewContentProviderRegistry.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWKWebViewContentProviderRegistrymm">trunk/Source/WebKit2/UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (165302 => 165303)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-03-08 01:02:30 UTC (rev 165302)
+++ trunk/Source/WebKit2/ChangeLog        2014-03-08 01:06:31 UTC (rev 165303)
</span><span class="lines">@@ -1,3 +1,127 @@
</span><ins>+2014-03-07  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        [WebKit2][iOS] Main-frame custom content providers
+        https://bugs.webkit.org/show_bug.cgi?id=129809
+
+        Reviewed by Dan Bernstein.
+
+        Re-introduce custom content providers to WebKit2 (removed in r152841), but
+        for iOS this time.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView initWithFrame:configuration:]):
+        Send the initial MIME types that have custom content providers to the WebProcess.
+
+        (-[WKWebView dealloc]):
+        Unregister our page from the content provider registry.
+        
+        (-[WKWebView _setHasCustomContentView:loadedMIMEType:]):
+        Install/uninstall the custom content provider. Create a view, if needed,
+        based on the class that the registry has associated with the given MIME type.
+        We unparent the WKContentView while the custom content provider is active,
+        and re-use the existing WKScrollView to contain the custom content provider.
+
+        (-[WKWebView _didFinishLoadingDataForCustomContentProviderWithSuggestedFilename:dataReference:]):
+        Forward loaded data on to the custom content provider for display.
+
+        (-[WKWebView _didCommitLayerTree:WebKit::]):
+        Assert that we aren't getting layer tree commits while using a custom content provider.
+
+        (-[WKWebView viewForZoomingInScrollView:]):
+        If we're using a custom content provider, its view should be used for zooming
+        instead of the (unparented) web content view.
+
+        (-[WKWebView hasContentView]):
+        (-[WKWebView scrollViewWillBeginZooming:withView:]):
+        (-[WKWebView scrollViewWillBeginDragging:]):
+        (-[WKWebView _didFinishScrolling]):
+        (-[WKWebView _updateVisibleContentRects]):
+        If we do not have a parented WKContentView because we are using a custom
+        content provider, we should not forward scroll view related changes to it.
+
+        (-[WKWebView _frameOrBoundsChanged]):
+        Update the minimum size of the custom content provider if the web view size changes.
+
+        * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
+        (-[WKWebViewConfiguration copyWithZone:]):
+        (-[WKWebViewConfiguration _contentProviderRegistry]):
+        (-[WKWebViewConfiguration _setContentProviderRegistry:]):
+        * UIProcess/API/Cocoa/WKWebViewConfigurationInternal.h: Added.
+        Add an internal WKWebViewConfiguration property, the WKWebViewContentProviderRegistry.
+
+        * UIProcess/API/Cocoa/WKWebViewInternal.h:
+
+        * UIProcess/Cocoa/WKWebViewContentProvider.h: Added.
+        A minimal protocol for informing custom content providers of changes to
+        the size of the view, the represented data, and the owning scroll view.
+
+        * UIProcess/Cocoa/WKWebViewContentProviderRegistry.h: Added.
+        * UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm: Added.
+        (-[WKWebViewContentProviderRegistry addPage:]):
+        (-[WKWebViewContentProviderRegistry removePage:]):
+        (-[WKWebViewContentProviderRegistry registerProvider:forMIMEType:]):
+        (-[WKWebViewContentProviderRegistry providerForMIMEType:]):
+        (-[WKWebViewContentProviderRegistry mimeTypesWithContentProviders]):
+        New class, keeps track of a mapping from MIME types to UIViews that
+        conform to the WKWebViewContentProvider protocol.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::WebPageProxy):
+        (WebKit::WebPageProxy::didCommitLoadForFrame):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+
+        * UIProcess/PageClient.h:
+        * UIProcess/ios/PageClientImplIOS.h:
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::PageClientImpl):
+        (WebKit::PageClientImpl::didCommitLoadForMainFrame):
+        (WebKit::PageClientImpl::didFinishLoadingDataForCustomContentProvider):
+        * UIProcess/mac/PageClientImpl.h:
+        * UIProcess/mac/PageClientImpl.mm:
+        (WebKit::PageClientImpl::didCommitLoadForMainFrame):
+        (WebKit::PageClientImpl::didFinishLoadingDataForCustomContentProvider):
+        Add parameters to didCommitLoadForMainFrame, indicating if we should use
+        a custom content provider to display the main frame, and what MIME type
+        was loaded in said frame, and add didFinishLoadingDataForCustomContentProvider.
+        On iOS, forward these to the WKWebView.
+        Also, give PageClientImplIOS a reference to the WKWebView.
+        
+        * UIProcess/ios/WKContentView.mm:
+        (-[WKContentView initWithFrame:context:WebKit::configuration:WebKit::webView:]):
+        
+        * WebKit2.xcodeproj/project.pbxproj:
+        * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm:
+        (-[WKWebProcessPlugInFrame _hasCustomContentProvider]):
+        * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFramePrivate.h:
+        Expose whether or not a given frame has a custom content provider to the plug-in.
+
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebKit::WebFrameLoaderClient::WebFrameLoaderClient):
+        (WebKit::WebFrameLoaderClient::hasHTMLView):
+        (WebKit::WebFrameLoaderClient::dispatchDidCommitLoad):
+        (WebKit::WebFrameLoaderClient::committedLoad):
+        (WebKit::WebFrameLoaderClient::finishedLoading):
+        (WebKit::WebFrameLoaderClient::transitionToCommittedFromCachedFrame):
+        (WebKit::WebFrameLoaderClient::transitionToCommittedForNewPage):
+        (WebKit::WebFrameLoaderClient::canCachePage):
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
+        (WebKit::WebFrameLoaderClient::frameHasCustomContentProvider):
+        Restore WebFrameLoaderClient custom representation code, which ensures
+        that data is routed correctly (to the UI process, and not to WebCore) and
+        that we don't try to use the page cache for frames with content providers.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::mainFrameHasCustomContentProvider):
+        (WebKit::WebPage::addMIMETypeWithCustomContentProvider):
+        (WebKit::WebPage::shouldUseCustomContentProviderForResponse):
+        (WebKit::WebPage::canShowMIMEType):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+        Keep a list of MIME types which can be displayed via custom content providers
+        in WebPage, which will be pushed down from the registry as new providers
+        are added. Plug-ins still take precendence over custom content providers.
+
</ins><span class="cx"> 2014-03-07  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         MigrateHeaders.make should remove C SPI includes from WebKit2 headers
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (165302 => 165303)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2014-03-08 01:02:30 UTC (rev 165302)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2014-03-08 01:06:31 UTC (rev 165303)
</span><span class="lines">@@ -45,8 +45,9 @@
</span><span class="cx"> #import &quot;WKProcessPoolInternal.h&quot;
</span><span class="cx"> #import &quot;WKRemoteObjectRegistryInternal.h&quot;
</span><span class="cx"> #import &quot;WKUIDelegate.h&quot;
</span><del>-#import &quot;WKWebViewConfigurationPrivate.h&quot;
</del><span class="cx"> #import &quot;WKVisitedLinkProviderInternal.h&quot;
</span><ins>+#import &quot;WKWebViewConfigurationInternal.h&quot;
+#import &quot;WKWebViewContentProvider.h&quot;
</ins><span class="cx"> #import &quot;WebCertificateInfo.h&quot;
</span><span class="cx"> #import &quot;WebContext.h&quot;
</span><span class="cx"> #import &quot;WebBackForwardList.h&quot;
</span><span class="lines">@@ -57,6 +58,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> #import &quot;WKScrollView.h&quot;
</span><ins>+#import &quot;WKWebViewContentProviderRegistry.h&quot;
</ins><span class="cx"> #import &lt;UIKit/UIPeripheralHost_Private.h&gt;
</span><span class="cx"> 
</span><span class="cx"> @interface UIScrollView (UIScrollViewInternal)
</span><span class="lines">@@ -96,6 +98,8 @@
</span><span class="cx"> 
</span><span class="cx">     std::unique_ptr&lt;WebKit::ViewGestureController&gt; _gestureController;
</span><span class="cx">     BOOL _allowsBackForwardNavigationGestures;
</span><ins>+
+    RetainPtr&lt;UIView &lt;WKWebViewContentProvider&gt;&gt; _customContentView;
</ins><span class="cx"> #endif
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx">     RetainPtr&lt;WKView&gt; _wkView;
</span><span class="lines">@@ -132,6 +136,11 @@
</span><span class="cx">     if (![_configuration visitedLinkProvider])
</span><span class="cx">         [_configuration setVisitedLinkProvider:adoptNS([[WKVisitedLinkProvider alloc] init]).get()];
</span><span class="cx"> 
</span><ins>+#if PLATFORM(IOS)
+    if (![_configuration _contentProviderRegistry])
+        [_configuration _setContentProviderRegistry:adoptNS([[WKWebViewContentProviderRegistry alloc] init]).get()];
+#endif
+
</ins><span class="cx">     CGRect bounds = self.bounds;
</span><span class="cx"> 
</span><span class="cx">     WebKit::WebContext&amp; context = *[_configuration processPool]-&gt;_context;
</span><span class="lines">@@ -163,6 +172,8 @@
</span><span class="cx">     [center addObserver:self selector:@selector(_keyboardDidChangeFrame:) name:UIKeyboardDidChangeFrameNotification object:nil];
</span><span class="cx">     [center addObserver:self selector:@selector(_keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
</span><span class="cx">     [center addObserver:self selector:@selector(_keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
</span><ins>+
+    [[_configuration _contentProviderRegistry] addPage:*_page];
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="lines">@@ -184,6 +195,7 @@
</span><span class="cx"> {
</span><span class="cx">     [_remoteObjectRegistry _invalidate];
</span><span class="cx"> #if PLATFORM(IOS)
</span><ins>+    [[_configuration _contentProviderRegistry] removePage:*_page];
</ins><span class="cx">     [[NSNotificationCenter defaultCenter] removeObserver:self];
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -321,6 +333,35 @@
</span><span class="cx">     return [_contentView browsingContextController];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)_setHasCustomContentView:(BOOL)pageHasCustomContentView loadedMIMEType:(const WTF::String&amp;)mimeType
+{
+    if (pageHasCustomContentView) {
+        [_customContentView removeFromSuperview];
+
+        Class representationClass = [[_configuration _contentProviderRegistry] providerForMIMEType:mimeType];
+        ASSERT(representationClass);
+        _customContentView = adoptNS([[representationClass alloc] init]);
+
+        [_contentView removeFromSuperview];
+        [_scrollView addSubview:_customContentView.get()];
+
+        [_customContentView web_setMinimumSize:self.bounds.size];
+        [_customContentView web_setScrollView:_scrollView.get()];
+    } else if (_customContentView) {
+        [_customContentView removeFromSuperview];
+        _customContentView = nullptr;
+
+        [_scrollView addSubview:_contentView.get()];
+        [_scrollView setContentSize:[_contentView frame].size];
+    }
+}
+
+- (void)_didFinishLoadingDataForCustomContentProviderWithSuggestedFilename:(const String&amp;)suggestedFilename data:(NSData *)data
+{
+    ASSERT(_customContentView);
+    [_customContentView web_setContentProviderData:data];
+}
+
</ins><span class="cx"> - (void)_didCommitLoadForMainFrame
</span><span class="cx"> {
</span><span class="cx">     _isWaitingForNewLayerTreeAfterDidCommitLoad = YES;
</span><span class="lines">@@ -328,6 +369,8 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_didCommitLayerTree:(const WebKit::RemoteLayerTreeTransaction&amp;)layerTreeTransaction
</span><span class="cx"> {
</span><ins>+    ASSERT(!_customContentView);
+
</ins><span class="cx">     [_scrollView setContentSize:[_contentView frame].size];
</span><span class="cx">     [_scrollView setMinimumZoomScale:layerTreeTransaction.minimumScaleFactor()];
</span><span class="cx">     [_scrollView setMaximumZoomScale:layerTreeTransaction.maximumScaleFactor()];
</span><span class="lines">@@ -466,14 +509,26 @@
</span><span class="cx"> 
</span><span class="cx"> #pragma mark - UIScrollViewDelegate
</span><span class="cx"> 
</span><ins>+- (BOOL)usesStandardContentView
+{
+    return !_customContentView;
+}
+
</ins><span class="cx"> - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
</span><span class="cx"> {
</span><span class="cx">     ASSERT(_scrollView == scrollView);
</span><ins>+
+    if (_customContentView)
+        return _customContentView.get();
+
</ins><span class="cx">     return _contentView.get();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)scrollViewWillBeginZooming:(UIScrollView *)scrollView withView:(UIView *)view
</span><span class="cx"> {
</span><ins>+    if (![self usesStandardContentView])
+        return;
+
</ins><span class="cx">     if (scrollView.pinchGestureRecognizer.state == UIGestureRecognizerStateBegan)
</span><span class="cx">         [_contentView willStartUserTriggeredZoom];
</span><span class="cx">     [_contentView willStartZoomOrScroll];
</span><span class="lines">@@ -481,6 +536,9 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
</span><span class="cx"> {
</span><ins>+    if (![self usesStandardContentView])
+        return;
+
</ins><span class="cx">     if (scrollView.panGestureRecognizer.state == UIGestureRecognizerStateBegan)
</span><span class="cx">         [_contentView willStartUserTriggeredScroll];
</span><span class="cx">     [_contentView willStartZoomOrScroll];
</span><span class="lines">@@ -488,6 +546,9 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_didFinishScrolling
</span><span class="cx"> {
</span><ins>+    if (![self usesStandardContentView])
+        return;
+
</ins><span class="cx">     [self _updateVisibleContentRects];
</span><span class="cx">     [_contentView didFinishScrolling];
</span><span class="cx"> }
</span><span class="lines">@@ -534,11 +595,15 @@
</span><span class="cx">         [_contentView setMinimumLayoutSize:bounds.size];
</span><span class="cx">     [_scrollView setFrame:bounds];
</span><span class="cx">     [_contentView setMinimumSize:bounds.size];
</span><ins>+    [_customContentView web_setMinimumSize:bounds.size];
</ins><span class="cx">     [self _updateVisibleContentRects];
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_updateVisibleContentRects
</span><span class="cx"> {
</span><ins>+    if (![self usesStandardContentView])
+        return;
+
</ins><span class="cx">     CGRect fullViewRect = self.bounds;
</span><span class="cx">     CGRect visibleRectInContentCoordinates = [self convertRect:fullViewRect toView:_contentView.get()];
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewConfigurationmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm (165302 => 165303)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm        2014-03-08 01:02:30 UTC (rev 165302)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm        2014-03-08 01:06:31 UTC (rev 165303)
</span><span class="lines">@@ -24,10 +24,11 @@
</span><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> #import &quot;config.h&quot;
</span><del>-#import &quot;WKWebViewConfigurationPrivate.h&quot;
</del><ins>+#import &quot;WKWebViewConfigurationInternal.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> #if WK_API_ENABLED
</span><span class="cx"> 
</span><ins>+#import &quot;WKWebViewContentProviderRegistry.h&quot;
</ins><span class="cx"> #import &quot;WeakObjCPtr.h&quot;
</span><span class="cx"> #import &lt;wtf/RetainPtr.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -36,6 +37,9 @@
</span><span class="cx">     RetainPtr&lt;WKPreferences&gt; _preferences;
</span><span class="cx">     RetainPtr&lt;WKVisitedLinkProvider&gt; _visitedLinkProvider;
</span><span class="cx">     WebKit::WeakObjCPtr&lt;WKWebView&gt; _relatedWebView;
</span><ins>+#if PLATFORM(IOS)
+    RetainPtr&lt;WKWebViewContentProviderRegistry&gt; _contentProviderRegistry;
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (NSString *)description
</span><span class="lines">@@ -50,6 +54,9 @@
</span><span class="cx">     configuration.processPool = _processPool.get();
</span><span class="cx">     configuration.preferences = _preferences.get();
</span><span class="cx">     configuration._relatedWebView = _relatedWebView.get().get();
</span><ins>+#if PLATFORM(IOS)
+    configuration._contentProviderRegistry = _contentProviderRegistry.get();
+#endif
</ins><span class="cx"> 
</span><span class="cx">     return configuration;
</span><span class="cx"> }
</span><span class="lines">@@ -94,6 +101,18 @@
</span><span class="cx">     _relatedWebView = relatedWebView;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if PLATFORM(IOS)
+- (WKWebViewContentProviderRegistry *)_contentProviderRegistry
+{
+    return _contentProviderRegistry.get();
+}
+
+- (void)_setContentProviderRegistry:(WKWebViewContentProviderRegistry *)registry
+{
+    _contentProviderRegistry = registry;
+}
+#endif
+
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> #endif // WK_API_ENABLED
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewConfigurationInternalh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfigurationInternal.h (0 => 165303)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfigurationInternal.h                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfigurationInternal.h        2014-03-08 01:06:31 UTC (rev 165303)
</span><span class="lines">@@ -0,0 +1,41 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import &quot;WKWebViewConfigurationPrivate.h&quot;
+
+#if WK_API_ENABLED
+
+@class WKWebView;
+@class WKWebViewContentProviderRegistry;
+
+@interface WKWebViewConfiguration ()
+
+#if PLATFORM(IOS)
+@property (nonatomic, setter=_setContentProviderRegistry:) WKWebViewContentProviderRegistry *_contentProviderRegistry;
+#endif
+
+@end
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewInternalh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h (165302 => 165303)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h        2014-03-08 01:02:30 UTC (rev 165302)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h        2014-03-08 01:06:31 UTC (rev 165303)
</span><span class="lines">@@ -62,6 +62,9 @@
</span><span class="cx"> - (BOOL)_scrollToRect:(WebCore::FloatRect)targetRect origin:(WebCore::FloatPoint)origin minimumScrollDistance:(float)minimumScrollDistance;
</span><span class="cx"> - (BOOL)_zoomToRect:(WebCore::FloatRect)targetRect withOrigin:(WebCore::FloatPoint)origin fitEntireRect:(BOOL)fitEntireRect minimumScale:(double)minimumScale maximumScale:(double)maximumScale minimumScrollDistance:(float)minimumScrollDistance;
</span><span class="cx"> - (void)_zoomOutWithOrigin:(WebCore::FloatPoint)origin;
</span><ins>+
+- (void)_setHasCustomContentView:(BOOL)hasCustomContentView loadedMIMEType:(const WTF::String&amp;)mimeType;
+- (void)_didFinishLoadingDataForCustomContentProviderWithSuggestedFilename:(const WTF::String&amp;)suggestedFilename data:(NSData *)data;
</ins><span class="cx"> #endif
</span><span class="cx"> @end
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWKWebViewContentProviderh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/Cocoa/WKWebViewContentProvider.h (0 => 165303)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WKWebViewContentProvider.h                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WKWebViewContentProvider.h        2014-03-08 01:06:31 UTC (rev 165303)
</span><span class="lines">@@ -0,0 +1,49 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import &lt;WebKit2/WKFoundation.h&gt;
+
+#if WK_API_ENABLED
+
+#if PLATFORM(IOS)
+
+@class NSData;
+@class UIScrollView;
+@protocol NSObject;
+struct CGSize;
+
+// FIXME: This should be API.
+@protocol WKWebViewContentProvider &lt;NSObject&gt;
+
+- (void)web_setContentProviderData:(NSData *)data;
+- (void)web_setMinimumSize:(CGSize)size;
+- (void)web_setScrollView:(UIScrollView *)scrollView;
+
+@end
+
+#endif // PLATFORM(IOS)
+
+#endif // WK_API_ENABLED
+
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWKWebViewContentProviderRegistryh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/Cocoa/WKWebViewContentProviderRegistry.h (0 => 165303)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WKWebViewContentProviderRegistry.h                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WKWebViewContentProviderRegistry.h        2014-03-08 01:06:31 UTC (rev 165303)
</span><span class="lines">@@ -0,0 +1,52 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import &lt;WebKit2/WKFoundation.h&gt;
+
+#if WK_API_ENABLED
+
+#if PLATFORM(IOS)
+
+#import &lt;wtf/text/WTFString.h&gt;
+
+namespace WebKit {
+class WebPageProxy;
+}
+
+@protocol WKWebViewContentProvider;
+
+@interface WKWebViewContentProviderRegistry : NSObject
+
+- (void)addPage:(WebKit::WebPageProxy&amp;)page;
+- (void)removePage:(WebKit::WebPageProxy&amp;)page;
+
+- (void)registerProvider:(Class &lt;WKWebViewContentProvider&gt;)contentProvider forMIMEType:(const String&amp;)mimeType;
+- (Class &lt;WKWebViewContentProvider&gt;)providerForMIMEType:(const String&amp;)mimeType;
+
+@end
+
+#endif // PLATFORM(IOS)
+
+#endif // WK_API_ENABLED
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWKWebViewContentProviderRegistrymm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm (0 => 165303)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm        2014-03-08 01:06:31 UTC (rev 165303)
</span><span class="lines">@@ -0,0 +1,85 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import &quot;config.h&quot;
+#import &quot;WKWebViewContentProviderRegistry.h&quot;
+
+#if WK_API_ENABLED
+
+#if PLATFORM(IOS)
+
+#import &quot;WKWebViewInternal.h&quot;
+#import &quot;WebPageProxy.h&quot;
+#import &lt;wtf/HashCountedSet.h&gt;
+#import &lt;wtf/HashMap.h&gt;
+#import &lt;wtf/text/StringHash.h&gt;
+#import &lt;wtf/text/WTFString.h&gt;
+
+using namespace WebKit;
+
+@implementation WKWebViewContentProviderRegistry {
+    HashMap&lt;String, Class &lt;WKWebViewContentProvider&gt;, CaseFoldingHash&gt; _contentProviderForMIMEType;
+    HashCountedSet&lt;WebPageProxy*&gt; _pages;
+}
+
+- (void)addPage:(WebPageProxy&amp;)page
+{
+    ASSERT(!_pages.contains(&amp;page));
+    _pages.add(&amp;page);
+
+    for (auto&amp; mimeType : _contentProviderForMIMEType.keys())
+        page.addMIMETypeWithCustomContentProvider(mimeType);
+}
+
+- (void)removePage:(WebPageProxy&amp;)page
+{
+    ASSERT(_pages.contains(&amp;page));
+
+    _pages.remove(&amp;page);
+}
+
+- (void)registerProvider:(Class &lt;WKWebViewContentProvider&gt;)contentProvider forMIMEType:(const String&amp;)mimeType
+{
+    _contentProviderForMIMEType.set(mimeType, contentProvider);
+
+    for (auto&amp; page : _pages)
+        page.key-&gt;addMIMETypeWithCustomContentProvider(mimeType);
+}
+
+- (Class &lt;WKWebViewContentProvider&gt;)providerForMIMEType:(const String&amp;)mimeType
+{
+    const auto&amp; representation = _contentProviderForMIMEType.find(mimeType);
+
+    if (representation == _contentProviderForMIMEType.end())
+        return nil;
+
+    return representation-&gt;value;
+}
+
+@end
+
+#endif // PLATFORM(IOS)
+
+#endif // WK_API_ENABLED
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessPageClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/PageClient.h (165302 => 165303)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/PageClient.h        2014-03-08 01:02:30 UTC (rev 165302)
+++ trunk/Source/WebKit2/UIProcess/PageClient.h        2014-03-08 01:06:31 UTC (rev 165303)
</span><span class="lines">@@ -131,7 +131,7 @@
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    virtual void didCommitLoadForMainFrame() = 0;
</del><ins>+    virtual void didCommitLoadForMainFrame(const String&amp; mimeType, bool useCustomContentProvider) = 0;
</ins><span class="cx"> 
</span><span class="cx"> #if USE(TILED_BACKING_STORE)
</span><span class="cx">     virtual void pageDidRequestScroll(const WebCore::IntPoint&amp;) = 0;
</span><span class="lines">@@ -256,6 +256,9 @@
</span><span class="cx"> #if ENABLE(FULLSCREEN_API)
</span><span class="cx">     virtual WebFullScreenManagerProxyClient&amp; fullScreenManagerProxyClient() = 0;
</span><span class="cx"> #endif
</span><ins>+
+    // Custom representations.
+    virtual void didFinishLoadingDataForCustomContentProvider(const String&amp; suggestedFilename, const IPC::DataReference&amp;) = 0;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (165302 => 165303)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2014-03-08 01:02:30 UTC (rev 165302)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2014-03-08 01:06:31 UTC (rev 165303)
</span><span class="lines">@@ -311,6 +311,7 @@
</span><span class="cx">     , m_spellDocumentTag(0)
</span><span class="cx">     , m_hasSpellDocumentTag(false)
</span><span class="cx">     , m_pendingLearnOrIgnoreWordMessageCount(0)
</span><ins>+    , m_mainFrameHasCustomContentProvider(false)
</ins><span class="cx">     , m_delegatesScrolling(false)
</span><span class="cx">     , m_mainFrameHasHorizontalScrollbar(false)
</span><span class="cx">     , m_mainFrameHasVerticalScrollbar(false)
</span><span class="lines">@@ -2236,7 +2237,7 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPageProxy::didCommitLoadForFrame(uint64_t frameID, uint64_t navigationID, const String&amp; mimeType, uint32_t opaqueFrameLoadType, const WebCore::CertificateInfo&amp; certificateInfo, IPC::MessageDecoder&amp; decoder)
</del><ins>+void WebPageProxy::didCommitLoadForFrame(uint64_t frameID, uint64_t navigationID, const String&amp; mimeType, bool frameHasCustomContentProvider, uint32_t opaqueFrameLoadType, const WebCore::CertificateInfo&amp; certificateInfo, IPC::MessageDecoder&amp; decoder)
</ins><span class="cx"> {
</span><span class="cx">     RefPtr&lt;API::Object&gt; userData;
</span><span class="cx">     WebContextUserMessageDecoder messageDecoder(userData, process());
</span><span class="lines">@@ -2248,10 +2249,8 @@
</span><span class="cx"> 
</span><span class="cx">     auto transaction = m_pageLoadState.transaction();
</span><span class="cx"> 
</span><del>-    if (frame-&gt;isMainFrame()) {
</del><ins>+    if (frame-&gt;isMainFrame())
</ins><span class="cx">         m_pageLoadState.didCommitLoad(transaction);
</span><del>-        m_pageClient.didCommitLoadForMainFrame();
-    }
</del><span class="cx"> 
</span><span class="cx"> #if USE(APPKIT)
</span><span class="cx">     // FIXME (bug 59111): didCommitLoadForFrame comes too late when restoring a page from b/f cache, making us disable secure event mode in password fields.
</span><span class="lines">@@ -2265,6 +2264,20 @@
</span><span class="cx"> 
</span><span class="cx">     frame-&gt;didCommitLoad(mimeType, certificateInfo);
</span><span class="cx"> 
</span><ins>+    if (frame-&gt;isMainFrame()) {
+        m_mainFrameHasCustomContentProvider = frameHasCustomContentProvider;
+
+        if (m_mainFrameHasCustomContentProvider) {
+            // Always assume that the main frame is pinned here, since the custom representation view will handle
+            // any wheel events and dispatch them to the WKView when necessary.
+            m_mainFrameIsPinnedToLeftSide = true;
+            m_mainFrameIsPinnedToRightSide = true;
+            m_mainFrameIsPinnedToTopSide = true;
+            m_mainFrameIsPinnedToBottomSide = true;
+        }
+        m_pageClient.didCommitLoadForMainFrame(mimeType, frameHasCustomContentProvider);
+    }
+
</ins><span class="cx">     // Even if WebPage has the default pageScaleFactor (and therefore doesn't reset it),
</span><span class="cx">     // WebPageProxy's cache of the value can get out of sync (e.g. in the case where a
</span><span class="cx">     // plugin is handling page scaling itself) so we should reset it to the default
</span><span class="lines">@@ -4237,6 +4250,11 @@
</span><span class="cx">     return !m_canShortCircuitHorizontalWheelEvents;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebPageProxy::didFinishLoadingDataForCustomContentProvider(const String&amp; suggestedFilename, const IPC::DataReference&amp; dataReference)
+{
+    m_pageClient.didFinishLoadingDataForCustomContentProvider(suggestedFilename, dataReference);
+}
+
</ins><span class="cx"> void WebPageProxy::backForwardRemovedItem(uint64_t itemID)
</span><span class="cx"> {
</span><span class="cx">     m_process-&gt;send(Messages::WebPage::DidRemoveBackForwardItem(itemID), m_pageID);
</span><span class="lines">@@ -4541,4 +4559,9 @@
</span><span class="cx">     m_process-&gt;send(Messages::WebPage::SetThumbnailScale(scale), m_pageID);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebPageProxy::addMIMETypeWithCustomContentProvider(const String&amp; mimeType)
+{
+    m_process-&gt;send(Messages::WebPage::AddMIMETypeWithCustomContentProvider(mimeType), m_pageID);
+}
+
</ins><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (165302 => 165303)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2014-03-08 01:02:30 UTC (rev 165302)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2014-03-08 01:06:31 UTC (rev 165303)
</span><span class="lines">@@ -451,6 +451,8 @@
</span><span class="cx">     bool isViewWindowActive() const;
</span><span class="cx">     bool isProcessSuppressible() const;
</span><span class="cx"> 
</span><ins>+    void addMIMETypeWithCustomContentProvider(const String&amp; mimeType);
+
</ins><span class="cx">     void executeEditCommand(const String&amp; commandName);
</span><span class="cx">     void validateCommand(const String&amp; commandName, PassRefPtr&lt;ValidateCommandCallback&gt;);
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="lines">@@ -949,7 +951,7 @@
</span><span class="cx">     void didStartProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, const String&amp; url, const String&amp; unreachableURL, IPC::MessageDecoder&amp;);
</span><span class="cx">     void didReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, const String&amp;, IPC::MessageDecoder&amp;);
</span><span class="cx">     void didFailProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, const WebCore::ResourceError&amp;, IPC::MessageDecoder&amp;);
</span><del>-    void didCommitLoadForFrame(uint64_t frameID, uint64_t navigationID, const String&amp; mimeType, uint32_t frameLoadType, const WebCore::CertificateInfo&amp;, IPC::MessageDecoder&amp;);
</del><ins>+    void didCommitLoadForFrame(uint64_t frameID, uint64_t navigationID, const String&amp; mimeType, bool frameHasCustomContentProvider, uint32_t frameLoadType, const WebCore::CertificateInfo&amp;, IPC::MessageDecoder&amp;);
</ins><span class="cx">     void didFinishDocumentLoadForFrame(uint64_t frameID, IPC::MessageDecoder&amp;);
</span><span class="cx">     void didFinishLoadForFrame(uint64_t frameID, uint64_t navigationID, IPC::MessageDecoder&amp;);
</span><span class="cx">     void didFailLoadForFrame(uint64_t frameID, uint64_t navigationID, const WebCore::ResourceError&amp;, IPC::MessageDecoder&amp;);
</span><span class="lines">@@ -1157,6 +1159,7 @@
</span><span class="cx">     void didReceiveAuthenticationChallenge(uint64_t frameID, const WebCore::AuthenticationChallenge&amp;, uint64_t challengeID);
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(COCOA)
</span><ins>+    void didFinishLoadingDataForCustomContentProvider(const String&amp; suggestedFilename, const IPC::DataReference&amp;);
</ins><span class="cx">     void pluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus);
</span><span class="cx">     void setPluginComplexTextInputState(uint64_t pluginComplexTextInputIdentifier, uint64_t complexTextInputState);
</span><span class="cx"> #endif
</span><span class="lines">@@ -1395,6 +1398,8 @@
</span><span class="cx">     bool m_hasSpellDocumentTag;
</span><span class="cx">     unsigned m_pendingLearnOrIgnoreWordMessageCount;
</span><span class="cx"> 
</span><ins>+    bool m_mainFrameHasCustomContentProvider;
+
</ins><span class="cx"> #if ENABLE(DRAG_SUPPORT)
</span><span class="cx">     WebCore::DragSession m_currentDragSession;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (165302 => 165303)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in        2014-03-08 01:02:30 UTC (rev 165302)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in        2014-03-08 01:06:31 UTC (rev 165303)
</span><span class="lines">@@ -121,7 +121,7 @@
</span><span class="cx">     DidStartProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, String url, String unreachableURL, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
</span><span class="cx">     DidReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, String url, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
</span><span class="cx">     DidFailProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, WebCore::ResourceError error, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
</span><del>-    DidCommitLoadForFrame(uint64_t frameID, uint64_t navigationID, String mimeType, uint32_t loadType, WebCore::CertificateInfo certificateInfo, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
</del><ins>+    DidCommitLoadForFrame(uint64_t frameID, uint64_t navigationID, String mimeType, bool hasCustomContentProvider, uint32_t loadType, WebCore::CertificateInfo certificateInfo, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
</ins><span class="cx">     DidFailLoadForFrame(uint64_t frameID, uint64_t navigationID, WebCore::ResourceError error, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
</span><span class="cx">     DidFinishDocumentLoadForFrame(uint64_t frameID, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
</span><span class="cx">     DidFinishLoadForFrame(uint64_t frameID, uint64_t navigationID, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
</span><span class="lines">@@ -137,6 +137,9 @@
</span><span class="cx"> 
</span><span class="cx">     FrameDidBecomeFrameSet(uint64_t frameID, bool value)
</span><span class="cx"> 
</span><ins>+    # Custom representations
+    DidFinishLoadingDataForCustomContentProvider(String suggestedFilename, IPC::DataReference data)
+
</ins><span class="cx">     # Forms messages
</span><span class="cx">     WillSubmitForm(uint64_t frameID, uint64_t sourceFrameID, Vector&lt;std::pair&lt;String, String&gt;&gt; textFieldValues, uint64_t listenerID, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosPageClientImplIOSh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h (165302 => 165303)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h        2014-03-08 01:02:30 UTC (rev 165302)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h        2014-03-08 01:06:31 UTC (rev 165303)
</span><span class="lines">@@ -32,7 +32,8 @@
</span><span class="cx"> #import &quot;WebFullScreenManagerProxy.h&quot;
</span><span class="cx"> #import &lt;wtf/RetainPtr.h&gt;
</span><span class="cx"> 
</span><del>-@class WKContentView;
</del><ins>+OBJC_CLASS WKContentView;
+OBJC_CLASS WKWebView;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx">     
</span><span class="lines">@@ -42,7 +43,7 @@
</span><span class="cx"> #endif
</span><span class="cx">     {
</span><span class="cx"> public:
</span><del>-    explicit PageClientImpl(WKContentView *);
</del><ins>+    explicit PageClientImpl(WKContentView *, WKWebView *);
</ins><span class="cx">     virtual ~PageClientImpl();
</span><span class="cx">     
</span><span class="cx"> private:
</span><span class="lines">@@ -63,7 +64,7 @@
</span><span class="cx">     virtual void preferencesDidChange() override;
</span><span class="cx">     virtual void toolTipChanged(const String&amp;, const String&amp;) override;
</span><span class="cx">     virtual bool decidePolicyForGeolocationPermissionRequest(WebFrameProxy&amp;, WebSecurityOrigin&amp;, GeolocationPermissionRequestProxy&amp;) override;
</span><del>-    virtual void didCommitLoadForMainFrame() override;
</del><ins>+    virtual void didCommitLoadForMainFrame(const String&amp; mimeType, bool useCustomContentProvider) override;
</ins><span class="cx">     virtual void setCursor(const WebCore::Cursor&amp;) override;
</span><span class="cx">     virtual void setCursorHiddenUntilMouseMoves(bool) override;
</span><span class="cx">     virtual void didChangeViewportProperties(const WebCore::ViewportAttributes&amp;) override;
</span><span class="lines">@@ -129,7 +130,10 @@
</span><span class="cx">     virtual void beganExitFullScreen(const WebCore::IntRect&amp; initialFrame, const WebCore::IntRect&amp; finalFrame) override;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    virtual void didFinishLoadingDataForCustomContentProvider(const String&amp; suggestedFilename, const IPC::DataReference&amp;) override;
+
</ins><span class="cx">     WKContentView *m_contentView;
</span><ins>+    WKWebView *m_webView;
</ins><span class="cx"> };
</span><span class="cx"> } // namespace WebKit
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosPageClientImplIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm (165302 => 165303)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm        2014-03-08 01:02:30 UTC (rev 165302)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm        2014-03-08 01:06:31 UTC (rev 165303)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #import &quot;InteractionInformationAtPosition.h&quot;
</span><span class="cx"> #import &quot;WKContentView.h&quot;
</span><span class="cx"> #import &quot;WKContentViewInteraction.h&quot;
</span><ins>+#import &quot;WKWebViewInternal.h&quot;
</ins><span class="cx"> #import &quot;WebContextMenuProxy.h&quot;
</span><span class="cx"> #import &quot;WebEditCommandProxy.h&quot;
</span><span class="cx"> #import &lt;UIKit/UIImagePickerController_Private.h&gt;
</span><span class="lines">@@ -49,8 +50,9 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><del>-PageClientImpl::PageClientImpl(WKContentView *view)
-    : m_contentView(view)
</del><ins>+PageClientImpl::PageClientImpl(WKContentView *contentView, WKWebView *webView)
+    : m_contentView(contentView)
+    , m_webView(webView)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -146,8 +148,9 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PageClientImpl::didCommitLoadForMainFrame()
</del><ins>+void PageClientImpl::didCommitLoadForMainFrame(const String&amp; mimeType, bool useCustomContentProvider)
</ins><span class="cx"> {
</span><ins>+    [m_webView _setHasCustomContentView:useCustomContentProvider loadedMIMEType:mimeType];
</ins><span class="cx">     [m_contentView _didCommitLoadForMainFrame];
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -402,6 +405,12 @@
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(FULLSCREEN_API)
</span><span class="cx"> 
</span><ins>+void PageClientImpl::didFinishLoadingDataForCustomContentProvider(const String&amp; suggestedFilename, const IPC::DataReference&amp; dataReference)
+{
+    RetainPtr&lt;NSData&gt; data = adoptNS([[NSData alloc] initWithBytes:dataReference.data() length:dataReference.size()]);
+    [m_webView _didFinishLoadingDataForCustomContentProviderWithSuggestedFilename:suggestedFilename data:data.get()];
+}
+
</ins><span class="cx"> } // namespace WebKit
</span><span class="cx"> 
</span><span class="cx"> #endif // PLATFORM(IOS)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKContentViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm (165302 => 165303)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm        2014-03-08 01:02:30 UTC (rev 165302)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm        2014-03-08 01:06:31 UTC (rev 165303)
</span><span class="lines">@@ -76,7 +76,7 @@
</span><span class="cx"> 
</span><span class="cx">     InitializeWebKit2();
</span><span class="cx"> 
</span><del>-    _pageClient = std::make_unique&lt;PageClientImpl&gt;(self);
</del><ins>+    _pageClient = std::make_unique&lt;PageClientImpl&gt;(self, webView);
</ins><span class="cx"> 
</span><span class="cx">     _page = context.createWebPage(*_pageClient, std::move(webPageConfiguration));
</span><span class="cx">     _page-&gt;initializeWebPage();
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacPageClientImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h (165302 => 165303)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h        2014-03-08 01:02:30 UTC (rev 165302)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h        2014-03-08 01:06:31 UTC (rev 165303)
</span><span class="lines">@@ -79,7 +79,8 @@
</span><span class="cx">     virtual void didRelaunchProcess();
</span><span class="cx">     virtual void preferencesDidChange() override;
</span><span class="cx">     virtual void toolTipChanged(const String&amp; oldToolTip, const String&amp; newToolTip);
</span><del>-    virtual void didCommitLoadForMainFrame() override;
</del><ins>+    virtual void didCommitLoadForMainFrame(const String&amp; mimeType, bool useCustomContentProvider) override;
+    virtual void didFinishLoadingDataForCustomContentProvider(const String&amp; suggestedFilename, const IPC::DataReference&amp;) override;
</ins><span class="cx">     virtual void setCursor(const WebCore::Cursor&amp;);
</span><span class="cx">     virtual void setCursorHiddenUntilMouseMoves(bool);
</span><span class="cx">     virtual void didChangeViewportProperties(const WebCore::ViewportAttributes&amp;);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacPageClientImplmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm (165302 => 165303)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm        2014-03-08 01:02:30 UTC (rev 165302)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm        2014-03-08 01:06:31 UTC (rev 165303)
</span><span class="lines">@@ -285,10 +285,14 @@
</span><span class="cx">     [m_wkView _toolTipChangedFrom:nsStringFromWebCoreString(oldToolTip) to:nsStringFromWebCoreString(newToolTip)];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PageClientImpl::didCommitLoadForMainFrame()
</del><ins>+void PageClientImpl::didCommitLoadForMainFrame(const String&amp; mimeType, bool useCustomContentProvider)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void PageClientImpl::didFinishLoadingDataForCustomContentProvider(const String&amp; suggestedFilename, const IPC::DataReference&amp; dataReference)
+{
+}
+
</ins><span class="cx"> void PageClientImpl::setCursor(const WebCore::Cursor&amp; cursor)
</span><span class="cx"> {
</span><span class="cx">     if (![NSApp _cursorRectCursor])
</span></span></pre></div>
<a id="trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (165302 => 165303)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2014-03-08 01:02:30 UTC (rev 165302)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2014-03-08 01:06:31 UTC (rev 165303)
</span><span class="lines">@@ -498,6 +498,8 @@
</span><span class="cx">                 2D6B371C18A967AD0042AE80 /* WKThumbnailView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D6B371A18A967AD0042AE80 /* WKThumbnailView.mm */; };
</span><span class="cx">                 2D6CD119189058A500E5A4A0 /* ViewSnapshotStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D6CD117189058A500E5A4A0 /* ViewSnapshotStore.h */; };
</span><span class="cx">                 2D6CD11A189058A500E5A4A0 /* ViewSnapshotStore.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D6CD118189058A500E5A4A0 /* ViewSnapshotStore.mm */; };
</span><ins>+                2D7AAFD318C8640600A7ACD4 /* WKWebViewContentProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D7AAFD218C8640600A7ACD4 /* WKWebViewContentProvider.h */; };
+                2D7AAFD618C956AF00A7ACD4 /* WKWebViewConfigurationInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D7AAFD518C956AF00A7ACD4 /* WKWebViewConfigurationInternal.h */; };
</ins><span class="cx">                 2D819B9E18627EE9001F03D1 /* ViewGestureGeometryCollector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D819B99186275B3001F03D1 /* ViewGestureGeometryCollector.cpp */; };
</span><span class="cx">                 2D819BA11862800E001F03D1 /* ViewGestureGeometryCollectorMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D819B9F1862800E001F03D1 /* ViewGestureGeometryCollectorMessageReceiver.cpp */; };
</span><span class="cx">                 2D819BA21862800E001F03D1 /* ViewGestureGeometryCollectorMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D819BA01862800E001F03D1 /* ViewGestureGeometryCollectorMessages.h */; };
</span><span class="lines">@@ -529,6 +531,8 @@
</span><span class="cx">                 2DACE64E18ADBFF000E4CA76 /* WKThumbnailViewInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DACE64D18ADBFF000E4CA76 /* WKThumbnailViewInternal.h */; };
</span><span class="cx">                 2DAF06D618BD1A470081CEB1 /* SmartMagnificationController.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DAF06D418BD1A470081CEB1 /* SmartMagnificationController.h */; };
</span><span class="cx">                 2DAF06D718BD1A470081CEB1 /* SmartMagnificationController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DAF06D518BD1A470081CEB1 /* SmartMagnificationController.mm */; };
</span><ins>+                2DC6D9C318C44A610043BAD4 /* WKWebViewContentProviderRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DC6D9C118C44A610043BAD4 /* WKWebViewContentProviderRegistry.h */; };
+                2DC6D9C418C44A610043BAD4 /* WKWebViewContentProviderRegistry.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DC6D9C218C44A610043BAD4 /* WKWebViewContentProviderRegistry.mm */; };
</ins><span class="cx">                 2DDE0AFA18298CC900F97EAA /* RemoteLayerTreePropertyApplier.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DDE0AF818298CC900F97EAA /* RemoteLayerTreePropertyApplier.h */; };
</span><span class="cx">                 2DDE0AFB18298CC900F97EAA /* RemoteLayerTreePropertyApplier.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DDE0AF918298CC900F97EAA /* RemoteLayerTreePropertyApplier.mm */; };
</span><span class="cx">                 2DE6943D18BD2A68005C15E5 /* SmartMagnificationControllerMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2DE6943B18BD2A68005C15E5 /* SmartMagnificationControllerMessageReceiver.cpp */; };
</span><span class="lines">@@ -2255,6 +2259,8 @@
</span><span class="cx">                 2D6CD118189058A500E5A4A0 /* ViewSnapshotStore.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ViewSnapshotStore.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2D70AB1318A1D51A00026D6E /* Info-iOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = &quot;Info-iOS.plist&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2D70AB1418A1D57C00026D6E /* Info-iOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = &quot;Info-iOS.plist&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                2D7AAFD218C8640600A7ACD4 /* WKWebViewContentProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebViewContentProvider.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                2D7AAFD518C956AF00A7ACD4 /* WKWebViewConfigurationInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebViewConfigurationInternal.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 2D819B99186275B3001F03D1 /* ViewGestureGeometryCollector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ViewGestureGeometryCollector.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2D819B9A186275B3001F03D1 /* ViewGestureGeometryCollector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewGestureGeometryCollector.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2D819B9B186275B3001F03D1 /* ViewGestureGeometryCollector.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ViewGestureGeometryCollector.messages.in; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -2290,6 +2296,8 @@
</span><span class="cx">                 2DAF06D418BD1A470081CEB1 /* SmartMagnificationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SmartMagnificationController.h; path = ios/SmartMagnificationController.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2DAF06D518BD1A470081CEB1 /* SmartMagnificationController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = SmartMagnificationController.mm; path = ios/SmartMagnificationController.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2DAF06D818BD23BA0081CEB1 /* SmartMagnificationController.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; name = SmartMagnificationController.messages.in; path = ios/SmartMagnificationController.messages.in; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                2DC6D9C118C44A610043BAD4 /* WKWebViewContentProviderRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebViewContentProviderRegistry.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                2DC6D9C218C44A610043BAD4 /* WKWebViewContentProviderRegistry.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewContentProviderRegistry.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 2DDE0AF818298CC900F97EAA /* RemoteLayerTreePropertyApplier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteLayerTreePropertyApplier.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2DDE0AF918298CC900F97EAA /* RemoteLayerTreePropertyApplier.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteLayerTreePropertyApplier.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2DE6943B18BD2A68005C15E5 /* SmartMagnificationControllerMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SmartMagnificationControllerMessageReceiver.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -4144,6 +4152,9 @@
</span><span class="cx">                 1ABC3DF21899E415004F0626 /* Cocoa */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                2D7AAFD218C8640600A7ACD4 /* WKWebViewContentProvider.h */,
+                                2DC6D9C118C44A610043BAD4 /* WKWebViewContentProviderRegistry.h */,
+                                2DC6D9C218C44A610043BAD4 /* WKWebViewContentProviderRegistry.mm */,
</ins><span class="cx">                                 0F0C365918C0555800F607D7 /* LayerRepresentation.h */,
</span><span class="cx">                                 1A422F8D18B29C6400D8CD96 /* HistoryClient.h */,
</span><span class="cx">                                 1A422F8C18B29C6400D8CD96 /* HistoryClient.mm */,
</span><span class="lines">@@ -4547,6 +4558,7 @@
</span><span class="cx">                                 1ADF59191890528E0043C145 /* WKWebViewConfiguration.h */,
</span><span class="cx">                                 1ADF59181890528E0043C145 /* WKWebViewConfiguration.mm */,
</span><span class="cx">                                 1AC1415018AC47EE006C602C /* WKWebViewConfigurationPrivate.h */,
</span><ins>+                                2D7AAFD518C956AF00A7ACD4 /* WKWebViewConfigurationInternal.h */,
</ins><span class="cx">                                 1A66BF8E18A052ED002071B4 /* WKWebViewInternal.h */,
</span><span class="cx">                                 26F9A83A18A3463F00AEB88A /* WKWebViewPrivate.h */,
</span><span class="cx">                         );
</span><span class="lines">@@ -6553,6 +6565,7 @@
</span><span class="cx">                                 BC4BEEAB120A0A5F00FBA0C7 /* InjectedBundleNodeHandle.h in Headers */,
</span><span class="cx">                                 378E1A4E18208D700031007A /* WKNSURL.h in Headers */,
</span><span class="cx">                                 1A1B0EB818A424CD0038481A /* WKNavigationResponseInternal.h in Headers */,
</span><ins>+                                2D7AAFD318C8640600A7ACD4 /* WKWebViewContentProvider.h in Headers */,
</ins><span class="cx">                                 512935E41288D97800A4B695 /* InjectedBundlePageContextMenuClient.h in Headers */,
</span><span class="cx">                                 E1EE53E311F8CFC000CCBEE4 /* InjectedBundlePageEditorClient.h in Headers */,
</span><span class="cx">                                 BC14E10A120B905E00826C0C /* InjectedBundlePageFormClient.h in Headers */,
</span><span class="lines">@@ -6759,6 +6772,7 @@
</span><span class="cx">                                 3F87B9C0158940D80090FF62 /* WebColorPicker.h in Headers */,
</span><span class="cx">                                 BC4A6290147312BE006C681A /* WebConnection.h in Headers */,
</span><span class="cx">                                 0FCB4E5418BBE044000FCFC9 /* WKScrollView.h in Headers */,
</span><ins>+                                2DC6D9C318C44A610043BAD4 /* WKWebViewContentProviderRegistry.h in Headers */,
</ins><span class="cx">                                 2DE6943E18BD2A68005C15E5 /* SmartMagnificationControllerMessages.h in Headers */,
</span><span class="cx">                                 BC4A6292147312BE006C681A /* WebConnectionClient.h in Headers */,
</span><span class="cx">                                 1A1FEC1D1627B45700700F6D /* WebConnectionMessages.h in Headers */,
</span><span class="lines">@@ -6793,6 +6807,7 @@
</span><span class="cx">                                 1A2464F31891E45100234C5B /* APILoaderClient.h in Headers */,
</span><span class="cx">                                 BC1DD7B2114DC396005ADAF3 /* WebCoreArgumentCoders.h in Headers */,
</span><span class="cx">                                 512F589B12A8838800629530 /* WebCredential.h in Headers */,
</span><ins>+                                2D7AAFD618C956AF00A7ACD4 /* WKWebViewConfigurationInternal.h in Headers */,
</ins><span class="cx">                                 2DACE64E18ADBFF000E4CA76 /* WKThumbnailViewInternal.h in Headers */,
</span><span class="cx">                                 51578B831209ECEF00A37C4A /* APIData.h in Headers */,
</span><span class="cx">                                 F6A25FDD12ADC6CC00DC40CC /* WebDatabaseManager.h in Headers */,
</span><span class="lines">@@ -8032,6 +8047,7 @@
</span><span class="cx">                                 51CBBA0F165219B6005BE8FD /* NetworkResourceLoadParameters.cpp in Sources */,
</span><span class="cx">                                 51829DA51637C70C000953D6 /* NetworkResourceLoadScheduler.cpp in Sources */,
</span><span class="cx">                                 512C069016390E6900ABB911 /* NetworkResourceLoadSchedulerMac.mm in Sources */,
</span><ins>+                                2DC6D9C418C44A610043BAD4 /* WKWebViewContentProviderRegistry.mm in Sources */,
</ins><span class="cx">                                 BC8283AC16B4BF3F00A278FE /* NetworkServiceEntryPoint.mm in Sources */,
</span><span class="cx">                                 31A2EC551489982E00810D71 /* NotificationPermissionRequest.cpp in Sources */,
</span><span class="cx">                                 3131261E148FF82C00BA2A39 /* NotificationPermissionRequestManager.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessInjectedBundleAPICocoaWKWebProcessPlugInFramemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm (165302 => 165303)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm        2014-03-08 01:02:30 UTC (rev 165302)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm        2014-03-08 01:06:31 UTC (rev 165303)
</span><span class="lines">@@ -102,6 +102,14 @@
</span><span class="cx">     return [wrapper(*API::FrameHandle::create(_frame-&gt;frameID()).leakRef()) autorelease];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (BOOL)_hasCustomContentProvider
+{
+    if (!_frame-&gt;isMainFrame())
+        return false;
+
+    return _frame-&gt;page()-&gt;mainFrameHasCustomContentProvider();
+}
+
</ins><span class="cx"> #pragma mark WKObject protocol implementation
</span><span class="cx"> 
</span><span class="cx"> - (API::Object&amp;)_apiObject
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessInjectedBundleAPICocoaWKWebProcessPlugInFramePrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFramePrivate.h (165302 => 165303)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFramePrivate.h        2014-03-08 01:02:30 UTC (rev 165302)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFramePrivate.h        2014-03-08 01:06:31 UTC (rev 165303)
</span><span class="lines">@@ -35,6 +35,8 @@
</span><span class="cx"> 
</span><span class="cx"> @property (nonatomic, readonly) WKWebProcessPlugInBrowserContextController *_browserContextController;
</span><span class="cx"> 
</span><ins>+@property (nonatomic, readonly) BOOL _hasCustomContentProvider;
+
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> #endif // WK_API_ENABLED
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebFrameLoaderClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (165302 => 165303)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp        2014-03-08 01:02:30 UTC (rev 165302)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp        2014-03-08 01:06:31 UTC (rev 165303)
</span><span class="lines">@@ -90,6 +90,7 @@
</span><span class="cx">     : m_frame(0)
</span><span class="cx">     , m_hasSentResponseToPluginView(false)
</span><span class="cx">     , m_didCompletePageTransitionAlready(false)
</span><ins>+    , m_frameHasCustomContentProvider(false)
</ins><span class="cx">     , m_frameCameFromPageCache(false)
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="lines">@@ -109,6 +110,11 @@
</span><span class="cx">     m_frame-&gt;deref();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool WebFrameLoaderClient::hasHTMLView() const
+{
+    return !m_frameHasCustomContentProvider;
+}
+
</ins><span class="cx"> bool WebFrameLoaderClient::hasWebView() const
</span><span class="cx"> {
</span><span class="cx">     return m_frame-&gt;page();
</span><span class="lines">@@ -445,8 +451,7 @@
</span><span class="cx"> 
</span><span class="cx">     // Notify the UIProcess.
</span><span class="cx"> 
</span><del>-    webPage-&gt;send(Messages::WebPageProxy::DidCommitLoadForFrame(m_frame-&gt;frameID(), documentLoader.navigationID(), documentLoader.response().mimeType(), m_frame-&gt;coreFrame()-&gt;loader().loadType(), CertificateInfo(documentLoader.response()), InjectedBundleUserMessageEncoder(userData.get())));
-
</del><ins>+    webPage-&gt;send(Messages::WebPageProxy::DidCommitLoadForFrame(m_frame-&gt;frameID(), documentLoader.navigationID(), documentLoader.response().mimeType(), m_frameHasCustomContentProvider, m_frame-&gt;coreFrame()-&gt;loader().loadType(), CertificateInfo(documentLoader.response()), InjectedBundleUserMessageEncoder(userData.get())));
</ins><span class="cx">     webPage-&gt;didCommitLoad(m_frame);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -826,7 +831,7 @@
</span><span class="cx">         return;
</span><span class="cx">     
</span><span class="cx">     m_pluginView-&gt;manualLoadDidFail(error);
</span><del>-    m_pluginView = 0;
</del><ins>+    m_pluginView = nullptr;
</ins><span class="cx">     m_hasSentResponseToPluginView = false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -852,6 +857,10 @@
</span><span class="cx"> 
</span><span class="cx"> void WebFrameLoaderClient::committedLoad(DocumentLoader* loader, const char* data, int length)
</span><span class="cx"> {
</span><ins>+    // If we're loading a custom representation, we don't want to hand off the data to WebCore.
+    if (m_frameHasCustomContentProvider)
+        return;
+
</ins><span class="cx">     if (!m_pluginView)
</span><span class="cx">         loader-&gt;commitData(data, length);
</span><span class="cx"> 
</span><span class="lines">@@ -878,8 +887,19 @@
</span><span class="cx"> 
</span><span class="cx"> void WebFrameLoaderClient::finishedLoading(DocumentLoader* loader)
</span><span class="cx"> {
</span><del>-    if (!m_pluginView)
</del><ins>+    if (!m_pluginView) {
+        if (m_frameHasCustomContentProvider) {
+            WebPage* webPage = m_frame-&gt;page();
+            if (!webPage)
+                return;
+
+            RefPtr&lt;ResourceBuffer&gt; mainResourceData = loader-&gt;mainResourceData();
+            IPC::DataReference dataReference(reinterpret_cast&lt;const uint8_t*&gt;(mainResourceData ? mainResourceData-&gt;data() : 0), mainResourceData ? mainResourceData-&gt;size() : 0);
+            webPage-&gt;send(Messages::WebPageProxy::DidFinishLoadingDataForCustomContentProvider(loader-&gt;response().suggestedFilename(), dataReference));
+        }
+
</ins><span class="cx">         return;
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">     // If we just received an empty response without any data, we won't have sent a response to the plug-in view.
</span><span class="cx">     // Make sure to do this before calling manualLoadDidFinishLoading.
</span><span class="lines">@@ -892,7 +912,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     m_pluginView-&gt;manualLoadDidFinishLoading();
</span><del>-    m_pluginView = 0;
</del><ins>+    m_pluginView = nullptr;
</ins><span class="cx">     m_hasSentResponseToPluginView = false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1166,6 +1186,9 @@
</span><span class="cx"> 
</span><span class="cx"> void WebFrameLoaderClient::transitionToCommittedFromCachedFrame(CachedFrame*)
</span><span class="cx"> {
</span><ins>+    const ResourceResponse&amp; response = m_frame-&gt;coreFrame()-&gt;loader().documentLoader()-&gt;response();
+    m_frameHasCustomContentProvider = m_frame-&gt;isMainFrame() &amp;&amp; m_frame-&gt;page()-&gt;shouldUseCustomContentProviderForResponse(response);
+    m_frameCameFromPageCache = true;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebFrameLoaderClient::transitionToCommittedForNewPage()
</span><span class="lines">@@ -1173,7 +1196,7 @@
</span><span class="cx">     WebPage* webPage = m_frame-&gt;page();
</span><span class="cx"> 
</span><span class="cx">     Color backgroundColor = webPage-&gt;drawsTransparentBackground() ? Color::transparent : Color::white;
</span><del>-    bool isMainFrame = webPage-&gt;mainWebFrame() == m_frame;
</del><ins>+    bool isMainFrame = m_frame-&gt;isMainFrame();
</ins><span class="cx">     bool isTransparent = !webPage-&gt;drawsBackground();
</span><span class="cx">     bool shouldUseFixedLayout = isMainFrame &amp;&amp; webPage-&gt;useFixedLayout();
</span><span class="cx">     bool shouldDisableScrolling = isMainFrame &amp;&amp; !webPage-&gt;mainFrameIsScrollable();
</span><span class="lines">@@ -1185,6 +1208,8 @@
</span><span class="cx">         fixedVisibleContentRect = m_frame-&gt;coreFrame()-&gt;view()-&gt;fixedVisibleContentRect();
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    const ResourceResponse&amp; response = m_frame-&gt;coreFrame()-&gt;loader().documentLoader()-&gt;response();
+    m_frameHasCustomContentProvider = isMainFrame &amp;&amp; webPage-&gt;shouldUseCustomContentProviderForResponse(response);
</ins><span class="cx">     m_frameCameFromPageCache = false;
</span><span class="cx"> 
</span><span class="cx">     ScrollbarMode defaultScrollbarMode = shouldHideScrollbars ? ScrollbarAlwaysOff : ScrollbarAuto;
</span><span class="lines">@@ -1244,6 +1269,13 @@
</span><span class="cx">     webPage-&gt;send(Messages::WebPageProxy::FrameDidBecomeFrameSet(m_frame-&gt;frameID(), value));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool WebFrameLoaderClient::canCachePage() const
+{
+    // We cannot cache frames that have custom representations because they are
+    // rendered in the UIProcess.
+    return !m_frameHasCustomContentProvider;
+}
+
</ins><span class="cx"> void WebFrameLoaderClient::convertMainResourceLoadToDownload(DocumentLoader *documentLoader, const ResourceRequest&amp; request, const ResourceResponse&amp; response)
</span><span class="cx"> {
</span><span class="cx">     m_frame-&gt;convertMainResourceLoadToDownload(documentLoader, request, response);
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebFrameLoaderClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h (165302 => 165303)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h        2014-03-08 01:02:30 UTC (rev 165302)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h        2014-03-08 01:06:31 UTC (rev 165303)
</span><span class="lines">@@ -41,10 +41,12 @@
</span><span class="cx">     void setWebFrame(WebFrame* webFrame) { m_frame = webFrame; }
</span><span class="cx">     WebFrame* webFrame() const { return m_frame; }
</span><span class="cx"> 
</span><ins>+    bool frameHasCustomContentProvider() const { return m_frameHasCustomContentProvider; }
+
</ins><span class="cx"> private:
</span><span class="cx">     virtual void frameLoaderDestroyed() override;
</span><span class="cx"> 
</span><del>-    virtual bool hasHTMLView() const override { return true; }
</del><ins>+    virtual bool hasHTMLView() const override;
</ins><span class="cx">     virtual bool hasWebView() const override;
</span><span class="cx">     
</span><span class="cx">     virtual void makeRepresentation(WebCore::DocumentLoader*) override;
</span><span class="lines">@@ -175,9 +177,9 @@
</span><span class="cx"> 
</span><span class="cx">     virtual void dispatchDidBecomeFrameset(bool) override;
</span><span class="cx"> 
</span><del>-    virtual bool canCachePage() const override { return true; }
</del><ins>+    virtual bool canCachePage() const override;
</ins><span class="cx">     virtual void convertMainResourceLoadToDownload(WebCore::DocumentLoader*, const WebCore::ResourceRequest&amp;, const WebCore::ResourceResponse&amp;) override;
</span><del>-    
</del><ins>+
</ins><span class="cx">     virtual PassRefPtr&lt;WebCore::Frame&gt; createFrame(const WebCore::URL&amp; url, const String&amp; name, WebCore::HTMLFrameOwnerElement* ownerElement,
</span><span class="cx">                                           const String&amp; referrer, bool allowsScrolling, int marginWidth, int marginHeight) override;
</span><span class="cx">     
</span><span class="lines">@@ -232,6 +234,7 @@
</span><span class="cx">     RefPtr&lt;PluginView&gt; m_pluginView;
</span><span class="cx">     bool m_hasSentResponseToPluginView;
</span><span class="cx">     bool m_didCompletePageTransitionAlready;
</span><ins>+    bool m_frameHasCustomContentProvider;
</ins><span class="cx">     bool m_frameCameFromPageCache;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (165302 => 165303)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2014-03-08 01:02:30 UTC (rev 165302)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2014-03-08 01:06:31 UTC (rev 165303)
</span><span class="lines">@@ -3070,6 +3070,22 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+bool WebPage::mainFrameHasCustomContentProvider() const
+{
+    if (Frame* frame = mainFrame()) {
+        WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(frame-&gt;loader().client());
+        ASSERT(webFrameLoaderClient);
+        return webFrameLoaderClient-&gt;frameHasCustomContentProvider();
+    }
+
+    return false;
+}
+
+void WebPage::addMIMETypeWithCustomContentProvider(const String&amp; mimeType)
+{
+    m_mimeTypesWithCustomContentProviders.add(mimeType);
+}
+
</ins><span class="cx"> void WebPage::updateMainFrameScrollOffsetPinning()
</span><span class="cx"> {
</span><span class="cx">     Frame&amp; frame = m_page-&gt;mainFrame();
</span><span class="lines">@@ -3812,6 +3828,12 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool WebPage::shouldUseCustomContentProviderForResponse(const ResourceResponse&amp; response)
+{
+    // If a plug-in exists that claims to support this response, it should take precedence over the custom content provider.
+    return m_mimeTypesWithCustomContentProviders.contains(response.mimeType()) &amp;&amp; !canPluginHandleResponse(response);
+}
+
</ins><span class="cx"> #if PLATFORM(GTK)
</span><span class="cx"> static Frame* targetFrameForEditing(WebPage* page)
</span><span class="cx"> {
</span><span class="lines">@@ -3957,6 +3979,9 @@
</span><span class="cx">     if (MIMETypeRegistry::canShowMIMEType(MIMEType))
</span><span class="cx">         return true;
</span><span class="cx"> 
</span><ins>+    if (m_mimeTypesWithCustomContentProviders.contains(MIMEType))
+        return true;
+
</ins><span class="cx">     const PluginData&amp; pluginData = m_page-&gt;pluginData();
</span><span class="cx">     if (pluginData.supportsMimeType(MIMEType, PluginData::AllPlugins) &amp;&amp; corePage()-&gt;mainFrame().loader().subframeLoader().allowPlugins(NotAboutToInstantiatePlugin))
</span><span class="cx">         return true;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (165302 => 165303)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2014-03-08 01:02:30 UTC (rev 165302)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2014-03-08 01:06:31 UTC (rev 165303)
</span><span class="lines">@@ -625,6 +625,9 @@
</span><span class="cx"> 
</span><span class="cx">     void updateMainFrameScrollOffsetPinning();
</span><span class="cx"> 
</span><ins>+    bool mainFrameHasCustomContentProvider() const;
+    void addMIMETypeWithCustomContentProvider(const String&amp;);
+
</ins><span class="cx">     void mainFrameDidLayout();
</span><span class="cx"> 
</span><span class="cx">     bool canRunBeforeUnloadConfirmPanel() const { return m_canRunBeforeUnloadConfirmPanel; }
</span><span class="lines">@@ -679,6 +682,7 @@
</span><span class="cx">     uint64_t nativeWindowHandle() { return m_nativeWindowHandle; }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    bool shouldUseCustomContentProviderForResponse(const WebCore::ResourceResponse&amp;);
</ins><span class="cx">     bool canPluginHandleResponse(const WebCore::ResourceResponse&amp; response);
</span><span class="cx"> 
</span><span class="cx">     bool asynchronousPluginInitializationEnabled() const { return m_asynchronousPluginInitializationEnabled; }
</span><span class="lines">@@ -1108,6 +1112,7 @@
</span><span class="cx"> 
</span><span class="cx">     WebInspectorClient* m_inspectorClient;
</span><span class="cx"> 
</span><ins>+    HashSet&lt;String, CaseFoldingHash&gt; m_mimeTypesWithCustomContentProviders;
</ins><span class="cx">     WebCore::Color m_backgroundColor;
</span><span class="cx"> 
</span><span class="cx">     HashSet&lt;unsigned&gt; m_activeRenderingSuppressionTokens;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagemessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (165302 => 165303)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in        2014-03-08 01:02:30 UTC (rev 165302)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in        2014-03-08 01:06:31 UTC (rev 165303)
</span><span class="lines">@@ -183,6 +183,8 @@
</span><span class="cx">     SelectFindMatch(uint32_t matchIndex)
</span><span class="cx">     HideFindUI()
</span><span class="cx">     CountStringMatches(String string, uint32_t findOptions, unsigned maxMatchCount)
</span><ins>+    
+    AddMIMETypeWithCustomContentProvider(String mimeType)
</ins><span class="cx"> 
</span><span class="cx">     # Drag and drop.
</span><span class="cx"> #if PLATFORM(GTK) &amp;&amp; ENABLE(DRAG_SUPPORT)
</span></span></pre>
</div>
</div>

</body>
</html>