summaryrefslogtreecommitdiffstats
path: root/WebKit/android
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/android')
-rw-r--r--WebKit/android/WebCoreSupport/WebResourceRequest.cpp50
1 files changed, 29 insertions, 21 deletions
diff --git a/WebKit/android/WebCoreSupport/WebResourceRequest.cpp b/WebKit/android/WebCoreSupport/WebResourceRequest.cpp
index c3ec562..9b70fce 100644
--- a/WebKit/android/WebCoreSupport/WebResourceRequest.cpp
+++ b/WebKit/android/WebCoreSupport/WebResourceRequest.cpp
@@ -36,10 +36,37 @@ namespace android {
WebResourceRequest::WebResourceRequest(const WebCore::ResourceRequest& resourceRequest)
{
+ // Set the load flags based on the WebCore request.
+ m_loadFlags = net::LOAD_NORMAL;
+ switch (resourceRequest.cachePolicy()) {
+ case ReloadIgnoringCacheData:
+ m_loadFlags |= net::LOAD_VALIDATE_CACHE;
+ break;
+ case ReturnCacheDataElseLoad:
+ m_loadFlags |= net::LOAD_PREFERRING_CACHE;
+ break;
+ case ReturnCacheDataDontLoad:
+ m_loadFlags |= net::LOAD_ONLY_FROM_CACHE;
+ break;
+ case UseProtocolCachePolicy:
+ break;
+ }
+
+ // TODO: We should consider setting these flags and net::LOAD_DO_NOT_SEND_AUTH_DATA
+ // when FrameLoaderClient::shouldUseCredentialStorage() is false. However,
+ // the required WebKit logic is not yet in place. See Chromium's
+ // FrameLoaderClientImpl::shouldUseCredentialStorage().
+ if (!resourceRequest.allowCookies()) {
+ m_loadFlags |= net::LOAD_DO_NOT_SAVE_COOKIES;
+ m_loadFlags |= net::LOAD_DO_NOT_SEND_COOKIES;
+ }
+
+
// Set the request headers
const HTTPHeaderMap& map = resourceRequest.httpHeaderFields();
for (HTTPHeaderMap::const_iterator it = map.begin(); it != map.end(); ++it) {
const std::string& nameUtf8 = it->first.string().utf8().data();
+ const std::string& valueUtf8 = it->second.utf8().data();
// Skip over referrer headers found in the header map because we already
// pulled it out as a separate parameter. We likewise prune the UA since
@@ -47,17 +74,13 @@ WebResourceRequest::WebResourceRequest(const WebCore::ResourceRequest& resourceR
if (LowerCaseEqualsASCII(nameUtf8, "referer") || LowerCaseEqualsASCII(nameUtf8, "user-agent"))
continue;
- // The next comment does not match what is happening in code since the load flags are not implemented
- // (http://b/issue?id=2889880)
- // TODO: Check this is correct when load flags are implemented and working.
-
// Skip over "Cache-Control: max-age=0" header if the corresponding
// load flag is already specified. FrameLoader sets both the flag and
// the extra header -- the extra header is redundant since our network
// implementation will add the necessary headers based on load flags.
// See http://code.google.com/p/chromium/issues/detail?id=3434.
- const std::string& valueUtf8 = it->second.utf8().data();
- if (LowerCaseEqualsASCII(nameUtf8, "cache-control") && LowerCaseEqualsASCII(valueUtf8, "max-age=0"))
+ if ((m_loadFlags & net::LOAD_VALIDATE_CACHE) &&
+ LowerCaseEqualsASCII(nameUtf8, "cache-control") && LowerCaseEqualsASCII(valueUtf8, "max-age=0"))
continue;
m_requestHeaders.SetHeader(nameUtf8, valueUtf8);
@@ -68,21 +91,6 @@ WebResourceRequest::WebResourceRequest(const WebCore::ResourceRequest& resourceR
m_userAgent = resourceRequest.httpUserAgent().utf8().data();
m_url = resourceRequest.url().string().utf8().data();
-
- m_loadFlags = net::LOAD_NORMAL;
- switch (resourceRequest.cachePolicy()) {
- case ReloadIgnoringCacheData:
- m_loadFlags |= net::LOAD_VALIDATE_CACHE;
- break;
- case ReturnCacheDataElseLoad:
- m_loadFlags |= net::LOAD_PREFERRING_CACHE;
- break;
- case ReturnCacheDataDontLoad:
- m_loadFlags |= net::LOAD_ONLY_FROM_CACHE;
- break;
- case UseProtocolCachePolicy:
- break;
- }
}
} // namespace android