Move allowCredentials from ThreadableLoaderOptions down
authorjaphet@chromium.org <japhet@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Aug 2011 23:31:55 +0000 (23:31 +0000)
committerjaphet@chromium.org <japhet@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Aug 2011 23:31:55 +0000 (23:31 +0000)
to ResourceLoaderOptions. This allows us to remove
getShouldUseCredentialStorage() from SubresourceLoaderClient
and check allowCredentials in ResourceLoader.
https://bugs.webkit.org/show_bug.cgi?id=65330

Reviewed by Alexey Proskuryakov.

No new tests, refractor only.

* loader/DocumentThreadableLoader.cpp:
* loader/DocumentThreadableLoader.h:
* loader/MainResourceLoader.cpp:
* loader/NetscapePlugInStreamLoader.cpp:
* loader/ResourceLoadScheduler.h:
* loader/ResourceLoader.cpp:
(WebCore::ResourceLoader::shouldUseCredentialStorage): Check
    m_options.allowCredentials instead of calling a client.
* loader/ResourceLoaderOptions.h:
* loader/SubresourceLoader.cpp:
* loader/SubresourceLoader.h:
* loader/SubresourceLoaderClient.h:
* loader/ThreadableLoader.h:
* loader/cache/CachedResourceRequest.cpp:

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

13 files changed:
Source/WebCore/ChangeLog
Source/WebCore/loader/DocumentThreadableLoader.cpp
Source/WebCore/loader/DocumentThreadableLoader.h
Source/WebCore/loader/MainResourceLoader.cpp
Source/WebCore/loader/NetscapePlugInStreamLoader.cpp
Source/WebCore/loader/ResourceLoadScheduler.h
Source/WebCore/loader/ResourceLoader.cpp
Source/WebCore/loader/ResourceLoaderOptions.h
Source/WebCore/loader/SubresourceLoader.cpp
Source/WebCore/loader/SubresourceLoader.h
Source/WebCore/loader/SubresourceLoaderClient.h
Source/WebCore/loader/ThreadableLoader.h
Source/WebCore/loader/cache/CachedResourceRequest.cpp

index 420067e..a038e1e 100644 (file)
@@ -1,3 +1,30 @@
+2011-08-26  Nate Chapin  <japhet@chromium.org>
+
+        Move allowCredentials from ThreadableLoaderOptions down
+        to ResourceLoaderOptions. This allows us to remove
+        getShouldUseCredentialStorage() from SubresourceLoaderClient
+        and check allowCredentials in ResourceLoader.
+        https://bugs.webkit.org/show_bug.cgi?id=65330
+
+        Reviewed by Alexey Proskuryakov.
+
+        No new tests, refractor only.
+
+        * loader/DocumentThreadableLoader.cpp:
+        * loader/DocumentThreadableLoader.h:
+        * loader/MainResourceLoader.cpp:
+        * loader/NetscapePlugInStreamLoader.cpp:
+        * loader/ResourceLoadScheduler.h:
+        * loader/ResourceLoader.cpp:
+        (WebCore::ResourceLoader::shouldUseCredentialStorage): Check
+            m_options.allowCredentials instead of calling a client.
+        * loader/ResourceLoaderOptions.h:
+        * loader/SubresourceLoader.cpp:
+        * loader/SubresourceLoader.h:
+        * loader/SubresourceLoaderClient.h:
+        * loader/ThreadableLoader.h:
+        * loader/cache/CachedResourceRequest.cpp:
+
 2011-08-26  Ojan Vafai  <ojan@chromium.org>
 
         change the default preferred width of the flex() function to 0px per the new spec
index 092b99b..73ef31b 100644 (file)
@@ -288,18 +288,6 @@ void DocumentThreadableLoader::didFail(SubresourceLoader* loader, const Resource
     m_client->didFail(error);
 }
 
