WebCore:
authordglazkov@chromium.org <dglazkov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Jan 2009 21:16:25 +0000 (21:16 +0000)
committerdglazkov@chromium.org <dglazkov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Jan 2009 21:16:25 +0000 (21:16 +0000)
2009-01-22  Eric Roman  <eroman@chromium.org>

        Reviewed by Eric Seidel.

        https://bugs.webkit.org/show_bug.cgi?id=20806
        Send referrer for history navigations.

        Test: http/tests/navigation/back-send-referrer.html

        Consolidates HistoryItem::rssFeedReferrer and HistoryItem::formReferrer into a single HistoryItem::referrer property.

        * history/HistoryItem.cpp:
        (WebCore::HistoryItem::HistoryItem):
        (WebCore::HistoryItem::referrer):
        (WebCore::HistoryItem::setReferrer):
        (WebCore::HistoryItem::formReferrer):
        (WebCore::HistoryItem::rssFeedReferrer):
        (WebCore::HistoryItem::setRSSFeedReferrer):
        (WebCore::HistoryItem::setFormInfoFromRequest):
        * history/HistoryItem.h:
        * loader/FrameLoader.cpp:
        (WebCore::FrameLoader::loadItem):

WebKit/win:

2009-01-22  Eric Roman  <eroman@chromium.org>

        Reviewed by Eric Seidel.

        https://bugs.webkit.org/show_bug.cgi?id=20806
        Deprecate RSSFeedReferrer() and setRSSFeedReferrer().

        * WebHistoryItem.cpp:
        (WebHistoryItem::RSSFeedReferrer):
        (WebHistoryItem::setRSSFeedReferrer):

WebKit/mac:

2009-01-22  Eric Roman  <eroman@chromium.og>

        Reviewed by Eric Seidel.

        https://bugs.webkit.org/show_bug.cgi?id=20806
        Deprecate RSSFeedReferrer() and setRSSFeedReferrer().

        * History/WebHistoryItem.mm:
        (-[WebHistoryItem RSSFeedReferrer]):
        (-[WebHistoryItem setRSSFeedReferrer:]):

LayoutTests:

2009-01-22  Eric Roman  <eroman@chromium.org>

        Reviewed by Eric Seidel.

        https://bugs.webkit.org/show_bug.cgi?id=20806
        "Referer" header not sent for history navigation.

        * http/tests/navigation/back-send-referrer-expected.txt: Added.
        * http/tests/navigation/back-send-referrer.html: Added.
        * http/tests/navigation/resources/back-send-referrer-helper.php: Added.

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

14 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/navigation/back-send-referrer-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/navigation/back-send-referrer.html [new file with mode: 0644]
LayoutTests/http/tests/navigation/resources/back-send-referrer-helper.php [new file with mode: 0644]
WebCore/ChangeLog
WebCore/WebCore.base.exp
WebCore/WebCore.order
WebCore/history/HistoryItem.cpp
WebCore/history/HistoryItem.h
WebCore/loader/FrameLoader.cpp
WebKit/mac/ChangeLog
WebKit/mac/History/WebHistoryItem.mm
WebKit/win/ChangeLog
WebKit/win/WebHistoryItem.cpp

index 70fcdbc..8d1ce36 100644 (file)
@@ -1,3 +1,14 @@
+2009-01-22  Eric Roman  <eroman@chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        https://bugs.webkit.org/show_bug.cgi?id=20806
+        "Referer" header not sent for history navigation.
+
+        * http/tests/navigation/back-send-referrer-expected.txt: Added.
+        * http/tests/navigation/back-send-referrer.html: Added.
+        * http/tests/navigation/resources/back-send-referrer-helper.php: Added.
+
 2009-01-22  Oliver Hunt  <oliver@apple.com>
 
         Reviewed by Geoff Garen.
