Take referrer policy into account when clearing the referrer header
https://bugs.webkit.org/show_bug.cgi?id=86000

Patch by Marja Hölttä <marja@chromium.org> on 2013-02-06
Reviewed by Alexey Proskuryakov.

Source/WebCore:

The referrer should only be cleared when doing a https -> http redirect,
if the policy is "default". Otherwise the referrer should be left intact.

In order to do that, added a function for checking the policy in
NetworkingContext, and stored the NetworkingContext in ResourceHandle
(like some ports already did).

No new tests (unskipped old tests).

* loader/FrameNetworkingContext.h:
(WebCore::FrameNetworkingContext::shouldClearReferrerOnHTTPSToHTTPRedirect):
(FrameNetworkingContext):
* platform/network/BlobResourceHandle.cpp:
(WebCore::BlobResourceHandle::BlobResourceHandle):
* platform/network/NetworkingContext.h:
(NetworkingContext):
* platform/network/ResourceHandle.cpp:
(WebCore::ResourceHandle::ResourceHandle):
(WebCore::ResourceHandle::create):
(WebCore::ResourceHandle::context):
(WebCore):
* platform/network/ResourceHandle.h:
(ResourceHandle):
* platform/network/ResourceHandleInternal.h:
(WebCore::ResourceHandleInternal::ResourceHandleInternal):
(ResourceHandleInternal):
* platform/network/blackberry/ResourceHandleBlackBerry.cpp:
(WebCore::ResourceHandle::start):
(WebCore::ResourceHandle::loadResourceSynchronously):
* platform/network/cf/ResourceHandleCFNet.cpp:
(WebCore::willSendRequest):
(WebCore::ResourceHandle::start):
(WebCore::ResourceHandle::loadResourceSynchronously):
* platform/network/chromium/ResourceHandle.cpp:
(WebCore::ResourceHandleInternal::ResourceHandleInternal):
(WebCore::ResourceHandle::ResourceHandle):
(WebCore::ResourceHandle::create):
(WebCore::ResourceHandle::context):
(WebCore):
(WebCore::ResourceHandle::start):
* platform/network/chromium/ResourceHandleInternal.h:
(WebCore):
(ResourceHandleInternal):
(WebCore::ResourceHandleInternal::context):
* platform/network/curl/ResourceHandleCurl.cpp:
(WebCore::ResourceHandle::start):
(WebCore::ResourceHandle::loadResourceSynchronously):
* platform/network/mac/ResourceHandleMac.mm:
(WebCore::ResourceHandle::start):
(WebCore::ResourceHandle::loadResourceSynchronously):
(-[WebCoreResourceHandleAsDelegate connection:willSendRequest:redirectResponse:]):
* platform/network/qt/QNetworkReplyHandler.cpp:
(WebCore::QNetworkReplyHandler::redirect):
* platform/network/qt/ResourceHandleQt.cpp:
(WebCore::ResourceHandle::start):
(WebCore::ResourceHandle::loadResourceSynchronously):
* platform/network/soup/ResourceHandleSoup.cpp:
(WebCore::doRedirect):
(WebCore::ResourceHandle::start):
* platform/network/win/ResourceHandleWin.cpp:
(WebCore::ResourceHandle::start):
(WebCore::ResourceHandle::loadResourceSynchronously):

Source/WebKit2:

The referrer should only be cleared when doing a https -> http redirect,
if the policy is "default". Otherwise the referrer should be left intact.

* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::start):
* NetworkProcess/SchedulableLoader.cpp:
(WebKit::SchedulableLoader::SchedulableLoader):
* NetworkProcess/SchedulableLoader.h:
(WebKit::SchedulableLoader::shouldClearReferrerOnHTTPSToHTTPRedirect):
(SchedulableLoader):
* NetworkProcess/SyncNetworkResourceLoader.cpp:
(WebKit::SyncNetworkResourceLoader::start):
* NetworkProcess/mac/RemoteNetworkingContext.h:
(WebKit::RemoteNetworkingContext::create):
(RemoteNetworkingContext):
* NetworkProcess/mac/RemoteNetworkingContext.mm:
(WebKit::RemoteNetworkingContext::shouldClearReferrerOnHTTPSToHTTPRedirect):
(WebKit):
(WebKit::RemoteNetworkingContext::RemoteNetworkingContext):
* Shared/Network/NetworkResourceLoadParameters.cpp:
(WebKit::NetworkResourceLoadParameters::NetworkResourceLoadParameters):
(WebKit::NetworkResourceLoadParameters::encode):
(WebKit::NetworkResourceLoadParameters::decode):
* Shared/Network/NetworkResourceLoadParameters.h:
(NetworkResourceLoadParameters):
(WebKit::NetworkResourceLoadParameters::shouldClearReferrerOnHTTPSToHTTPRedirect):
* WebProcess/Network/WebResourceLoadScheduler.cpp:
(WebKit::WebResourceLoadScheduler::scheduleSubresourceLoad):
(WebKit::WebResourceLoadScheduler::schedulePluginStreamLoad):
(WebKit::WebResourceLoadScheduler::scheduleLoad):
* WebProcess/Network/WebResourceLoadScheduler.h:
(WebResourceLoadScheduler):
* WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
(WebKit::WebPlatformStrategies::loadResourceSynchronously):

LayoutTests:

Unskip http/tests/security/referrer-policy-redirect-link.html

Skipping the tests on wk2, because other referrer policy tests are
skipped, too ( https://bugs.webkit.org/show_bug.cgi?id=73913 ).

* platform/gtk/TestExpectations:
* platform/mac/TestExpectations:
* platform/qt/TestExpectations:
* platform/win/TestExpectations:
* platform/wk2/TestExpectations:

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