-bool DocumentThreadableLoader::getShouldUseCredentialStorage(SubresourceLoader* loader, bool& shouldUseCredentialStorage)
-{
-    ASSERT_UNUSED(loader, loader == m_loader || !m_loader);
-
-    if (m_options.allowCredentials == DoNotAllowStoredCredentials) {
-        shouldUseCredentialStorage = false;
-        return true;
-    }
-
-    return false; // Only FrameLoaderClient can ultimately permit credential use.
-}
-
 void DocumentThreadableLoader::didReceiveAuthenticationChallenge(SubresourceLoader* loader, const AuthenticationChallenge& challenge)
 {
     ASSERT(loader == m_loader);
index 24be48a..bc2578c 100644 (file)
@@ -82,7 +82,6 @@ namespace WebCore {
         virtual void didFinishLoading(SubresourceLoader*, double);
         virtual void didFail(SubresourceLoader*, const ResourceError&);
 
-        virtual bool getShouldUseCredentialStorage(SubresourceLoader*, bool& shouldUseCredentialStorage);
         virtual void didReceiveAuthenticationChallenge(SubresourceLoader*, const AuthenticationChallenge&);
 
         void didReceiveResponse(unsigned long identifier, const ResourceResponse&);
index 17a6bc5..87c5bae 100644 (file)
@@ -60,7 +60,7 @@
 namespace WebCore {
 
 MainResourceLoader::MainResourceLoader(Frame* frame)
-    : ResourceLoader(frame, ResourceLoaderOptions(SendCallbacks, SniffContent, BufferData))
+    : ResourceLoader(frame, ResourceLoaderOptions(SendCallbacks, SniffContent, BufferData, AllowStoredCredentials))
     , m_dataLoadTimer(this, &MainResourceLoader::handleDataLoadNow)
     , m_loadingMultipartContent(false)
     , m_waitingForContentPolicy(false)
index 9541546..a1672e9 100644 (file)
@@ -36,7 +36,7 @@
 namespace WebCore {
 
 NetscapePlugInStreamLoader::NetscapePlugInStreamLoader(Frame* frame, NetscapePlugInStreamLoaderClient* client)
-    : ResourceLoader(frame, ResourceLoaderOptions(SendCallbacks, SniffContent, DoNotBufferData))
+    : ResourceLoader(frame, ResourceLoaderOptions(SendCallbacks, SniffContent, DoNotBufferData, AllowStoredCredentials))
     , m_client(client)
 {
 }
index d388b96..371c7c8 100644 (file)
@@ -51,7 +51,7 @@ class ResourceLoadScheduler {
 public:
     friend ResourceLoadScheduler* resourceLoadScheduler();
 
-    PassRefPtr<SubresourceLoader> scheduleSubresourceLoad(Frame*, SubresourceLoaderClient*, const ResourceRequest&, ResourceLoadPriority = ResourceLoadPriorityLow, SecurityCheckPolicy = DoSecurityCheck, const ResourceLoaderOptions& = ResourceLoaderOptions(SendCallbacks, SniffContent, BufferData));
+    PassRefPtr<SubresourceLoader> scheduleSubresourceLoad(Frame*, SubresourceLoaderClient*, const ResourceRequest&, ResourceLoadPriority = ResourceLoadPriorityLow, SecurityCheckPolicy = DoSecurityCheck, const ResourceLoaderOptions& = ResourceLoaderOptions(SendCallbacks, SniffContent, BufferData, AllowStoredCredentials));
     PassRefPtr<NetscapePlugInStreamLoader> schedulePluginStreamLoad(Frame*, NetscapePlugInStreamLoaderClient*, const ResourceRequest&);
     void addMainResourceLoad(ResourceLoader*);
     void remove(ResourceLoader*);
index d623fcd..6169f48 100644 (file)
@@ -517,6 +517,10 @@ bool ResourceLoader::shouldUseCredentialStorage()
 #endif
     if (!fastMallocSize(documentLoader()->frame()))
         CRASH();
+
+    if (m_options.allowCredentials == DoNotAllowStoredCredentials)
+        return false;
+    
     RefPtr<ResourceLoader> protector(this);
     return frameLoader()->client()->shouldUseCredentialStorage(documentLoader(), identifier());
 }
index a92fb22..d6adeb1 100644 (file)
@@ -31,6 +31,8 @@
 #ifndef ResourceLoaderOptions_h
 #define ResourceLoaderOptions_h
 
+#include "ResourceHandle.h"
+
 namespace WebCore {
     
 enum SendCallbackPolicy {
@@ -49,11 +51,12 @@ enum DataBufferingPolicy {
 };
 
 struct ResourceLoaderOptions {
-    ResourceLoaderOptions() : sendLoadCallbacks(DoNotSendCallbacks), sniffContent(DoNotSniffContent), shouldBufferData(BufferData) { }
-    ResourceLoaderOptions(SendCallbackPolicy sendLoadCallbacksArg, ContentSniffingPolicy sniffContentArg, DataBufferingPolicy shouldBufferDataArg) : sendLoadCallbacks(sendLoadCallbacksArg), sniffContent(sniffContentArg), shouldBufferData(shouldBufferDataArg) { }
+    ResourceLoaderOptions() : sendLoadCallbacks(DoNotSendCallbacks), sniffContent(DoNotSniffContent), shouldBufferData(BufferData), allowCredentials(DoNotAllowStoredCredentials) { }
+    ResourceLoaderOptions(SendCallbackPolicy sendLoadCallbacksArg, ContentSniffingPolicy sniffContentArg, DataBufferingPolicy shouldBufferDataArg, StoredCredentials allowCredentialsArg) : sendLoadCallbacks(sendLoadCallbacksArg), sniffContent(sniffContentArg), shouldBufferData(shouldBufferDataArg), allowCredentials(allowCredentialsArg) { }
     SendCallbackPolicy sendLoadCallbacks;
     ContentSniffingPolicy sniffContent;
     DataBufferingPolicy shouldBufferData;
+    StoredCredentials allowCredentials; // Whether HTTP credentials and cookies are sent with the request.
 };
 
 } // namespace WebCore    
index 429248e..8fe5d27 100644 (file)
@@ -234,17 +234,6 @@ void SubresourceLoader::didCancel(const ResourceError&)
     m_documentLoader->removeSubresourceLoader(this);
 }
 
-bool SubresourceLoader::shouldUseCredentialStorage()
-{
-    RefPtr<SubresourceLoader> protect(this);
-
-    bool shouldUse;
-    if (m_client && m_client->getShouldUseCredentialStorage(this, shouldUse))
-        return shouldUse;
-
-    return ResourceLoader::shouldUseCredentialStorage();
-}
-
 void SubresourceLoader::didReceiveAuthenticationChallenge(const AuthenticationChallenge& challenge)
 {
     RefPtr<SubresourceLoader> protect(this);
index 9e79636..0d6b9af 100644 (file)
@@ -56,7 +56,6 @@ namespace WebCore {
         virtual void didReceiveCachedMetadata(const char*, int);
         virtual void didFinishLoading(double finishTime);
         virtual void didFail(const ResourceError&);
-        virtual bool shouldUseCredentialStorage();
         virtual void didReceiveAuthenticationChallenge(const AuthenticationChallenge&);
         virtual void willCancel(const ResourceError&);
         virtual void didCancel(const ResourceError&);
index adddeec..be89d78 100644 (file)
@@ -51,7 +51,6 @@ public:
     virtual void didFinishLoading(SubresourceLoader*, double /*finishTime*/) { }
     virtual void didFail(SubresourceLoader*, const ResourceError&) { }
     
-    virtual bool getShouldUseCredentialStorage(SubresourceLoader*, bool& /*shouldUseCredentialStorage*/) { return false; }
     virtual void didReceiveAuthenticationChallenge(SubresourceLoader*, const AuthenticationChallenge&) { }
 };
 
index 9d35187..88e8dd1 100644 (file)
@@ -60,8 +60,7 @@ namespace WebCore {
     };
 
     struct ThreadableLoaderOptions : public ResourceLoaderOptions {
-        ThreadableLoaderOptions() : allowCredentials(DoNotAllowStoredCredentials), preflightPolicy(ConsiderPreflight), crossOriginRequestPolicy(DenyCrossOriginRequests) { }
-        StoredCredentials allowCredentials; // Whether HTTP credentials and cookies are sent with the request.
+        ThreadableLoaderOptions() : preflightPolicy(ConsiderPreflight), crossOriginRequestPolicy(DenyCrossOriginRequests) { }
         PreflightPolicy preflightPolicy; // If AccessControl is used, how to determine if a preflight is needed.
         CrossOriginRequestPolicy crossOriginRequestPolicy;
         RefPtr<SecurityOrigin> securityOrigin;
index ea56b92..26beb98 100644 (file)
@@ -125,7 +125,7 @@ PassOwnPtr<CachedResourceRequest> CachedResourceRequest::load(CachedResourceLoad
     resourceRequest.setPriority(priority);
 
     RefPtr<SubresourceLoader> loader = resourceLoadScheduler()->scheduleSubresourceLoad(cachedResourceLoader->document()->frame(), request.get(), resourceRequest, priority, securityCheck,
-                                                                                        ResourceLoaderOptions(sendResourceLoadCallbacks ? SendCallbacks : DoNotSendCallbacks, SniffContent, BufferData));
+                                                                                        ResourceLoaderOptions(sendResourceLoadCallbacks ? SendCallbacks : DoNotSendCallbacks, SniffContent, BufferData, AllowStoredCredentials));
     if (!loader || loader->reachedTerminalState()) {
         // FIXME: What if resources in other frames were waiting for this revalidation?
         LOG(ResourceLoading, "Cannot start loading '%s'", resource->url().string().latin1().data());