Title: [101883] trunk
Revision
101883
Author
[email protected]
Date
2011-12-02 17:38:26 -0800 (Fri, 02 Dec 2011)

Log Message

Source/WebCore: Fix mixed content handling for video in Chromium by having
CachedResourceLoader & SubresourceLoader use the
ResourceRequest::TargetType when determining if a RawResource can
be requested.
https://bugs.webkit.org/show_bug.cgi?id=72178

Patch by Aaron Colwell <[email protected]> on 2011-12-02
Reviewed by Adam Barth.

Tests: http/tests/security/mixedContent/insecure-video-in-iframe.html
       http/tests/security/mixedContent/insecure-video-in-main-frame.html
       http/tests/security/mixedContent/redirect-http-to-https-video-in-main-frame.html
       http/tests/security/mixedContent/redirect-https-to-http-video-in-main-frame.html

* loader/SubresourceLoader.cpp:
(WebCore::SubresourceLoader::willSendRequest):
* loader/cache/CachedRawResource.cpp:
(WebCore::CachedRawResource::CachedRawResource):
* loader/cache/CachedRawResource.h:
* loader/cache/CachedResource.cpp:
(WebCore::defaultPriorityForResourceType):
(WebCore::cachedResourceTypeToTargetType):
(WebCore::CachedResource::targetTypeToCachedResourceType):
* loader/cache/CachedResource.h:
* loader/cache/CachedResourceLoader.cpp:
(WebCore::createResource):
(WebCore::CachedResourceLoader::checkInsecureContent):
(WebCore::CachedResourceLoader::canRequest):
(WebCore::CachedResourceLoader::requestResource):

LayoutTests: Adding mixed content tests for video tag.
https://bugs.webkit.org/show_bug.cgi?id=72178

Patch by Aaron Colwell <[email protected]> on 2011-12-02
Reviewed by Adam Barth.

* http/tests/security/mixedContent/insecure-video-in-iframe-expected.txt: Added.
* http/tests/security/mixedContent/insecure-video-in-iframe.html: Added.
* http/tests/security/mixedContent/insecure-video-in-main-frame-expected.txt: Added.
* http/tests/security/mixedContent/insecure-video-in-main-frame.html: Added.
* http/tests/security/mixedContent/redirect-http-to-https-video-in-main-frame-expected.txt: Added.
* http/tests/security/mixedContent/redirect-http-to-https-video-in-main-frame.html: Added.
* http/tests/security/mixedContent/redirect-https-to-http-video-in-main-frame-expected.txt: Added.
* http/tests/security/mixedContent/redirect-https-to-http-video-in-main-frame.html: Added.
* http/tests/security/mixedContent/resources/frame-with-insecure-video.html: Added.
* http/tests/security/mixedContent/resources/frame-with-redirect-http-to-https-video.html: Added.
* http/tests/security/mixedContent/resources/frame-with-redirect-https-to-http-video.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (101882 => 101883)


--- trunk/LayoutTests/ChangeLog	2011-12-03 01:35:56 UTC (rev 101882)
+++ trunk/LayoutTests/ChangeLog	2011-12-03 01:38:26 UTC (rev 101883)
@@ -1,3 +1,22 @@
+2011-12-02  Aaron Colwell  <[email protected]>
+
+        Adding mixed content tests for video tag.
+        https://bugs.webkit.org/show_bug.cgi?id=72178
+
+        Reviewed by Adam Barth.
+
+        * http/tests/security/mixedContent/insecure-video-in-iframe-expected.txt: Added.
+        * http/tests/security/mixedContent/insecure-video-in-iframe.html: Added.
+        * http/tests/security/mixedContent/insecure-video-in-main-frame-expected.txt: Added.
+        * http/tests/security/mixedContent/insecure-video-in-main-frame.html: Added.
+        * http/tests/security/mixedContent/redirect-http-to-https-video-in-main-frame-expected.txt: Added.
+        * http/tests/security/mixedContent/redirect-http-to-https-video-in-main-frame.html: Added.
+        * http/tests/security/mixedContent/redirect-https-to-http-video-in-main-frame-expected.txt: Added.
+        * http/tests/security/mixedContent/redirect-https-to-http-video-in-main-frame.html: Added.
+        * http/tests/security/mixedContent/resources/frame-with-insecure-video.html: Added.
+        * http/tests/security/mixedContent/resources/frame-with-redirect-http-to-https-video.html: Added.
+        * http/tests/security/mixedContent/resources/frame-with-redirect-https-to-http-video.html: Added.
+
 2011-12-02  Vincent Scheib  <[email protected]>
 
         [Chromium] Rebaselining svg/custom/svg-fonts-word-spacing.html

