Title: [146216] trunk/Source/WebCore
Revision
146216
Author
jap...@chromium.org
Date
2013-03-19 10:08:17 -0700 (Tue, 19 Mar 2013)

Log Message

Merge MainResourceLoader::responseReceived into DocumentLoader
https://bugs.webkit.org/show_bug.cgi?id=112593

Part of the ongoing effort to merge MainResourceLoader entirely
into DocumentLoader.

Reviewed by Adam Barth.

No new tests, refactor only.

* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::DocumentLoader):
(WebCore::DocumentLoader::stopLoading):
(WebCore::DocumentLoader::finishedLoading): The only thing left in
    MainResourceLoader related to this function was a RefPtr which indirectly
    protected DocumentLoader. Move the RefPtr here and protect DocumentLoader directly.
(WebCore::DocumentLoader::responseReceived): Moved from MainResourceLoader.
(WebCore::DocumentLoader::callContinueAfterContentPolicy): Moved from MainResourceLoader.
(WebCore::DocumentLoader::continueAfterContentPolicy): Moved from MainResourceLoader.
(WebCore::DocumentLoader::interruptedForPolicyChangeError): Moved from MainResourceLoader.
(WebCore::DocumentLoader::stopLoadingForPolicyChange): Moved from MainResourceLoader.
(WebCore::DocumentLoader::receivedData):
(WebCore::DocumentLoader::cancelMainResourceLoad):
* loader/DocumentLoader.h:
(WebCore::DocumentLoader::isLoadingMultipartContent): Store multipart bit here.
* loader/MainResourceLoader.cpp:
(WebCore::MainResourceLoader::MainResourceLoader):
(WebCore::MainResourceLoader::cancel):
(WebCore::MainResourceLoader::responseReceived):
(WebCore::MainResourceLoader::notifyFinished):
* loader/MainResourceLoader.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (146215 => 146216)


--- trunk/Source/WebCore/ChangeLog	2013-03-19 17:06:10 UTC (rev 146215)
+++ trunk/Source/WebCore/ChangeLog	2013-03-19 17:08:17 UTC (rev 146216)
@@ -1,3 +1,37 @@
+2013-03-19  Nate Chapin  <jap...@chromium.org>
+
+        Merge MainResourceLoader::responseReceived into DocumentLoader
+        https://bugs.webkit.org/show_bug.cgi?id=112593
+
+        Part of the ongoing effort to merge MainResourceLoader entirely
+        into DocumentLoader.
+
+        Reviewed by Adam Barth.
+
+        No new tests, refactor only.
+
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::DocumentLoader):
+        (WebCore::DocumentLoader::stopLoading):
+        (WebCore::DocumentLoader::finishedLoading): The only thing left in
+            MainResourceLoader related to this function was a RefPtr which indirectly
+            protected DocumentLoader. Move the RefPtr here and protect DocumentLoader directly.
+        (WebCore::DocumentLoader::responseReceived): Moved from MainResourceLoader.
+        (WebCore::DocumentLoader::callContinueAfterContentPolicy): Moved from MainResourceLoader.
+        (WebCore::DocumentLoader::continueAfterContentPolicy): Moved from MainResourceLoader.
+        (WebCore::DocumentLoader::interruptedForPolicyChangeError): Moved from MainResourceLoader.
+        (WebCore::DocumentLoader::stopLoadingForPolicyChange): Moved from MainResourceLoader.
+        (WebCore::DocumentLoader::receivedData):
+        (WebCore::DocumentLoader::cancelMainResourceLoad):
+        * loader/DocumentLoader.h:
+        (WebCore::DocumentLoader::isLoadingMultipartContent): Store multipart bit here.
+        * loader/MainResourceLoader.cpp:
+        (WebCore::MainResourceLoader::MainResourceLoader):
+        (WebCore::MainResourceLoader::cancel):
+        (WebCore::MainResourceLoader::responseReceived):
+        (WebCore::MainResourceLoader::notifyFinished):
+        * loader/MainResourceLoader.h:
+
 2013-03-19  Tony Chang  <t...@chromium.org>
 
         Cleanup defaultUnifiedTextCheckerEnabled type

Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (146215 => 146216)


