JavaScriptCore:
authormjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Dec 2006 23:20:13 +0000 (23:20 +0000)
committermjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Dec 2006 23:20:13 +0000 (23:20 +0000)
        Reviewed by Anders.

        - added equality and inequality operations for HashMap and Vector, useful for comparing more complex types

        * wtf/HashMap.h:
        (WTF::operator==):
        (WTF::operator!=):
        * wtf/Vector.h:
        (WTF::operator==):
        (WTF::operator!=):

WebCore:

        Reviewed by Anders.

        - converted many places to use ResourceRequest instead of NSURLRequest

        * WebCore.exp:
        * loader/DocumentLoader.h:
        * loader/FrameLoader.cpp:
        (WebCore::FrameLoader::stopPolicyCheck):
        * loader/FrameLoader.h:
        (WebCore::PolicyCheck::request):
        * loader/FrameLoaderClient.h:
        * loader/MainResourceLoader.h:
        * loader/mac/DocumentLoaderMac.mm:
        (WebCore::DocumentLoader::DocumentLoader):
        (WebCore::DocumentLoader::originalRequest):
        (WebCore::DocumentLoader::originalRequestCopy):
        (WebCore::DocumentLoader::request):
        (WebCore::DocumentLoader::initialRequest):
        (WebCore::DocumentLoader::actualRequest):
        (WebCore::DocumentLoader::URL):
        (WebCore::DocumentLoader::unreachableURL):
        (WebCore::DocumentLoader::replaceRequestURLForAnchorScroll):
        (WebCore::DocumentLoader::setRequest):
        (WebCore::DocumentLoader::stopLoading):
        (WebCore::DocumentLoader::setLastCheckedRequest):
        (WebCore::DocumentLoader::lastCheckedRequest):
        (WebCore::DocumentLoader::URLForHistory):
        * loader/mac/FrameLoaderMac.mm:
        (WebCore::FrameLoader::load):
        (WebCore::FrameLoader::startLoadingMainResource):
        (WebCore::FrameLoader::applyUserAgent):
        (WebCore::FrameLoader::originalRequest):
        (WebCore::FrameLoader::receivedMainResourceError):
        (WebCore::FrameLoader::callContinueFragmentScrollAfterNavigationPolicy):
        (WebCore::FrameLoader::continueFragmentScrollAfterNavigationPolicy):
        (WebCore::FrameLoader::commitProvisionalLoad):
        (WebCore::FrameLoader::initialRequest):
        (WebCore::FrameLoader::setRequest):
        (WebCore::FrameLoader::checkNavigationPolicy):
        (WebCore::FrameLoader::shouldReloadToHandleUnreachableURL):
        (WebCore::FrameLoader::reloadAllowingStaleData):
        (WebCore::FrameLoader::reload):
        (WebCore::FrameLoader::checkNewWindowPolicy):
        (WebCore::FrameLoader::continueAfterNewWindowPolicy):
        (WebCore::FrameLoader::continueAfterNavigationPolicy):
        (WebCore::FrameLoader::callContinueLoadAfterNavigationPolicy):
        (WebCore::FrameLoader::continueLoadAfterNavigationPolicy):
        (WebCore::FrameLoader::checkLoadCompleteForThisFrame):
        (WebCore::FrameLoader::callContinueLoadAfterNewWindowPolicy):
        (WebCore::FrameLoader::continueLoadAfterNewWindowPolicy):
        (WebCore::FrameLoader::post):
        (WebCore::FrameLoader::addExtraFieldsToRequest):
        (WebCore::FrameLoader::isReloading):
        (WebCore::FrameLoader::referrer):
        (WebCore::FrameLoader::loadEmptyDocumentSynchronously):
        (WebCore::FrameLoader::loadResourceSynchronously):
        (WebCore::FrameLoader::originalRequestURL):
        (WebCore::PolicyCheck::set):
        (WebCore::PolicyCheck::call):
        (WebCore::PolicyCheck::clearRequest):
        * loader/mac/MainResourceLoaderMac.mm:
        (WebCore::MainResourceLoader::callContinueAfterNavigationPolicy):
        (WebCore::MainResourceLoader::continueAfterNavigationPolicy):
        (WebCore::MainResourceLoader::isPostOrRedirectAfterPost):
        * loader/mac/SubresourceLoaderMac.mm:
        (WebCore::SubresourceLoader::create):
        * loader/mac/WebDataProtocol.h:
        * loader/mac/WebDataProtocol.mm:
        * platform/KURL.cpp:
        (WebCore::operator!=):
        * platform/KURL.h:
        * platform/mac/KURLMac.mm:
        (WebCore::KURL::getNSURL):
        * platform/network/FormData.h:
        (WebCore::operator==):
        (WebCore::operator!=):
        * platform/network/ResourceRequest.cpp:
        (WebCore::operator==):
        * platform/network/ResourceRequest.h:
        * platform/network/mac/ResourceRequestMac.mm:
        (WebCore::ResourceRequest::doUpdatePlatformRequest):

WebKit:

        Reviewed by Anders.

        - adjusted for changes from NSURLRequest to ResourceRequest

        * Plugins/WebPluginController.mm:
        * WebCoreSupport/WebFrameLoaderClient.h:
        * WebCoreSupport/WebFrameLoaderClient.mm:
        (WebFrameLoaderClient::updateHistoryForReload):
        (WebFrameLoaderClient::dispatchIdentifierForInitialRequest):
        (WebFrameLoaderClient::dispatchDecidePolicyForMIMEType):
        (WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction):
        (WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
        (WebFrameLoaderClient::startDownload):
        (WebFrameLoaderClient::cannotShowURLError):
        (WebFrameLoaderClient::createDocumentLoader):
        * WebView/WebDataSource.mm:
        (-[WebDataSource _initWithDocumentLoader:]):
        (-[WebDataSource initialRequest]):
        (-[WebDataSource request]):
        * WebView/WebDocumentLoaderMac.h:
        * WebView/WebDocumentLoaderMac.mm:
        (WebDocumentLoaderMac::WebDocumentLoaderMac):
        * WebView/WebFrame.mm:
        (-[WebFrame _createItem:]):
        (-[WebFrame _loadItem:withLoadType:]):
        (-[WebFrame loadArchive:]):

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

30 files changed:
JavaScriptCore/ChangeLog
JavaScriptCore/wtf/HashMap.h
JavaScriptCore/wtf/Vector.h
WebCore/ChangeLog
WebCore/WebCore.exp
WebCore/loader/DocumentLoader.h
WebCore/loader/FrameLoader.cpp
WebCore/loader/FrameLoader.h
WebCore/loader/FrameLoaderClient.h
WebCore/loader/MainResourceLoader.h
WebCore/loader/mac/DocumentLoaderMac.mm
WebCore/loader/mac/FrameLoaderMac.mm
WebCore/loader/mac/MainResourceLoaderMac.mm
WebCore/loader/mac/SubresourceLoaderMac.mm
WebCore/loader/mac/WebDataProtocol.h
WebCore/loader/mac/WebDataProtocol.mm
WebCore/platform/KURL.h
WebCore/platform/mac/KURLMac.mm
WebCore/platform/network/FormData.h
WebCore/platform/network/ResourceRequest.cpp
WebCore/platform/network/ResourceRequest.h
WebCore/platform/network/mac/ResourceRequestMac.mm
WebKit/ChangeLog
WebKit/Plugins/WebPluginController.mm
WebKit/WebCoreSupport/WebFrameLoaderClient.h
WebKit/WebCoreSupport/WebFrameLoaderClient.mm
WebKit/WebView/WebDataSource.mm
WebKit/WebView/WebDocumentLoaderMac.h
WebKit/WebView/WebDocumentLoaderMac.mm
WebKit/WebView/WebFrame.mm

index ca3dc5c29eac3552ebeb9052c6575ec9c507da6b..95cc96d3b856f95d09e3e59ceb8afe22bccc24e0 100644 (file)
@@ -1,3 +1,16 @@
+2006-12-13  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Anders.
+        
+        - added equality and inequality operations for HashMap and Vector, useful for comparing more complex types
+
+        * wtf/HashMap.h:
+        (WTF::operator==):
+        (WTF::operator!=):
+        * wtf/Vector.h:
+        (WTF::operator==):
+        (WTF::operator!=):
+
 2006-12-12  Alexey Proskuryakov  <ap@webkit.org>
 
         Reviewed by Geoff. Based on a patch by Maks Orlovich.
index eef38c20d2948f5a27485db89fbbe91da7ece5db..32ef80065d9785c363fd7f45aa167ff452a95e7d 100644 (file)
@@ -305,6 +305,31 @@ namespace WTF {
         m_impl.clear();
     }
 
+    template<typename T, typename U, typename V, typename W, typename X>
+    bool operator==(const HashMap<T, U, V, W, X>& a, const HashMap<T, U, V, W, X>& b)
+    {
+        if (a.size() != b.size())
+            return false;
+
+        typedef typename HashMap<T, U, V, W, X>::const_iterator const_iterator;
+
+        const_iterator end = a.end();
+        const_iterator notFound = b.end();
+        for (const_iterator it = a.begin(); it != end; ++it) {
+            const_iterator bPos = b.find(it->first);
+            if (bPos == notFound || it->second != bPos->second)
+                return false;
+        }
+
+        return true;
+    }
+
+    template<typename T, typename U, typename V, typename W, typename X>
+    inline bool operator!=(const HashMap<T, U, V, W, X>& a, const HashMap<T, U, V, W, X>& b)
+    {
+        return !(a == b);
+    }
+
     template<typename MappedType, typename HashTableType>
     void deleteAllPairSeconds(HashTableType& collection)
     {
index 496f1c761ed69bded8790580dd0ef1afd953b194..e578ae8c6952497a116ef6aa6bcde3785a02067a 100644 (file)
@@ -662,6 +662,26 @@ namespace WTF {
         a.swap(b);
     }
 
+    template<typename T, size_t inlineCapacity>
+    void operator==(Vector<T, inlineCapacity>& a, Vector<T, inlineCapacity>& b)
+    {
+        if (a.size() != b.size())
+            return false;
+
+        for (int i = 0; i < a.size(); ++i)
+            if (a[i] != b[i])
+                return false;
+
+        return true;
+    }
+
+    template<typename T, size_t inlineCapacity>
+    inline void operator!=(Vector<T, inlineCapacity>& a, Vector<T, inlineCapacity>& b)
+    {
+        return !(a == b);
+    }
+
+
 } // namespace WTF
 
 using WTF::Vector;
index 1527be435a9c80a90243242498b59e1108da17b2..744bb58b47ac46c77f617c9163088369ee5fcaef 100644 (file)
@@ -1,3 +1,87 @@
+2006-12-13  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Anders.
+
+        - converted many places to use ResourceRequest instead of NSURLRequest
+
+        * WebCore.exp:
+        * loader/DocumentLoader.h:
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::stopPolicyCheck):
+        * loader/FrameLoader.h:
+        (WebCore::PolicyCheck::request):
+        * loader/FrameLoaderClient.h:
+        * loader/MainResourceLoader.h:
+        * loader/mac/DocumentLoaderMac.mm:
+        (WebCore::DocumentLoader::DocumentLoader):
+        (WebCore::DocumentLoader::originalRequest):
+        (WebCore::DocumentLoader::originalRequestCopy):
+        (WebCore::DocumentLoader::request):
+        (WebCore::DocumentLoader::initialRequest):
+        (WebCore::DocumentLoader::actualRequest):
+        (WebCore::DocumentLoader::URL):
+        (WebCore::DocumentLoader::unreachableURL):
+        (WebCore::DocumentLoader::replaceRequestURLForAnchorScroll):
+        (WebCore::DocumentLoader::setRequest):
+        (WebCore::DocumentLoader::stopLoading):
+        (WebCore::DocumentLoader::setLastCheckedRequest):
+        (WebCore::DocumentLoader::lastCheckedRequest):
+        (WebCore::DocumentLoader::URLForHistory):
+        * loader/mac/FrameLoaderMac.mm:
+        (WebCore::FrameLoader::load):
+        (WebCore::FrameLoader::startLoadingMainResource):
+        (WebCore::FrameLoader::applyUserAgent):
+        (WebCore::FrameLoader::originalRequest):
+        (WebCore::FrameLoader::receivedMainResourceError):
+        (WebCore::FrameLoader::callContinueFragmentScrollAfterNavigationPolicy):
+        (WebCore::FrameLoader::continueFragmentScrollAfterNavigationPolicy):
+        (WebCore::FrameLoader::commitProvisionalLoad):
+        (WebCore::FrameLoader::initialRequest):
+        (WebCore::FrameLoader::setRequest):
+        (WebCore::FrameLoader::checkNavigationPolicy):
+        (WebCore::FrameLoader::shouldReloadToHandleUnreachableURL):
+        (WebCore::FrameLoader::reloadAllowingStaleData):
+        (WebCore::FrameLoader::reload):
+        (WebCore::FrameLoader::checkNewWindowPolicy):
+        (WebCore::FrameLoader::continueAfterNewWindowPolicy):
+        (WebCore::FrameLoader::continueAfterNavigationPolicy):
+        (WebCore::FrameLoader::callContinueLoadAfterNavigationPolicy):
+        (WebCore::FrameLoader::continueLoadAfterNavigationPolicy):
+        (WebCore::FrameLoader::checkLoadCompleteForThisFrame):
+        (WebCore::FrameLoader::callContinueLoadAfterNewWindowPolicy):
+        (WebCore::FrameLoader::continueLoadAfterNewWindowPolicy):
+        (WebCore::FrameLoader::post):
+        (WebCore::FrameLoader::addExtraFieldsToRequest):
+        (WebCore::FrameLoader::isReloading):
+        (WebCore::FrameLoader::referrer):
+        (WebCore::FrameLoader::loadEmptyDocumentSynchronously):
+        (WebCore::FrameLoader::loadResourceSynchronously):
+        (WebCore::FrameLoader::originalRequestURL):
+        (WebCore::PolicyCheck::set):
+        (WebCore::PolicyCheck::call):
+        (WebCore::PolicyCheck::clearRequest):
+        * loader/mac/MainResourceLoaderMac.mm:
+        (WebCore::MainResourceLoader::callContinueAfterNavigationPolicy):
+        (WebCore::MainResourceLoader::continueAfterNavigationPolicy):
+        (WebCore::MainResourceLoader::isPostOrRedirectAfterPost):
+        * loader/mac/SubresourceLoaderMac.mm:
+        (WebCore::SubresourceLoader::create):
+        * loader/mac/WebDataProtocol.h:
+        * loader/mac/WebDataProtocol.mm:
+        * platform/KURL.cpp:
+        (WebCore::operator!=):
+        * platform/KURL.h:
+        * platform/mac/KURLMac.mm:
+        (WebCore::KURL::getNSURL):
+        * platform/network/FormData.h:
+        (WebCore::operator==):
+        (WebCore::operator!=):
+        * platform/network/ResourceRequest.cpp:
+        (WebCore::operator==):
+        * platform/network/ResourceRequest.h:
+        * platform/network/mac/ResourceRequestMac.mm:
+        (WebCore::ResourceRequest::doUpdatePlatformRequest):
+
 2006-12-13  Geoffrey Garen  <ggaren@apple.com>
 
         Reviewed by Darin Adler, Dave Hyatt.