Added: trunk/LayoutTests/http/tests/security/mixedContent/insecure-video-in-iframe-expected.txt (0 => 101883)


--- trunk/LayoutTests/http/tests/security/mixedContent/insecure-video-in-iframe-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/mixedContent/insecure-video-in-iframe-expected.txt	2011-12-03 01:38:26 UTC (rev 101883)
@@ -0,0 +1,11 @@
+frame "<!--framePath //<!--frame0-->-->" - didStartProvisionalLoadForFrame
+main frame - didFinishDocumentLoadForFrame
+frame "<!--framePath //<!--frame0-->-->" - didCommitLoadForFrame
+frame "<!--framePath //<!--frame0-->-->" - didFinishDocumentLoadForFrame
+frame "<!--framePath //<!--frame0-->-->" - didHandleOnloadEventsForFrame
+main frame - didHandleOnloadEventsForFrame
+frame "<!--framePath //<!--frame0-->-->" - didFinishLoadForFrame
+main frame - didFinishLoadForFrame
+This test loads a secure iframe that loads an insecure video. We should *not* get a mixed content callback because the main frame is HTTP and the video doesn't contaminate the child iframe's security origin with mixed content.
+
+

Added: trunk/LayoutTests/http/tests/security/mixedContent/insecure-video-in-iframe.html (0 => 101883)


--- trunk/LayoutTests/http/tests/security/mixedContent/insecure-video-in-iframe.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/mixedContent/insecure-video-in-iframe.html	2011-12-03 01:38:26 UTC (rev 101883)
@@ -0,0 +1,14 @@
+<html>
+    <body>
+        <script>
+            if (window.layoutTestController) {
+                layoutTestController.dumpAsText();
+                layoutTestController.dumpFrameLoadCallbacks();
+            }
+        </script>
+        <p>This test loads a secure iframe that loads an insecure video.  We should
+*not* get a mixed content callback because the main frame is HTTP and the video
+doesn't contaminate the child iframe's security origin with mixed content.</p>
+        <iframe src=""
+    </body>
+</html>

Added: trunk/LayoutTests/http/tests/security/mixedContent/insecure-video-in-main-frame-expected.txt (0 => 101883)


--- trunk/LayoutTests/http/tests/security/mixedContent/insecure-video-in-main-frame-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/mixedContent/insecure-video-in-main-frame-expected.txt	2011-12-03 01:38:26 UTC (rev 101883)
@@ -0,0 +1,12 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishLoadForFrame
+main frame - didCommitLoadForFrame
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishLoadForFrame
+CONSOLE MESSAGE: line 1: The page at https://127.0.0.1:8443/security/mixedContent/resources/frame-with-insecure-video.html displayed insecure content from http://127.0.0.1:8080/resources/test.ogv.
+
+didDisplayInsecureContent
+This test opens a window that loads an insecure video. We should trigger a mixed content callback because the main frame in the window is HTTPS but is displaying insecure content.

Added: trunk/LayoutTests/http/tests/security/mixedContent/insecure-video-in-main-frame.html (0 => 101883)