--- trunk/Source/WebCore/loader/DocumentLoader.cpp	2013-03-19 17:06:10 UTC (rev 146215)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp	2013-03-19 17:08:17 UTC (rev 146216)
@@ -105,12 +105,14 @@
     , m_isStopping(false)
     , m_gotFirstByte(false)
     , m_isClientRedirect(false)
+    , m_isLoadingMultipartContent(false)
     , m_loadingEmptyDocument(false)
     , m_wasOnloadHandled(false)
     , m_stopRecordingResponses(false)
     , m_substituteResourceDeliveryTimer(this, &DocumentLoader::substituteResourceDeliveryTimerFired)
     , m_didCreateGlobalHistoryEntry(false)
     , m_timeOfLastDataReceived(0.0)
+    , m_waitingForContentPolicy(false)
     , m_applicationCacheHost(adoptPtr(new ApplicationCacheHost(this)))
 {
 }
@@ -276,7 +278,7 @@
     
     if (m_mainResourceLoader)
         // Stop the main resource loader and let it send the cancelled message.
-        m_mainResourceLoader->cancel();
+        m_mainResourceLoader->cancel(frameLoader->cancelledError(m_request));
     else if (!m_subresourceLoaders.isEmpty())
         // The main resource loader already finished loading. Set the cancelled error on the 
         // document and let the subresourceLoaders send individual cancelled messages below.
@@ -320,6 +322,8 @@
     ASSERT(!m_frame->page()->defersLoading() || InspectorInstrumentation::isDebuggerPaused(m_frame));
 #endif
 
