diff options
Diffstat (limited to 'WebKit/android')
-rw-r--r-- | WebKit/android/WebCoreSupport/WebRequest.cpp | 20 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/WebRequest.h | 2 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/WebRequestContext.cpp | 10 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/WebRequestContext.h | 3 | ||||
-rw-r--r-- | WebKit/android/jni/WebSettings.cpp | 9 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 9 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.h | 3 |
7 files changed, 53 insertions, 3 deletions
diff --git a/WebKit/android/WebCoreSupport/WebRequest.cpp b/WebKit/android/WebCoreSupport/WebRequest.cpp index 9e464c1..1c84687 100644 --- a/WebKit/android/WebCoreSupport/WebRequest.cpp +++ b/WebKit/android/WebCoreSupport/WebRequest.cpp @@ -67,6 +67,7 @@ WebRequest::WebRequest(WebUrlLoaderClient* loader, const WebResourceRequest& web , m_userAgent(webResourceRequest.userAgent()) , m_loadState(Created) , m_authRequestCount(0) + , m_cacheMode(0) { GURL gurl(m_url); @@ -88,6 +89,7 @@ WebRequest::WebRequest(WebUrlLoaderClient* loader, const WebResourceRequest& web , m_userAgent(webResourceRequest.userAgent()) , m_loadState(Created) , m_authRequestCount(0) + , m_cacheMode(0) { } @@ -154,10 +156,23 @@ void WebRequest::appendBytesToUpload(WTF::Vector<char>* data) void WebRequest::setRequestContext(WebRequestContext* context) { + m_cacheMode = context->getCacheMode(); if (m_request) m_request->set_context(context); } +void WebRequest::updateLoadFlags(int& loadFlags) +{ + if (m_cacheMode == 1) { // LOAD_CACHE_ELSE_NETWORK + loadFlags |= net::LOAD_PREFERRING_CACHE; + loadFlags &= ~net::LOAD_VALIDATE_CACHE; + } + if (m_cacheMode == 2) // LOAD_NO_CACHE + loadFlags |= net::LOAD_BYPASS_CACHE; + if (m_cacheMode == 3) // LOAD_CACHE_ONLY + loadFlags |= net::LOAD_ONLY_FROM_CACHE; +} + void WebRequest::start() { ASSERT(m_loadState == Created, "Start called on a WebRequest not in CREATED state: (%s)", m_url.c_str()); @@ -174,6 +189,11 @@ void WebRequest::start() if (m_request->url().SchemeIs("browser")) return handleBrowserURL(m_request->url()); + // Update load flags with settings from WebSettings + int loadFlags = m_request->load_flags(); + updateLoadFlags(loadFlags); + m_request->set_load_flags(loadFlags); + m_request->Start(); } diff --git a/WebKit/android/WebCoreSupport/WebRequest.h b/WebKit/android/WebCoreSupport/WebRequest.h index e896284..0ce4b77 100644 --- a/WebKit/android/WebCoreSupport/WebRequest.h +++ b/WebKit/android/WebCoreSupport/WebRequest.h @@ -97,6 +97,7 @@ private: void handleBrowserURL(GURL); void handleInterceptedURL(); void finish(bool success); + void updateLoadFlags(int& loadFlags); scoped_refptr<WebUrlLoaderClient> m_urlLoader; OwnPtr<URLRequest> m_request; @@ -107,6 +108,7 @@ private: std::string m_userAgent; LoadState m_loadState; int m_authRequestCount; + int m_cacheMode; }; } // namespace android diff --git a/WebKit/android/WebCoreSupport/WebRequestContext.cpp b/WebKit/android/WebCoreSupport/WebRequestContext.cpp index e108e2a..341a23c 100644 --- a/WebKit/android/WebCoreSupport/WebRequestContext.cpp +++ b/WebKit/android/WebCoreSupport/WebRequestContext.cpp @@ -89,6 +89,16 @@ void WebRequestContext::setUserAgent(const String& string) m_userAgent = string.utf8().data(); } +void WebRequestContext::setCacheMode(int mode) +{ + m_cacheMode = mode; +} + +int WebRequestContext::getCacheMode() +{ + return m_cacheMode; +} + const std::string& WebRequestContext::GetUserAgent(const GURL& url) const { MutexLocker lock(m_userAgentMutex); diff --git a/WebKit/android/WebCoreSupport/WebRequestContext.h b/WebKit/android/WebCoreSupport/WebRequestContext.h index 1b82406..51f0514 100644 --- a/WebKit/android/WebCoreSupport/WebRequestContext.h +++ b/WebKit/android/WebCoreSupport/WebRequestContext.h @@ -44,6 +44,8 @@ public: // These methods are threadsafe. void setUserAgent(const WTF::String&); + void setCacheMode(int); + int getCacheMode(); static void setAcceptLanguage(const WTF::String&); static const WTF::String& acceptLanguage(); @@ -52,6 +54,7 @@ private: ~WebRequestContext(); std::string m_userAgent; + int m_cacheMode; mutable WTF::Mutex m_userAgentMutex; bool m_isPrivateBrowsing; }; diff --git a/WebKit/android/jni/WebSettings.cpp b/WebKit/android/jni/WebSettings.cpp index e4b30c3..3712135 100644 --- a/WebKit/android/jni/WebSettings.cpp +++ b/WebKit/android/jni/WebSettings.cpp @@ -147,6 +147,9 @@ struct FieldIds { mAutoFillProfilePhoneNumber = env->GetFieldID(autoFillProfileClass, "mPhoneNumber", "Ljava/lang/String;"); env->DeleteLocalRef(autoFillProfileClass); #endif +#if USE(CHROME_NETWORK_STACK) + mOverrideCacheMode = env->GetFieldID(clazz, "mOverrideCacheMode", "I"); +#endif LOG_ASSERT(mLayoutAlgorithm, "Could not find field mLayoutAlgorithm"); LOG_ASSERT(mTextSize, "Could not find field mTextSize"); @@ -270,6 +273,9 @@ struct FieldIds { jfieldID mAutoFillProfileCountry; jfieldID mAutoFillProfilePhoneNumber; #endif +#if USE(CHROME_NETWORK_STACK) + jfieldID mOverrideCacheMode; +#endif }; static struct FieldIds* gFieldIds; @@ -372,6 +378,9 @@ public: #if USE(CHROME_NETWORK_STACK) WebViewCore::getWebViewCore(pFrame->view())->setWebRequestContextUserAgent(); + jint cacheMode = env->GetIntField(obj, gFieldIds->mOverrideCacheMode); + WebViewCore::getWebViewCore(pFrame->view())->setWebRequestContextCacheMode(cacheMode); + str = (jstring)env->GetObjectField(obj, gFieldIds->mAcceptLanguage); WebRequestContext::setAcceptLanguage(jstringToWtfString(env, str)); #endif diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 69585b2..defa66e 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -3477,8 +3477,12 @@ bool WebViewCore::drawIsPaused() const #if USE(CHROME_NETWORK_STACK) void WebViewCore::setWebRequestContextUserAgent() { - if (m_webRequestContext) - m_webRequestContext->setUserAgent(WebFrame::getWebFrame(m_mainFrame)->userAgentForURL(0)); // URL not used + webRequestContext()->setUserAgent(WebFrame::getWebFrame(m_mainFrame)->userAgentForURL(0)); // URL not used +} + +void WebViewCore::setWebRequestContextCacheMode(int mode) +{ + webRequestContext()->setCacheMode(mode); } WebRequestContext* WebViewCore::webRequestContext() @@ -3486,7 +3490,6 @@ WebRequestContext* WebViewCore::webRequestContext() if (!m_webRequestContext) { Settings* settings = mainFrame()->settings(); m_webRequestContext = new WebRequestContext(settings && settings->privateBrowsingEnabled()); - setWebRequestContextUserAgent(); } return m_webRequestContext.get(); } diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h index f6c6f66..4d1110f 100644 --- a/WebKit/android/jni/WebViewCore.h +++ b/WebKit/android/jni/WebViewCore.h @@ -566,8 +566,11 @@ namespace android { bool isPaused() const { return m_isPaused; } void setIsPaused(bool isPaused) { m_isPaused = isPaused; } bool drawIsPaused() const; +#if USE(CHROME_NETWORK_STACK) void setWebRequestContextUserAgent(); + void setWebRequestContextCacheMode(int mode); WebRequestContext* webRequestContext(); +#endif // end of shared members // internal functions |