--- trunk/LayoutTests/http/tests/security/mixedContent/insecure-video-in-main-frame.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/mixedContent/insecure-video-in-main-frame.html	2011-12-03 01:38:26 UTC (rev 101883)
@@ -0,0 +1,25 @@
+<html>
+    <body>
+        <script>
+            if (window.layoutTestController) {
+                layoutTestController.waitUntilDone();
+                layoutTestController.dumpAsText();
+                layoutTestController.dumpFrameLoadCallbacks();
+                layoutTestController.setCanOpenWindows();
+                layoutTestController.setCloseRemainingWindowsWhenComplete(true);
+            }
+
+            window.addEventListener("message", function (e) {
+                if (window.layoutTestController)
+                    layoutTestController.notifyDone();
+            }, false);
+
+        </script>
+        <p>This test opens a window that loads an insecure video.  We should trigger a
+mixed content callback because the main frame in the window is HTTPS but is
+displaying insecure content.</p>
+        <script>
+            window.open("https://127.0.0.1:8443/security/mixedContent/resources/frame-with-insecure-video.html");
+        </script>
+    </body>
+</html>

Added: trunk/LayoutTests/http/tests/security/mixedContent/redirect-http-to-https-video-in-main-frame-expected.txt (0 => 101883)


--- trunk/LayoutTests/http/tests/security/mixedContent/redirect-http-to-https-video-in-main-frame-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/mixedContent/redirect-http-to-https-video-in-main-frame-expected.txt	2011-12-03 01:38:26 UTC (rev 101883)
@@ -0,0 +1,12 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishLoadForFrame
+main frame - didCommitLoadForFrame
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishLoadForFrame
+CONSOLE MESSAGE: line 1: The page at https://127.0.0.1:8443/security/mixedContent/resources/frame-with-redirect-http-to-https-video.html displayed insecure content from http://127.0.0.1:8080/security/resources/redir.php?url=""
+
+didDisplayInsecureContent
+This test opens a window that loads an insecure video(via a tricky redirect). We should trigger a mixed content callback because the main frame in the window is HTTPS but is displaying insecure content.

Added: trunk/LayoutTests/http/tests/security/mixedContent/redirect-http-to-https-video-in-main-frame.html (0 => 101883)


--- trunk/LayoutTests/http/tests/security/mixedContent/redirect-http-to-https-video-in-main-frame.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/mixedContent/redirect-http-to-https-video-in-main-frame.html	2011-12-03 01:38:26 UTC (rev 101883)
@@ -0,0 +1,25 @@
+<html>
+    <body>
+        <script>
+            if (window.layoutTestController) {
+                layoutTestController.waitUntilDone();
+                layoutTestController.dumpAsText();
+                layoutTestController.dumpFrameLoadCallbacks();
+                layoutTestController.setCanOpenWindows();
+                layoutTestController.setCloseRemainingWindowsWhenComplete(true);
+            }
+
+            window.addEventListener("message", function (e) {
+                if (window.layoutTestController)
+                    layoutTestController.notifyDone();
+            }, false);
+
+        </script>
+        <p>This test opens a window that loads an insecure video(via a tricky 
+redirect).  We should trigger a mixed content callback because the main frame in the window is HTTPS but is
+displaying insecure content.</p>
+        <script>
+            window.open("https://127.0.0.1:8443/security/mixedContent/resources/frame-with-redirect-http-to-https-video.html");
+        </script>
+    </body>
+</html>

Added: trunk/LayoutTests/http/tests/security/mixedContent/redirect-https-to-http-video-in-main-frame-expected.txt (0 => 101883)


--- trunk/LayoutTests/http/tests/security/mixedContent/redirect-https-to-http-video-in-main-frame-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/mixedContent/redirect-https-to-http-video-in-main-frame-expected.txt	2011-12-03 01:38:26 UTC (rev 101883)
@@ -0,0 +1,12 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishLoadForFrame
+main frame - didCommitLoadForFrame
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishLoadForFrame
+CONSOLE MESSAGE: line 1: The page at https://127.0.0.1:8443/security/mixedContent/resources/frame-with-redirect-https-to-http-video.html displayed insecure content from http://127.0.0.1:8080/resources/test.ogv.
+
+didDisplayInsecureContent
+This test opens a window that loads an insecure video(via a tricky redirect). We should trigger a mixed content callback because the main frame in the window is HTTPS but is displaying insecure content.