diff --git a/LayoutTests/http/tests/navigation/back-send-referrer-expected.txt b/LayoutTests/http/tests/navigation/back-send-referrer-expected.txt
new file mode 100644 (file)
index 0000000..fe786b2
--- /dev/null
@@ -0,0 +1,3 @@
+Referrer: http://127.0.0.1:8000/navigation/back-send-referrer.html
+window.name: 3
+
diff --git a/LayoutTests/http/tests/navigation/back-send-referrer.html b/LayoutTests/http/tests/navigation/back-send-referrer.html
new file mode 100644 (file)
index 0000000..4045f6b
--- /dev/null
@@ -0,0 +1,9 @@
+<script>
+    if (window.layoutTestController) {
+        layoutTestController.waitUntilDone();
+        layoutTestController.dumpAsText();
+    }
+
+    window.name = "0";
+    window.location = "resources/back-send-referrer-helper.php";
+</script>
diff --git a/LayoutTests/http/tests/navigation/resources/back-send-referrer-helper.php b/LayoutTests/http/tests/navigation/resources/back-send-referrer-helper.php
new file mode 100644 (file)
index 0000000..bf629ef
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+    // Prevent from being cached.
+    header("Cache-Control: no-cache, private, max-age=0");
+    header("Content-Type: text/html");
+?>
+
+<html>
+
+<script>
+    window.name = parseInt(window.name) + 1;
+</script>
+
+Referrer: <?php echo $_SERVER['HTTP_REFERER']; ?>
+<br/>
+window.name: <script>document.write(window.name)</script>
+
+<form name=loopback action="" method=GET></form>
+
+<script>
+    if (window.name == 1) {
+        // Navigate once more to add a history entry.
+        document.loopback.submit();
+    } else if (window.name == 2) {
+        history.go(-1);
+    } else {
+        if (window.layoutTestController)
+            window.layoutTestController.notifyDone();
+    }
+</script>
+
+</html>
index 5573527..ae266cb 100644 (file)
@@ -1,3 +1,26 @@
+2009-01-22  Eric Roman  <eroman@chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        https://bugs.webkit.org/show_bug.cgi?id=20806
+        Send referrer for history navigations.
+
+        Test: http/tests/navigation/back-send-referrer.html
+
+        Consolidates HistoryItem::rssFeedReferrer and HistoryItem::formReferrer into a single HistoryItem::referrer property.
+
+        * history/HistoryItem.cpp:
+        (WebCore::HistoryItem::HistoryItem):
+        (WebCore::HistoryItem::referrer):
+        (WebCore::HistoryItem::setReferrer):
+        (WebCore::HistoryItem::formReferrer):
+        (WebCore::HistoryItem::rssFeedReferrer):
+        (WebCore::HistoryItem::setRSSFeedReferrer):
+        (WebCore::HistoryItem::setFormInfoFromRequest):
+        * history/HistoryItem.h:
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::loadItem):
+
 2009-01-22  Nikolas Zimmermann  <nikolas.zimmermann@torchmobile.com>
 
         Reviewed by Eric Seidel.
index baf88cd..a8e76c8 100644 (file)
@@ -174,6 +174,7 @@ __ZN7WebCore11FrameLoader4loadERKNS_15ResourceRequestERKNS_6StringE
 __ZN7WebCore11FrameLoader6reloadEb
 __ZN7WebCore11FrameLoader7addDataEPKci
 __ZN7WebCore11FrameLoader7canLoadERKNS_4KURLERKNS_6StringEPKNS_8DocumentE
+__ZN7WebCore11HistoryItem11setReferrerERKNS_6StringE
 __ZN7WebCore11HistoryItem12addChildItemEN3WTF10PassRefPtrIS0_EE
 __ZN7WebCore11HistoryItem12setURLStringERKNS_6StringE
 __ZN7WebCore11HistoryItem12setViewStateEP11objc_object