+    RefPtr<DocumentLoader> protect(this);
+
     if (m_mainResourceLoader && m_mainResourceLoader->identifierForLoadWithoutResourceLoader()) {
         frameLoader()->notifier()->dispatchDidFinishLoading(this, m_mainResourceLoader->identifier(), finishTime);
         m_mainResourceLoader->clearIdentifierForLoadWithoutResourceLoader();
@@ -457,7 +461,7 @@
 void DocumentLoader::continueAfterNavigationPolicy(const ResourceRequest& request, bool shouldContinue)
 {
     if (!shouldContinue)
-        m_mainResourceLoader->stopLoadingForPolicyChange();
+        stopLoadingForPolicyChange();
     else if (m_substituteData.isValid()) {
         // A redirect resulted in loading substitute data.
         ASSERT(timing()->redirectCount());
@@ -479,15 +483,164 @@
 
 void DocumentLoader::responseReceived(const ResourceResponse& response)
 {
+    bool willLoadFallback = m_applicationCacheHost->maybeLoadFallbackForMainResponse(request(), response);
+
+    // The memory cache doesn't understand the application cache or its caching rules. So if a main resource is served
+    // from the application cache, ensure we don't save the result for future use.
+    bool shouldRemoveResourceFromCache = willLoadFallback;
+#if PLATFORM(CHROMIUM)
+    // chromium's ApplicationCacheHost implementation always returns true for maybeLoadFallbackForMainResponse(). However, all responses loaded
+    // from appcache will have a non-zero appCacheID().
+    if (response.appCacheID())
+        shouldRemoveResourceFromCache = true;
+#endif
+    if (shouldRemoveResourceFromCache)
+        memoryCache()->remove(m_mainResourceLoader->cachedMainResource());
+
+    if (willLoadFallback)
+        return;
+
+    DEFINE_STATIC_LOCAL(AtomicString, xFrameOptionHeader, ("x-frame-options", AtomicString::ConstructFromLiteral));
+    HTTPHeaderMap::const_iterator it = response.httpHeaderFields().find(xFrameOptionHeader);
+    if (it != response.httpHeaderFields().end()) {
+        String content = it->value;
+        unsigned long identifier = m_mainResourceLoader->identifier();
+        if (frameLoader()->shouldInterruptLoadForXFrameOptions(content, response.url(), identifier)) {
+            InspectorInstrumentation::continueAfterXFrameOptionsDenied(m_frame, this, identifier, response);
+            String message = "Refused to display '" + response.url().elidedString() + "' in a frame because it set 'X-Frame-Options' to '" + content + "'.";
+            frame()->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, message, identifier);
+            cancelMainResourceLoad(frameLoader()->cancelledError(m_request));
+            return;
+        }
+    }
+
+    // There is a bug in CFNetwork where callbacks can be dispatched even when loads are deferred.
+    // See <rdar://problem/6304600> for more details.
+#if !USE(CF)
+    ASSERT(!m_frame->page()->defersLoading());
+#endif
+
+    if (m_isLoadingMultipartContent) {
+        setupForReplace();
+        m_mainResourceLoader->cachedMainResource()->clear();
+    } else if (response.isMultipart()) {
+        FeatureObserver::observe(m_frame->document(), FeatureObserver::MultipartMainResource);
+        m_isLoadingMultipartContent = true;
+    }
+
     setResponse(response);
 
+    if (m_mainResourceLoader->identifierForLoadWithoutResourceLoader())
+        frameLoader()->notifier()->dispatchDidReceiveResponse(this, m_mainResourceLoader->identifierForLoadWithoutResourceLoader(), m_response, 0);
+
+    ASSERT(!m_waitingForContentPolicy);
+    m_waitingForContentPolicy = true;
+
+    // Always show content with valid substitute data.
+    if (m_substituteData.isValid()) {
+        continueAfterContentPolicy(PolicyUse);
+        return;
+    }
+
+#if ENABLE(FTPDIR)
+    // Respect the hidden FTP Directory Listing pref so it can be tested even if the policy delegate might otherwise disallow it
+    Settings* settings = m_frame->settings();
+    if (settings && settings->forceFTPDirectoryListings() && m_response.mimeType() == "application/x-ftp-directory") {
+        continueAfterContentPolicy(PolicyUse);
+        return;
+    }
+#endif
+
 #if USE(CONTENT_FILTERING)
     if (response.url().protocolIs("https") && ContentFilter::isEnabled())
         m_contentFilter = ContentFilter::create(response);
 #endif
 
+    frameLoader()->policyChecker()->checkContentPolicy(m_response, callContinueAfterContentPolicy, this);
 }
 
+void DocumentLoader::callContinueAfterContentPolicy(void* argument, PolicyAction policy)
+{
+    static_cast<DocumentLoader*>(argument)->continueAfterContentPolicy(policy);
+}
+
+void DocumentLoader::continueAfterContentPolicy(PolicyAction policy)
+{
+    ASSERT(m_waitingForContentPolicy);
+    m_waitingForContentPolicy = false;
+    if (isStopping())
+        return;
+
+    KURL url = ""
+    const String& mimeType = m_response.mimeType();
+    
+    switch (policy) {
+    case PolicyUse: {
+        // Prevent remote web archives from loading because they can claim to be from any domain and thus avoid cross-domain security checks (4120255).
+        bool isRemoteWebArchive = (equalIgnoringCase("application/x-webarchive", mimeType)
+#if PLATFORM(GTK)
+            || equalIgnoringCase("message/rfc822", mimeType)
+#endif
+            || equalIgnoringCase("multipart/related", mimeType))
+            && !m_substituteData.isValid() && !SchemeRegistry::shouldTreatURLSchemeAsLocal(url.protocol());
+        if (!frameLoader()->client()->canShowMIMEType(mimeType) || isRemoteWebArchive) {
+            frameLoader()->policyChecker()->cannotShowMIMEType(m_response);
+            // Check reachedTerminalState since the load may have already been canceled inside of _handleUnimplementablePolicyWithErrorCode::.
+            stopLoadingForPolicyChange();
+            return;
+        }
+        break;
+    }
+
+    case PolicyDownload: {
+        // The main CachedResource can be null, e.g. when loading a substitute resource from application cache.
+        if (!m_mainResourceLoader->cachedMainResource()) {
+            mainReceivedError(frameLoader()->client()->cannotShowURLError(m_request));
+            return;
+        }
+        InspectorInstrumentation::continueWithPolicyDownload(m_frame, this, mainResourceLoader()->identifier(), m_response);
+
+        // When starting the request, we didn't know that it would result in download and not navigation. Now we know that main document URL didn't change.
+        // Download may use this knowledge for purposes unrelated to cookies, notably for setting file quarantine data.
+        frameLoader()->setOriginalURLForDownloadRequest(m_request);
+        frameLoader()->client()->convertMainResourceLoadToDownload(this, m_request, m_response);
+
+        // It might have gone missing
+        if (mainResourceLoader())
+            mainResourceLoader()->didFail(interruptedForPolicyChangeError());
+        return;
+    }
+    case PolicyIgnore:
+        InspectorInstrumentation::continueWithPolicyIgnore(m_frame, this, mainResourceLoader()->identifier(), m_response);
+        stopLoadingForPolicyChange();
+        return;
+    
+    default:
+        ASSERT_NOT_REACHED();
+    }
+
+    if (m_response.isHTTP()) {
+        int status = m_response.httpStatusCode();
+        if (status < 200 || status >= 300) {
+            bool hostedByObject = frameLoader()->isHostedByObjectElement();
+
+            frameLoader()->handleFallbackContent();
+            // object elements are no longer rendered after we fallback, so don't
+            // keep trying to process data from their load
+
+            if (hostedByObject)
+                cancelMainResourceLoad(frameLoader()->cancelledError(m_request));
+        }
+    }
+
+    if (!isStopping() && m_substituteData.isValid()) {
+        if (m_substituteData.content()->size())
+            receivedData(m_substituteData.content()->data(), m_substituteData.content()->size());
+        if (isLoadingMainResource())
+            finishedLoading(0);
+    }
+}
+
 void DocumentLoader::commitLoad(const char* data, int length)
 {
     // Both unloading the old page and parsing the new page may execute _javascript_ which destroys the datasource
@@ -506,6 +659,18 @@
     frameLoader->client()->committedLoad(this, data, length);
 }
 
+ResourceError DocumentLoader::interruptedForPolicyChangeError() const
+{
+    return frameLoader()->client()->interruptedForPolicyChangeError(request());
+}
+
+void DocumentLoader::stopLoadingForPolicyChange()
+{
+    ResourceError error = interruptedForPolicyChangeError();
+    error.setIsCancellation(true);
+    cancelMainResourceLoad(error);
+}
+
 void DocumentLoader::commitData(const char* bytes, size_t length)
 {
     if (!m_gotFirstByte) {
@@ -626,7 +791,7 @@
 
 #if USE(CONTENT_FILTERING)
     if (loadWasBlockedBeforeFinishing)
-        cancelMainResourceLoad(ResourceError());
+        cancelMainResourceLoad(frameLoader()->cancelledError(m_request));
 #endif
 }
 
@@ -1098,11 +1263,6 @@
     return !!m_mainResourceLoader || m_loadingEmptyDocument;
 }
 
-bool DocumentLoader::isLoadingMultipartContent() const
-{
-    return m_mainResourceLoader && m_mainResourceLoader->isLoadingMultipartContent();
-}
-
 bool DocumentLoader::isMultipartReplacingLoad() const
 {
     return isLoadingMultipartContent() && frameLoader()->isReplacing();
@@ -1165,6 +1325,13 @@
 
 void DocumentLoader::cancelMainResourceLoad(const ResourceError& error)
 {
+    ASSERT(!error.isNull());
+
+    if (m_waitingForContentPolicy) {
+        frameLoader()->policyChecker()->cancelCheck();
+        ASSERT(m_waitingForContentPolicy);
+        m_waitingForContentPolicy = false;
+    }
     m_mainResourceLoader->cancel(error);
 }
 

Modified: trunk/Source/WebCore/loader/DocumentLoader.h (146215 => 146216)


--- trunk/Source/WebCore/loader/DocumentLoader.h	2013-03-19 17:06:10 UTC (rev 146215)
+++ trunk/Source/WebCore/loader/DocumentLoader.h	2013-03-19 17:08:17 UTC (rev 146216)
@@ -212,7 +212,7 @@
         void getIconDataForIconURL(const String&);
         
         bool isLoadingMainResource() const;
-        bool isLoadingMultipartContent() const;
+        bool isLoadingMultipartContent() const { return m_isLoadingMultipartContent; }
 
         void stopLoadingPlugIns();
         void stopLoadingSubresources();
@@ -285,6 +285,12 @@
         static void callContinueAfterNavigationPolicy(void*, const ResourceRequest&, PassRefPtr<FormState>, bool shouldContinue);
         void continueAfterNavigationPolicy(const ResourceRequest&, bool shouldContinue);
 
+        static void callContinueAfterContentPolicy(void*, PolicyAction);
+        void continueAfterContentPolicy(PolicyAction);
+
+        void stopLoadingForPolicyChange();
+        ResourceError interruptedForPolicyChangeError() const;
+
         void deliverSubstituteResourcesAfterDelay();
         void substituteResourceDeliveryTimerFired(Timer<DocumentLoader>*);
                 
@@ -325,6 +331,7 @@
         bool m_isStopping;
         bool m_gotFirstByte;
         bool m_isClientRedirect;
+        bool m_isLoadingMultipartContent;
         bool m_loadingEmptyDocument;
 
         // FIXME: Document::m_processingLoadEvent and DocumentLoader::m_wasOnloadHandled are roughly the same
@@ -368,6 +375,8 @@
         DocumentLoadTiming m_documentLoadTiming;
 
         double m_timeOfLastDataReceived;
+
+        bool m_waitingForContentPolicy;
     
         RefPtr<IconLoadDecisionCallback> m_iconLoadDecisionCallback;
         RefPtr<IconDataCallback> m_iconDataCallback;

Modified: trunk/Source/WebCore/loader/MainResourceLoader.cpp (146215 => 146216)


--- trunk/Source/WebCore/loader/MainResourceLoader.cpp	2013-03-19 17:06:10 UTC (rev 146215)
+++ trunk/Source/WebCore/loader/MainResourceLoader.cpp	2013-03-19 17:08:17 UTC (rev 146216)
@@ -68,8 +68,6 @@
 MainResourceLoader::MainResourceLoader(DocumentLoader* documentLoader)
     : m_dataLoadTimer(this, &MainResourceLoader::handleSubstituteDataLoadNow)
     , m_documentLoader(documentLoader)
-    , m_loadingMultipartContent(false)
-    , m_waitingForContentPolicy(false)
     , m_identifierForLoadWithoutResourceLoader(0)
 {
 }
@@ -113,14 +111,6 @@
     ResourceError resourceError = error.isNull() ? frameLoader()->cancelledError(request()) : error;
 
     m_dataLoadTimer.stop();
-
-    if (m_waitingForContentPolicy) {
-        frameLoader()->policyChecker()->cancelCheck();
-        ASSERT(m_waitingForContentPolicy);
-        m_waitingForContentPolicy = false;
-        deref(); // balances ref in responseReceived
-    }
-
     if (loader())
         loader()->cancel(resourceError);
 
@@ -146,18 +136,6 @@
     return m_resource ? m_resource->resourceRequest() : m_initialRequest;
 }
 
-ResourceError MainResourceLoader::interruptedForPolicyChangeError() const
-{
-    return frameLoader()->client()->interruptedForPolicyChangeError(request());
-}
-
-void MainResourceLoader::stopLoadingForPolicyChange()
-{
-    ResourceError error = interruptedForPolicyChangeError();
-    error.setIsCancellation(true);
-    cancel(error);
-}
-
 PassRefPtr<ResourceBuffer> MainResourceLoader::resourceData()
 {
     if (m_resource)
@@ -171,177 +149,10 @@
     m_documentLoader->willSendRequest(request, redirectResponse);
 }
 
-void MainResourceLoader::continueAfterContentPolicy(PolicyAction contentPolicy, const ResourceResponse& r)
-{
-    KURL url = ""
-    const String& mimeType = r.mimeType();
-    
-    switch (contentPolicy) {
-    case PolicyUse: {
-        // Prevent remote web archives from loading because they can claim to be from any domain and thus avoid cross-domain security checks (4120255).
-        bool isRemoteWebArchive = (equalIgnoringCase("application/x-webarchive", mimeType)
-#if PLATFORM(GTK)
-                                   || equalIgnoringCase("message/rfc822", mimeType)
-#endif
-                                   || equalIgnoringCase("multipart/related", mimeType))
-            && !m_documentLoader->substituteData().isValid() && !SchemeRegistry::shouldTreatURLSchemeAsLocal(url.protocol());
-        if (!frameLoader()->client()->canShowMIMEType(mimeType) || isRemoteWebArchive) {
-            frameLoader()->policyChecker()->cannotShowMIMEType(r);
-            // Check reachedTerminalState since the load may have already been canceled inside of _handleUnimplementablePolicyWithErrorCode::.
-            stopLoadingForPolicyChange();
-            return;
-        }
-        break;
-    }
-
-    case PolicyDownload: {
-        // m_resource can be null, e.g. when loading a substitute resource from application cache.
-        if (!m_resource) {
-            receivedError(frameLoader()->client()->cannotShowURLError(request()));
-            return;
-        }
-        InspectorInstrumentation::continueWithPolicyDownload(m_documentLoader->frame(), documentLoader(), identifier(), r);
-
-        // When starting the request, we didn't know that it would result in download and not navigation. Now we know that main document URL didn't change.
-        // Download may use this knowledge for purposes unrelated to cookies, notably for setting file quarantine data.
-        ResourceRequest request = this->request();
-        frameLoader()->setOriginalURLForDownloadRequest(request);
-
-        frameLoader()->client()->convertMainResourceLoadToDownload(documentLoader(), request, r);
-
-        // It might have gone missing
-        if (loader())
-            loader()->didFail(interruptedForPolicyChangeError());
-        return;
-    }
-    case PolicyIgnore:
-        InspectorInstrumentation::continueWithPolicyIgnore(m_documentLoader->frame(), documentLoader(), identifier(), r);
-        stopLoadingForPolicyChange();
-        return;
-    
-    default:
-        ASSERT_NOT_REACHED();
-    }
-
-    RefPtr<MainResourceLoader> protect(this);
-
-    if (r.isHTTP()) {
-        int status = r.httpStatusCode();
-        if (status < 200 || status >= 300) {
-            bool hostedByObject = frameLoader()->isHostedByObjectElement();
-
-            frameLoader()->handleFallbackContent();
-            // object elements are no longer rendered after we fallback, so don't
-            // keep trying to process data from their load
-
-            if (hostedByObject)
-                cancel();
-        }
-    }
-
-    if (!m_documentLoader->isStopping() && m_documentLoader->substituteData().isValid()) {
-        if (m_documentLoader->substituteData().content()->size())
-            dataReceived(0, m_documentLoader->substituteData().content()->data(), m_documentLoader->substituteData().content()->size());
-        if (m_documentLoader->isLoadingMainResource())
-            didFinishLoading(0);
-    }
-}
-
-void MainResourceLoader::callContinueAfterContentPolicy(void* argument, PolicyAction policy)
-{
-    static_cast<MainResourceLoader*>(argument)->continueAfterContentPolicy(policy);
-}
-
-void MainResourceLoader::continueAfterContentPolicy(PolicyAction policy)
-{
-    ASSERT(m_waitingForContentPolicy);
-    m_waitingForContentPolicy = false;
-    if (!m_documentLoader->isStopping())
-        continueAfterContentPolicy(policy, m_response);
-    deref(); // balances ref in responseReceived
-}
-
 void MainResourceLoader::responseReceived(CachedResource* resource, const ResourceResponse& r)
 {
     ASSERT_UNUSED(resource, m_resource == resource);
-    bool willLoadFallback = documentLoader()->applicationCacheHost()->maybeLoadFallbackForMainResponse(request(), r);
-
-    // The memory cache doesn't understand the application cache or its caching rules. So if a main resource is served
-    // from the application cache, ensure we don't save the result for future use.
-    bool shouldRemoveResourceFromCache = willLoadFallback;
-#if PLATFORM(CHROMIUM)
-    // chromium's ApplicationCacheHost implementation always returns true for maybeLoadFallbackForMainResponse(). However, all responses loaded
-    // from appcache will have a non-zero appCacheID().
-    if (r.appCacheID())
-        shouldRemoveResourceFromCache = true;
-#endif
-    if (shouldRemoveResourceFromCache)
-        memoryCache()->remove(m_resource.get());
-
-    if (willLoadFallback)
-        return;
-
-    DEFINE_STATIC_LOCAL(AtomicString, xFrameOptionHeader, ("x-frame-options", AtomicString::ConstructFromLiteral));
-    HTTPHeaderMap::const_iterator it = r.httpHeaderFields().find(xFrameOptionHeader);
-    if (it != r.httpHeaderFields().end()) {
-        String content = it->value;
-        if (frameLoader()->shouldInterruptLoadForXFrameOptions(content, r.url(), identifier())) {
-            InspectorInstrumentation::continueAfterXFrameOptionsDenied(m_documentLoader->frame(), documentLoader(), identifier(), r);
-            String message = "Refused to display '" + r.url().elidedString() + "' in a frame because it set 'X-Frame-Options' to '" + content + "'.";
-            m_documentLoader->frame()->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, message, identifier());
-
-            cancel();
-            return;
-        }
-    }
-
-    // There is a bug in CFNetwork where callbacks can be dispatched even when loads are deferred.
-    // See <rdar://problem/6304600> for more details.
-#if !USE(CF)
-    ASSERT(!defersLoading());
-#endif
-
-    if (m_loadingMultipartContent) {
-        m_documentLoader->setupForReplace();
-        m_resource->clear();
-    }
-    
-    if (r.isMultipart()) {
-        FeatureObserver::observe(m_documentLoader->frame()->document(), FeatureObserver::MultipartMainResource);
-        m_loadingMultipartContent = true;
-    }
-        
-    // The additional processing can do anything including possibly removing the last
-    // reference to this object; one example of this is 3266216.
-    RefPtr<MainResourceLoader> protect(this);
-
     m_documentLoader->responseReceived(r);
-
-    m_response = r;
-
-    if (m_identifierForLoadWithoutResourceLoader)
-        frameLoader()->notifier()->dispatchDidReceiveResponse(documentLoader(), identifier(), m_response, 0);
-
-    ASSERT(!m_waitingForContentPolicy);
-    m_waitingForContentPolicy = true;
-    ref(); // balanced by deref in continueAfterContentPolicy and cancel
-
-    // Always show content with valid substitute data.
-    if (m_documentLoader->substituteData().isValid()) {
-        callContinueAfterContentPolicy(this, PolicyUse);
-        return;
-    }
-
-#if ENABLE(FTPDIR)
-    // Respect the hidden FTP Directory Listing pref so it can be tested even if the policy delegate might otherwise disallow it
-    Settings* settings = m_documentLoader->frame()->settings();
-    if (settings && settings->forceFTPDirectoryListings() && m_response.mimeType() == "application/x-ftp-directory") {
-        callContinueAfterContentPolicy(this, PolicyUse);
-        return;
-    }
-#endif
-
-    frameLoader()->policyChecker()->checkContentPolicy(m_response, callContinueAfterContentPolicy, this);
 }
 
 void MainResourceLoader::dataReceived(CachedResource* resource, const char* data, int length)
@@ -350,20 +161,12 @@
     documentLoader()->receivedData(data, length);
 }
 