Added: trunk/LayoutTests/http/tests/security/mixedContent/redirect-https-to-http-video-in-main-frame.html (0 => 101883)


--- trunk/LayoutTests/http/tests/security/mixedContent/redirect-https-to-http-video-in-main-frame.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/mixedContent/redirect-https-to-http-video-in-main-frame.html	2011-12-03 01:38:26 UTC (rev 101883)
@@ -0,0 +1,25 @@
+<html>
+    <body>
+        <script>
+            if (window.layoutTestController) {
+                layoutTestController.waitUntilDone();
+                layoutTestController.dumpAsText();
+                layoutTestController.dumpFrameLoadCallbacks();
+                layoutTestController.setCanOpenWindows();
+                layoutTestController.setCloseRemainingWindowsWhenComplete(true);
+            }
+
+            window.addEventListener("message", function (e) {
+                if (window.layoutTestController)
+                    layoutTestController.notifyDone();
+            }, false);
+
+        </script>
+        <p>This test opens a window that loads an insecure video(via a tricky 
+redirect).  We should trigger a mixed content callback because the main frame in the window is HTTPS but is
+displaying insecure content.</p>
+        <script>
+            window.open("https://127.0.0.1:8443/security/mixedContent/resources/frame-with-redirect-https-to-http-video.html");
+        </script>
+    </body>
+</html>

Added: trunk/LayoutTests/http/tests/security/mixedContent/resources/frame-with-insecure-video.html (0 => 101883)


--- trunk/LayoutTests/http/tests/security/mixedContent/resources/frame-with-insecure-video.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/mixedContent/resources/frame-with-insecure-video.html	2011-12-03 01:38:26 UTC (rev 101883)
@@ -0,0 +1,23 @@
+<html>
+    <head>
+        <script src=""
+        <script>
+            function frameLoaded() {
+                video = document.getElementById('v');
+
+                video.addEventListener('loadedmetadata', function(e) {
+                    if (window.opener)
+                        window.opener.postMessage('done', '*');
+                 }, true);
+
+                var mediaFile = findMediaFile('video', 'resources/test');
+                video.src = '' + mediaFile;
+                video.play();
+            }
+        </script>
+    </head>
+    <body _onload_="frameLoaded()">
+        <video id="v"> </video>
+        <p>Test that at least one progress event is fired after starting to load the video.</p>
+    </body>
+</html>

Added: trunk/LayoutTests/http/tests/security/mixedContent/resources/frame-with-redirect-http-to-https-video.html (0 => 101883)


--- trunk/LayoutTests/http/tests/security/mixedContent/resources/frame-with-redirect-http-to-https-video.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/mixedContent/resources/frame-with-redirect-http-to-https-video.html	2011-12-03 01:38:26 UTC (rev 101883)
@@ -0,0 +1,23 @@
+<html>
+    <head>
+        <script src=""
+        <script>
+            function frameLoaded() {
+                video = document.getElementById('v');
+
+                video.addEventListener('loadedmetadata', function(e) {
+                    if (window.opener)
+                        window.opener.postMessage('done', '*');
+                 }, true);
+
+                var mediaFile = findMediaFile('video', 'resources/test');
+                video.src = '' + mediaFile;
+                video.play();
+            }
+        </script>
+    </head>
+    <body _onload_="frameLoaded()">
+        <video id="v"> </video>
+        <p>Test that at least one progress event is fired after starting to load the video.</p>
+    </body>
+</html>

Added: trunk/LayoutTests/http/tests/security/mixedContent/resources/frame-with-redirect-https-to-http-video.html (0 => 101883)


--- trunk/LayoutTests/http/tests/security/mixedContent/resources/frame-with-redirect-https-to-http-video.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/mixedContent/resources/frame-with-redirect-https-to-http-video.html	2011-12-03 01:38:26 UTC (rev 101883)
@@ -0,0 +1,23 @@
+<html>
+    <head>
+        <script src=""
+        <script>
+            function frameLoaded() {
+                video = document.getElementById('v');
+
+                video.addEventListener('loadedmetadata', function(e) {
+                    if (window.opener)
+                        window.opener.postMessage('done', '*');
+                 }, true);
+
+                var mediaFile = findMediaFile('video', 'resources/test');
+                video.src = '' + mediaFile;
+                video.play();
+            }
+        </script>
+    </head>
+    <body _onload_="frameLoaded()">
+        <video id="v"> </video>
+        <p>Test that at least one progress event is fired after starting to load the video.</p>
+    </body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (101882 => 101883)