@@ -182,7 +183,6 @@ __ZN7WebCore11HistoryItem14setScrollPointERKNS_8IntPointE
 __ZN7WebCore11HistoryItem15setIsTargetItemEb
 __ZN7WebCore11HistoryItem17setAlternateTitleERKNS_6StringE
 __ZN7WebCore11HistoryItem18setLastVisitedTimeEd
-__ZN7WebCore11HistoryItem18setRSSFeedReferrerERKNS_6StringE
 __ZN7WebCore11HistoryItem20setOriginalURLStringERKNS_6StringE
 __ZN7WebCore11HistoryItem20setTransientPropertyERKNS_6StringEP11objc_object
 __ZN7WebCore11HistoryItem22mergeAutoCompleteHintsEPS0_
@@ -716,7 +716,6 @@ __ZNK7WebCore11HistoryItem11scrollPointEv
 __ZNK7WebCore11HistoryItem12isTargetItemEv
 __ZNK7WebCore11HistoryItem14alternateTitleEv
 __ZNK7WebCore11HistoryItem15lastVisitedTimeEv
-__ZNK7WebCore11HistoryItem15rssFeedReferrerEv
 __ZNK7WebCore11HistoryItem17childItemWithNameERKNS_6StringE
 __ZNK7WebCore11HistoryItem17originalURLStringEv
 __ZNK7WebCore11HistoryItem20getTransientPropertyERKNS_6StringE
@@ -726,6 +725,7 @@ __ZNK7WebCore11HistoryItem4iconEv
 __ZNK7WebCore11HistoryItem5titleEv
 __ZNK7WebCore11HistoryItem6targetEv
 __ZNK7WebCore11HistoryItem8childrenEv
+__ZNK7WebCore11HistoryItem8referrerEv
 __ZNK7WebCore11HistoryItem9urlStringEv
 __ZNK7WebCore11HistoryItem9viewStateEv
 __ZNK7WebCore12EventHandler17eventMayStartDragERKNS_18PlatformMouseEventE
index 67de812..af08132 100644 (file)
@@ -6519,7 +6519,6 @@ __ZN7WebCore14RenderThemeMac16paintSliderThumbEPNS_12RenderObjectERKNS1_9PaintIn
 __ZNK7WebCore14RenderThemeMac21sliderThumbHorizontalEv
 __ZNK7WebCore12RenderSlider10inDragModeEv
 __ZNK7WebCore12RenderObject14caretMaxOffsetEv
-__ZNK7WebCore11HistoryItem15rssFeedReferrerEv
 __ZN7WebCore11FrameLoader6reloadEv
 __ZN7WebCore17RenderFlexibleBoxD1Ev
 __ZN7WebCore11EllipsisBoxD1Ev
@@ -8602,7 +8601,6 @@ __ZN7WebCore7Marquee15computePositionENS_17EMarqueeDirectionEb
 __ZN7WebCore7Marquee5startEv
 __ZN7WebCore5TimerINS_7MarqueeEE5firedEv
 __ZN7WebCore7Marquee10timerFiredEPNS_5TimerIS0_EE
-__ZNK7WebCore11HistoryItem12formReferrerEv
 __ZNK7WebCore11HistoryItem15formContentTypeEv
 __ZN7WebCore14ResourceHandle17willLoadFromCacheERNS_15ResourceRequestE
 __ZNK7WebCore15HTMLLinkElement14isURLAttributeEPNS_9AttributeE
index 82068fe..f95e854 100644 (file)
@@ -107,6 +107,7 @@ inline HistoryItem::HistoryItem(const HistoryItem& item)
     : RefCounted<HistoryItem>()
     , m_urlString(item.m_urlString)
     , m_originalURLString(item.m_originalURLString)
+    , m_referrer(item.m_referrer)
     , m_target(item.m_target)
     , m_parent(item.m_parent)
     , m_title(item.m_title)
