summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSelim Gurun <sgurun@google.com>2012-08-29 15:38:48 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-08-29 15:38:49 -0700
commit9976df9e944fed76ce8c5b22b6317a63117c4e40 (patch)
treee92b0b39efeba04a198539e740ce385d9912c78e
parentf39a3cbeac21b1d076bee9cbc25bec1d981f6aab (diff)
parentfd1365ed14367fb8af3b0ba958f268b1e9491e6e (diff)
downloadexternal_webkit-9976df9e944fed76ce8c5b22b6317a63117c4e40.zip
external_webkit-9976df9e944fed76ce8c5b22b6317a63117c4e40.tar.gz
external_webkit-9976df9e944fed76ce8c5b22b6317a63117c4e40.tar.bz2
Merge "Provide referer when download requested" into jb-mr1-dev
-rw-r--r--Source/WebKit/android/WebCoreSupport/WebRequest.cpp7
-rw-r--r--Source/WebKit/android/WebCoreSupport/WebRequest.h2
-rw-r--r--Source/WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp2
-rw-r--r--Source/WebKit/android/jni/WebCoreFrameBridge.cpp8
-rw-r--r--Source/WebKit/android/jni/WebCoreFrameBridge.h2
5 files changed, 16 insertions, 5 deletions
diff --git a/Source/WebKit/android/WebCoreSupport/WebRequest.cpp b/Source/WebKit/android/WebCoreSupport/WebRequest.cpp
index 9d16378..dda0ee1 100644
--- a/Source/WebKit/android/WebCoreSupport/WebRequest.cpp
+++ b/Source/WebKit/android/WebCoreSupport/WebRequest.cpp
@@ -83,6 +83,7 @@ WebRequest::WebRequest(WebUrlLoaderClient* loader, const WebResourceRequest& web
: m_urlLoader(loader)
, m_url(webResourceRequest.url())
, m_userAgent(webResourceRequest.userAgent())
+ , m_referer(webResourceRequest.referrer())
, m_loadState(Created)
, m_authRequestCount(0)
, m_cacheMode(0)
@@ -109,6 +110,7 @@ WebRequest::WebRequest(WebUrlLoaderClient* loader, const WebResourceRequest& web
, m_interceptResponse(intercept)
, m_url(webResourceRequest.url())
, m_userAgent(webResourceRequest.userAgent())
+ , m_referer(webResourceRequest.referrer())
, m_loadState(Created)
, m_authRequestCount(0)
, m_cacheMode(0)
@@ -136,6 +138,11 @@ const std::string& WebRequest::getUserAgent() const
return m_userAgent;
}
+const std::string& WebRequest::getReferer() const
+{
+ return m_referer;
+}
+
#ifdef LOG_REQUESTS
namespace {
int remaining = 0;
diff --git a/Source/WebKit/android/WebCoreSupport/WebRequest.h b/Source/WebKit/android/WebCoreSupport/WebRequest.h
index d9054e9..4a4e10b 100644
--- a/Source/WebKit/android/WebCoreSupport/WebRequest.h
+++ b/Source/WebKit/android/WebCoreSupport/WebRequest.h
@@ -89,6 +89,7 @@ public:
const std::string& getUrl() const;
const std::string& getUserAgent() const;
+ const std::string& getReferer() const;
void setSync(bool sync) { m_isSync = sync; }
private:
@@ -109,6 +110,7 @@ private:
scoped_ptr<UrlInterceptResponse> m_interceptResponse;
std::string m_url;
std::string m_userAgent;
+ std::string m_referer;
LoadState m_loadState;
int m_authRequestCount;
int m_cacheMode;
diff --git a/Source/WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp b/Source/WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp
index 5df0ed2..003b334 100644
--- a/Source/WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp
+++ b/Source/WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp
@@ -245,7 +245,7 @@ void WebUrlLoaderClient::downloadFile()
if (m_response) {
std::string contentDisposition;
m_response->getHeader("content-disposition", &contentDisposition);
- m_webFrame->downloadStart(m_response->getUrl(), m_request->getUserAgent(), contentDisposition, m_response->getMimeType(), m_response->getExpectedSize());
+ m_webFrame->downloadStart(m_response->getUrl(), m_request->getUserAgent(), contentDisposition, m_response->getMimeType(), m_request->getReferer(), m_response->getExpectedSize());
m_isCertMimeType = isMimeTypeForCert(m_response->getMimeType());
// Currently, only certificate mime type needs to receive the data.
diff --git a/Source/WebKit/android/jni/WebCoreFrameBridge.cpp b/Source/WebKit/android/jni/WebCoreFrameBridge.cpp
index 39ae07e..61ffd29 100644
--- a/Source/WebKit/android/jni/WebCoreFrameBridge.cpp
+++ b/Source/WebKit/android/jni/WebCoreFrameBridge.cpp
@@ -273,7 +273,7 @@ WebFrame::WebFrame(JNIEnv* env, jobject obj, jobject historyList, WebCore::Page*
mJavaFrame->mReportSslCertError = env->GetMethodID(clazz, "reportSslCertError", "(II[BLjava/lang/String;)V");
mJavaFrame->mRequestClientCert = env->GetMethodID(clazz, "requestClientCert", "(ILjava/lang/String;)V");
mJavaFrame->mDownloadStart = env->GetMethodID(clazz, "downloadStart",
- "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;J)V");
+ "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;J)V");
mJavaFrame->mDidReceiveData = env->GetMethodID(clazz, "didReceiveData", "([BI)V");
mJavaFrame->mDidFinishLoading = env->GetMethodID(clazz, "didFinishLoading", "()V");
mJavaFrame->mSetCertificate = env->GetMethodID(clazz, "setCertificate", "([B)V");
@@ -836,7 +836,7 @@ WebFrame::requestClientCert(WebUrlLoaderClient* client, const std::string& hostA
}
void
-WebFrame::downloadStart(const std::string& url, const std::string& userAgent, const std::string& contentDisposition, const std::string& mimetype, long long contentLength)
+WebFrame::downloadStart(const std::string& url, const std::string& userAgent, const std::string& contentDisposition, const std::string& mimetype, const std::string& referer, long long contentLength)
{
JNIEnv* env = getJNIEnv();
AutoJObject javaFrame = mJavaFrame->frame(env);
@@ -846,13 +846,15 @@ WebFrame::downloadStart(const std::string& url, const std::string& userAgent, co
jstring jUserAgent = stdStringToJstring(env, userAgent, true);
jstring jContentDisposition = stdStringToJstring(env, contentDisposition, true);
jstring jMimetype = stdStringToJstring(env, mimetype, true);
+ jstring jReferer = stdStringToJstring(env, referer, true);
- env->CallVoidMethod(javaFrame.get(), mJavaFrame->mDownloadStart, jUrl, jUserAgent, jContentDisposition, jMimetype, contentLength);
+ env->CallVoidMethod(javaFrame.get(), mJavaFrame->mDownloadStart, jUrl, jUserAgent, jContentDisposition, jMimetype, jReferer, contentLength);
env->DeleteLocalRef(jUrl);
env->DeleteLocalRef(jUserAgent);
env->DeleteLocalRef(jContentDisposition);
env->DeleteLocalRef(jMimetype);
+ env->DeleteLocalRef(jReferer);
checkException(env);
}
diff --git a/Source/WebKit/android/jni/WebCoreFrameBridge.h b/Source/WebKit/android/jni/WebCoreFrameBridge.h
index 30c1d83..56b095b 100644
--- a/Source/WebKit/android/jni/WebCoreFrameBridge.h
+++ b/Source/WebKit/android/jni/WebCoreFrameBridge.h
@@ -116,7 +116,7 @@ class WebFrame : public WebCoreRefObject {
void didReceiveAuthenticationChallenge(WebUrlLoaderClient*, const std::string& host, const std::string& realm, bool useCachedCredentials, bool suppressDialog);
void reportSslCertError(WebUrlLoaderClient* client, int cert_error, const std::string& cert, const std::string& url);
void requestClientCert(WebUrlLoaderClient* client, const std::string& hostAndPort);
- void downloadStart(const std::string& url, const std::string& userAgent, const std::string& contentDisposition, const std::string& mimetype, long long contentLength);
+ void downloadStart(const std::string& url, const std::string& userAgent, const std::string& contentDisposition, const std::string& mimetype, const std::string& referer, long long contentLength);
void didReceiveData(const char* data, int size);
void didFinishLoading();
void setCertificate(const std::string& cert);