--- trunk/Source/WebCore/ChangeLog	2011-12-03 01:35:56 UTC (rev 101882)
+++ trunk/Source/WebCore/ChangeLog	2011-12-03 01:38:26 UTC (rev 101883)
@@ -1,3 +1,34 @@
+2011-12-02  Aaron Colwell  <[email protected]>
+
+        Fix mixed content handling for video in Chromium by having
+        CachedResourceLoader & SubresourceLoader use the 
+        ResourceRequest::TargetType when determining if a RawResource can
+        be requested.
+        https://bugs.webkit.org/show_bug.cgi?id=72178
+
+        Reviewed by Adam Barth.
+
+        Tests: http/tests/security/mixedContent/insecure-video-in-iframe.html
+               http/tests/security/mixedContent/insecure-video-in-main-frame.html
+               http/tests/security/mixedContent/redirect-http-to-https-video-in-main-frame.html
+               http/tests/security/mixedContent/redirect-https-to-http-video-in-main-frame.html
+
+        * loader/SubresourceLoader.cpp:
+        (WebCore::SubresourceLoader::willSendRequest):
+        * loader/cache/CachedRawResource.cpp:
+        (WebCore::CachedRawResource::CachedRawResource):
+        * loader/cache/CachedRawResource.h:
+        * loader/cache/CachedResource.cpp:
+        (WebCore::defaultPriorityForResourceType):
+        (WebCore::cachedResourceTypeToTargetType):
+        (WebCore::CachedResource::targetTypeToCachedResourceType):
+        * loader/cache/CachedResource.h:
+        * loader/cache/CachedResourceLoader.cpp:
+        (WebCore::createResource):
+        (WebCore::CachedResourceLoader::checkInsecureContent):
+        (WebCore::CachedResourceLoader::canRequest):
+        (WebCore::CachedResourceLoader::requestResource):
+
 2011-12-02  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r101731.

Modified: trunk/Source/WebCore/loader/SubresourceLoader.cpp (101882 => 101883)