index 026772e458d80a7dd74b3ba87ab39d274aff309d..fe21096675a2fd20d17794aa0eea5e835a489ce8 100644 (file)
@@ -149,11 +149,11 @@ __ZN7WebCore11FrameLoader23reloadAllowingStaleDataERKNS_6StringE
 __ZN7WebCore11FrameLoader23timeOfLastCompletedLoadEv
 __ZN7WebCore11FrameLoader24removePlugInStreamLoaderEPNS_14ResourceLoaderE
 __ZN7WebCore11FrameLoader25provisionalDocumentLoaderEv
-__ZN7WebCore11FrameLoader4loadEP12NSURLRequest
-__ZN7WebCore11FrameLoader4loadEP12NSURLRequestRKNS_16NavigationActionENS_13FrameLoadTypeEN3WTF10PassRefPtrINS_9FormStateEEE
-__ZN7WebCore11FrameLoader4loadEP12NSURLRequestRKNS_6StringE
 __ZN7WebCore11FrameLoader4loadEPNS_14DocumentLoaderE
 __ZN7WebCore11FrameLoader4loadEPNS_14DocumentLoaderENS_13FrameLoadTypeEN3WTF10PassRefPtrINS_9FormStateEEE
+__ZN7WebCore11FrameLoader4loadERKNS_15ResourceRequestE
+__ZN7WebCore11FrameLoader4loadERKNS_15ResourceRequestERKNS_16NavigationActionENS_13FrameLoadTypeEN3WTF10PassRefPtrINS_9FormStateEEE
+__ZN7WebCore11FrameLoader4loadERKNS_15ResourceRequestERKNS_6StringE
 __ZN7WebCore11FrameLoader4loadERKNS_4KURLEPNS_5EventE
 __ZN7WebCore11FrameLoader4loadERKNS_4KURLERKNS_6StringENS_13FrameLoadTypeES6_PNS_5EventEPNS_15HTMLFormElementERKN3WTF7HashMapIS4_S4_NSC_7StrHashIS4_EENSC_10HashTraitsIS4_EESH_EE
 __ZN7WebCore11FrameLoader5clearEb
@@ -200,7 +200,7 @@ __ZN7WebCore14DocumentLoader19prepareForLoadStartEv
 __ZN7WebCore14DocumentLoader19setOverrideEncodingERKNS_6StringE
 __ZN7WebCore14DocumentLoader32replaceRequestURLForAnchorScrollERKNS_4KURLE
 __ZN7WebCore14DocumentLoader7requestEv
-__ZN7WebCore14DocumentLoaderC2EP12NSURLRequest
+__ZN7WebCore14DocumentLoaderC2ERKNS_15ResourceRequestE
 __ZN7WebCore14DocumentLoaderD2Ev
 __ZN7WebCore14RenderListItem17markerStringValueEv
 __ZN7WebCore14ResourceHandle12releaseProxyEv
@@ -228,6 +228,7 @@ __ZN7WebCore26NetscapePlugInStreamLoader6createEPNS_5FrameEP11objc_object
 __ZN7WebCore36InitializeLoggingChannelsIfNecessaryEv
 __ZN7WebCore4KURLC1EP5NSURL
 __ZN7WebCore4KURLC1ERKNS_16DeprecatedStringE
+__ZN7WebCore4KURLC1Ev
 __ZN7WebCore4Page12setGroupNameERKNS_6StringE
 __ZN7WebCore4Page16setDefersLoadingEb
 __ZN7WebCore4PageC1EPNS_12ChromeClientEPNS_17ContextMenuClientEPNS_12EditorClientE
@@ -367,6 +368,7 @@ __ZNK7WebCore14ResourceHandle10connectionEv
 __ZNK7WebCore14ResourceLoader11frameLoaderEv
 __ZNK7WebCore15ContextMenuItem19platformDescriptionEv
 __ZNK7WebCore15ResourceRequest12nsURLRequestEv
+__ZNK7WebCore15ResourceRequest3urlEv
 __ZNK7WebCore15ResourceRequest7isEmptyEv
 __ZNK7WebCore16DeprecatedString11getNSStringEv
 __ZNK7WebCore16DeprecatedString2atEj
index 10f346d22aa76f831c2f3a9e969cf271cd39e826..e6aacab4177648026430d2aeb4761b6bb1956009 100644 (file)
@@ -31,6 +31,7 @@
 #include "NavigationAction.h"
 #include "Shared.h"
 #include "PlatformString.h"
+#include "ResourceRequest.h"
 #include <wtf/Vector.h>
 
 #if PLATFORM(MAC)