@@ -119,8 +120,6 @@ inline HistoryItem::HistoryItem(const HistoryItem& item)
     , m_isTargetItem(item.m_isTargetItem)
     , m_visitCount(item.m_visitCount)
     , m_formContentType(item.m_formContentType)
-    , m_formReferrer(item.m_formReferrer)
-    , m_rssFeedReferrer(item.m_rssFeedReferrer)
 {
     if (item.m_formData)
         m_formData = item.m_formData->copy();
@@ -179,6 +178,11 @@ KURL HistoryItem::originalURL() const
     return KURL(m_originalURLString);
 }
 
+const String& HistoryItem::referrer() const
+{
+    return m_referrer;
+}
+
 const String& HistoryItem::target() const
 {
     return m_target;
@@ -219,6 +223,12 @@ void HistoryItem::setOriginalURLString(const String& urlString)
     notifyHistoryItemChanged();
 }
 
+void HistoryItem::setReferrer(const String& referrer)
+{
+    m_referrer = referrer;
+    notifyHistoryItemChanged();
+}
+
 void HistoryItem::setTitle(const String& title)
 {
     m_title = title;
@@ -357,33 +367,18 @@ String HistoryItem::formContentType() const
     return m_formContentType;
 }
 
-String HistoryItem::formReferrer() const
-{
-    return m_formReferrer;
-}
-
-String HistoryItem::rssFeedReferrer() const
-{
-    return m_rssFeedReferrer;
-}
-
-void HistoryItem::setRSSFeedReferrer(const String& referrer)
-{
-    m_rssFeedReferrer = referrer;
-}
-
 void HistoryItem::setFormInfoFromRequest(const ResourceRequest& request)
 {
+    m_referrer = request.httpReferrer();
+    
     if (equalIgnoringCase(request.httpMethod(), "POST")) {
         // FIXME: Eventually we have to make this smart enough to handle the case where
         // we have a stream for the body to handle the "data interspersed with files" feature.
         m_formData = request.httpBody();
         m_formContentType = request.httpContentType();
-        m_formReferrer = request.httpReferrer();
     } else {
         m_formData = 0;
         m_formContentType = String();
-        m_formReferrer = String();
     }
 }
 
index 23e1f6b..bd20ba3 100644 (file)
@@ -91,13 +91,12 @@ public:
     const String& parent() const;
     KURL url() const;
     KURL originalURL() const;
+    const String& referrer() const;
     const String& target() const;
     bool isTargetItem() const;
     
     FormData* formData();
     String formContentType() const;
-    String formReferrer() const;
-    String rssFeedReferrer() const;
     
     int visitCount() const;
     bool lastVisitWasFailure() const { return m_lastVisitWasFailure; }
@@ -115,6 +114,7 @@ public:
     void setURL(const KURL&);
     void setURLString(const String&);
     void setOriginalURLString(const String&);
+    void setReferrer(const String&);
     void setTarget(const String&);
     void setParent(const String&);
     void setTitle(const String&);
@@ -122,7 +122,7 @@ public:
     
     void setFormInfoFromRequest(const ResourceRequest&);
 
-    void setRSSFeedReferrer(const String&);
+
     void setVisitCount(int);
     void setLastVisitWasFailure(bool wasFailure) { m_lastVisitWasFailure = wasFailure; }
     void setLastVisitWasHTTPNonGet(bool wasNotGet) { m_lastVisitWasHTTPNonGet = wasNotGet; }
@@ -171,6 +171,7 @@ private:
 
     String m_urlString;
     String m_originalURLString;
+    String m_referrer;
     String m_target;
     String m_parent;
     String m_title;
@@ -192,10 +193,6 @@ private:
     // info used to repost form data
     RefPtr<FormData> m_formData;
     String m_formContentType;
-    String m_formReferrer;
-    
-    // info used to support RSS feeds
-    String m_rssFeedReferrer;
 
     // PageCache controls these fields.
     HistoryItem* m_next;