--- trunk/Source/WebCore/loader/SubresourceLoader.cpp	2011-12-03 01:35:56 UTC (rev 101882)
+++ trunk/Source/WebCore/loader/SubresourceLoader.cpp	2011-12-03 01:38:26 UTC (rev 101883)
@@ -127,10 +127,16 @@
 {
     // Store the previous URL because the call to ResourceLoader::willSendRequest will modify it.
     KURL previousURL = request().url();
-    
+    CachedResource::Type requestTypeForCanRequest = m_resource->type();
+
+#if PLATFORM(CHROMIUM)
+    if (requestTypeForCanRequest == CachedResource::RawResource)
+        requestTypeForCanRequest = CachedResource::targetTypeToCachedResourceType(request().targetType());
+#endif
+
     ResourceLoader::willSendRequest(newRequest, redirectResponse);
     if (!previousURL.isNull() && !newRequest.isNull() && previousURL != newRequest.url()) {
-        if (!m_document->cachedResourceLoader()->canRequest(m_resource->type(), newRequest.url())) {
+        if (!m_document->cachedResourceLoader()->canRequest(requestTypeForCanRequest, newRequest.url())) {
             cancel();
             return;
         }

Modified: trunk/Source/WebCore/loader/cache/CachedRawResource.cpp (101882 => 101883)


--- trunk/Source/WebCore/loader/cache/CachedRawResource.cpp	2011-12-03 01:35:56 UTC (rev 101882)
+++ trunk/Source/WebCore/loader/cache/CachedRawResource.cpp	2011-12-03 01:38:26 UTC (rev 101883)
@@ -41,6 +41,12 @@
 {
 }
 
+CachedRawResource::CachedRawResource(ResourceRequest& resourceRequest, Type type)
+    : CachedResource(resourceRequest, type)
+    , m_dataLength(0)
+{
+}
+
 void CachedRawResource::data(PassRefPtr<SharedBuffer> data, bool allDataReceived)
 {
     CachedResourceHandle<CachedRawResource> protect(this);

Modified: trunk/Source/WebCore/loader/cache/CachedRawResource.h (101882 => 101883)


--- trunk/Source/WebCore/loader/cache/CachedRawResource.h	2011-12-03 01:35:56 UTC (rev 101882)
+++ trunk/Source/WebCore/loader/cache/CachedRawResource.h	2011-12-03 01:38:26 UTC (rev 101883)
@@ -30,7 +30,8 @@
 
 class CachedRawResource : public CachedResource {
 public:
-    CachedRawResource(ResourceRequest&);
+    explicit CachedRawResource(ResourceRequest&);
+    CachedRawResource(ResourceRequest&, Type);
 
     // FIXME: AssociatedURLLoader shouldn't be a DocumentThreadableLoader and therefore shouldn't
     // use CachedRawResource. However, it is, and it needs to be able to defer loading.

Modified: trunk/Source/WebCore/loader/cache/CachedResource.cpp (101882 => 101883)


--- trunk/Source/WebCore/loader/cache/CachedResource.cpp	2011-12-03 01:35:56 UTC (rev 101882)
+++ trunk/Source/WebCore/loader/cache/CachedResource.cpp	2011-12-03 01:38:26 UTC (rev 101883)
@@ -73,6 +73,10 @@
         case CachedResource::LinkSubresource:
             return ResourceLoadPriorityVeryLow;
 #endif
+#if ENABLE(VIDEO)
+        case CachedResource::MediaResource:
+            return ResourceLoadPriorityMedium;
+#endif
 #if ENABLE(VIDEO_TRACK)
         case CachedResource::TextTrackResource:
             return ResourceLoadPriorityLow;
@@ -111,6 +115,10 @@
     case CachedResource::LinkSubresource:
         return ResourceRequest::TargetIsSubresource;
 #endif
+#if ENABLE(VIDEO)
+    case CachedResource::MediaResource:
+        return ResourceRequest::TargetIsMedia;
+#endif
 #if ENABLE(VIDEO_TRACK)
     case CachedResource::TextTrackResource:
         return ResourceRequest::TargetIsTextTrack;
@@ -119,8 +127,51 @@
     ASSERT_NOT_REACHED();
     return ResourceRequest::TargetIsSubresource;
 }
+
+CachedResource::Type CachedResource::targetTypeToCachedResourceType(ResourceRequest::TargetType type)
+{
+    switch (type) {
+    case ResourceRequest::TargetIsStyleSheet:
+        return CachedResource::CSSStyleSheet;
+    case ResourceRequest::TargetIsScript:
+        return CachedResource::Script;
+    case ResourceRequest::TargetIsFontResource:
+        return CachedResource::FontResource;
+    case ResourceRequest::TargetIsImage:
+    case ResourceRequest::TargetIsFavicon:
+        return CachedResource::ImageResource;
+    case ResourceRequest::TargetIsSubresource:
+        return CachedResource::RawResource;
+    case ResourceRequest::TargetIsWorker:
+    case ResourceRequest::TargetIsSharedWorker:
+        return CachedResource::Script;
+    case ResourceRequest::TargetIsObject:
+    case ResourceRequest::TargetIsMainFrame:
+    case ResourceRequest::TargetIsSubframe:
+    case ResourceRequest::TargetIsXHR:
+    case ResourceRequest::TargetIsUnspecified:
+        return CachedResource::RawResource;
+#if ENABLE(LINK_PREFETCH)
+    case ResourceRequest::TargetIsPrefetch:
+        return CachedResource::LinkPrefetch;
+    case ResourceRequest::TargetIsPrerender:
+        return CachedResource::LinkPrerender;
 #endif
+#if ENABLE(VIDEO)
+    case ResourceRequest::TargetIsMedia:
+        return CachedResource::MediaResource;
+#endif
+#if ENABLE(VIDEO_TRACK)
+    case ResourceRequest::TargetIsTextTrack:
+        return CachedResource::TextTrackResource;
+#endif
+    }
+    ASSERT_NOT_REACHED();
+    return CachedResource::RawResource;
+}
 
+#endif
+
 DEFINE_DEBUG_ONLY_GLOBAL(RefCountedLeakCounter, cachedResourceLeakCounter, ("CachedResource"));
 
 CachedResource::CachedResource(const ResourceRequest& request, Type type)

Modified: trunk/Source/WebCore/loader/cache/CachedResource.h (101882 => 101883)


--- trunk/Source/WebCore/loader/cache/CachedResource.h	2011-12-03 01:35:56 UTC (rev 101882)
+++ trunk/Source/WebCore/loader/cache/CachedResource.h	2011-12-03 01:38:26 UTC (rev 101883)
@@ -79,6 +79,9 @@
 #if ENABLE(CSS_SHADERS)
         , ShaderResource
 #endif
+#if ENABLE(VIDEO)
+        , MediaResource
+#endif
     };
 
     enum Status {
@@ -238,6 +241,8 @@
     virtual void didSendData(unsigned long long /* bytesSent */, unsigned long long /* totalBytesToBeSent */) { }
 #if PLATFORM(CHROMIUM)
     virtual void didDownloadData(int) { }
+
+    static Type targetTypeToCachedResourceType(ResourceRequest::TargetType);
 #endif
 
     void setLoadFinishTime(double finishTime) { m_loadFinishTime = finishTime; }

Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (101882 => 101883)


--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2011-12-03 01:35:56 UTC (rev 101882)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2011-12-03 01:38:26 UTC (rev 101883)
@@ -88,6 +88,10 @@
     case CachedResource::LinkSubresource:
         return new CachedResource(request, CachedResource::LinkSubresource);
 #endif
+#if ENABLE(VIDEO)
+    case CachedResource::MediaResource:
+        return new CachedRawResource(request, CachedResource::MediaResource);
+#endif
 #if ENABLE(VIDEO_TRACK)
     case CachedResource::TextTrackResource:
         return new CachedTextTrack(request);
@@ -253,6 +257,9 @@
             if (!f->loader()->checkIfRunInsecureContent(m_document->securityOrigin(), url))
                 return false;
         break;
+#if ENABLE(VIDEO)
+    case CachedResource::MediaResource:
+#endif
 #if ENABLE(VIDEO_TRACK)
     case CachedResource::TextTrackResource:
 #endif
@@ -304,6 +311,9 @@
     case CachedResource::LinkPrerender:
     case CachedResource::LinkSubresource:
 #endif
+#if ENABLE(VIDEO)
+    case CachedResource::MediaResource:
+#endif
 #if ENABLE(VIDEO_TRACK)
     case CachedResource::TextTrackResource:
 #endif
@@ -369,8 +379,11 @@
     case CachedResource::LinkSubresource:
 #endif
         break;
+#if ENABLE(VIDEO)
+    case CachedResource::MediaResource:
 #if ENABLE(VIDEO_TRACK)
     case CachedResource::TextTrackResource:
+#endif
         // Cues aren't called out in the CPS spec yet, but they only work with a media element
         // so use the media policy.
         if (!m_document->contentSecurityPolicy()->allowMediaFromSource(url))
@@ -402,7 +415,14 @@
     if (!url.isValid())
         return 0;
 
-    if (!canRequest(type, url, forPreload))
+    CachedResource::Type requestTypeForCanRequest = type;
+
+#if PLATFORM(CHROMIUM)
+    if (requestTypeForCanRequest == CachedResource::RawResource)
+        requestTypeForCanRequest = CachedResource::targetTypeToCachedResourceType(request.targetType());
+#endif
+
+    if (!canRequest(requestTypeForCanRequest, url, forPreload))
         return 0;
 
     if (memoryCache()->disabled()) {
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to