Remove CachedResource::passesSameOriginPolicyCheck
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Oct 2016 07:52:09 +0000 (07:52 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Oct 2016 07:52:09 +0000 (07:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=163593

Patch by Youenn Fablet <youenn@apple.com> on 2016-10-24
Reviewed by Andreas Kling.

No change of behavior.

Removing no-longer used code.

* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::redirectReceived):
(WebCore::CachedResource::passesAccessControlCheck): Deleted.
(WebCore::CachedResource::passesSameOriginPolicyCheck): Deleted.
(WebCore::CachedResource::responseForSameOriginPolicyChecks): Deleted.
* loader/cache/CachedResource.h:
(WebCore::CachedResource::response):

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

Source/WebCore/ChangeLog
Source/WebCore/loader/cache/CachedResource.cpp
Source/WebCore/loader/cache/CachedResource.h

index 61091c5..2637d07 100644 (file)
@@ -1,5 +1,24 @@
 2016-10-24  Youenn Fablet  <youenn@apple.com>
 
+        Remove CachedResource::passesSameOriginPolicyCheck
+        https://bugs.webkit.org/show_bug.cgi?id=163593
+
+        Reviewed by Andreas Kling.
+
+        No change of behavior.
+
+        Removing no-longer used code.
+
+        * loader/cache/CachedResource.cpp:
+        (WebCore::CachedResource::redirectReceived):
+        (WebCore::CachedResource::passesAccessControlCheck): Deleted.
+        (WebCore::CachedResource::passesSameOriginPolicyCheck): Deleted.
+        (WebCore::CachedResource::responseForSameOriginPolicyChecks): Deleted.
+        * loader/cache/CachedResource.h:
+        (WebCore::CachedResource::response):
+
+2016-10-24  Youenn Fablet  <youenn@apple.com>
+
         Redirections should be upgraded if CSP policy says so
         https://bugs.webkit.org/show_bug.cgi?id=163544
 
index 7b28ecf..09d8738 100644 (file)
@@ -410,19 +410,6 @@ void CachedResource::finish()
         m_status = Cached;
 }
 