index 4bb1b89..20f85fa 100644 (file)
@@ -4537,6 +4537,9 @@ void FrameLoader::loadItem(HistoryItem* item, FrameLoadType loadType)
             bool addedExtraFields = false;
             ResourceRequest request(itemURL);
 
+            if (!item->referrer().isNull())
+                request.setHTTPReferrer(item->referrer());
+            
             // If this was a repost that failed the page cache, we might try to repost the form.
             NavigationAction action;
             if (formData) {
@@ -4544,10 +4547,9 @@ void FrameLoader::loadItem(HistoryItem* item, FrameLoadType loadType)
                 formData->generateFiles(m_frame->page()->chrome()->client());
 
                 request.setHTTPMethod("POST");
-                request.setHTTPReferrer(item->formReferrer());
                 request.setHTTPBody(formData);
                 request.setHTTPContentType(item->formContentType());
-                RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::createFromString(item->formReferrer());
+                RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::createFromString(item->referrer());
                 addHTTPOriginIfNeeded(request, securityOrigin->toString());
         
                 // Make sure to add extra fields to the request after the Origin header is added for the FormData case.
index 29fe9b2..3633d60 100644 (file)
@@ -1,3 +1,14 @@
+2009-01-22  Eric Roman  <eroman@chromium.og>
+
+        Reviewed by Eric Seidel.
+
+        https://bugs.webkit.org/show_bug.cgi?id=20806
+        Deprecate RSSFeedReferrer() and setRSSFeedReferrer().
+
+        * History/WebHistoryItem.mm:
+        (-[WebHistoryItem RSSFeedReferrer]):
+        (-[WebHistoryItem setRSSFeedReferrer:]):
+
 2009-01-22  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Kevin Decker.
index 41dc630..3eec4ad 100644 (file)
@@ -464,12 +464,12 @@ static WebWindowWatcher *_windowWatcher = nil;
 
 - (NSString *)RSSFeedReferrer
 {
-    return nsStringNilIfEmpty(core(_private)->rssFeedReferrer());
+    return nsStringNilIfEmpty(core(_private)->referrer());
 }
 
 - (void)setRSSFeedReferrer:(NSString *)referrer
 {
-    core(_private)->setRSSFeedReferrer(referrer);
+    core(_private)->setReferrer(referrer);
 }
 
 - (NSArray *)children
index aca59d3..94c9709 100644 (file)
@@ -1,3 +1,14 @@
+2009-01-22  Eric Roman  <eroman@chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        https://bugs.webkit.org/show_bug.cgi?id=20806
+        Deprecate RSSFeedReferrer() and setRSSFeedReferrer().
+
+        * WebHistoryItem.cpp:
+        (WebHistoryItem::RSSFeedReferrer):
+        (WebHistoryItem::setRSSFeedReferrer):
+
 2009-01-19  Sam Weinig  <sam@webkit.org>
 
         Rubber-stamped by Gavin Barraclough.
index 17274ce..770f511 100644 (file)
@@ -242,7 +242,7 @@ HRESULT STDMETHODCALLTYPE WebHistoryItem::setTitle(BSTR title)
 
 HRESULT STDMETHODCALLTYPE WebHistoryItem::RSSFeedReferrer(BSTR* url)
 {
-    BString str(m_historyItem->rssFeedReferrer());
+    BString str(m_historyItem->referrer());
     *url = str.release();
 
     return S_OK;
@@ -250,7 +250,7 @@ HRESULT STDMETHODCALLTYPE WebHistoryItem::RSSFeedReferrer(BSTR* url)
 
 HRESULT STDMETHODCALLTYPE WebHistoryItem::setRSSFeedReferrer(BSTR url)
 {
-    m_historyItem->setRSSFeedReferrer(String(url, SysStringLen(url)));
+    m_historyItem->setReferrer(String(url, SysStringLen(url)));
 
     return S_OK;
 }