@@ -62,11 +63,7 @@ namespace WebCore {
 
     class DocumentLoader : public Shared<DocumentLoader> {
     public:
-#if PLATFORM(MAC)
-        DocumentLoader(NSURLRequest *);
-#elif PLATFORM(QT)
-        DocumentLoader();
-#endif
+        DocumentLoader(const ResourceRequest&);
         virtual ~DocumentLoader();
 
         void setFrame(Frame*);
@@ -76,15 +73,19 @@ namespace WebCore {
         FrameLoader* frameLoader() const;
 #if PLATFORM(MAC)
         NSData *mainResourceData() const;
-        NSURLRequest *originalRequest() const;
-        NSURLRequest *originalRequestCopy() const;
-        NSMutableURLRequest *request();
-        void setRequest(NSURLRequest *);
-        NSMutableURLRequest *actualRequest();
-        NSURLRequest *initialRequest() const;
 #endif
-        KURL URL() const;
-        KURL unreachableURL() const;
+        const ResourceRequest& originalRequest() const;
+        const ResourceRequest& originalRequestCopy() const;
+
+        const ResourceRequest& request() const;
+        ResourceRequest& request();
+        void setRequest(const ResourceRequest&);
+        const ResourceRequest& actualRequest() const;
+        ResourceRequest& actualRequest();
+        const ResourceRequest& initialRequest() const;
+
+        const KURL& URL() const;
+        const KURL unreachableURL() const;
         void replaceRequestURLForAnchorScroll(const KURL&);
         bool isStopping() const;
         void stopLoading();
@@ -118,10 +119,9 @@ namespace WebCore {
         const NavigationAction& triggeringAction() const;
         void setTriggeringAction(const NavigationAction&);
         void setOverrideEncoding(const String&);
-#if PLATFORM(MAC)
-        void setLastCheckedRequest(NSURLRequest *request);
-        NSURLRequest *lastCheckedRequest() const;
-#endif
+        void setLastCheckedRequest(const ResourceRequest& request);
+        const ResourceRequest& lastCheckedRequest() const;
+
         void stopRecordingResponses();
         String title() const;
         KURL URLForHistory() const;
@@ -144,22 +144,26 @@ namespace WebCore {
 
 #if PLATFORM(MAC)
         RetainPtr<NSData> m_mainResourceData;
+#endif
 
         // A reference to actual request used to create the data source.
         // This should only be used by the resourceLoadDelegate's
         // identifierForInitialRequest:fromDatasource: method. It is
         // not guaranteed to remain unchanged, as requests are mutable.
-        RetainPtr<NSURLRequest> m_originalRequest;    
+        ResourceRequest m_originalRequest;    
 
         // A copy of the original request used to create the data source.
         // We have to copy the request because requests are mutable.
-        RetainPtr<NSURLRequest> m_originalRequestCopy;
+        ResourceRequest m_originalRequestCopy;
         
         // The 'working' request. It may be mutated
         // several times from the original request to include additional
         // headers, cookie information, canonicalization and redirects.
-        RetainPtr<NSMutableURLRequest> m_request;
+        ResourceRequest m_request;
+
+        mutable ResourceRequest m_externalRequest;
 
+#if PLATFORM(MAC)
         RetainPtr<NSURLResponse> m_response;
     
         RetainPtr<NSError> m_mainDocumentError;    
@@ -183,11 +187,11 @@ namespace WebCore {
         // benefit of the various policy handlers.
         NavigationAction m_triggeringAction;
 
-#if PLATFORM(MAC)
         // The last request that we checked click policy for - kept around
         // so we can avoid asking again needlessly.
-        RetainPtr<NSURLRequest> m_lastCheckedRequest;
+        ResourceRequest m_lastCheckedRequest;
 
+#if PLATFORM(MAC)
         // We retain all the received responses so we can play back the
         // WebResourceLoadDelegate messages if the item is loaded from the
         // page cache.
index c62ed652c22453e28a108ad33a0e3460e8958d91..dcc031d149fd8d92d1809fa1aedecb69f92ac4bb 100644 (file)
@@ -2058,7 +2058,7 @@ void FrameLoader::stopPolicyCheck()
     PolicyCheck check = m_policyCheck;
     m_policyCheck.clear();
     check.clearRequest();
-    check.call();
+    check.call(false);
 }
 
 void FrameLoader::continueAfterContentPolicy(PolicyAction policy)
index 9a89b4ef346935785a1f12c85225f5e56bac303f..052ce4978471fe2209504e53552bc13773c2c22a 100644 (file)
 #include <wtf/Noncopyable.h>
 #include <wtf/OwnPtr.h>
 #include <wtf/RefPtr.h>
+#include "ResourceRequest.h"
 
 #if PLATFORM(MAC)
 
-#import "RetainPtr.h"
-#import <objc/objc.h>
+typedef struct objc_object* id;
 
 #ifdef __OBJC__
 
@@ -115,12 +115,10 @@ namespace WebCore {
 
     bool isBackForwardLoadType(FrameLoadType);
 
-#if PLATFORM(MAC)
     typedef void (*NavigationPolicyDecisionFunction)(void* argument,
-        NSURLRequest *, PassRefPtr<FormState>);
+        const ResourceRequest&, PassRefPtr<FormState>, bool shouldContinue);
     typedef void (*NewWindowPolicyDecisionFunction)(void* argument,
-        NSURLRequest *, PassRefPtr<FormState>, const String& frameName);
-#endif
+        const ResourceRequest&, PassRefPtr<FormState>, const String& frameName, bool shouldContinue);
     typedef void (*ContentPolicyDecisionFunction)(void* argument, PolicyAction);
 
     class PolicyCheck {
@@ -128,33 +126,25 @@ namespace WebCore {
         PolicyCheck();
 
         void clear();
-#if PLATFORM(MAC)
-        void set(NSURLRequest *, PassRefPtr<FormState>,
+        void set(const ResourceRequest&, PassRefPtr<FormState>,
             NavigationPolicyDecisionFunction, void* argument);
-        void set(NSURLRequest *, PassRefPtr<FormState>, const String& frameName,
+        void set(const ResourceRequest&, PassRefPtr<FormState>, const String& frameName,
             NewWindowPolicyDecisionFunction, void* argument);
-#endif
         void set(ContentPolicyDecisionFunction, void* argument);
 
-#if PLATFORM(MAC)
-        NSURLRequest *request() const { return m_request.get(); }
-#endif
+        const ResourceRequest& request() const { return m_request; }
         void clearRequest();
 
-        void call();
+        void call(bool shouldContinue);
         void call(PolicyAction);
 
     private:
-#if PLATFORM(MAC)
-        RetainPtr<NSURLRequest> m_request;
-#endif
+        ResourceRequest m_request;
         RefPtr<FormState> m_formState;
         String m_frameName;
 
-#if PLATFORM(MAC)
         NavigationPolicyDecisionFunction m_navigationFunction;
         NewWindowPolicyDecisionFunction m_newWindowFunction;
-#endif
         ContentPolicyDecisionFunction m_contentFunction;
         void* m_argument;
     };
@@ -179,11 +169,9 @@ namespace WebCore {
         void post(const KURL&, const String& referrer, const String& target,
             PassRefPtr<FormData>, const String& contentType,
             Event*, HTMLFormElement*, const HashMap<String, String>& formValues);
-#if PLATFORM(MAC)
-        void load(NSURLRequest *);
-        void load(NSURLRequest *, const String& frameName);
-        void load(NSURLRequest *, const NavigationAction&, FrameLoadType, PassRefPtr<FormState>);
-#endif
+        void load(const ResourceRequest&);
+        void load(const ResourceRequest&, const String& frameName);
+        void load(const ResourceRequest&, const NavigationAction&, FrameLoadType, PassRefPtr<FormState>);
         void load(DocumentLoader*);
         void load(DocumentLoader*, FrameLoadType, PassRefPtr<FormState>);
 
@@ -246,12 +234,12 @@ namespace WebCore {
         void didFailToLoad(ResourceLoader*, NSError *);
 #endif
         bool privateBrowsingEnabled() const;
+        const ResourceRequest& originalRequest() const;
+        const ResourceRequest& initialRequest() const;
+        void setRequest(const ResourceRequest&);
 #if PLATFORM(MAC)
-        NSURLRequest *originalRequest() const;
         void receivedMainResourceError(NSError *, bool isComplete);
-        NSURLRequest *initialRequest() const;
         void receivedData(NSData *);
-        void setRequest(NSURLRequest *);
 #endif
         void handleFallbackContent();
         bool isStopping() const;
@@ -281,9 +269,7 @@ namespace WebCore {
 
         void notifyIconChanged();
 
-#if PLATFORM(MAC)
-        void checkNavigationPolicy(NSURLRequest *, NavigationPolicyDecisionFunction, void* argument);
-#endif
+        void checkNavigationPolicy(const ResourceRequest&, NavigationPolicyDecisionFunction function, void* argument);
         void checkContentPolicy(const String& MIMEType, ContentPolicyDecisionFunction, void* argument);
         void cancelContentPolicyCheck();
 
@@ -333,6 +319,7 @@ namespace WebCore {
 #if PLATFORM(MAC)
         void addExtraFieldsToRequest(NSMutableURLRequest *, bool isMainResource, bool alwaysFromRequest);
 #endif
+        void addExtraFieldsToRequest(ResourceRequest&, bool isMainResource, bool alwaysFromRequest);
 
         FrameLoaderClient* client() const;
 
@@ -500,9 +487,7 @@ namespace WebCore {
 
         // Also not cool.
         void startLoading();
-#if PLATFORM(MAC)
-        bool startLoadingMainResource(NSMutableURLRequest *, id identifier);
-#endif
+        bool startLoadingMainResource(ResourceRequest&, id identifier);
         void stopLoadingSubframes();
 
         void clearProvisionalLoad();
@@ -516,26 +501,22 @@ namespace WebCore {
 
         void setLoadType(FrameLoadType);
 
-#if PLATFORM(MAC)
-        void checkNavigationPolicy(NSURLRequest *, DocumentLoader*, PassRefPtr<FormState>,
-            NavigationPolicyDecisionFunction, void* argument);
-        void checkNewWindowPolicy(const NavigationAction&,
-            NSURLRequest *, PassRefPtr<FormState>, const String& frameName);
-#endif
+        void checkNavigationPolicy(const ResourceRequest&, DocumentLoader*, PassRefPtr<FormState>,
+                                   NavigationPolicyDecisionFunction, void* argument);
+        void checkNewWindowPolicy(const NavigationAction&, const ResourceRequest&, 
+                                  PassRefPtr<FormState>, const String& frameName);
 
         void continueAfterNavigationPolicy(PolicyAction);
         void continueAfterNewWindowPolicy(PolicyAction);
         void continueAfterContentPolicy(PolicyAction);
         void continueAfterWillSubmitForm(PolicyAction = PolicyUse);
 
-#if PLATFORM(MAC)
-        static void callContinueLoadAfterNavigationPolicy(void*, NSURLRequest *, PassRefPtr<FormState>);
-        void continueLoadAfterNavigationPolicy(NSURLRequest *, PassRefPtr<FormState>);
-        static void callContinueLoadAfterNewWindowPolicy(void*, NSURLRequest *, PassRefPtr<FormState>, const String& frameName);
-        void continueLoadAfterNewWindowPolicy(NSURLRequest *, PassRefPtr<FormState>, const String& frameName);
-        static void callContinueFragmentScrollAfterNavigationPolicy(void*, NSURLRequest *, PassRefPtr<FormState>);
-        void continueFragmentScrollAfterNavigationPolicy(NSURLRequest *);
-#endif
+        static void callContinueLoadAfterNavigationPolicy(void*, const ResourceRequest&, PassRefPtr<FormState>, bool shouldContinue);
+        void continueLoadAfterNavigationPolicy(const ResourceRequest&, PassRefPtr<FormState>, bool shouldContinue);
+        static void callContinueLoadAfterNewWindowPolicy(void*, const ResourceRequest&, PassRefPtr<FormState>, const String& frameName, bool shouldContinue);
+        void continueLoadAfterNewWindowPolicy(const ResourceRequest&, PassRefPtr<FormState>, const String& frameName, bool shouldContinue);
+        static void callContinueFragmentScrollAfterNavigationPolicy(void*, const ResourceRequest&, PassRefPtr<FormState>, bool shouldContinue);
+        void continueFragmentScrollAfterNavigationPolicy(const ResourceRequest&, bool shouldContinue);
 
         void stopPolicyCheck();
 
@@ -558,12 +539,13 @@ namespace WebCore {
         void open(PageState&);
         void opened();
 
+        bool shouldReloadToHandleUnreachableURL(const ResourceRequest&);
 #if PLATFORM(MAC)
         void handleUnimplementablePolicy(NSError *);
-        bool shouldReloadToHandleUnreachableURL(NSURLRequest *);
 
         void applyUserAgent(NSMutableURLRequest *);
 #endif
+        void applyUserAgent(ResourceRequest& request);
 
         bool canTarget(Frame*) const;
 
index b8b5ef48e46f8a4f34c9b91228deb474b82c2330..7e4650a5218ba3dc3e08bf2c490a981ebfba3a6d 100644 (file)
@@ -110,6 +110,7 @@ namespace WebCore {
 #if PLATFORM(MAC)
         virtual void download(ResourceHandle*, NSURLRequest *, NSURLResponse *) = 0;
 
+        virtual id dispatchIdentifierForInitialRequest(DocumentLoader*, const ResourceRequest&) = 0;
         virtual id dispatchIdentifierForInitialRequest(DocumentLoader*, NSURLRequest *) = 0;
         virtual NSURLRequest *dispatchWillSendRequest(DocumentLoader*, id identifier, NSURLRequest *, NSURLResponse *redirectResponse) = 0;
         virtual void dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, id identifier, NSURLAuthenticationChallenge *) = 0;
@@ -144,9 +145,9 @@ namespace WebCore {
         virtual void dispatchShow() = 0;
 
 #if PLATFORM(MAC)
-        virtual void dispatchDecidePolicyForMIMEType(FramePolicyFunction, const String& MIMEType, NSURLRequest *) = 0;
-        virtual void dispatchDecidePolicyForNewWindowAction(FramePolicyFunction, const NavigationAction&, NSURLRequest *, const String& frameName) = 0;
-        virtual void dispatchDecidePolicyForNavigationAction(FramePolicyFunction, const NavigationAction&, NSURLRequest *) = 0;
+        virtual void dispatchDecidePolicyForMIMEType(FramePolicyFunction, const String& MIMEType, const ResourceRequest&) = 0;
+        virtual void dispatchDecidePolicyForNewWindowAction(FramePolicyFunction, const NavigationAction&, const ResourceRequest&, const String& frameName) = 0;
+        virtual void dispatchDecidePolicyForNavigationAction(FramePolicyFunction, const NavigationAction&, const ResourceRequest&) = 0;
 #endif
         virtual void cancelPolicyCheck() = 0;
 
@@ -177,7 +178,7 @@ namespace WebCore {
         virtual void setMainFrameDocumentReady(bool) = 0;
 
 #if PLATFORM(MAC)
-        virtual void startDownload(NSURLRequest *) = 0;
+        virtual void startDownload(const ResourceRequest&) = 0;
 #endif
 
         virtual void willChangeTitle(DocumentLoader*) = 0;
@@ -191,7 +192,7 @@ namespace WebCore {
 
 #if PLATFORM(MAC)
         virtual NSError *cancelledError(NSURLRequest *) = 0;
-        virtual NSError *cannotShowURLError(NSURLRequest *) = 0;
+        virtual NSError *cannotShowURLError(const ResourceRequest&) = 0;
         virtual NSError *interruptForPolicyChangeError(NSURLRequest *) = 0;
 
         virtual NSError *cannotShowMIMETypeError(NSURLResponse *) = 0;
@@ -221,8 +222,9 @@ namespace WebCore {
         virtual void addHistoryItemForFragmentScroll() = 0;
         virtual void didFinishLoad() = 0;
         virtual void prepareForDataSourceReplacement() = 0;
+
 #if PLATFORM(MAC)
-        virtual PassRefPtr<DocumentLoader> createDocumentLoader(NSURLRequest *) = 0;
+        virtual PassRefPtr<DocumentLoader> createDocumentLoader(const ResourceRequest&) = 0;
 #endif
         virtual void setTitle(const String& title, const KURL&) = 0;
 
index 6fd9d31fb1cea8caa2c040e8fed2d96815a7993e..3f742d509216cf9e45f2d4148247363a64b2dd80 100644 (file)
@@ -33,6 +33,7 @@
 namespace WebCore {
 
     class FormState;
+    class ResourceRequest;
 
     class MainResourceLoader : public ResourceLoader {
     public:
@@ -67,8 +68,8 @@ namespace WebCore {
         void stopLoadingForPolicyChange();
         bool isPostOrRedirectAfterPost(NSURLRequest *newRequest, NSURLResponse *redirectResponse);
 
-        static void callContinueAfterNavigationPolicy(void*, NSURLRequest *, PassRefPtr<FormState>);
-        void continueAfterNavigationPolicy(NSURLRequest *);
+        static void callContinueAfterNavigationPolicy(void*, const ResourceRequest&, PassRefPtr<FormState>, bool shouldContinue);
+        void continueAfterNavigationPolicy(const ResourceRequest&, bool shouldContinue);
 
         static void callContinueAfterContentPolicy(void*, PolicyAction);
         void continueAfterContentPolicy(PolicyAction);
index 38f166b5c6efeeecdb2271377a65087fae33d571..d1ad79e99ff5deabe433eaa128b6bad3059ca4df 100644 (file)
@@ -100,11 +100,11 @@ static inline String canonicalizedTitle(const String& title, Frame* frame)
     return String::adopt(stringBuilder);
 }
 
-DocumentLoader::DocumentLoader(NSURLRequest *req)
+DocumentLoader::DocumentLoader(const ResourceRequest& req)
     : m_frame(0)
     , m_originalRequest(req)
-    , m_originalRequestCopy([req copy])
-    , m_request([req mutableCopy])
+    , m_originalRequestCopy(req)
+    , m_request(req)
     , m_loadingStartedTime(0)
     , m_committed(false)
     , m_stopping(false)
@@ -114,9 +114,6 @@ DocumentLoader::DocumentLoader(NSURLRequest *req)
     , m_isClientRedirect(false)
     , m_stopRecordingResponses(false)
 {
-    [m_originalRequestCopy.get() release];
-    [m_request.get() release];
-    wkSupportsMultipartXMixedReplace(m_request.get());
 }
 
 FrameLoader* DocumentLoader::frameLoader() const
@@ -141,69 +138,64 @@ NSData *DocumentLoader::mainResourceData() const
     return m_mainResourceData ? m_mainResourceData.get() : frameLoader()->mainResourceData();
 }
 
-NSURLRequest *DocumentLoader::originalRequest() const
+const ResourceRequest& DocumentLoader::originalRequest() const
 {
-    return m_originalRequest.get();
+    return m_originalRequest;
 }
 
-NSURLRequest *DocumentLoader::originalRequestCopy() const
+const ResourceRequest& DocumentLoader::originalRequestCopy() const
 {
-    return m_originalRequestCopy.get();
+    return m_originalRequestCopy;
 }
 
-NSMutableURLRequest *DocumentLoader::request()
+const ResourceRequest& DocumentLoader::request() const
 {
-    NSMutableURLRequest *clientRequest = [m_request.get() _webDataRequestExternalRequest];
-    if (!clientRequest)
-        clientRequest = m_request.get();
-    return clientRequest;
+    // FIXME: need a better way to handle data loads
+    return m_request;
 }
 
-NSURLRequest *DocumentLoader::initialRequest() const
+ResourceRequest& DocumentLoader::request()
 {
-    NSURLRequest *clientRequest = [m_originalRequest.get() _webDataRequestExternalRequest];
-    if (!clientRequest)
-        clientRequest = m_originalRequest.get();
-    return clientRequest;
+    // FIXME: need a better way to handle data loads
+    return m_request;
 }
 
-NSMutableURLRequest *DocumentLoader::actualRequest()
+const ResourceRequest& DocumentLoader::initialRequest() const
 {
-    return m_request.get();
+    // FIXME: need a better way to handle data loads
+    return m_originalRequest;
 }
 
-KURL DocumentLoader::URL() const
+ResourceRequest& DocumentLoader::actualRequest()
 {
-    return [const_cast<DocumentLoader*>(this)->request() URL];
+    return m_request;
 }
 
-KURL DocumentLoader::unreachableURL() const
+const KURL& DocumentLoader::URL() const
 {
-    return [m_originalRequest.get() _webDataRequestUnreachableURL];
+    return request().url();
 }
 
-void DocumentLoader::replaceRequestURLForAnchorScroll(const KURL& URL)
+const KURL DocumentLoader::unreachableURL() const
 {
-    NSURL *newURL = URL.getNSURL();
-
-    NSMutableURLRequest *newOriginalRequest = [m_originalRequestCopy.get() mutableCopy];
-    [newOriginalRequest setURL:newURL];
-    m_originalRequestCopy = newOriginalRequest;
-    [newOriginalRequest release];
-    
-    NSMutableURLRequest *newRequest = [m_request.get() mutableCopy];
-    [newRequest setURL:newURL];
-    m_request = newRequest;
-    [newRequest release];
+    return [m_originalRequest.nsURLRequest() _webDataRequestUnreachableURL];
 }
 
-void DocumentLoader::setRequest(NSURLRequest *req)
+void DocumentLoader::replaceRequestURLForAnchorScroll(const KURL& URL)
 {
-    ASSERT_ARG(req, req != m_request);
+    m_originalRequestCopy.setURL(URL);
+    m_request.setURL(URL);
+}
 
+void DocumentLoader::setRequest(const ResourceRequest& req)
+{
     // Replacing an unreachable URL with alternate content looks like a server-side
     // redirect at this point, but we can replace a committed dataSource.
-    bool handlingUnreachableURL = [req _webDataRequestUnreachableURL] != nil;
+    bool handlingUnreachableURL = false;
+
+    // FIXME: need a better way to handle data loads
+    handlingUnreachableURL = [req.nsURLRequest() _webDataRequestUnreachableURL];
+
     if (handlingUnreachableURL)
         m_committed = false;
 
@@ -212,17 +204,13 @@ void DocumentLoader::setRequest(NSURLRequest *req)
     // would be a WebFoundation bug if it sent a redirect callback after commit.
     ASSERT(!m_committed);
 
-    NSURLRequest *oldRequest = [m_request.get() retain];
-    NSMutableURLRequest *copy = [req mutableCopy];
-    m_request = copy;
-    [copy release];
+    KURL oldURL = m_request.url();
+    m_request = req;
 
     // Only send webView:didReceiveServerRedirectForProvisionalLoadForFrame: if URL changed.
     // Also, don't send it when replacing unreachable URLs with alternate content.
-    if (!handlingUnreachableURL && ![[oldRequest URL] isEqual:[req URL]])
+    if (!handlingUnreachableURL && oldURL.url() != req.url().url())
         frameLoader()->didReceiveServerRedirectForProvisionalLoadForFrame();
-
-    [oldRequest release];
 }
 
 void DocumentLoader::setResponse(NSURLResponse *resp)
@@ -287,11 +275,12 @@ void DocumentLoader::stopLoading()
     else if (frameLoader->isLoadingSubresources())
         // The main resource loader already finished loading. Set the cancelled error on the 
         // document and let the subresourceLoaders send individual cancelled messages below.
-        setMainDocumentError(frameLoader->cancelledError(m_request.get()));
+
+        setMainDocumentError(frameLoader->cancelledError(m_request.nsURLRequest()));
     else
         // If there are no resource loaders, we need to manufacture a cancelled message.
         // (A back/forward navigation has no resource loaders because its resources are cached.)
-        mainReceivedError(frameLoader->cancelledError(m_request.get()), true);
+        mainReceivedError(frameLoader->cancelledError(m_request.nsURLRequest()), true);
     
     frameLoader->stopLoadingSubresources();
     frameLoader->stopLoadingPlugIns();
@@ -500,18 +489,14 @@ String DocumentLoader::title() const
     return m_pageTitle;
 }
 
-void DocumentLoader::setLastCheckedRequest(NSURLRequest *req)
+void DocumentLoader::setLastCheckedRequest(const ResourceRequest& req)
 {
-    NSURLRequest *copy = [req copy];
     m_lastCheckedRequest = req;
-    [copy release];
 }
 
-NSURLRequest *DocumentLoader::lastCheckedRequest() const
+const ResourceRequest& DocumentLoader::lastCheckedRequest() const
 {
-    // It's OK not to make a copy here because we know the caller
-    // isn't going to modify this request
-    return [[m_lastCheckedRequest.get() retain] autorelease];
+    return m_lastCheckedRequest;
 }
 
 const NavigationAction& DocumentLoader::triggeringAction() const
@@ -557,10 +542,13 @@ KURL DocumentLoader::URLForHistory() const
     // Return the URL to be used for history and B/F list.
     // Returns nil for WebDataProtocol URLs that aren't alternates 
     // for unreachable URLs, because these can't be stored in history.
-    NSURL *URL = [m_originalRequestCopy.get() URL];
-    if ([WebDataProtocol _webIsDataProtocolURL:URL])
-        URL = [m_originalRequestCopy.get() _webDataRequestUnreachableURL];
-    return URL;
+
+    KURL url = [m_originalRequestCopy.nsURLRequest() _webDataRequestUnreachableURL];
+
+    if (url.isEmpty())
+        url = m_originalRequestCopy.url();
+
+    return url;
 }
 
 }
index 6618e628ec4c0853eddd7b67828056d134cea461..c99da5438f7d08224b5627dd2415c7588d0b1ec6 100644 (file)
@@ -118,11 +118,12 @@ void FrameLoader::load(const KURL& URL, const String& referrer, FrameLoadType ne
 {
     bool isFormSubmission = !values.isEmpty();
     
-    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:URL.getNSURL()];
-    setHTTPReferrer(request, referrer);
+    ResourceRequest request(URL);
+    if (!referrer.isEmpty())
+        request.setHTTPReferrer(referrer);
     addExtraFieldsToRequest(request, true, event || isFormSubmission);
     if (newLoadType == FrameLoadTypeReload)
-        [request setCachePolicy:NSURLRequestReloadIgnoringCacheData];
+        request.setCachePolicy(ReloadIgnoringCacheData);
 
     ASSERT(newLoadType != FrameLoadTypeSame);
 
@@ -137,7 +138,6 @@ void FrameLoader::load(const KURL& URL, const String& referrer, FrameLoadType ne
             targetFrame->loader()->load(URL, referrer, newLoadType, String(), event, form, values);
         else
             checkNewWindowPolicy(action, request, formState.release(), frameName);
-        [request release];
         return;
     }
 
@@ -182,18 +182,16 @@ void FrameLoader::load(const KURL& URL, const String& referrer, FrameLoadType ne
             // frame, where the user has clicked on the same link repeatedly.
             m_loadType = FrameLoadTypeSame;
     }
-    
-    [request release];
 }
 
-void FrameLoader::load(NSURLRequest *request)
+void FrameLoader::load(const ResourceRequest& request)
 {
     // FIXME: is this the right place to reset loadType? Perhaps this should be done after loading is finished or aborted.
     m_loadType = FrameLoadTypeStandard;
     load(m_client->createDocumentLoader(request).get());
 }
 
-void FrameLoader::load(NSURLRequest *request, const String& frameName)
+void FrameLoader::load(const ResourceRequest& request, const String& frameName)
 {
     if (frameName.isEmpty()) {
         load(request);
@@ -206,11 +204,10 @@ void FrameLoader::load(NSURLRequest *request, const String& frameName)
         return;
     }
 
-    checkNewWindowPolicy(NavigationAction([request URL], NavigationTypeOther),
-        request, 0, frameName);
+    checkNewWindowPolicy(NavigationAction(request.url(), NavigationTypeOther), request, 0, frameName);
 }
 
-void FrameLoader::load(NSURLRequest *request, const NavigationAction& action, FrameLoadType type, PassRefPtr<FormState> formState)
+void FrameLoader::load(const ResourceRequest& request, const NavigationAction& action, FrameLoadType type, PassRefPtr<FormState> formState)
 {
     RefPtr<DocumentLoader> loader = m_client->createDocumentLoader(request);
     setPolicyDocumentLoader(loader.get());
@@ -227,11 +224,11 @@ void FrameLoader::load(DocumentLoader* newDocumentLoader)
     stopPolicyCheck();
     setPolicyDocumentLoader(newDocumentLoader);
 
-    NSMutableURLRequest *r = newDocumentLoader->request();
+    ResourceRequest& r = newDocumentLoader->request();
     addExtraFieldsToRequest(r, true, false);
     FrameLoadType type;
-    if (m_client->shouldTreatURLAsSameAsCurrent([newDocumentLoader->originalRequest() URL])) {
-        [r setCachePolicy:NSURLRequestReloadIgnoringCacheData];
+    if (m_client->shouldTreatURLAsSameAsCurrent(newDocumentLoader->originalRequest().url())) {
+        r.setCachePolicy(ReloadIgnoringCacheData);
         type = FrameLoadTypeSame;
     } else
         type = FrameLoadTypeStandard;
@@ -283,16 +280,17 @@ bool FrameLoader::canLoad(NSURL *URL, const String& referrer, bool& hideReferrer
     return !URLIsFileURL || referrerIsLocalURL;
 }
 
-bool FrameLoader::startLoadingMainResource(NSMutableURLRequest *request, id identifier)
+bool FrameLoader::startLoadingMainResource(ResourceRequest& request, id identifier)
 {
     ASSERT(!m_mainResourceLoader);
     m_mainResourceLoader = MainResourceLoader::create(m_frame);
     m_mainResourceLoader->setIdentifier(identifier);
+    // FIXME: is there any way the extra fields could have not been added by now?
     addExtraFieldsToRequest(request, true, false);
-    if (!m_mainResourceLoader->load(request)) {
+    if (!m_mainResourceLoader->load(request.nsURLRequest())) {
         // FIXME: If this should really be caught, we should just ASSERT this doesn't happen;
         // should it be caught by other parts of WebKit or other parts of the app?
-        LOG_ERROR("could not create WebResourceHandle for URL %@ -- should be caught by policy handler level", [request URL]);
+        LOG_ERROR("could not create WebResourceHandle for URL %@ -- should be caught by policy handler level", request.url().getNSURL());
         m_mainResourceLoader = 0;
         return false;
     }
@@ -344,6 +342,13 @@ void FrameLoader::applyUserAgent(NSMutableURLRequest *request)
     [request setValue:lastUserAgentNSString.get() forHTTPHeaderField:@"User-Agent"];
 }
 
+void FrameLoader::applyUserAgent(ResourceRequest& request)
+{
+    String userAgent = client()->userAgent();
+    ASSERT(!userAgent.isNull());
+    request.setHTTPUserAgent(userAgent);
+}
+
 NSURLRequest *FrameLoader::willSendRequest(ResourceLoader* loader, NSMutableURLRequest *clientRequest, NSURLResponse *redirectResponse)
 {
     applyUserAgent(clientRequest);
@@ -381,7 +386,7 @@ void FrameLoader::didFailToLoad(ResourceLoader* loader, NSError *error)
         m_client->dispatchDidFailLoading(activeDocumentLoader(), loader->identifier(), error);
 }
 
-NSURLRequest *FrameLoader::originalRequest() const
+const ResourceRequest& FrameLoader::originalRequest() const
 {
     return activeDocumentLoader()->originalRequestCopy();
 }
@@ -403,7 +408,7 @@ void FrameLoader::receivedMainResourceError(NSError *error, bool isComplete)
     
     if (m_state == FrameStateProvisional) {
 #ifdef MULTIPLE_FORM_SUBMISSION_PROTECTION
-        NSURL *failedURL = [m_provisionalDocumentLoader->originalRequestCopy() URL];
+        KURL failedURL = m_provisionalDocumentLoader->originalRequestCopy().url();
         didNotOpenURL(failedURL);
 #endif
         // We might have made a page cache item, but now we're bailing out due to an error before we ever
@@ -428,18 +433,15 @@ void FrameLoader::receivedMainResourceError(NSError *error, bool isComplete)
 }
 
 void FrameLoader::callContinueFragmentScrollAfterNavigationPolicy(void* argument,
-    NSURLRequest *request, PassRefPtr<FormState>)
+    const ResourceRequest& request, PassRefPtr<FormState>, bool shouldContinue)
 {
     FrameLoader* loader = static_cast<FrameLoader*>(argument);
-    loader->continueFragmentScrollAfterNavigationPolicy(request);
+    loader->continueFragmentScrollAfterNavigationPolicy(request, shouldContinue);
 }
 
-void FrameLoader::continueFragmentScrollAfterNavigationPolicy(NSURLRequest *request)
+void FrameLoader::continueFragmentScrollAfterNavigationPolicy(const ResourceRequest& request, bool shouldContinue)
 {
-    if (!request)
-        return;
-    
-    NSURL *URL = [request URL];
+    KURL URL = request.url();
     
     bool isRedirect = m_quickRedirectComing;
     m_quickRedirectComing = false;
@@ -529,11 +531,16 @@ void FrameLoader::commitProvisionalLoad(NSDictionary *pageCache)
     } else {
         NSURLResponse *response = pdl->response();
     
-        NSURL *URL = [pdl->request() _webDataRequestBaseURL];
-        if (!URL)
+        KURL URL;
+#if PLATFORM(MAC)
+        if (WebDataRequestParameters* params = [pdl->request().nsURLRequest() _webDataRequestParametersForReading])
+            URL = params->baseURL;
+#endif
+
+        if (URL.isEmpty())
             URL = [response URL];
-        if (!URL || urlIsEmpty(URL))
-            URL = [NSURL URLWithString:@"about:blank"];    
+        if (URL.isEmpty())
+            URL = "about:blank";    
 
         m_responseMIMEType = [response MIMEType];
         if (didOpenURL(URL)) {
@@ -547,7 +554,7 @@ void FrameLoader::commitProvisionalLoad(NSDictionary *pageCache)
     opened();
 }
 
-NSURLRequest *FrameLoader::initialRequest() const
+const ResourceRequest& FrameLoader::initialRequest() const
 {
     return activeDocumentLoader()->initialRequest();
 }
@@ -557,7 +564,7 @@ void FrameLoader::receivedData(NSData *data)
     activeDocumentLoader()->receivedData(data);
 }
 
-void FrameLoader::setRequest(NSURLRequest *request)
+void FrameLoader::setRequest(const ResourceRequest& request)
 {
     activeDocumentLoader()->setRequest(request);
 }
@@ -604,8 +611,7 @@ NSError *FrameLoader::interruptionForPolicyChangeError(NSURLRequest *request)
     return m_client->interruptForPolicyChangeError(request);
 }
 
-void FrameLoader::checkNavigationPolicy(NSURLRequest *newRequest,
-    NavigationPolicyDecisionFunction function, void* argument)
+void FrameLoader::checkNavigationPolicy(const ResourceRequest& newRequest, NavigationPolicyDecisionFunction function, void* argument)
 {
     checkNavigationPolicy(newRequest, activeDocumentLoader(), 0, function, argument);
 }
@@ -617,10 +623,14 @@ void FrameLoader::checkContentPolicy(const String& MIMEType, ContentPolicyDecisi
         MIMEType, activeDocumentLoader()->request());
 }
 
-bool FrameLoader::shouldReloadToHandleUnreachableURL(NSURLRequest *request)
+bool FrameLoader::shouldReloadToHandleUnreachableURL(const ResourceRequest& request)
 {
-    NSURL *unreachableURL = [request _webDataRequestUnreachableURL];
-    if (unreachableURL == nil)
+    KURL unreachableURL;
+#if PLATFORM(MAC)
+    unreachableURL = [request.nsURLRequest() _webDataRequestUnreachableURL];
+#endif
+
+    if (unreachableURL.isEmpty())
         return false;
 
     if (!isBackForwardLoadType(m_policyLoadType))
@@ -637,7 +647,7 @@ bool FrameLoader::shouldReloadToHandleUnreachableURL(NSURLRequest *request)
     else if (m_delegateIsHandlingProvisionalLoadError)
         compareDocumentLoader = m_provisionalDocumentLoader.get();
 
-    return compareDocumentLoader && [unreachableURL isEqual:[compareDocumentLoader->request() URL]];
+    return compareDocumentLoader && unreachableURL != compareDocumentLoader->request().url();
 }
 
 void FrameLoader::reloadAllowingStaleData(const String& encoding)
@@ -645,18 +655,16 @@ void FrameLoader::reloadAllowingStaleData(const String& encoding)
     if (!m_documentLoader)
         return;
 
-    NSMutableURLRequest *request = [m_documentLoader->request() mutableCopy];
+    ResourceRequest request = m_documentLoader->request();
     KURL unreachableURL = m_documentLoader->unreachableURL();
     if (!unreachableURL.isEmpty())
-        [request setURL:unreachableURL.getNSURL()];
+        request.setURL(unreachableURL);
 
-    [request setCachePolicy:NSURLRequestReturnCacheDataElseLoad];
+    request.setCachePolicy(ReturnCacheDataElseLoad);
 
     RefPtr<DocumentLoader> loader = m_client->createDocumentLoader(request);
     setPolicyDocumentLoader(loader.get());
 
-    [request release];
-
     loader->setOverrideEncoding(encoding);
 
     load(loader.get(), FrameLoadTypeReloadAllowingStaleData, 0);
@@ -667,28 +675,31 @@ void FrameLoader::reload()
     if (!m_documentLoader)
         return;
 
-    NSMutableURLRequest *initialRequest = m_documentLoader->request();
+    ResourceRequest& initialRequest = m_documentLoader->request();
     
     // If a window is created by javascript, its main frame can have an empty but non-nil URL.
     // Reloading in this case will lose the current contents (see 4151001).
-    if ([[[initialRequest URL] absoluteString] length] == 0)
+    if (initialRequest.url().isEmpty())
         return;
 
     // Replace error-page URL with the URL we were trying to reach.
-    NSURL *unreachableURL = [initialRequest _webDataRequestUnreachableURL];
-    if (unreachableURL != nil)
-        initialRequest = [NSURLRequest requestWithURL:unreachableURL];
+    KURL unreachableURL;
+#if PLATFORM(MAC)
+    unreachableURL = [initialRequest.nsURLRequest() _webDataRequestUnreachableURL];
+#endif
+    if (!unreachableURL.isEmpty())
+        initialRequest = ResourceRequest(unreachableURL);
     
     RefPtr<DocumentLoader> loader = m_client->createDocumentLoader(initialRequest);
     setPolicyDocumentLoader(loader.get());
 
-    NSMutableURLRequest *request = loader->request();
+    ResourceRequest& request = loader->request();
 
-    [request setCachePolicy:NSURLRequestReloadIgnoringCacheData];
+    request.setCachePolicy(ReloadIgnoringCacheData);
 
     // If we're about to re-post, set up action so the application can warn the user.
-    if ([[request HTTPMethod] isEqualToString:@"POST"])
-        loader->setTriggeringAction(NavigationAction([request URL], NavigationTypeFormResubmitted));
+    if (request.httpMethod() == "POST")
+        loader->setTriggeringAction(NavigationAction(request.url(), NavigationTypeFormResubmitted));
 
     loader->setOverrideEncoding(m_documentLoader->overrideEncoding());
     
@@ -727,7 +738,7 @@ void FrameLoader::didChangeTitle(DocumentLoader* loader)
         }
 }
 
-void FrameLoader::checkNewWindowPolicy(const NavigationAction& action, NSURLRequest *request,
+void FrameLoader::checkNewWindowPolicy(const NavigationAction& action, const ResourceRequest& request,
     PassRefPtr<FormState> formState, const String& frameName)
 {
     m_policyCheck.set(request, formState, frameName,
@@ -753,33 +764,35 @@ void FrameLoader::continueAfterNewWindowPolicy(PolicyAction policy)
             break;
     }
 
-    check.call();
+    check.call(policy == PolicyUse);
 }
 
-void FrameLoader::checkNavigationPolicy(NSURLRequest *request, DocumentLoader* loader,
+void FrameLoader::checkNavigationPolicy(const ResourceRequest& request, DocumentLoader* loader,
     PassRefPtr<FormState> formState, NavigationPolicyDecisionFunction function, void* argument)
 {
     NavigationAction action = loader->triggeringAction();
     if (action.isEmpty()) {
-        action = NavigationAction([request URL], NavigationTypeOther);
+        action = NavigationAction(request.url(), NavigationTypeOther);
         loader->setTriggeringAction(action);
     }
         
     // Don't ask more than once for the same request or if we are loading an empty URL.
     // This avoids confusion on the part of the client.
-    if ([request isEqual:loader->lastCheckedRequest()] || urlIsEmpty([request URL])) {
-        function(argument, request, 0);
+    if (request == loader->lastCheckedRequest() || request.url().isEmpty()) {
+        function(argument, request, 0, true);
         return;
     }
     
     // We are always willing to show alternate content for unreachable URLs;
     // treat it like a reload so it maintains the right state for b/f list.
-    if ([request _webDataRequestUnreachableURL] != nil) {
+#if PLATFORM(MAC)
+    if ([request.nsURLRequest() _webDataRequestUnreachableURL]) {
         if (isBackForwardLoadType(m_policyLoadType))
             m_policyLoadType = FrameLoadTypeReload;
-        function(argument, request, 0);
+        function(argument, request, 0, true);
         return;
     }
+#endif
     
     loader->setLastCheckedRequest(request);
 
@@ -814,18 +827,17 @@ void FrameLoader::continueAfterNavigationPolicy(PolicyAction policy)
         }
     }
 
-    check.call();
+    check.call(policy == PolicyUse);
 }
 
 void FrameLoader::callContinueLoadAfterNavigationPolicy(void* argument,
-    NSURLRequest *request, PassRefPtr<FormState> formState)
+    const ResourceRequest& request, PassRefPtr<FormState> formState, bool shouldContinue)
 {
     FrameLoader* loader = static_cast<FrameLoader*>(argument);
-    loader->continueLoadAfterNavigationPolicy(request, formState);
+    loader->continueLoadAfterNavigationPolicy(request, formState, shouldContinue);
 }
 
-void FrameLoader::continueLoadAfterNavigationPolicy(NSURLRequest *request,
-    PassRefPtr<FormState> formState)
+void FrameLoader::continueLoadAfterNavigationPolicy(const ResourceRequest& request, PassRefPtr<FormState> formState, bool shouldContinue)
 {
     // If we loaded an alternate page to replace an unreachableURL, we'll get in here with a
     // nil policyDataSource because loading the alternate page will have passed
@@ -839,7 +851,7 @@ void FrameLoader::continueLoadAfterNavigationPolicy(NSURLRequest *request,
     //       is the user responding Cancel to the form repost nag sheet.
     //    2) User responded Cancel to an alert popped up by the before unload event handler.
     // The "before unload" event handler runs only for the main frame.
-    bool canContinue = request && (!isLoadingMainFrame() || Mac(m_frame)->shouldClose());
+    bool canContinue = shouldContinue && (!isLoadingMainFrame() || Mac(m_frame)->shouldClose());
 
     if (!canContinue) {
         // If we were waiting for a quick redirect, but the policy delegate decided to ignore it, then we 
@@ -990,7 +1002,7 @@ void FrameLoader::checkLoadCompleteForThisFrame()
                     clearProvisionalLoad();
                 else if (m_documentLoader) {
                     KURL unreachableURL = m_documentLoader->unreachableURL();
-                    if (!unreachableURL.isEmpty() && unreachableURL == [pdl->request() URL])
+                    if (!unreachableURL.isEmpty() && unreachableURL == pdl->request().url())
                         shouldReset = false;
                 }
             }
@@ -1040,16 +1052,16 @@ void FrameLoader::checkLoadCompleteForThisFrame()
 }
 
 void FrameLoader::callContinueLoadAfterNewWindowPolicy(void* argument,
-    NSURLRequest *request, PassRefPtr<FormState> formState, const String& frameName)
+    const ResourceRequest& request, PassRefPtr<FormState> formState, const String& frameName, bool shouldContinue)
 {
     FrameLoader* loader = static_cast<FrameLoader*>(argument);
-    loader->continueLoadAfterNewWindowPolicy(request, formState, frameName);
+    loader->continueLoadAfterNewWindowPolicy(request, formState, frameName, shouldContinue);
 }
 
-void FrameLoader::continueLoadAfterNewWindowPolicy(NSURLRequest *request,
-    PassRefPtr<FormState> formState, const String& frameName)
+void FrameLoader::continueLoadAfterNewWindowPolicy(const ResourceRequest& request,
+    PassRefPtr<FormState> formState, const String& frameName, bool shouldContinue)
 {
-    if (!request)
+    if (!shouldContinue)
         return;
 
     RefPtr<Frame> frame = m_frame;
@@ -1112,13 +1124,14 @@ void FrameLoader::post(const KURL& URL, const String& referrer, const String& fr
 
     // FIXME: Where's the code that implements what the comment above says?
 
-    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:URL.getNSURL()];
+    ResourceRequest request(URL);
     addExtraFieldsToRequest(request, true, true);
 
-    setHTTPReferrer(request, referrer);
-    [request setHTTPMethod:@"POST"];
-    setHTTPBody(request, formData);
-    [request setValue:contentType forHTTPHeaderField:@"Content-Type"];
+    if (!referrer.isEmpty())
+        request.setHTTPReferrer(referrer);
+    request.setHTTPMethod("POST");
+    request.setHTTPBody(formData);
+    request.setHTTPContentType(contentType);
 
     NavigationAction action(URL, FrameLoadTypeStandard, true, event);
 
@@ -1133,8 +1146,25 @@ void FrameLoader::post(const KURL& URL, const String& referrer, const String& fr
             checkNewWindowPolicy(action, request, formState.release(), frameName);
     } else
         load(request, action, FrameLoadTypeStandard, formState.release());
+}
 
-    [request release];
+void FrameLoader::addExtraFieldsToRequest(ResourceRequest& request, bool mainResource, bool alwaysFromRequest)
+{
+    applyUserAgent(request);
+    
+    if (m_loadType == FrameLoadTypeReload)
+        request.setHTTPHeaderField("Cache-Control", "max-age=0");
+    
+    // Don't set the cookie policy URL if it's already been set.
+    if (request.mainDocumentURL().isEmpty()) {
+        if (mainResource && (isLoadingMainFrame() || alwaysFromRequest))
+            request.setMainDocumentURL(request.url());
+        else
+            request.setMainDocumentURL(m_frame->page()->mainFrame()->loader()->url());
+    }
+    
+    if (mainResource)
+        request.setHTTPAccept("text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5");
 }
 
 void FrameLoader::addExtraFieldsToRequest(NSMutableURLRequest *request, bool mainResource, bool alwaysFromRequest)
@@ -1158,21 +1188,18 @@ void FrameLoader::addExtraFieldsToRequest(NSMutableURLRequest *request, bool mai
 
 bool FrameLoader::isReloading() const
 {
-    return [documentLoader()->request() cachePolicy] == NSURLRequestReloadIgnoringCacheData;
+    return documentLoader()->request().cachePolicy() == ReloadIgnoringCacheData;
 }
 
 String FrameLoader::referrer() const
 {
-    return [documentLoader()->request() valueForHTTPHeaderField:@"Referer"];
+    return documentLoader()->request().httpReferrer();
 }
 
 void FrameLoader::loadEmptyDocumentSynchronously()
 {
-    NSURL *url = [[NSURL alloc] initWithString:@""];
-    NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
+    ResourceRequest request(KURL(""));
     load(request);
-    [request release];
-    [url release];
 }
 
 void FrameLoader::loadResourceSynchronously(const ResourceRequest& request, Vector<char>& data, ResourceResponse& r)
@@ -1203,12 +1230,12 @@ void FrameLoader::loadResourceSynchronously(const ResourceRequest& request, Vect
     if (isConditionalRequest(initialRequest))
         [initialRequest setCachePolicy:NSURLRequestReloadIgnoringCacheData];
     else
-        [initialRequest setCachePolicy:[documentLoader()->request() cachePolicy]];
+        [initialRequest setCachePolicy:(NSURLRequestCachePolicy)documentLoader()->request().cachePolicy()];
     
     if (!referrer.isEmpty())
         setHTTPReferrer(initialRequest, referrer);
     
-    [initialRequest setMainDocumentURL:[m_frame->page()->mainFrame()->loader()->documentLoader()->request() URL]];
+    [initialRequest setMainDocumentURL:m_frame->page()->mainFrame()->loader()->documentLoader()->request().url().getNSURL()];
     applyUserAgent(initialRequest);
     
     NSError *error = nil;
@@ -1386,7 +1413,7 @@ bool FrameLoader::canGoBackOrForward(int distance) const
 
 KURL FrameLoader::originalRequestURL() const
 {
-    return [activeDocumentLoader()->initialRequest() URL];
+    return activeDocumentLoader()->initialRequest().url();
 }
 
 int FrameLoader::getHistoryLength()
@@ -1440,7 +1467,7 @@ void PolicyCheck::clear()
     m_contentFunction = 0;
 }
 
-void PolicyCheck::set(NSURLRequest *request, PassRefPtr<FormState> formState,
+void PolicyCheck::set(const ResourceRequest& request, PassRefPtr<FormState> formState,
     NavigationPolicyDecisionFunction function, void* argument)
 {
     m_request = request;
@@ -1453,7 +1480,7 @@ void PolicyCheck::set(NSURLRequest *request, PassRefPtr<FormState> formState,
     m_argument = argument;
 }
 
-void PolicyCheck::set(NSURLRequest *request, PassRefPtr<FormState> formState,
+void PolicyCheck::set(const ResourceRequest& request, PassRefPtr<FormState> formState,
     const String& frameName, NewWindowPolicyDecisionFunction function, void* argument)
 {
     m_request = request;
@@ -1468,7 +1495,7 @@ void PolicyCheck::set(NSURLRequest *request, PassRefPtr<FormState> formState,
 
 void PolicyCheck::set(ContentPolicyDecisionFunction function, void* argument)
 {
-    m_request = nil;
+    m_request = ResourceRequest();
     m_formState = 0;
     m_frameName = String();
 
@@ -1478,12 +1505,12 @@ void PolicyCheck::set(ContentPolicyDecisionFunction function, void* argument)
     m_argument = argument;
 }
 
-void PolicyCheck::call()
+void PolicyCheck::call(bool shouldContinue)
 {
     if (m_navigationFunction)
-        m_navigationFunction(m_argument, m_request.get(), m_formState.get());
+        m_navigationFunction(m_argument, m_request, m_formState.get(), shouldContinue);
     if (m_newWindowFunction)
-        m_newWindowFunction(m_argument, m_request.get(), m_formState.get(), m_frameName);
+        m_newWindowFunction(m_argument, m_request, m_formState.get(), m_frameName, shouldContinue);
     ASSERT(!m_contentFunction);
 }
 
@@ -1497,7 +1524,7 @@ void PolicyCheck::call(PolicyAction action)
 
 void PolicyCheck::clearRequest()
 {
-    m_request = nil;
+    m_request = ResourceRequest();
     m_formState = 0;
     m_frameName = String();
 }
index 6773f93000cdfadb64b52b0df0c4f1698ca2834d..4d1371bdc04eb8eaa8e0388a2cd752d015bfcf99 100644 (file)
@@ -112,14 +112,14 @@ void MainResourceLoader::stopLoadingForPolicyChange()
     cancel(interruptionForPolicyChangeError());
 }
 
-void MainResourceLoader::callContinueAfterNavigationPolicy(void* argument, NSURLRequest *request, PassRefPtr<FormState>)
+void MainResourceLoader::callContinueAfterNavigationPolicy(void* argument, const ResourceRequest& request, PassRefPtr<FormState>, bool shouldContinue)
 {
-    static_cast<MainResourceLoader*>(argument)->continueAfterNavigationPolicy(request);
+    static_cast<MainResourceLoader*>(argument)->continueAfterNavigationPolicy(request, shouldContinue);
 }
 
-void MainResourceLoader::continueAfterNavigationPolicy(NSURLRequest *request)
+void MainResourceLoader::continueAfterNavigationPolicy(const ResourceRequest& request, bool shouldContinue)
 {
-    if (!request)
+    if (!shouldContinue)
         stopLoadingForPolicyChange();
     deref(); // balances ref in willSendRequest
 }
@@ -132,7 +132,7 @@ bool MainResourceLoader::isPostOrRedirectAfterPost(NSURLRequest *newRequest, NSU
     if (redirectResponse && [redirectResponse isKindOfClass:[NSHTTPURLResponse class]]) {
         int status = [(NSHTTPURLResponse *)redirectResponse statusCode];
         if (((status >= 301 && status <= 303) || status == 307)
-                && [[frameLoader()->initialRequest() HTTPMethod] isEqualToString:@"POST"])
+            && frameLoader()->initialRequest().httpMethod() == "POST")
             return true;
     }
     
index a1af0a1788408d61aa904f578bde88d31f900e23..fbf371775f26f839e3175a8a41689252a72a6158 100644 (file)
@@ -108,7 +108,7 @@ PassRefPtr<SubresourceLoader> SubresourceLoader::create(Frame* frame, Subresourc
     if (isConditionalRequest(newNSURLRequest))
         [newNSURLRequest setCachePolicy:NSURLRequestReloadIgnoringCacheData];
     else
-        [newNSURLRequest setCachePolicy:[fl->originalRequest() cachePolicy]];
+        [newNSURLRequest setCachePolicy:(NSURLRequestCachePolicy)fl->originalRequest().cachePolicy()];
     
     fl->addExtraFieldsToRequest(newNSURLRequest, false, false);
 
index 665b739f3b7f85a79e581ac6046428f5f390fe95..45373c468af3ef5667267f46625d74a8d9e04b9a 100644 (file)
 #import <Foundation/NSURLProtocol.h>
 
 
+extern NSString *WebDataRequestPropertyKey;
+
+@interface WebDataRequestParameters : NSObject <NSCopying>
+{
+@public
+    NSData *data;
+    NSString *MIMEType;
+    NSString *encoding;
+    NSURL *baseURL;
+    NSURL *unreachableURL;
+}
+@end
+
 @interface WebDataProtocol : NSURLProtocol
 {
 }
@@ -44,6 +57,7 @@
 @end
 
 @interface NSURLRequest (WebDataRequest)
+- (WebDataRequestParameters *)_webDataRequestParametersForReading;
 + (NSString *)_webDataRequestPropertyKey;
 - (NSURL *)_webDataRequestBaseURL;
 - (NSURL *)_webDataRequestUnreachableURL;
index 72dae55af33fee0c0b5349fd7d4e0098200cf3a1..afc27d3275cf9f75d561212a49d96e30fa53caec 100644 (file)
 #import <wtf/Assertions.h>
 
 NSString *WebDataProtocolScheme = @"applewebdata";
-static NSString *WebDataRequestPropertyKey = @"WebDataRequest";
-
-@interface WebDataRequestParameters : NSObject <NSCopying>
-{
-@public
-    NSData *data;
-    NSString *MIMEType;
-    NSString *encoding;
-    NSURL *baseURL;
-    NSURL *unreachableURL;
-}
-@end
+NSString *WebDataRequestPropertyKey = @"WebDataRequest";
 
 @implementation WebDataRequestParameters
 
index ca031b39004509ff5d6075a76b062939907483c6..e734138d9e58ecbbfdbbec47ee32c03705a72bfe 100644 (file)
@@ -50,6 +50,8 @@ namespace WebCore {
     class TextEncoding;
 
     bool operator==(const KURL&, const KURL&);
+    inline bool operator!=(const KURL &a, const KURL &b) { return !(a == b); }
+
     bool equalIgnoringRef(const KURL&, const KURL&);
 
 class KURL {
index 744d807177a03615d9638ef31d4b552b0ab64dd3..13ab95905bf5abcef4b45cbc61d82c65ab760cbe 100644 (file)
@@ -55,6 +55,10 @@ KURL::KURL(NSURL *url)
 
 NSURL *KURL::getNSURL() const
 {
+    // FIXME: CFURL can't hold an empty URL, unlike NSURL
+    if (isEmpty())
+        return [NSURL URLWithString:@""];
+
     return HardAutorelease(createCFURL());
 }
 
index 8ba2d3936a8ecf332b2ee5f61a267f46e294d35a..6bd582312128febaca2303b4895048386bc368da 100644 (file)
@@ -37,6 +37,23 @@ public:
     String m_filename;
 };
 
+inline bool operator==(const FormDataElement& a, const FormDataElement& b)
+{
+    if (a.m_type != b.m_type)
+        return false;
+    if (a.m_data != b.m_data)
+        return false;
+    if (a.m_filename != b.m_filename)
+        return false;
+
+    return true;
+}
+inline bool operator!=(const FormDataElement& a, const FormDataElement& b)
+{
+    return !(a == b);
+}
 class FormData : public Shared<FormData> {
 public:
     FormData() { } 
@@ -56,6 +73,16 @@ private:
      Vector<FormDataElement> m_elements;
 };
 
+inline bool operator==(const FormData& a, const FormData& b)
+{
+    return a.elements() == b.elements();
+}
+
+inline bool operator!=(const FormData& a, const FormData& b)
+{
+    return a.elements() != b.elements();
+}
+
 } // namespace WebCore
 
 #endif
index 239727905e639fe815842cc35acd4570f2301b20..73809ab719b5c488051e5ef396f9c62baa57a540 100644 (file)
@@ -207,4 +207,34 @@ void ResourceRequest::addHTTPHeaderFields(const HTTPHeaderMap& headerFields)
         addHTTPHeaderField(it->first, it->second);
 }
 
+
+bool operator==(const ResourceRequest& a, const ResourceRequest& b)
+{
+    if (a.url() != b.url())
+        return false;
+
+    if (a.cachePolicy() != b.cachePolicy())
+        return false;
+
+    if (a.timeoutInterval() != b.timeoutInterval())
+        return false;
+    if (a.mainDocumentURL() != b.mainDocumentURL())
+        return false;
+
+    if (a.httpMethod() != b.httpMethod())
+        return false;
+
+    if (a.httpBody() != b.httpBody())
+        return false;
+
+    if (a.allowHTTPCookies() != b.allowHTTPCookies())
+        return false;
+
+    if (a.httpHeaderFields() != b.httpHeaderFields())
+        return false;
+
+     return true;
+}
+
 }
index 2b680d567abf2aed8f4a712014e06e909246dd57..063592145da306094c9e14f52f0359d832751f3f 100644 (file)
@@ -127,7 +127,7 @@ namespace WebCore {
         void setHTTPContentType(const String& httpContentType) { setHTTPHeaderField("Content-Type", httpContentType); }
         
         String httpReferrer() const { return httpHeaderField("Referer"); }
-        void setHTTPReferrer(const String& httpReferrer) { setHTTPHeaderField("Referer", httpReferrer); }
+        void ResourceRequest::setHTTPReferrer(const String& httpReferrer) { setHTTPHeaderField("Referer", httpReferrer); }
         
         String httpUserAgent() const { return httpHeaderField("User-Agent"); }
         void setHTTPUserAgent(const String& httpUserAgent) { setHTTPHeaderField("User-Agent", httpUserAgent); }
@@ -185,6 +185,8 @@ namespace WebCore {
 #endif
     };
 
+    bool operator==(const ResourceRequest& a, const ResourceRequest& b);
+
 } // namespace WebCore
 
 #endif // ResourceRequest_H_
index 3ccf8e17ad71b2ea261a8ad136f4c34ff64e909d..c84cdcb13336e36961b577a071140fd52a859c72 100644 (file)
@@ -26,6 +26,8 @@
 
 #import "config.h"
 #import "ResourceRequest.h"
+#import "WebCoreSystemInterface.h"
+#import "WebDataProtocol.h"
 
 #import "FormDataStreamMac.h"
 
@@ -66,7 +68,12 @@ void ResourceRequest::doUpdateResourceRequest()
 
 void ResourceRequest::doUpdatePlatformRequest()
 {
-    NSMutableURLRequest* nsRequest = [[NSMutableURLRequest alloc] initWithURL:url().getNSURL()];
+    NSMutableURLRequest* nsRequest = [m_nsRequest.get() mutableCopy];
+
+    if (nsRequest)
+        [nsRequest setURL:url().getNSURL()];
+    else
+        nsRequest = [[NSMutableURLRequest alloc] initWithURL:url().getNSURL()];
     
     [nsRequest setCachePolicy:(NSURLRequestCachePolicy)cachePolicy()];
     [nsRequest setTimeoutInterval:timeoutInterval()];
index a7eccb695d08a07f3420258ec968f34fc9374f0e..73f901506e9245626f22610c9d641f0955439849 100644 (file)
@@ -1,3 +1,32 @@
+2006-12-13  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Anders.
+        
+        - adjusted for changes from NSURLRequest to ResourceRequest
+
+        * Plugins/WebPluginController.mm:
+        * WebCoreSupport/WebFrameLoaderClient.h:
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (WebFrameLoaderClient::updateHistoryForReload):
+        (WebFrameLoaderClient::dispatchIdentifierForInitialRequest):
+        (WebFrameLoaderClient::dispatchDecidePolicyForMIMEType):
+        (WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction):
+        (WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
+        (WebFrameLoaderClient::startDownload):
+        (WebFrameLoaderClient::cannotShowURLError):
+        (WebFrameLoaderClient::createDocumentLoader):
+        * WebView/WebDataSource.mm:
+        (-[WebDataSource _initWithDocumentLoader:]):
+        (-[WebDataSource initialRequest]):
+        (-[WebDataSource request]):
+        * WebView/WebDocumentLoaderMac.h:
+        * WebView/WebDocumentLoaderMac.mm:
+        (WebDocumentLoaderMac::WebDocumentLoaderMac):
+        * WebView/WebFrame.mm:
+        (-[WebFrame _createItem:]):
+        (-[WebFrame _loadItem:withLoadType:]):
+        (-[WebFrame loadArchive:]):
+
 2006-12-12  Anders Carlsson  <acarlsson@apple.com>
 
         Reviewed by Darin.
index f13b80019afe8baf9b9e8ffccc38ed298ba99c76..b47bca0de642277995a08683d6cda6b20e359907 100644 (file)
@@ -31,6 +31,7 @@
 
 #import <Foundation/NSURLRequest.h>
 #import <WebCore/FrameLoader.h>
+#import <WebCore/ResourceRequest.h>
 #import <WebCore/PlatformString.h>
 #import <WebCore/WebCoreFrameBridge.h>
 #import <WebCore/DocumentLoader.h>
index d5b17173174619bd5c1c1deee6bb35100f655017..2e99316a250c35b4408914156d69aea270db7de4 100644 (file)
@@ -100,6 +100,7 @@ private:
     virtual void download(WebCore::ResourceHandle*, NSURLRequest *, NSURLResponse *);
 
     virtual id dispatchIdentifierForInitialRequest(WebCore::DocumentLoader*, NSURLRequest *);
+    virtual id dispatchIdentifierForInitialRequest(WebCore::DocumentLoader*, const WebCore::ResourceRequest&);
     virtual NSURLRequest *dispatchWillSendRequest(WebCore::DocumentLoader*, id identifier, NSURLRequest *, NSURLResponse *redirectResponse);
     virtual void dispatchDidReceiveAuthenticationChallenge(WebCore::DocumentLoader*, id identifier, NSURLAuthenticationChallenge *);
     virtual void dispatchDidCancelAuthenticationChallenge(WebCore::DocumentLoader*, id identifier, NSURLAuthenticationChallenge *);
@@ -127,11 +128,11 @@ private:
     virtual void dispatchShow();
 
     virtual void dispatchDecidePolicyForMIMEType(WebCore::FramePolicyFunction,
-        const WebCore::String& MIMEType, NSURLRequest *);
+        const WebCore::String& MIMEType, const WebCore::ResourceRequest&);
     virtual void dispatchDecidePolicyForNewWindowAction(WebCore::FramePolicyFunction,
-        const WebCore::NavigationAction&, NSURLRequest *, const WebCore::String& frameName);
+        const WebCore::NavigationAction&, const WebCore::ResourceRequest&, const WebCore::String& frameName);
     virtual void dispatchDecidePolicyForNavigationAction(WebCore::FramePolicyFunction,
-        const WebCore::NavigationAction&, NSURLRequest *);
+        const WebCore::NavigationAction&, const WebCore::ResourceRequest&);
     virtual void cancelPolicyCheck();
 
     virtual void dispatchUnableToImplementPolicy(NSError *);
@@ -155,7 +156,7 @@ private:
 
     virtual void setMainFrameDocumentReady(bool);
 
-    virtual void startDownload(NSURLRequest *);
+    virtual void startDownload(const WebCore::ResourceRequest&);
 
     virtual void willChangeTitle(WebCore::DocumentLoader*);
     virtual void didChangeTitle(WebCore::DocumentLoader*);
@@ -165,7 +166,7 @@ private:
     virtual void finalSetupForReplace(WebCore::DocumentLoader*);
 
     virtual NSError *cancelledError(NSURLRequest *);
-    virtual NSError *cannotShowURLError(NSURLRequest *);
+    virtual NSError *cannotShowURLError(const WebCore::ResourceRequest&);
     virtual NSError *interruptForPolicyChangeError(NSURLRequest *);
 
     virtual NSError *cannotShowMIMETypeError(NSURLResponse *);
@@ -194,7 +195,7 @@ private:
     virtual void addHistoryItemForFragmentScroll();
     virtual void didFinishLoad();
     virtual void prepareForDataSourceReplacement();
-    virtual PassRefPtr<WebCore::DocumentLoader> createDocumentLoader(NSURLRequest *);
+    virtual PassRefPtr<WebCore::DocumentLoader> createDocumentLoader(const WebCore::ResourceRequest&);
     virtual void setTitle(const WebCore::String& title, const WebCore::KURL&);
 
     void deliverArchivedResourcesAfterDelay() const;
index 5bf5cdccac63836d905d6e06ebcbe1d404580cb7..08e6d86455e935f1e498fa594b18a83f0c05f4f4 100644 (file)
@@ -281,7 +281,7 @@ void WebFrameLoaderClient::updateHistoryForReload()
     if ([request _webDataRequestUnreachableURL] == nil)
         [currItem setURL:[request URL]];
     // Update the last visited time. Mostly interesting for URL autocompletion statistics.
-    NSURL *URL = [[[dataSource _documentLoader]->originalRequestCopy() URL] _webkit_canonicalize];
+    NSURL *URL = [[dataSource _documentLoader]->originalRequestCopy().url().getNSURL() _webkit_canonicalize];
     WebHistory *sharedHistory = [WebHistory optionalSharedHistory];
     WebHistoryItem *oldItem = [sharedHistory itemForURL:URL];
     if (oldItem)
@@ -439,6 +439,11 @@ bool WebFrameLoaderClient::dispatchDidLoadResourceFromMemoryCache(DocumentLoader
     return true;
 }
 
+id WebFrameLoaderClient::dispatchIdentifierForInitialRequest(DocumentLoader* loader, const ResourceRequest& request)
+{
+    return dispatchIdentifierForInitialRequest(loader, request.nsURLRequest());
+}
+
 id WebFrameLoaderClient::dispatchIdentifierForInitialRequest(DocumentLoader* loader, NSURLRequest *request)
 {
     WebView *webView = getWebView(loader);
@@ -658,35 +663,35 @@ void WebFrameLoaderClient::dispatchShow()
 }
 
 void WebFrameLoaderClient::dispatchDecidePolicyForMIMEType(FramePolicyFunction function,
-    const String& MIMEType, NSURLRequest *request)
+    const String& MIMEType, const ResourceRequest& request)
 {
     WebView *webView = getWebView(m_webFrame.get());
 
     [[webView _policyDelegateForwarder] webView:webView
                         decidePolicyForMIMEType:MIMEType
-                                        request:request
+                                        request:request.nsURLRequest()
                                           frame:m_webFrame.get()
                                decisionListener:setUpPolicyListener(function).get()];
 }
 
 void WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function,
-    const NavigationAction& action, NSURLRequest *request, const String& frameName)
+    const NavigationAction& action, const ResourceRequest& request, const String& frameName)
 {
     WebView *webView = getWebView(m_webFrame.get());
     [[webView _policyDelegateForwarder] webView:webView
             decidePolicyForNewWindowAction:actionDictionary(action)
-                                   request:request
+                                   request:request.nsURLRequest()
                               newFrameName:frameName
                           decisionListener:setUpPolicyListener(function).get()];
 }
 
 void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(FramePolicyFunction function,
-    const NavigationAction& action, NSURLRequest *request)
+    const NavigationAction& action, const ResourceRequest& request)
 {
     WebView *webView = getWebView(m_webFrame.get());
     [[webView _policyDelegateForwarder] webView:webView
                 decidePolicyForNavigationAction:actionDictionary(action)
-                                        request:request
+                                        request:request.nsURLRequest()
                                           frame:m_webFrame.get()
                                decisionListener:setUpPolicyListener(function).get()];
 }
@@ -790,10 +795,10 @@ void WebFrameLoaderClient::setMainFrameDocumentReady(bool ready)
     [getWebView(m_webFrame.get()) setMainFrameDocumentReady:ready];
 }
 
-void WebFrameLoaderClient::startDownload(NSURLRequest *request)
+void WebFrameLoaderClient::startDownload(const ResourceRequest& request)
 {
     // FIXME: Should download full request.
-    [getWebView(m_webFrame.get()) _downloadURL:[request URL]];
+    [getWebView(m_webFrame.get()) _downloadURL:request.url().getNSURL()];
 }
 
 void WebFrameLoaderClient::willChangeTitle(DocumentLoader* loader)
@@ -828,9 +833,9 @@ NSError *WebFrameLoaderClient::cancelledError(NSURLRequest *request)
     return [NSError _webKitErrorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled URL:[request URL]];
 }
 
-NSError *WebFrameLoaderClient::cannotShowURLError(NSURLRequest *request)
+NSError *WebFrameLoaderClient::cannotShowURLError(const ResourceRequest& request)
 {
-    return [NSError _webKitErrorWithDomain:WebKitErrorDomain code:WebKitErrorCannotShowURL URL:[request URL]];
+    return [NSError _webKitErrorWithDomain:WebKitErrorDomain code:WebKitErrorCannotShowURL URL:request.url().getNSURL()];
 }
 
 NSError *WebFrameLoaderClient::interruptForPolicyChangeError(NSURLRequest *request)
@@ -1039,7 +1044,7 @@ void WebFrameLoaderClient::prepareForDataSourceReplacement()
     core(m_webFrame.get())->loader()->detachChildren();
 }
 
-PassRefPtr<DocumentLoader> WebFrameLoaderClient::createDocumentLoader(NSURLRequest *request)
+PassRefPtr<DocumentLoader> WebFrameLoaderClient::createDocumentLoader(const ResourceRequest& request)
 {
     RefPtr<WebDocumentLoaderMac> loader = new WebDocumentLoaderMac(request);
 
index a961d5b9623d8a2e32afe207d68a7fd2b82346ab..d1db6f762427770fe77e871d02e3676db40418d7 100644 (file)
@@ -53,6 +53,7 @@
 #import <WebCore/FrameLoader.h>
 #import <WebCore/KURL.h>
 #import <WebKit/DOMHTML.h>
+#import <WebCore/ResourceRequest.h>
 #import <WebKit/DOMPrivate.h>
 #import <WebKitSystemInterface.h>
 #import <WebCore/MimeTypeRegistry.h>
@@ -366,7 +367,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
     _private->loader = loader;
     loader->ref();
         
-    LOG(Loading, "creating datasource for %@", [_private->loader->request() URL]);
+    LOG(Loading, "creating datasource for %@", _private->loader->request().url().getNSURL());
     
     ++WebDataSourceCount;
     
@@ -418,12 +419,13 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
 
 - (NSURLRequest *)initialRequest
 {
-    return _private->loader->initialRequest();
+    return _private->loader->initialRequest().nsURLRequest();
 }
 
 - (NSMutableURLRequest *)request
 {
-    return _private->loader->request();
+    // FIXME: XXX
+    return (NSMutableURLRequest*)_private->loader->request().nsURLRequest();
 }
 
 - (NSURLResponse *)response
index c3af978d533ed776025faa1f5063947a18bd580f..bf914684db6e20d038c8412b3a01a14bd89e32c2 100644 (file)
@@ -33,7 +33,7 @@
 class WebDocumentLoaderMac : public WebCore::DocumentLoader
 {
 public:
-    WebDocumentLoaderMac(NSURLRequest *);
+    WebDocumentLoaderMac(const WebCore::ResourceRequest&);
 
     void setDataSource(WebDataSource *);
     WebDataSource *dataSource() const;
index 4f20e5866a1c819abf3c68cf68b4886945e0fd8f..43a797ca5452393c8c77707e6e737c9aa4c125f0 100644 (file)
@@ -30,7 +30,9 @@
 
 #import <JavaScriptCore/Assertions.h>
 
-WebDocumentLoaderMac::WebDocumentLoaderMac(NSURLRequest *request)
+using namespace WebCore;
+
+WebDocumentLoaderMac::WebDocumentLoaderMac(const ResourceRequest& request)
     : DocumentLoader(request)
     , m_detachedDataSource(nil)
 {
index f6fb3bef503ecabb4cbebd05faf04b5ec3f9540e..92578fdf7a5bb413c236a10e02d2dc2d166c0228 100644 (file)
 #import <WebCore/SelectionController.h>
 #import <WebCore/WebDataProtocol.h>
 #import <WebCore/FormState.h>
+#import <WebCore/ResourceRequest.h>
 #import <WebKit/DOMDocument.h>
 #import <WebKit/DOMElement.h>
 #import <WebKit/DOMHTMLElement.h>
 #import <WebKit/DOMNode.h>
 #import <WebKit/DOMRange.h>
 
+using namespace WebCore;
+
 /*
 Here is the current behavior matrix for four types of navigations:
 
@@ -282,27 +285,28 @@ WebView *getWebView(WebFrame *webFrame)
 - (WebHistoryItem *)_createItem:(BOOL)useOriginal
 {
     WebDataSource *dataSrc = [self dataSource];
-    NSURLRequest *request;
+    ResourceRequest request;
     NSURL *unreachableURL = [dataSrc unreachableURL];
     NSURL *URL;
     NSURL *originalURL;
     WebHistoryItem *bfItem;
     WebCoreDocumentLoader *documentLoader = [dataSrc _documentLoader];
 
-    if (useOriginal)
-        request = documentLoader ? documentLoader->originalRequestCopy() : nil;
-    else
-        request = [dataSrc request];
+    if (documentLoader)
+        if (useOriginal)
+            request =  documentLoader->originalRequestCopy();
+        else
+            request = documentLoader->request();
 
     if (unreachableURL != nil) {
         URL = unreachableURL;
         originalURL = unreachableURL;
     } else {
-        URL = [request URL];
-        originalURL = documentLoader ? [documentLoader->originalRequestCopy() URL] : nil;
+        URL = request.url().getNSURL();
+        originalURL = documentLoader ? documentLoader->originalRequestCopy().url().getNSURL() : nil;
     }
 
-    LOG (History, "creating item for %@", request);
+    LOG (History, "creating item for %@", request.nsURLRequest());
     
     // Frames that have never successfully loaded any content
     // may have no URL at all. Currently our history code can't
@@ -320,7 +324,7 @@ WebView *getWebView(WebFrame *webFrame)
     [bfItem setOriginalURLString:[originalURL _web_originalDataAsString]];
 
     // save form state if this is a POST
-    [bfItem _setFormInfoFromRequest:request];
+    [bfItem _setFormInfoFromRequest:request.nsURLRequest()];
 
     // Set the item for which we will save document state
     [self _setPreviousItem:_private->currentItem];
@@ -557,7 +561,7 @@ WebView *getWebView(WebFrame *webFrame)
 
                 action = NavigationAction(itemOriginalURL, loadType, false);
             }
-
+            
             [self _frameLoader]->load(request, action, loadType, 0);
             [request release];
         }