diff options
Diffstat (limited to 'Source/WebKit/android/jni')
-rw-r--r-- | Source/WebKit/android/jni/AndroidHitTestResult.cpp | 36 | ||||
-rw-r--r-- | Source/WebKit/android/jni/AndroidHitTestResult.h | 3 | ||||
-rw-r--r-- | Source/WebKit/android/jni/CacheManager.cpp | 4 | ||||
-rw-r--r-- | Source/WebKit/android/jni/CookieManager.cpp | 41 | ||||
-rw-r--r-- | Source/WebKit/android/jni/JavaBridge.cpp | 2 | ||||
-rw-r--r-- | Source/WebKit/android/jni/JniUtil.cpp | 58 | ||||
-rw-r--r-- | Source/WebKit/android/jni/WebCoreFrameBridge.cpp | 133 | ||||
-rw-r--r-- | Source/WebKit/android/jni/WebCoreFrameBridge.h | 6 | ||||
-rw-r--r-- | Source/WebKit/android/jni/WebCoreJni.cpp | 4 | ||||
-rw-r--r-- | Source/WebKit/android/jni/WebCoreJni.h | 2 | ||||
-rw-r--r-- | Source/WebKit/android/jni/WebCoreJniOnLoad.cpp | 7 | ||||
-rw-r--r-- | Source/WebKit/android/jni/WebCoreResourceLoader.cpp | 327 | ||||
-rw-r--r-- | Source/WebKit/android/jni/WebCoreResourceLoader.h | 78 | ||||
-rw-r--r-- | Source/WebKit/android/jni/WebSettings.cpp | 8 | ||||
-rw-r--r-- | Source/WebKit/android/jni/WebViewCore.cpp | 315 | ||||
-rw-r--r-- | Source/WebKit/android/jni/WebViewCore.h | 18 |
16 files changed, 128 insertions, 914 deletions
diff --git a/Source/WebKit/android/jni/AndroidHitTestResult.cpp b/Source/WebKit/android/jni/AndroidHitTestResult.cpp index 6f94488..f5dcc48 100644 --- a/Source/WebKit/android/jni/AndroidHitTestResult.cpp +++ b/Source/WebKit/android/jni/AndroidHitTestResult.cpp @@ -28,6 +28,9 @@ #include "config.h" #include "AndroidHitTestResult.h" +#include "content/address_detector.h" +#include "content/PhoneEmailDetector.h" +#include "android/WebHitTestInfo.h" #include "Document.h" #include "Element.h" #include "Frame.h" @@ -63,6 +66,7 @@ static struct { jfieldID m_TapHighlightColor; jfieldID m_EnclosingParentRects; jfieldID m_HasFocus; + jfieldID m_IntentUrl; } gHitTestGlue; struct field { @@ -89,6 +93,7 @@ static void InitJni(JNIEnv* env) { hitTestClass, "mTouchRects", "[Landroid/graphics/Rect;", &gHitTestGlue.m_TouchRects }, { hitTestClass, "mEditable", "Z", &gHitTestGlue.m_Editable }, { hitTestClass, "mLinkUrl", "Ljava/lang/String;", &gHitTestGlue.m_LinkUrl }, + { hitTestClass, "mIntentUrl", "Ljava/lang/String;", &gHitTestGlue.m_IntentUrl }, { hitTestClass, "mAnchorText", "Ljava/lang/String;", &gHitTestGlue.m_AnchorText }, { hitTestClass, "mImageUrl", "Ljava/lang/String;", &gHitTestGlue.m_ImageUrl }, { hitTestClass, "mAltDisplayString", "Ljava/lang/String;", &gHitTestGlue.m_AltDisplayString }, @@ -135,13 +140,29 @@ void AndroidHitTestResult::buildHighlightRects() RenderObject* renderer = node->renderer(); Vector<FloatQuad> quads; renderer->absoluteFocusRingQuads(quads); - for (int i = 0; i < quads.size(); i++) { + for (size_t i = 0; i < quads.size(); i++) { IntRect boundingBox = quads[i].enclosingBoundingBox(); boundingBox.move(-frameOffset.x(), -frameOffset.y()); m_highlightRects.append(boundingBox); } } +void AndroidHitTestResult::searchContentDetectors() +{ + AddressDetector address; + PhoneEmailDetector phoneEmail; + WebKit::WebHitTestInfo webHitTest(m_hitTestResult); + m_searchResult = address.FindTappedContent(webHitTest); + if (!m_searchResult.valid) { + m_searchResult = phoneEmail.FindTappedContent(webHitTest); + } + if (m_searchResult.valid) { + m_highlightRects.clear(); + RefPtr<Range> range = (PassRefPtr<Range>) m_searchResult.range; + range->textRects(m_highlightRects, true); + } +} + void setStringField(JNIEnv* env, jobject obj, jfieldID field, const String& str) { jstring jstr = wtfStringToJstring(env, str, false); @@ -149,6 +170,13 @@ void setStringField(JNIEnv* env, jobject obj, jfieldID field, const String& str) env->DeleteLocalRef(jstr); } +void setStringField(JNIEnv* env, jobject obj, jfieldID field, const GURL& url) +{ + jstring jstr = stdStringToJstring(env, url.spec(), false); + env->SetObjectField(obj, field, jstr); + env->DeleteLocalRef(jstr); +} + void setRectArray(JNIEnv* env, jobject obj, jfieldID field, Vector<IntRect> &rects) { jobjectArray array = intRectVectorToRectArray(env, rects); @@ -176,6 +204,8 @@ jobject AndroidHitTestResult::createJavaObject(JNIEnv* env) SET_BOOL(Editable, m_hitTestResult.isContentEditable()); SET_STRING(LinkUrl, m_hitTestResult.absoluteLinkURL().string()); + if (m_searchResult.valid) + SET_STRING(IntentUrl, m_searchResult.intent_url); SET_STRING(ImageUrl, m_hitTestResult.absoluteImageURL().string()); SET_STRING(AltDisplayString, m_hitTestResult.altDisplayString()); TextDirection titleTextDirection; @@ -201,8 +231,8 @@ jobject AndroidHitTestResult::createJavaObject(JNIEnv* env) Vector<IntRect> AndroidHitTestResult::enclosingParentRects(Node* node) { - int lastX; int count = 0; + int lastX = 0; Vector<IntRect> rects; while (node && count < 5) { @@ -214,7 +244,7 @@ Vector<IntRect> AndroidHitTestResult::enclosingParentRects(Node* node) node->document()->frame()); IntRect rect = render->absoluteBoundingBoxRect(); rect.move(-frameOffset.x(), -frameOffset.y()); - if (rect.x() != lastX) { + if (count == 0 || rect.x() != lastX) { rects.append(rect); lastX = rect.x(); count++; diff --git a/Source/WebKit/android/jni/AndroidHitTestResult.h b/Source/WebKit/android/jni/AndroidHitTestResult.h index f9709ac..5bbfc6b 100644 --- a/Source/WebKit/android/jni/AndroidHitTestResult.h +++ b/Source/WebKit/android/jni/AndroidHitTestResult.h @@ -26,6 +26,7 @@ #ifndef AndroidHitTestResult_h #define AndroidHitTestResult_h +#include "content/content_detector.h" #include "Element.h" #include "HitTestResult.h" #include "IntRect.h" @@ -48,6 +49,7 @@ public: void setURLElement(WebCore::Element* element); void buildHighlightRects(); + void searchContentDetectors(); jobject createJavaObject(JNIEnv*); @@ -57,6 +59,7 @@ private: WebViewCore* m_webViewCore; WebCore::HitTestResult m_hitTestResult; Vector<WebCore::IntRect> m_highlightRects; + ContentDetector::Result m_searchResult; }; } // namespace android diff --git a/Source/WebKit/android/jni/CacheManager.cpp b/Source/WebKit/android/jni/CacheManager.cpp index d319054..b34776d 100644 --- a/Source/WebKit/android/jni/CacheManager.cpp +++ b/Source/WebKit/android/jni/CacheManager.cpp @@ -25,8 +25,6 @@ #include "config.h" -#if USE(CHROME_NETWORK_STACK) - #include "ChromiumIncludes.h" #include "WebCache.h" #include "WebCoreJni.h" @@ -140,5 +138,3 @@ int registerCacheManager(JNIEnv* env) } } // namespace android - -#endif // USE(CHROME_NETWORK_STACK) diff --git a/Source/WebKit/android/jni/CookieManager.cpp b/Source/WebKit/android/jni/CookieManager.cpp index 357d158..fca612f 100644 --- a/Source/WebKit/android/jni/CookieManager.cpp +++ b/Source/WebKit/android/jni/CookieManager.cpp @@ -40,49 +40,30 @@ static const char* javaCookieManagerClass = "android/webkit/CookieManager"; static bool acceptCookie(JNIEnv*, jobject) { -#if USE(CHROME_NETWORK_STACK) // This is a static method which gets the cookie policy for all WebViews. We // always apply the same configuration to the contexts for both regular and // private browsing, so expect the same result here. bool regularAcceptCookies = WebCookieJar::get(false)->allowCookies(); ASSERT(regularAcceptCookies == WebCookieJar::get(true)->allowCookies()); return regularAcceptCookies; -#else - // The Android HTTP stack is implemented Java-side. - ASSERT_NOT_REACHED(); - return false; -#endif } static jstring getCookie(JNIEnv* env, jobject, jstring url, jboolean privateBrowsing) { -#if USE(CHROME_NETWORK_STACK) GURL gurl(jstringToStdString(env, url)); CookieOptions options; options.set_include_httponly(); std::string cookies = WebCookieJar::get(privateBrowsing)->cookieStore()->GetCookieMonster()->GetCookiesWithOptions(gurl, options); return stdStringToJstring(env, cookies); -#else - // The Android HTTP stack is implemented Java-side. - ASSERT_NOT_REACHED(); - return jstring(); -#endif } static bool hasCookies(JNIEnv*, jobject, jboolean privateBrowsing) { -#if USE(CHROME_NETWORK_STACK) return WebCookieJar::get(privateBrowsing)->getNumCookiesInDatabase() > 0; -#else - // The Android HTTP stack is implemented Java-side. - ASSERT_NOT_REACHED(); - return false; -#endif } static void removeAllCookie(JNIEnv*, jobject) { -#if USE(CHROME_NETWORK_STACK) WebCookieJar::get(false)->cookieStore()->GetCookieMonster()->DeleteAll(true); // This will lazily create a new private browsing context. However, if the // context doesn't already exist, there's no need to create it, as cookies @@ -94,84 +75,62 @@ static void removeAllCookie(JNIEnv*, jobject) // The Java code removes cookies directly from the backing database, so we do the same, // but with a NULL callback so it's asynchronous. WebCookieJar::get(true)->cookieStore()->GetCookieMonster()->FlushStore(NULL); -#endif } static void removeExpiredCookie(JNIEnv*, jobject) { -#if USE(CHROME_NETWORK_STACK) // This simply forces a GC. The getters delete expired cookies so won't return expired cookies anyway. WebCookieJar::get(false)->cookieStore()->GetCookieMonster()->GetAllCookies(); WebCookieJar::get(true)->cookieStore()->GetCookieMonster()->GetAllCookies(); -#endif } static void removeSessionCookies(WebCookieJar* cookieJar) { -#if USE(CHROME_NETWORK_STACK) CookieMonster* cookieMonster = cookieJar->cookieStore()->GetCookieMonster(); CookieList cookies = cookieMonster->GetAllCookies(); for (CookieList::const_iterator iter = cookies.begin(); iter != cookies.end(); ++iter) { if (iter->IsSessionCookie()) cookieMonster->DeleteCanonicalCookie(*iter); } -#endif } static void removeSessionCookie(JNIEnv*, jobject) { -#if USE(CHROME_NETWORK_STACK) removeSessionCookies(WebCookieJar::get(false)); removeSessionCookies(WebCookieJar::get(true)); -#endif } static void setAcceptCookie(JNIEnv*, jobject, jboolean accept) { -#if USE(CHROME_NETWORK_STACK) // This is a static method which configures the cookie policy for all // WebViews, so we configure the contexts for both regular and private // browsing. WebCookieJar::get(false)->setAllowCookies(accept); WebCookieJar::get(true)->setAllowCookies(accept); -#endif } static void setCookie(JNIEnv* env, jobject, jstring url, jstring value, jboolean privateBrowsing) { -#if USE(CHROME_NETWORK_STACK) GURL gurl(jstringToStdString(env, url)); std::string line(jstringToStdString(env, value)); CookieOptions options; options.set_include_httponly(); WebCookieJar::get(privateBrowsing)->cookieStore()->GetCookieMonster()->SetCookieWithOptions(gurl, line, options); -#endif } static void flushCookieStore(JNIEnv*, jobject) { -#if USE(CHROME_NETWORK_STACK) WebCookieJar::flush(); -#endif } static bool acceptFileSchemeCookies(JNIEnv*, jobject) { -#if USE(CHROME_NETWORK_STACK) return WebCookieJar::acceptFileSchemeCookies(); -#else - // File scheme cookies are always accepted with the Android HTTP stack. - return true; -#endif } static void setAcceptFileSchemeCookies(JNIEnv*, jobject, jboolean accept) { -#if USE(CHROME_NETWORK_STACK) WebCookieJar::setAcceptFileSchemeCookies(accept); -#else - // File scheme cookies are always accepted with the Android HTTP stack. -#endif } static JNINativeMethod gCookieManagerMethods[] = { diff --git a/Source/WebKit/android/jni/JavaBridge.cpp b/Source/WebKit/android/jni/JavaBridge.cpp index 204ac4e..4c8234b 100644 --- a/Source/WebKit/android/jni/JavaBridge.cpp +++ b/Source/WebKit/android/jni/JavaBridge.cpp @@ -472,12 +472,10 @@ void JavaBridge::RemovePackageName(JNIEnv* env, jobject obj, jstring packageName void JavaBridge::UpdateProxy(JNIEnv* env, jobject obj, jstring newProxy, jstring newExList) { -#if USE(CHROME_NETWORK_STACK) std::string proxy = jstringToStdString(env, newProxy); std::string exList = jstringToStdString(env, newExList); WebCache::get(false)->proxy()->UpdateProxySettings(proxy, exList); WebCache::get(true)->proxy()->UpdateProxySettings(proxy, exList); -#endif } diff --git a/Source/WebKit/android/jni/JniUtil.cpp b/Source/WebKit/android/jni/JniUtil.cpp deleted file mode 100644 index 651016e..0000000 --- a/Source/WebKit/android/jni/JniUtil.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2010, The Android Open Source Project - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#include "ChromiumIncludes.h" -#include <JNIHelp.h> - -namespace android { - -static const char* javaJniUtilClass = "android/webkit/JniUtil"; - -static bool useChromiumHttpStack(JNIEnv*, jobject) -{ -#if USE(CHROME_NETWORK_STACK) - return true; -#else - return false; -#endif -} - -static JNINativeMethod gJniUtilMethods[] = { - { "nativeUseChromiumHttpStack", "()Z", (void*) useChromiumHttpStack }, -}; - -int registerJniUtil(JNIEnv* env) -{ -#ifndef NDEBUG - jclass jniUtil = env->FindClass(javaJniUtilClass); - ALOG_ASSERT(jniUtil, "Unable to find class"); - env->DeleteLocalRef(jniUtil); -#endif - return jniRegisterNativeMethods(env, javaJniUtilClass, gJniUtilMethods, NELEM(gJniUtilMethods)); -} - -} // namespace android diff --git a/Source/WebKit/android/jni/WebCoreFrameBridge.cpp b/Source/WebKit/android/jni/WebCoreFrameBridge.cpp index 2724d6b..d0f3830 100644 --- a/Source/WebKit/android/jni/WebCoreFrameBridge.cpp +++ b/Source/WebKit/android/jni/WebCoreFrameBridge.cpp @@ -83,7 +83,6 @@ #include "WebArchiveAndroid.h" #include "WebCache.h" #include "WebCoreJni.h" -#include "WebCoreResourceLoader.h" #include "WebHistory.h" #include "WebIconDatabase.h" #include "WebFrameView.h" @@ -229,8 +228,6 @@ WebFrame::WebFrame(JNIEnv* env, jobject obj, jobject historyList, WebCore::Page* mJavaFrame = new JavaBrowserFrame; mJavaFrame->mObj = env->NewWeakGlobalRef(obj); mJavaFrame->mHistoryList = env->NewWeakGlobalRef(historyList); - mJavaFrame->mStartLoadingResource = env->GetMethodID(clazz, "startLoadingResource", - "(ILjava/lang/String;Ljava/lang/String;Ljava/util/HashMap;[BJIZZZLjava/lang/String;Ljava/lang/String;)Landroid/webkit/LoadListener;"); mJavaFrame->mMaybeSavePassword = env->GetMethodID(clazz, "maybeSavePassword", "([BLjava/lang/String;Ljava/lang/String;)V"); mJavaFrame->mShouldInterceptRequest = @@ -286,7 +283,6 @@ WebFrame::WebFrame(JNIEnv* env, jobject obj, jobject historyList, WebCore::Page* "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); env->DeleteLocalRef(clazz); - ALOG_ASSERT(mJavaFrame->mStartLoadingResource, "Could not find method startLoadingResource"); ALOG_ASSERT(mJavaFrame->mMaybeSavePassword, "Could not find method maybeSavePassword"); ALOG_ASSERT(mJavaFrame->mShouldInterceptRequest, "Could not find method shouldInterceptRequest"); ALOG_ASSERT(mJavaFrame->mLoadStarted, "Could not find method loadStarted"); @@ -401,94 +397,6 @@ private: int m_size; }; -PassRefPtr<WebCore::ResourceLoaderAndroid> -WebFrame::startLoadingResource(WebCore::ResourceHandle* loader, - const WebCore::ResourceRequest& request, - bool mainResource, - bool synchronous) -{ - ALOGV("::WebCore:: startLoadingResource(%p, %s)", - loader, request.url().string().latin1().data()); - - JNIEnv* env = getJNIEnv(); - AutoJObject javaFrame = mJavaFrame->frame(env); - if (!javaFrame.get()) - return 0; - - WTF::String method = request.httpMethod(); - WebCore::HTTPHeaderMap headers = request.httpHeaderFields(); - - WTF::String urlStr = request.url().string(); - int colon = urlStr.find(':'); - bool allLower = true; - for (int index = 0; index < colon; index++) { - UChar ch = urlStr[index]; - if (!WTF::isASCIIAlpha(ch)) - break; - allLower &= WTF::isASCIILower(ch); - if (index == colon - 1 && !allLower) { - urlStr = urlStr.substring(0, colon).lower() - + urlStr.substring(colon); - } - } - ALOGV("%s lower=%s", __FUNCTION__, urlStr.latin1().data()); - jstring jUrlStr = wtfStringToJstring(env, urlStr); - jstring jMethodStr = NULL; - if (!method.isEmpty()) - jMethodStr = wtfStringToJstring(env, method); - WebCore::FormData* formdata = request.httpBody(); - jbyteArray jPostDataStr = getPostData(request); - jobject jHeaderMap = createJavaMapFromHTTPHeaders(env, headers); - - // Convert the WebCore Cache Policy to a WebView Cache Policy. - int cacheMode = 0; // WebSettings.LOAD_NORMAL - switch (request.cachePolicy()) { - case WebCore::ReloadIgnoringCacheData: - cacheMode = 2; // WebSettings.LOAD_NO_CACHE - break; - case WebCore::ReturnCacheDataDontLoad: - cacheMode = 3; // WebSettings.LOAD_CACHE_ONLY - break; - case WebCore::ReturnCacheDataElseLoad: - cacheMode = 1; // WebSettings.LOAD_CACHE_ELSE_NETWORK - break; - case WebCore::UseProtocolCachePolicy: - default: - break; - } - - ALOGV("::WebCore:: startLoadingResource %s with cacheMode %d", urlStr.ascii().data(), cacheMode); - - ResourceHandleInternal* loaderInternal = loader->getInternal(); - jstring jUsernameString = loaderInternal->m_user.isEmpty() ? - NULL : wtfStringToJstring(env, loaderInternal->m_user); - jstring jPasswordString = loaderInternal->m_pass.isEmpty() ? - NULL : wtfStringToJstring(env, loaderInternal->m_pass); - - bool isUserGesture = UserGestureIndicator::processingUserGesture(); - jobject jLoadListener = - env->CallObjectMethod(javaFrame.get(), mJavaFrame->mStartLoadingResource, - (int)loader, jUrlStr, jMethodStr, jHeaderMap, - jPostDataStr, formdata ? formdata->identifier(): 0, - cacheMode, mainResource, isUserGesture, - synchronous, jUsernameString, jPasswordString); - - env->DeleteLocalRef(jUrlStr); - env->DeleteLocalRef(jMethodStr); - env->DeleteLocalRef(jPostDataStr); - env->DeleteLocalRef(jHeaderMap); - env->DeleteLocalRef(jUsernameString); - env->DeleteLocalRef(jPasswordString); - if (checkException(env)) - return 0; - - RefPtr<WebCore::ResourceLoaderAndroid> h; - if (jLoadListener) - h = WebCoreResourceLoader::create(env, jLoadListener); - env->DeleteLocalRef(jLoadListener); - return h; -} - UrlInterceptResponse* WebFrame::shouldInterceptRequest(const WTF::String& url) { @@ -529,7 +437,6 @@ WebFrame::reportError(int errorCode, const WTF::String& description, WTF::String WebFrame::convertIDNToUnicode(const WebCore::KURL& url) { WTF::String converted = url.string(); -#if USE(CHROME_NETWORK_STACK) const WTF::String host = url.host(); if (host.find("xn--") == notFound) // no punycode IDN found. return converted; @@ -542,7 +449,6 @@ WebFrame::convertIDNToUnicode(const WebCore::KURL& url) { newUrl.setHost(convertedHost); converted = newUrl.string(); } -#endif return converted; } @@ -886,7 +792,6 @@ WebFrame::density() const return dpi; } -#if USE(CHROME_NETWORK_STACK) void WebFrame::didReceiveAuthenticationChallenge(WebUrlLoaderClient* client, const std::string& host, const std::string& realm, bool useCachedCredentials, bool suppressDialog) { @@ -998,7 +903,6 @@ void WebFrame::setCertificate(const std::string& cert) checkException(env); } -#endif // USE(CHROME_NETWORK_STACK) void WebFrame::autoLogin(const std::string& loginHeader) { @@ -1188,10 +1092,8 @@ static void CreateFrame(JNIEnv* env, jobject obj, jobject javaview, jobject jAss { ScriptController::initializeThreading(); -#if USE(CHROME_NETWORK_STACK) // needs to be called before any other chromium code initChromium(); -#endif // Create a new page ChromeClientAndroid* chromeC = new ChromeClientAndroid; @@ -1722,12 +1624,7 @@ static void ClearWebCoreCache() static void ClearWebViewCache() { -#if USE(CHROME_NETWORK_STACK) WebCache::get(false /*privateBrowsing*/)->clear(); -#else - // The Android network stack provides a WebView cache in CacheManager.java. - // Clearing this is handled entirely Java-side. -#endif } static void ClearCache(JNIEnv *env, jobject obj) @@ -1902,8 +1799,6 @@ static jboolean GetShouldStartScrolledRight(JNIEnv *env, jobject obj, return startScrolledRight; } -#if USE(CHROME_NETWORK_STACK) - static void AuthenticationProceed(JNIEnv *env, jobject obj, int handle, jstring jUsername, jstring jPassword) { WebUrlLoaderClient* client = reinterpret_cast<WebUrlLoaderClient*>(handle); @@ -2008,34 +1903,6 @@ static void SslClientCert(JNIEnv *env, jobject obj, int handle, jbyteArray pkey, client->sslClientCert(privateKey.release(), certificate); } -#else - -static void AuthenticationProceed(JNIEnv *env, jobject obj, int handle, jstring jUsername, jstring jPassword) -{ - ALOGW("Chromium authentication API called, but libchromium is not available"); -} - -static void AuthenticationCancel(JNIEnv *env, jobject obj, int handle) -{ - ALOGW("Chromium authentication API called, but libchromium is not available"); -} - -static void SslCertErrorProceed(JNIEnv *env, jobject obj, int handle) -{ - ALOGW("Chromium SSL API called, but libchromium is not available"); -} - -static void SslCertErrorCancel(JNIEnv *env, jobject obj, int handle, int cert_error) -{ - ALOGW("Chromium SSL API called, but libchromium is not available"); -} - -static void SslClientCert(JNIEnv *env, jobject obj, int handle, jbyteArray privateKey, jobjectArray chain) -{ - ALOGW("Chromium SSL API called, but libchromium is not available"); -} -#endif // USE(CHROME_NETWORK_STACK) - // ---------------------------------------------------------------------------- /* diff --git a/Source/WebKit/android/jni/WebCoreFrameBridge.h b/Source/WebKit/android/jni/WebCoreFrameBridge.h index eaee63c..13f99af 100644 --- a/Source/WebKit/android/jni/WebCoreFrameBridge.h +++ b/Source/WebKit/android/jni/WebCoreFrameBridge.h @@ -64,10 +64,6 @@ class WebFrame : public WebCoreRefObject { // helper function static WebFrame* getWebFrame(const WebCore::Frame* frame); - virtual PassRefPtr<WebCore::ResourceLoaderAndroid> startLoadingResource(WebCore::ResourceHandle*, - const WebCore::ResourceRequest& request, bool mainResource, - bool synchronous); - UrlInterceptResponse* shouldInterceptRequest(const WTF::String& url); void reportError(int errorCode, const WTF::String& description, @@ -117,7 +113,6 @@ class WebFrame : public WebCoreRefObject { float density() const; -#if USE(CHROME_NETWORK_STACK) 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); @@ -125,7 +120,6 @@ class WebFrame : public WebCoreRefObject { void didReceiveData(const char* data, int size); void didFinishLoading(); void setCertificate(const std::string& cert); -#endif void maybeSavePassword(WebCore::Frame* frame, const WebCore::ResourceRequest& request); diff --git a/Source/WebKit/android/jni/WebCoreJni.cpp b/Source/WebKit/android/jni/WebCoreJni.cpp index 65b6d20..5a142c8 100644 --- a/Source/WebKit/android/jni/WebCoreJni.cpp +++ b/Source/WebKit/android/jni/WebCoreJni.cpp @@ -79,8 +79,6 @@ jstring wtfStringToJstring(JNIEnv* env, const WTF::String& str, bool validOnZero return length || validOnZeroLength ? env->NewString(str.characters(), length) : 0; } - -#if USE(CHROME_NETWORK_STACK) string16 jstringToString16(JNIEnv* env, jstring jstr) { if (!jstr || !env) @@ -114,8 +112,6 @@ jstring stdStringToJstring(JNIEnv* env, const std::string& str, bool validOnZero return !str.empty() || validOnZeroLength ? env->NewStringUTF(str.c_str()) : 0; } -#endif - jobjectArray intRectVectorToRectArray(JNIEnv* env, Vector<WebCore::IntRect>& rects) { jclass rectClass = env->FindClass("android/graphics/Rect"); diff --git a/Source/WebKit/android/jni/WebCoreJni.h b/Source/WebKit/android/jni/WebCoreJni.h index 7a46f7b..25aa986 100644 --- a/Source/WebKit/android/jni/WebCoreJni.h +++ b/Source/WebKit/android/jni/WebCoreJni.h @@ -82,7 +82,6 @@ WTF::String jstringToWtfString(JNIEnv*, jstring); // an empty WTF String returns 0. jstring wtfStringToJstring(JNIEnv*, const WTF::String&, bool validOnZeroLength = false); -#if USE(CHROME_NETWORK_STACK) string16 jstringToString16(JNIEnv*, jstring); std::string jstringToStdString(JNIEnv*, jstring); @@ -90,7 +89,6 @@ std::string jstringToStdString(JNIEnv*, jstring); // passing in an empty std::string will result in an empty jstring. Otherwise // an empty std::string returns 0. jstring stdStringToJstring(JNIEnv*, const std::string&, bool validOnZeroLength = false); -#endif jobjectArray intRectVectorToRectArray(JNIEnv*, Vector<WebCore::IntRect>&); diff --git a/Source/WebKit/android/jni/WebCoreJniOnLoad.cpp b/Source/WebKit/android/jni/WebCoreJniOnLoad.cpp index 64aeb7e..2644dab 100644 --- a/Source/WebKit/android/jni/WebCoreJniOnLoad.cpp +++ b/Source/WebKit/android/jni/WebCoreJniOnLoad.cpp @@ -73,7 +73,6 @@ namespace android { extern int registerWebFrame(JNIEnv*); extern int registerJavaBridge(JNIEnv*); -extern int registerJniUtil(JNIEnv*); extern int registerResourceLoader(JNIEnv*); extern int registerWebViewCore(JNIEnv*); extern int registerWebHistory(JNIEnv*); @@ -92,9 +91,7 @@ extern int registerMediaPlayerVideo(JNIEnv*); #endif extern int registerDeviceMotionAndOrientationManager(JNIEnv*); extern int registerCookieManager(JNIEnv*); -#if USE(CHROME_NETWORK_STACK) extern int registerCacheManager(JNIEnv*); -#endif } @@ -105,9 +102,7 @@ struct RegistrationMethod { static RegistrationMethod gWebCoreRegMethods[] = { { "JavaBridge", android::registerJavaBridge }, - { "JniUtil", android::registerJniUtil }, { "WebFrame", android::registerWebFrame }, - { "WebCoreResourceLoader", android::registerResourceLoader }, { "WebViewCore", android::registerWebViewCore }, { "WebHistory", android::registerWebHistory }, { "WebIconDatabase", android::registerWebIconDatabase }, @@ -125,9 +120,7 @@ static RegistrationMethod gWebCoreRegMethods[] = { #endif { "DeviceMotionAndOrientationManager", android::registerDeviceMotionAndOrientationManager }, { "CookieManager", android::registerCookieManager }, -#if USE(CHROME_NETWORK_STACK) { "CacheManager", android::registerCacheManager }, -#endif }; EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) diff --git a/Source/WebKit/android/jni/WebCoreResourceLoader.cpp b/Source/WebKit/android/jni/WebCoreResourceLoader.cpp deleted file mode 100644 index f0861ff..0000000 --- a/Source/WebKit/android/jni/WebCoreResourceLoader.cpp +++ /dev/null @@ -1,327 +0,0 @@ -/* - * Copyright 2006, The Android Open Source Project - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#define LOG_TAG "webcoreglue" - -#include "config.h" -#include "WebCoreResourceLoader.h" - -#include "ResourceError.h" -#include "ResourceHandle.h" -#include "ResourceHandleClient.h" -#include "ResourceHandleInternal.h" -#include "ResourceResponse.h" -#include "SkUtils.h" -#include "WebCoreJni.h" - -#include <JNIHelp.h> -#include <JNIUtility.h> -#include <SkTypes.h> -#include <stdlib.h> -#include <utils/misc.h> -#include <wtf/Platform.h> -#include <wtf/text/CString.h> - -namespace android { - -// ---------------------------------------------------------------------------- - -static struct resourceloader_t { - jfieldID mObject; - jmethodID mCancelMethodID; - jmethodID mDownloadFileMethodID; - jmethodID mWillLoadFromCacheMethodID; - jmethodID mPauseLoadMethodID; -} gResourceLoader; - -// ---------------------------------------------------------------------------- - -#define GET_NATIVE_HANDLE(env, obj) ((WebCore::ResourceHandle*)env->GetIntField(obj, gResourceLoader.mObject)) -#define SET_NATIVE_HANDLE(env, obj, handle) (env->SetIntField(obj, gResourceLoader.mObject, handle)) - -//----------------------------------------------------------------------------- -// ResourceLoadHandler - -PassRefPtr<WebCore::ResourceLoaderAndroid> WebCoreResourceLoader::create(JNIEnv *env, jobject jLoadListener) -{ - return adoptRef<WebCore::ResourceLoaderAndroid>(new WebCoreResourceLoader(env, jLoadListener)); -} - -WebCoreResourceLoader::WebCoreResourceLoader(JNIEnv *env, jobject jLoadListener) - : mPausedLoad(false) -{ - mJLoader = env->NewGlobalRef(jLoadListener); -} - -WebCoreResourceLoader::~WebCoreResourceLoader() -{ - JNIEnv* env = JSC::Bindings::getJNIEnv(); - SET_NATIVE_HANDLE(env, mJLoader, 0); - env->DeleteGlobalRef(mJLoader); - mJLoader = 0; -} - -void WebCoreResourceLoader::cancel() -{ - JNIEnv* env = JSC::Bindings::getJNIEnv(); - env->CallVoidMethod(mJLoader, gResourceLoader.mCancelMethodID); - checkException(env); -} - -void WebCoreResourceLoader::downloadFile() -{ - JNIEnv* env = JSC::Bindings::getJNIEnv(); - env->CallVoidMethod(mJLoader, gResourceLoader.mDownloadFileMethodID); - checkException(env); -} - -void WebCoreResourceLoader::pauseLoad(bool pause) -{ - if (mPausedLoad == pause) - return; - - mPausedLoad = pause; - JNIEnv* env = JSC::Bindings::getJNIEnv(); - env->CallVoidMethod(mJLoader, gResourceLoader.mPauseLoadMethodID, pause); - checkException(env); -} - -/* -* This static method is called to check to see if a POST response is in -* the cache. This may be slow, but is only used during a navigation to -* a POST response. -*/ -bool WebCoreResourceLoader::willLoadFromCache(const WebCore::KURL& url, int64_t identifier) -{ - JNIEnv* env = JSC::Bindings::getJNIEnv(); - WTF::String urlStr = url.string(); - jstring jUrlStr = wtfStringToJstring(env, urlStr); - jclass resourceLoader = env->FindClass("android/webkit/LoadListener"); - bool val = env->CallStaticBooleanMethod(resourceLoader, gResourceLoader.mWillLoadFromCacheMethodID, jUrlStr, identifier); - checkException(env); - env->DeleteLocalRef(resourceLoader); - env->DeleteLocalRef(jUrlStr); - - return val; -} - -// ---------------------------------------------------------------------------- -void WebCoreResourceLoader::SetResponseHeader(JNIEnv* env, jobject obj, jint nativeResponse, jstring key, jstring val) -{ - WebCore::ResourceResponse* response = (WebCore::ResourceResponse*)nativeResponse; - ALOG_ASSERT(response, "nativeSetResponseHeader must take a valid response pointer!"); - - ALOG_ASSERT(key, "How did a null value become a key?"); - if (val) - response->setHTTPHeaderField(jstringToWtfString(env, key), jstringToWtfString(env, val)); -} - -jint WebCoreResourceLoader::CreateResponse(JNIEnv* env, jobject obj, jstring url, jint statusCode, - jstring statusText, jstring mimeType, jlong expectedLength, - jstring encoding) -{ - ALOG_ASSERT(url, "Must have a url in the response!"); - WebCore::KURL kurl(WebCore::ParsedURLString, jstringToWtfString(env, url)); - WTF::String encodingStr; - WTF::String mimeTypeStr; - if (mimeType) { - mimeTypeStr = jstringToWtfString(env, mimeType); - ALOGV("Response setMIMEType: %s", mimeTypeStr.latin1().data()); - } - if (encoding) { - encodingStr = jstringToWtfString(env, encoding); - ALOGV("Response setTextEncodingName: %s", encodingStr.latin1().data()); - } - WebCore::ResourceResponse* response = new WebCore::ResourceResponse( - kurl, mimeTypeStr, (long long)expectedLength, - encodingStr, WTF::String()); - response->setHTTPStatusCode(statusCode); - if (statusText) { - WTF::String status = jstringToWtfString(env, statusText); - response->setHTTPStatusText(status); - ALOGV("Response setStatusText: %s", status.latin1().data()); - } - return (int)response; -} - -void WebCoreResourceLoader::ReceivedResponse(JNIEnv* env, jobject obj, jint nativeResponse) -{ - WebCore::ResourceHandle* handle = GET_NATIVE_HANDLE(env, obj); - ALOG_ASSERT(handle, "nativeReceivedResponse must take a valid handle!"); - // ResourceLoader::didFail() can set handle to be NULL, we need to check - if (!handle) - return; - - WebCore::ResourceResponse* response = (WebCore::ResourceResponse*)nativeResponse; - ALOG_ASSERT(response, "nativeReceivedResponse must take a valid resource pointer!"); - handle->client()->didReceiveResponse(handle, *response); - // As the client makes a copy of the response, delete it here. - delete response; -} - -void WebCoreResourceLoader::AddData(JNIEnv* env, jobject obj, jbyteArray dataArray, jint length) -{ - ALOGV("webcore_resourceloader data(%d)", length); - - WebCore::ResourceHandle* handle = GET_NATIVE_HANDLE(env, obj); - ALOG_ASSERT(handle, "nativeAddData must take a valid handle!"); - // ResourceLoader::didFail() can set handle to be NULL, we need to check - if (!handle) - return; - - SkAutoMemoryUsageProbe mup("android_webcore_resourceloader_nativeAddData"); - - bool result = false; - jbyte * data = env->GetByteArrayElements(dataArray, NULL); - - ALOG_ASSERT(handle->client(), "Why do we not have a client?"); - handle->client()->didReceiveData(handle, (const char *)data, length, length); - env->ReleaseByteArrayElements(dataArray, data, JNI_ABORT); -} - -void WebCoreResourceLoader::Finished(JNIEnv* env, jobject obj) -{ - ALOGV("webcore_resourceloader finished"); - WebCore::ResourceHandle* handle = GET_NATIVE_HANDLE(env, obj); - ALOG_ASSERT(handle, "nativeFinished must take a valid handle!"); - // ResourceLoader::didFail() can set handle to be NULL, we need to check - if (!handle) - return; - - ALOG_ASSERT(handle->client(), "Why do we not have a client?"); - handle->client()->didFinishLoading(handle, 0); -} - -jstring WebCoreResourceLoader::RedirectedToUrl(JNIEnv* env, jobject obj, - jstring baseUrl, jstring redirectTo, jint nativeResponse) -{ - ALOGV("webcore_resourceloader redirectedToUrl"); - WebCore::ResourceHandle* handle = GET_NATIVE_HANDLE(env, obj); - ALOG_ASSERT(handle, "nativeRedirectedToUrl must take a valid handle!"); - // ResourceLoader::didFail() can set handle to be NULL, we need to check - if (!handle) - return NULL; - - ALOG_ASSERT(handle->client(), "Why do we not have a client?"); - WebCore::ResourceRequest r = handle->firstRequest(); - WebCore::KURL url(WebCore::KURL(WebCore::ParsedURLString, jstringToWtfString(env, baseUrl)), - jstringToWtfString(env, redirectTo)); - WebCore::ResourceResponse* response = (WebCore::ResourceResponse*)nativeResponse; - // If the url fails to resolve the relative path, return null. - if (url.protocol().isEmpty()) { - delete response; - return NULL; - } else { - // Ensure the protocol is lowercase. - url.setProtocol(url.protocol().lower()); - } - // Set the url after updating the protocol. - r.setURL(url); - if (r.httpMethod() == "POST") { - r.setHTTPMethod("GET"); - r.clearHTTPReferrer(); - r.setHTTPBody(0); - r.setHTTPContentType(""); - } - handle->client()->willSendRequest(handle, r, *response); - delete response; - return wtfStringToJstring(env, url.string()); -} - -void WebCoreResourceLoader::Error(JNIEnv* env, jobject obj, jint id, jstring description, - jstring failingUrl) -{ - ALOGV("webcore_resourceloader error"); - WebCore::ResourceHandle* handle = GET_NATIVE_HANDLE(env, obj); - ALOG_ASSERT(handle, "nativeError must take a valid handle!"); - // ResourceLoader::didFail() can set handle to be NULL, we need to check - if (!handle) - return; - - handle->client()->didFail(handle, WebCore::ResourceError("", id, - jstringToWtfString(env, failingUrl), jstringToWtfString(env, description))); -} - -// ---------------------------------------------------------------------------- - -/* - * JNI registration. - */ -static JNINativeMethod gResourceloaderMethods[] = { - /* name, signature, funcPtr */ - { "nativeSetResponseHeader", "(ILjava/lang/String;Ljava/lang/String;)V", - (void*) WebCoreResourceLoader::SetResponseHeader }, - { "nativeCreateResponse", "(Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;JLjava/lang/String;)I", - (void*) WebCoreResourceLoader::CreateResponse }, - { "nativeReceivedResponse", "(I)V", - (void*) WebCoreResourceLoader::ReceivedResponse }, - { "nativeAddData", "([BI)V", - (void*) WebCoreResourceLoader::AddData }, - { "nativeFinished", "()V", - (void*) WebCoreResourceLoader::Finished }, - { "nativeRedirectedToUrl", "(Ljava/lang/String;Ljava/lang/String;I)Ljava/lang/String;", - (void*) WebCoreResourceLoader::RedirectedToUrl }, - { "nativeError", "(ILjava/lang/String;Ljava/lang/String;)V", - (void*) WebCoreResourceLoader::Error } -}; - -int registerResourceLoader(JNIEnv* env) -{ - jclass resourceLoader = env->FindClass("android/webkit/LoadListener"); - LOG_FATAL_IF(resourceLoader == NULL, - "Unable to find class android/webkit/LoadListener"); - - gResourceLoader.mObject = - env->GetFieldID(resourceLoader, "mNativeLoader", "I"); - LOG_FATAL_IF(gResourceLoader.mObject == NULL, - "Unable to find android/webkit/LoadListener.mNativeLoader"); - - gResourceLoader.mCancelMethodID = - env->GetMethodID(resourceLoader, "cancel", "()V"); - LOG_FATAL_IF(gResourceLoader.mCancelMethodID == NULL, - "Could not find method cancel on LoadListener"); - - gResourceLoader.mDownloadFileMethodID = - env->GetMethodID(resourceLoader, "downloadFile", "()V"); - LOG_FATAL_IF(gResourceLoader.mDownloadFileMethodID == NULL, - "Could not find method downloadFile on LoadListener"); - - gResourceLoader.mPauseLoadMethodID = - env->GetMethodID(resourceLoader, "pauseLoad", "(Z)V"); - LOG_FATAL_IF(gResourceLoader.mPauseLoadMethodID == NULL, - "Could not find method pauseLoad on LoadListener"); - - gResourceLoader.mWillLoadFromCacheMethodID = - env->GetStaticMethodID(resourceLoader, "willLoadFromCache", "(Ljava/lang/String;J)Z"); - LOG_FATAL_IF(gResourceLoader.mWillLoadFromCacheMethodID == NULL, - "Could not find static method willLoadFromCache on LoadListener"); - - env->DeleteLocalRef(resourceLoader); - - return jniRegisterNativeMethods(env, "android/webkit/LoadListener", - gResourceloaderMethods, NELEM(gResourceloaderMethods)); -} - -} /* namespace android */ diff --git a/Source/WebKit/android/jni/WebCoreResourceLoader.h b/Source/WebKit/android/jni/WebCoreResourceLoader.h deleted file mode 100644 index 0e34a5b..0000000 --- a/Source/WebKit/android/jni/WebCoreResourceLoader.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2006, The Android Open Source Project - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef WebCoreResourceLoader_h -#define WebCoreResourceLoader_h - -#include <KURL.h> -#include <ResourceLoaderAndroid.h> -#include <jni.h> - -namespace android { - -class WebCoreResourceLoader : public WebCore::ResourceLoaderAndroid -{ -public: - static PassRefPtr<WebCore::ResourceLoaderAndroid> create(JNIEnv *env, jobject jLoadListener); - virtual ~WebCoreResourceLoader(); - - /** - * Call to java to cancel the current load. - */ - virtual void cancel(); - - /** - * Call to java to download the current load rather than feed it - * back to WebCore - */ - virtual void downloadFile(); - - virtual void pauseLoad(bool); - - /** - * Call to java to find out if this URL is in the cache - */ - static bool willLoadFromCache(const WebCore::KURL& url, int64_t identifier); - - // Native jni functions - static void SetResponseHeader(JNIEnv*, jobject, jint, jstring, jstring); - static jint CreateResponse(JNIEnv*, jobject, jstring, jint, jstring, - jstring, jlong, jstring); - static void ReceivedResponse(JNIEnv*, jobject, jint); - static void AddData(JNIEnv*, jobject, jbyteArray, jint); - static void Finished(JNIEnv*, jobject); - static jstring RedirectedToUrl(JNIEnv*, jobject, jstring, jstring, jint); - static void Error(JNIEnv*, jobject, jint, jstring, jstring); - -protected: - WebCoreResourceLoader(JNIEnv *env, jobject jLoadListener); -private: - jobject mJLoader; - bool mPausedLoad; -}; - -} // end namespace android - -#endif diff --git a/Source/WebKit/android/jni/WebSettings.cpp b/Source/WebKit/android/jni/WebSettings.cpp index 9f7c2fa..1a1cc33 100644 --- a/Source/WebKit/android/jni/WebSettings.cpp +++ b/Source/WebKit/android/jni/WebSettings.cpp @@ -144,9 +144,7 @@ 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 ALOG_ASSERT(mLayoutAlgorithm, "Could not find field mLayoutAlgorithm"); ALOG_ASSERT(mTextSize, "Could not find field mTextSize"); @@ -265,9 +263,7 @@ struct FieldIds { jfieldID mAutoFillProfileCountry; jfieldID mAutoFillProfilePhoneNumber; #endif -#if USE(CHROME_NETWORK_STACK) jfieldID mOverrideCacheMode; -#endif }; static struct FieldIds* gFieldIds; @@ -367,7 +363,6 @@ public: str = (jstring)env->GetObjectField(obj, gFieldIds->mUserAgent); WebFrame::getWebFrame(pFrame)->setUserAgent(jstringToWtfString(env, str)); -#if USE(CHROME_NETWORK_STACK) WebViewCore::getWebViewCore(pFrame->view())->setWebRequestContextUserAgent(); jint cacheMode = env->GetIntField(obj, gFieldIds->mOverrideCacheMode); @@ -375,7 +370,6 @@ public: str = (jstring)env->GetObjectField(obj, gFieldIds->mAcceptLanguage); WebRequestContext::setAcceptLanguage(jstringToWtfString(env, str)); -#endif jint size = env->GetIntField(obj, gFieldIds->mMinimumFontSize); s->setMinimumFontSize(size); @@ -589,9 +583,7 @@ public: // This is required to enable the XMLTreeViewer when loading an XML document that // has no style attached to it. http://trac.webkit.org/changeset/79799 s->setDeveloperExtrasEnabled(true); -#if !ENABLE(ANDROID_NAVCACHE) s->setSpatialNavigationEnabled(true); -#endif } }; diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp index 2a81bd5..b9a21de 100644 --- a/Source/WebKit/android/jni/WebViewCore.cpp +++ b/Source/WebKit/android/jni/WebViewCore.cpp @@ -34,6 +34,7 @@ #include "BaseLayerAndroid.h" #include "CachedNode.h" #include "CachedRoot.h" +#include "content/address_detector.h" #include "Chrome.h" #include "ChromeClientAndroid.h" #include "ChromiumIncludes.h" @@ -96,6 +97,7 @@ #include "ProgressTracker.h" #include "Range.h" #include "RenderBox.h" +#include "RenderImage.h" #include "RenderInline.h" #include "RenderLayer.h" #include "RenderPart.h" @@ -176,6 +178,69 @@ FILE* gRenderTreeFile = 0; namespace android { +// Copied from CacheBuilder, not sure if this is needed/correct +IntRect getAreaRect(const HTMLAreaElement* area) +{ + Node* node = area->document(); + while ((node = node->traverseNextNode()) != NULL) { + RenderObject* renderer = node->renderer(); + if (renderer && renderer->isRenderImage()) { + RenderImage* image = static_cast<RenderImage*>(renderer); + HTMLMapElement* map = image->imageMap(); + if (map) { + Node* n; + for (n = map->firstChild(); n; + n = n->traverseNextNode(map)) { + if (n == area) { + if (area->isDefault()) + return image->absoluteBoundingBoxRect(); + return area->computeRect(image); + } + } + } + } + } + return IntRect(); +} + +// Copied from CacheBuilder, not sure if this is needed/correct +// TODO: See if this is even needed (I suspect not), and if not remove it +bool validNode(Frame* startFrame, void* matchFrame, + void* matchNode) +{ + if (matchFrame == startFrame) { + if (matchNode == NULL) + return true; + Node* node = startFrame->document(); + while (node != NULL) { + if (node == matchNode) { + const IntRect& rect = node->hasTagName(HTMLNames::areaTag) ? + getAreaRect(static_cast<HTMLAreaElement*>(node)) : node->getRect(); + // Consider nodes with empty rects that are not at the origin + // to be valid, since news.google.com has valid nodes like this + if (rect.x() == 0 && rect.y() == 0 && rect.isEmpty()) + return false; + return true; + } + node = node->traverseNextNode(); + } + DBG_NAV_LOGD("frame=%p valid node=%p invalid\n", matchFrame, matchNode); + return false; + } + Frame* child = startFrame->tree()->firstChild(); + while (child) { + bool result = validNode(child, matchFrame, matchNode); + if (result) + return result; + child = child->tree()->nextSibling(); + } +#if DEBUG_NAV_UI + if (startFrame->tree()->parent() == NULL) + DBG_NAV_LOGD("frame=%p node=%p false\n", matchFrame, matchNode); +#endif + return false; +} + static SkTDArray<WebViewCore*> gInstanceList; void WebViewCore::addInstance(WebViewCore* inst) { @@ -386,9 +451,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m #if ENABLE(TOUCH_EVENTS) , m_forwardingTouchEvents(false) #endif -#if USE(CHROME_NETWORK_STACK) , m_webRequestContext(0) -#endif { ALOG_ASSERT(m_mainFrame, "Uh oh, somehow a frameview was made without an initial frame!"); @@ -460,9 +523,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m WebViewCore::addInstance(this); -#if USE(CHROME_NETWORK_STACK) AndroidNetworkLibraryImpl::InitWithApplicationContext(env, 0); -#endif // Static initialisation of certain important V8 static data gets performed at system startup when // libwebcore gets loaded. We now need to associate the WebCore thread with V8 to complete @@ -530,13 +591,6 @@ static bool layoutIfNeededRecursive(WebCore::Frame* f) return success && !v->needsLayout(); } -#if ENABLE(ANDROID_NAVCACHE) -CacheBuilder& WebViewCore::cacheBuilder() -{ - return FrameLoaderClientAndroid::get(m_mainFrame)->getCacheBuilder(); -} -#endif - WebCore::Node* WebViewCore::currentFocus() { return focusedFrame()->document()->focusedNode(); @@ -660,11 +714,6 @@ void WebViewCore::recordPictureSet(PictureSet* content) height = view->contentsHeight(); } -#if ENABLE(ANDROID_NAVCACHE) - if (cacheBuilder().pictureSetDisabled()) - content->clear(); -#endif - #if USE(ACCELERATED_COMPOSITING) // The invals are not always correct when the content size has changed. For // now, let's just reset the inval so that it invalidates the entire content @@ -703,56 +752,6 @@ void WebViewCore::recordPictureSet(PictureSet* content) // Rebuild the pictureset (webkit repaint) rebuildPictureSet(content); - -#if ENABLE(ANDROID_NAVCACHE) - WebCore::Node* oldFocusNode = currentFocus(); - m_frameCacheOutOfDate = true; - WebCore::IntRect oldBounds; - int oldSelStart = 0; - int oldSelEnd = 0; - if (oldFocusNode) { - oldBounds = oldFocusNode->getRect(); - getSelectionOffsets(oldFocusNode, oldSelStart, oldSelEnd); - } else - oldBounds = WebCore::IntRect(0,0,0,0); - unsigned latestVersion = 0; - if (m_check_domtree_version) { - // as domTreeVersion only increment, we can just check the sum to see - // whether we need to update the frame cache - for (Frame* frame = m_mainFrame; frame; frame = frame->tree()->traverseNext()) { - const Document* doc = frame->document(); - latestVersion += doc->domTreeVersion() + doc->styleVersion(); - } - } - DBG_NAV_LOGD("m_lastFocused=%p oldFocusNode=%p" - " m_lastFocusedBounds={%d,%d,%d,%d} oldBounds={%d,%d,%d,%d}" - " m_lastFocusedSelection={%d,%d} oldSelection={%d,%d}" - " m_check_domtree_version=%s latestVersion=%d m_domtree_version=%d", - m_lastFocused, oldFocusNode, - m_lastFocusedBounds.x(), m_lastFocusedBounds.y(), - m_lastFocusedBounds.width(), m_lastFocusedBounds.height(), - oldBounds.x(), oldBounds.y(), oldBounds.width(), oldBounds.height(), - m_lastFocusedSelStart, m_lastFocusedSelEnd, oldSelStart, oldSelEnd, - m_check_domtree_version ? "true" : "false", - latestVersion, m_domtree_version); - if (m_lastFocused == oldFocusNode && m_lastFocusedBounds == oldBounds - && m_lastFocusedSelStart == oldSelStart - && m_lastFocusedSelEnd == oldSelEnd - && !m_findIsUp - && (!m_check_domtree_version || latestVersion == m_domtree_version)) - { - return; - } - m_focusBoundsChanged |= m_lastFocused == oldFocusNode - && m_lastFocusedBounds != oldBounds; - m_lastFocused = oldFocusNode; - m_lastFocusedBounds = oldBounds; - m_lastFocusedSelStart = oldSelStart; - m_lastFocusedSelEnd = oldSelEnd; - m_domtree_version = latestVersion; - DBG_NAV_LOG("call updateFrameCache"); - updateFrameCache(); -#endif } // note: updateCursorBounds is called directly by the WebView thread @@ -1088,11 +1087,6 @@ void WebViewCore::didFirstLayout() || loadType == WebCore::FrameLoadTypeSame); checkException(env); -#if ENABLE(ANDROID_NAVCACHE) - DBG_NAV_LOG("call updateFrameCache"); - m_check_domtree_version = false; - updateFrameCache(); -#endif m_history.setDidFirstLayout(true); } @@ -1380,13 +1374,6 @@ void WebViewCore::dumpRenderTree(bool useFile) #endif } -void WebViewCore::dumpNavTree() -{ -#if DUMP_NAV_CACHE - cacheBuilder().mDebug.print(); -#endif -} - HTMLElement* WebViewCore::retrieveElement(int x, int y, const QualifiedName& tagName) { @@ -1452,7 +1439,7 @@ WTF::String WebViewCore::retrieveImageSource(int x, int y) WTF::String WebViewCore::requestLabel(WebCore::Frame* frame, WebCore::Node* node) { - if (node && CacheBuilder::validNode(m_mainFrame, frame, node)) { + if (node && validNode(m_mainFrame, frame, node)) { RefPtr<WebCore::NodeList> list = node->document()->getElementsByTagName("label"); unsigned length = list->length(); for (unsigned i = 0; i < length; i++) { @@ -1508,104 +1495,6 @@ void WebViewCore::revealSelection() focusedFrame->selection()->revealSelection(ScrollAlignment::alignToEdgeIfNeeded); } -#if ENABLE(ANDROID_NAVCACHE) -void WebViewCore::updateCacheOnNodeChange() -{ - gCursorBoundsMutex.lock(); - bool hasCursorBounds = m_hasCursorBounds; - Frame* frame = (Frame*) m_cursorFrame; - Node* node = (Node*) m_cursorNode; - IntRect bounds = m_cursorHitBounds; - gCursorBoundsMutex.unlock(); - if (!hasCursorBounds || !node) - return; - if (CacheBuilder::validNode(m_mainFrame, frame, node)) { - RenderObject* renderer = node->renderer(); - if (renderer && renderer->style()->visibility() != HIDDEN) { - IntRect absBox = renderer->absoluteBoundingBoxRect(); - int globalX, globalY; - CacheBuilder::GetGlobalOffset(frame, &globalX, &globalY); - absBox.move(globalX, globalY); - if (absBox == bounds) - return; - DBG_NAV_LOGD("absBox=(%d,%d,%d,%d) bounds=(%d,%d,%d,%d)", - absBox.x(), absBox.y(), absBox.width(), absBox.height(), - bounds.x(), bounds.y(), bounds.width(), bounds.height()); - } - } - DBG_NAV_LOGD("updateFrameCache node=%p", node); - updateFrameCache(); -} - -void WebViewCore::updateFrameCache() -{ - if (!m_frameCacheOutOfDate) { - DBG_NAV_LOG("!m_frameCacheOutOfDate"); - return; - } - - // If there is a pending style recalculation, do not update the frame cache. - // Until the recalculation is complete, there may be internal objects that - // are in an inconsistent state (such as font pointers). - // In any event, there's not much point to updating the cache while a style - // recalculation is pending, since it will simply have to be updated again - // once the recalculation is complete. - // TODO: Do we need to reschedule an update for after the style is recalculated? - if (m_mainFrame && m_mainFrame->document() && m_mainFrame->document()->isPendingStyleRecalc()) { - ALOGW("updateFrameCache: pending style recalc, ignoring."); - return; - } - m_frameCacheOutOfDate = false; - CachedRoot* tempCacheRoot = new CachedRoot(); - tempCacheRoot->init(m_mainFrame, &m_history); -#if USE(ACCELERATED_COMPOSITING) - GraphicsLayerAndroid* graphicsLayer = graphicsRootLayer(); - if (graphicsLayer) - tempCacheRoot->setRootLayer(graphicsLayer->contentLayer()); -#endif - CacheBuilder& builder = cacheBuilder(); - WebCore::Settings* settings = m_mainFrame->page()->settings(); - builder.allowAllTextDetection(); -#ifdef ANDROID_META_SUPPORT - if (settings) { - if (!settings->formatDetectionAddress()) - builder.disallowAddressDetection(); - if (!settings->formatDetectionEmail()) - builder.disallowEmailDetection(); - if (!settings->formatDetectionTelephone()) - builder.disallowPhoneDetection(); - } -#endif - builder.buildCache(tempCacheRoot); - SkPicture* tempPict = new SkPicture(); - recordPicture(tempPict); - tempCacheRoot->setPicture(tempPict); - SkSafeUnref(tempPict); - tempPict = 0; - tempCacheRoot->setTextGeneration(m_textGeneration); - WebCoreViewBridge* window = m_mainFrame->view()->platformWidget(); - tempCacheRoot->setVisibleRect(WebCore::IntRect(m_scrollOffsetX, - m_scrollOffsetY, window->width(), window->height())); - gFrameCacheMutex.lock(); - delete m_frameCacheKit; - m_frameCacheKit = tempCacheRoot; - m_updatedFrameCache = true; -#if DEBUG_NAV_UI - const CachedNode* cachedFocusNode = m_frameCacheKit->currentFocus(); - DBG_NAV_LOGD("cachedFocusNode=%d (nodePointer=%p)", - cachedFocusNode ? cachedFocusNode->index() : 0, - cachedFocusNode ? cachedFocusNode->nodePointer() : 0); -#endif - gFrameCacheMutex.unlock(); -} - -void WebViewCore::updateFrameCacheIfLoading() -{ - if (!m_check_domtree_version) - updateFrameCache(); -} -#endif - struct TouchNodeData { Node* mUrlNode; Node* mInnerNode; @@ -2018,6 +1907,7 @@ AndroidHitTestResult WebViewCore::hitTestAtPoint(int x, int y, int slop, bool do } } if (!nodeDataList.size()) { + androidHitResult.searchContentDetectors(); return androidHitResult; } // finally select the node with the largest overlap with the fat point @@ -2065,6 +1955,8 @@ AndroidHitTestResult WebViewCore::hitTestAtPoint(int x, int y, int slop, bool do m_scrollOffsetX, m_scrollOffsetY); } } + } else { + androidHitResult.searchContentDetectors(); } return androidHitResult; } @@ -2243,7 +2135,7 @@ Node* WebViewCore::cursorNodeIsPlugin() { Frame* frame = (Frame*) m_cursorFrame; Node* node = (Node*) m_cursorNode; gCursorBoundsMutex.unlock(); - if (hasCursorBounds && CacheBuilder::validNode(m_mainFrame, frame, node) + if (hasCursorBounds && validNode(m_mainFrame, frame, node) && nodeIsPlugin(node)) { return node; } @@ -2269,7 +2161,7 @@ void WebViewCore::moveMouseIfLatest(int moveGeneration, void WebViewCore::moveFocus(WebCore::Frame* frame, WebCore::Node* node) { DBG_NAV_LOGD("frame=%p node=%p", frame, node); - if (!node || !CacheBuilder::validNode(m_mainFrame, frame, node) + if (!node || !validNode(m_mainFrame, frame, node) || !node->isElementNode()) return; // Code borrowed from FocusController::advanceFocus @@ -2290,7 +2182,7 @@ void WebViewCore::moveMouse(WebCore::Frame* frame, int x, int y, HitTestResult* { DBG_NAV_LOGD("frame=%p x=%d y=%d scrollOffset=(%d,%d)", frame, x, y, m_scrollOffsetX, m_scrollOffsetY); - if (!frame || !CacheBuilder::validNode(m_mainFrame, frame, 0)) + if (!frame || !validNode(m_mainFrame, frame, 0)) frame = m_mainFrame; // mouse event expects the position in the window coordinate m_mousePos = WebCore::IntPoint(x - m_scrollOffsetX, y - m_scrollOffsetY); @@ -2300,9 +2192,6 @@ void WebViewCore::moveMouse(WebCore::Frame* frame, int x, int y, HitTestResult* WebCore::NoButton, WebCore::MouseEventMoved, 1, false, false, false, false, WTF::currentTime()); frame->eventHandler()->handleMouseMoveEvent(mouseEvent, hoveredNode); -#if ENABLE(ANDROID_NAVCACHE) - updateCacheOnNodeChange(); -#endif } Position WebViewCore::getPositionForOffset(Node* node, int offset) @@ -2426,7 +2315,7 @@ String WebViewCore::modifySelectionTextNavigationAxis(DOMSelection* selection, i // initialize the selection if necessary if (selection->rangeCount() == 0) { if (m_currentNodeDomNavigationAxis - && CacheBuilder::validNode(m_mainFrame, + && validNode(m_mainFrame, m_mainFrame, m_currentNodeDomNavigationAxis)) { RefPtr<Range> rangeRef = selection->frame()->document()->createRange(); @@ -2438,7 +2327,7 @@ String WebViewCore::modifySelectionTextNavigationAxis(DOMSelection* selection, i } else if (currentFocus()) { selection->setPosition(currentFocus(), 0, ec); } else if (m_cursorNode - && CacheBuilder::validNode(m_mainFrame, + && validNode(m_mainFrame, m_mainFrame, m_cursorNode)) { RefPtr<Range> rangeRef = selection->frame()->document()->createRange(); @@ -2858,7 +2747,7 @@ String WebViewCore::modifySelectionDomNavigationAxis(DOMSelection* selection, in if (!m_currentNodeDomNavigationAxis) m_currentNodeDomNavigationAxis = currentFocus(); if (!m_currentNodeDomNavigationAxis - || !CacheBuilder::validNode(m_mainFrame, m_mainFrame, + || !validNode(m_mainFrame, m_mainFrame, m_currentNodeDomNavigationAxis)) m_currentNodeDomNavigationAxis = body; Node* currentNode = m_currentNodeDomNavigationAxis; @@ -2959,7 +2848,7 @@ bool WebViewCore::isVisible(Node* node) while (currentNode && currentNode != body) { RenderStyle* style = currentNode->computedStyle(); if (style && - (style->display() == NONE || style->visibility() == HIDDEN)) { + (style->display() == WebCore::NONE || style->visibility() == WebCore::HIDDEN)) { return false; } currentNode = currentNode->parentNode(); @@ -3145,7 +3034,7 @@ void WebViewCore::setFocusControllerActive(bool active) void WebViewCore::saveDocumentState(WebCore::Frame* frame) { - if (!CacheBuilder::validNode(m_mainFrame, frame, 0)) + if (!validNode(m_mainFrame, frame, 0)) frame = m_mainFrame; WebCore::HistoryItem *item = frame->loader()->history()->currentItem(); @@ -3427,7 +3316,7 @@ void WebViewCore::touchUp(int touchGeneration, moveMouse(frame, x, y); m_lastGeneration = touchGeneration; } - if (frame && CacheBuilder::validNode(m_mainFrame, frame, 0)) { + if (frame && validNode(m_mainFrame, frame, 0)) { frame->loader()->resetMultipleFormSubmissionProtection(); } DBG_NAV_LOGD("touchGeneration=%d handleMouseClick frame=%p node=%p" @@ -3456,7 +3345,7 @@ static bool shouldSuppressKeyboard(const WebCore::Node* node) { // in which case, 'fake' is set to true bool WebViewCore::handleMouseClick(WebCore::Frame* framePtr, WebCore::Node* nodePtr, bool fake) { - bool valid = !framePtr || CacheBuilder::validNode(m_mainFrame, framePtr, nodePtr); + bool valid = !framePtr || validNode(m_mainFrame, framePtr, nodePtr); WebFrame* webFrame = WebFrame::getWebFrame(m_mainFrame); if (valid && nodePtr) { // Need to special case area tags because an image map could have an area element in the middle @@ -3501,15 +3390,8 @@ bool WebViewCore::handleMouseClick(WebCore::Frame* framePtr, WebCore::Node* node autoFill->formFieldFocused(static_cast<HTMLFormControlElement*>(focusNode)); } #endif - if (!fake) { -#if ENABLE(ANDROID_NAVCACHE) - // Force an update of the navcache as this will fire off a - // message to WebView that *must* have an updated focus. - m_frameCacheOutOfDate = true; - updateFrameCache(); -#endif + if (!fake) initEditField(focusNode); - } } else if (!fake) { requestKeyboard(false); } @@ -3943,14 +3825,14 @@ void WebViewCore::updateTextSelection() AutoJObject javaObject = m_javaGlue->object(env); if (!javaObject.get()) return; - WebCore::Node* focusNode = currentFocus(); + VisibleSelection selection = focusedFrame()->selection()->selection(); int start = 0; int end = 0; - if (focusNode) - getSelectionOffsets(focusNode, start, end); - SelectText* selectText = createSelectText(focusedFrame()->selection()->selection()); + if (selection.isCaretOrRange()) + getSelectionOffsets(selection.start().anchorNode(), start, end); + SelectText* selectText = createSelectText(selection); env->CallVoidMethod(javaObject.get(), - m_javaGlue->m_updateTextSelection, reinterpret_cast<int>(focusNode), + m_javaGlue->m_updateTextSelection, reinterpret_cast<int>(currentFocus()), start, end, m_textGeneration, reinterpret_cast<int>(selectText)); checkException(env); } @@ -4128,14 +4010,14 @@ void WebViewCore::keepScreenOn(bool screenOn) { bool WebViewCore::validNodeAndBounds(Frame* frame, Node* node, const IntRect& originalAbsoluteBounds) { - bool valid = CacheBuilder::validNode(m_mainFrame, frame, node); + bool valid = validNode(m_mainFrame, frame, node); if (!valid) return false; RenderObject* renderer = node->renderer(); if (!renderer) return false; IntRect absBounds = node->hasTagName(HTMLNames::areaTag) - ? CacheBuilder::getAreaRect(static_cast<HTMLAreaElement*>(node)) + ? getAreaRect(static_cast<HTMLAreaElement*>(node)) : renderer->absoluteBoundingBoxRect(); return absBounds == originalAbsoluteBounds; } @@ -4232,7 +4114,6 @@ bool WebViewCore::drawIsPaused() const return false; } -#if USE(CHROME_NETWORK_STACK) void WebViewCore::setWebRequestContextUserAgent() { // We cannot create a WebRequestContext, because we might not know it this is a private tab or not yet @@ -4260,7 +4141,6 @@ WebRequestContext* WebViewCore::webRequestContext() } return m_webRequestContext.get(); } -#endif void WebViewCore::scrollRenderLayer(int layer, const SkRect& rect) { @@ -4506,9 +4386,6 @@ static void ClearContent(JNIEnv* env, jobject obj, jint nativeClass) static void UpdateFrameCacheIfLoading(JNIEnv* env, jobject obj, jint nativeClass) { -#if ENABLE(ANDROID_NAVCACHE) - reinterpret_cast<WebViewCore*>(nativeClass)->updateFrameCacheIfLoading(); -#endif } static void SetSize(JNIEnv* env, jobject obj, jint nativeClass, jint width, @@ -4705,6 +4582,7 @@ static void SendListBoxChoices(JNIEnv* env, jobject obj, jint nativeClass, viewImpl->popupReply(array, count); } +// TODO: Move this to WebView.cpp since it is only needed there static jstring FindAddress(JNIEnv* env, jobject obj, jstring addr, jboolean caseInsensitive) { @@ -4714,9 +4592,9 @@ static jstring FindAddress(JNIEnv* env, jobject obj, jstring addr, if (!length) return 0; const jchar* addrChars = env->GetStringChars(addr, 0); - int start, end; - bool success = CacheBuilder::FindAddress(addrChars, length, - &start, &end, caseInsensitive) == CacheBuilder::FOUND_COMPLETE; + size_t start, end; + AddressDetector detector; + bool success = detector.FindContent(addrChars, addrChars + length, &start, &end); jstring ret = 0; if (success) ret = env->NewString(addrChars + start, end - start); @@ -4813,11 +4691,6 @@ static void MoveMouseIfLatest(JNIEnv* env, jobject obj, jint nativeClass, static void UpdateFrameCache(JNIEnv* env, jobject obj, jint nativeClass) { -#if ENABLE(ANDROID_NAVCACHE) - WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass); - ALOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__); - viewImpl->updateFrameCache(); -#endif } static jint GetContentMinPrefWidth(JNIEnv* env, jobject obj, jint nativeClass) @@ -4888,10 +4761,6 @@ static void DumpRenderTree(JNIEnv* env, jobject obj, jint nativeClass, static void DumpNavTree(JNIEnv* env, jobject obj, jint nativeClass) { - WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass); - ALOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__); - - viewImpl->dumpNavTree(); } static void SetJsFlags(JNIEnv* env, jobject obj, jint nativeClass, jstring flags) @@ -5090,10 +4959,8 @@ static void AutoFillForm(JNIEnv* env, jobject obj, jint nativeClass, static void CloseIdleConnections(JNIEnv* env, jobject obj, jint nativeClass) { -#if USE(CHROME_NETWORK_STACK) WebCache::get(true)->closeIdleConnections(); WebCache::get(false)->closeIdleConnections(); -#endif } static void nativeCertTrustChanged(JNIEnv *env, jobject obj) diff --git a/Source/WebKit/android/jni/WebViewCore.h b/Source/WebKit/android/jni/WebViewCore.h index 785b659..bf7c36b 100644 --- a/Source/WebKit/android/jni/WebViewCore.h +++ b/Source/WebKit/android/jni/WebViewCore.h @@ -26,9 +26,6 @@ #ifndef WebViewCore_h #define WebViewCore_h -#ifndef DISABLE_NAVCACHE -#include "CacheBuilder.h" -#endif #include "CachedHistory.h" #include "DeviceMotionAndOrientationManager.h" #include "DOMSelection.h" @@ -430,14 +427,9 @@ namespace android { jobject getWebViewJavaObject(); void setBackgroundColor(SkColor c); -#ifndef DISABLE_NAVCACHE - void updateFrameCache(); - void updateCacheOnNodeChange(); - void updateFrameCacheIfLoading(); -#endif + void dumpDomTree(bool); void dumpRenderTree(bool); - void dumpNavTree(); /* We maintain a list of active plugins. The list is edited by the pluginview itself. The list is used to service invals to the plugin @@ -584,11 +576,9 @@ namespace android { // The actual content (without title bar) size in doc coordinate int screenWidth() const { return m_screenWidth; } int screenHeight() const { return m_screenHeight; } -#if USE(CHROME_NETWORK_STACK) void setWebRequestContextUserAgent(); void setWebRequestContextCacheMode(int mode); WebRequestContext* webRequestContext(); -#endif // Attempts to scroll the layer to the x,y coordinates of rect. The // layer is the id of the LayerAndroid. void scrollRenderLayer(int layer, const SkRect& rect); @@ -653,9 +643,6 @@ namespace android { URL = 7, }; -#ifndef DISABLE_NAVCACHE - CacheBuilder& cacheBuilder(); -#endif WebCore::Node* currentFocus(); // Create a set of pictures to represent the drawn DOM, driven by // the invalidated region and the time required to draw (used to draw) @@ -808,10 +795,7 @@ namespace android { bool m_forwardingTouchEvents; #endif -#if USE(CHROME_NETWORK_STACK) scoped_refptr<WebRequestContext> m_webRequestContext; -#endif - }; } // namespace android |