-void MainResourceLoader::didFinishLoading(double finishTime)
-{
-    // The additional processing can do anything including possibly removing the last
-    // reference to this object.
-    RefPtr<MainResourceLoader> protect(this);
-    documentLoader()->finishedLoading(finishTime);
-}
-
 void MainResourceLoader::notifyFinished(CachedResource* resource)
 {
     ASSERT_UNUSED(resource, m_resource == resource);
     ASSERT(m_resource);
     if (!m_resource->errorOccurred() && !m_resource->wasCanceled()) {
-        didFinishLoading(m_resource->loadFinishTime());
+        documentLoader()->finishedLoading(m_resource->loadFinishTime());
         return;
     }
 

Modified: trunk/Source/WebCore/loader/MainResourceLoader.h (146215 => 146216)


--- trunk/Source/WebCore/loader/MainResourceLoader.h	2013-03-19 17:06:10 UTC (rev 146215)
+++ trunk/Source/WebCore/loader/MainResourceLoader.h	2013-03-19 17:08:17 UTC (rev 146216)
@@ -72,12 +72,10 @@
     void clearIdentifierForLoadWithoutResourceLoader() { m_identifierForLoadWithoutResourceLoader = 0; }
 
     unsigned long identifier() const;
-    bool isLoadingMultipartContent() const { return m_loadingMultipartContent; }
 
     void reportMemoryUsage(MemoryObjectInfo*) const;
 
     void takeIdentifierFromResourceLoader() { m_identifierForLoadWithoutResourceLoader = identifier(); }
-    void stopLoadingForPolicyChange();
     void handleSubstituteDataLoadSoon(const ResourceRequest&);
     void clearResource();
 
@@ -89,17 +87,11 @@
     virtual void dataReceived(CachedResource*, const char* data, int dataLength) OVERRIDE;
     virtual void notifyFinished(CachedResource*) OVERRIDE;
 
-    void didFinishLoading(double finishTime);
     void handleSubstituteDataLoadNow(MainResourceLoaderTimer*);
 
     void startDataLoadTimer();
 
     void receivedError(const ResourceError&);
-    ResourceError interruptedForPolicyChangeError() const;
-
-    static void callContinueAfterContentPolicy(void*, PolicyAction);
-    void continueAfterContentPolicy(PolicyAction);
-    void continueAfterContentPolicy(PolicyAction, const ResourceResponse&);
     
 #if PLATFORM(QT)
     void substituteMIMETypeFromPluginDatabase(const ResourceResponse&);
@@ -115,13 +107,10 @@
     CachedResourceHandle<CachedRawResource> m_resource;
 
     ResourceRequest m_initialRequest;
-    ResourceResponse m_response;
 
     MainResourceLoaderTimer m_dataLoadTimer;
     RefPtr<DocumentLoader> m_documentLoader;
 
-    bool m_loadingMultipartContent;
-    bool m_waitingForContentPolicy;
     unsigned long m_identifierForLoadWithoutResourceLoader;
 };
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to