-bool CachedResource::passesAccessControlCheck(SecurityOrigin& securityOrigin)
-{
-    String errorDescription;
-    return WebCore::passesAccessControlCheck(response(), resourceRequest().allowCookies() ? AllowStoredCredentials : DoNotAllowStoredCredentials, securityOrigin, errorDescription);
-}
-
-bool CachedResource::passesSameOriginPolicyCheck(SecurityOrigin& securityOrigin)
-{
-    if (securityOrigin.canRequest(responseForSameOriginPolicyChecks().url()))
-        return true;
-    return passesAccessControlCheck(securityOrigin);
-}
-
 void CachedResource::setCrossOrigin()
 {
     ASSERT(m_options.mode != FetchOptions::Mode::SameOrigin);
@@ -484,24 +471,15 @@ std::chrono::microseconds CachedResource::freshnessLifetime(const ResourceRespon
     return computeFreshnessLifetimeForHTTPFamily(response, m_responseTimestamp);
 }
 
-void CachedResource::redirectReceived(ResourceRequest& request, const ResourceResponse& response)
+void CachedResource::redirectReceived(ResourceRequest&, const ResourceResponse& response)
 {
     m_requestedFromNetworkingLayer = true;
     if (response.isNull())
         return;
 
-    // Redirect to data: URL uses the last HTTP response for SOP.
-    if (response.isHTTP() && request.url().protocolIsData())
-        m_redirectResponseForSameOriginPolicyChecks = response;
-
     updateRedirectChainStatus(m_redirectChainCacheStatus, response);
 }
 
-const ResourceResponse& CachedResource::responseForSameOriginPolicyChecks() const
-{
-    return m_redirectResponseForSameOriginPolicyChecks.isNull() ? m_response : m_redirectResponseForSameOriginPolicyChecks;
-}
-
 void CachedResource::setResponse(const ResourceResponse& response)
 {
     ASSERT(m_response.type() == ResourceResponse::Type::Default);
index f04b1d5..e95749e 100644 (file)
@@ -20,8 +20,7 @@
     Boston, MA 02110-1301, USA.
 */
 
-#ifndef CachedResource_h
-#define CachedResource_h
+#pragma once
 
 #include "CachePolicy.h"
 #include "CacheValidation.h"
 
 namespace WebCore {
 
-class MemoryCache;
 class CachedResourceClient;
 class CachedResourceHandleBase;
 class CachedResourceLoader;
 class CachedResourceRequest;
 class InspectorResource;
+class MemoryCache;
 class SecurityOrigin;
 class SharedBuffer;
 class SubresourceLoader;
@@ -60,7 +59,7 @@ class CachedResource {
     WTF_MAKE_NONCOPYABLE(CachedResource); WTF_MAKE_FAST_ALLOCATED;
     friend class MemoryCache;
     friend class InspectorResource;
-    
+
 public:
     enum Type {
         MainResource,
@@ -152,7 +151,7 @@ public:
     unsigned encodedSize() const { return m_encodedSize; }
     unsigned decodedSize() const { return m_decodedSize; }
     unsigned overheadSize() const;
-    
+
     bool isLoaded() const { return !m_loading; } // FIXME. Method name is inaccurate. Loading might not have started yet.
 
     bool isLoading() const { return m_loading; }
@@ -180,20 +179,17 @@ public:
     unsigned accessCount() const { return m_accessCount; }
     void increaseAccessCount() { m_accessCount++; }
 
-    // Computes the status of an object after loading.  
+    // Computes the status of an object after loading.
     // Updates the expire date on the cache entry file
     void finish();
 
-    bool passesAccessControlCheck(SecurityOrigin&);
-    bool passesSameOriginPolicyCheck(SecurityOrigin&);
-
     // Called by the cache if the object has been removed from the cache
     // while still being referenced. This means the object should delete itself
     // if the number of clients observing it ever drops to 0.
     // The resource can be brought back to cache after successful revalidation.
     void setInCache(bool inCache) { m_inCache = inCache; }
     bool inCache() const { return m_inCache; }
-    
+
     void clearLoader();
 
     SharedBuffer* resourceBuffer() const { return m_data.get(); }
@@ -203,8 +199,6 @@ public:
     virtual bool shouldCacheResponse(const ResourceResponse&) { return true; }
     void setResponse(const ResourceResponse&);
     const ResourceResponse& response() const { return m_response; }
-    // This is the same as response() except after HTTP redirect to data: URL.
-    const ResourceResponse& responseForSameOriginPolicyChecks() const;
 
     void setCrossOrigin();
     bool isCrossOrigin() const;
@@ -295,7 +289,6 @@ protected:
     ResourceLoaderOptions m_options;
     ResourceResponse m_response;
     ResourceResponse::Tainting m_responseTainting { ResourceResponse::Tainting::Basic };
-    ResourceResponse m_redirectResponseForSameOriginPolicyChecks;
     RefPtr<SharedBuffer> m_data;
     DeferrableOneShotTimer m_decodedDataDeletionTimer;
 
@@ -352,7 +345,7 @@ private:
 #endif
 
     CachedResourceLoader* m_owningCachedResourceLoader { nullptr }; // only non-null for resources that are not in the cache
-    
+
     // If this field is non-null we are using the resource as a proxy for checking whether an existing resource is still up to date
     // using HTTP If-Modified-Since/If-None-Match headers. If the response is 304 all clients of this resource are moved
     // to to be clients of m_resourceToRevalidate and the resource is deleted. If not, the field is zeroed and this
@@ -395,5 +388,3 @@ private:
 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToClassName) \
     static bool isType(const WebCore::CachedResource& resource) { return resource.type() == WebCore::CachedResourceType; } \
 SPECIALIZE_TYPE_TRAITS_END()
-
-#endif // CachedResource_h