diff options
Diffstat (limited to 'WebKit/android/jni/WebCoreFrameBridge.cpp')
-rw-r--r-- | WebKit/android/jni/WebCoreFrameBridge.cpp | 96 |
1 files changed, 76 insertions, 20 deletions
diff --git a/WebKit/android/jni/WebCoreFrameBridge.cpp b/WebKit/android/jni/WebCoreFrameBridge.cpp index 2981441..745cc57 100644 --- a/WebKit/android/jni/WebCoreFrameBridge.cpp +++ b/WebKit/android/jni/WebCoreFrameBridge.cpp @@ -289,6 +289,10 @@ WebFrame::startLoadingResource(WebCore::ResourceHandle* loader, WebCore::HTTPHeaderMap headers = request.httpHeaderFields(); JNIEnv* env = JSC::Bindings::getJNIEnv(); + AutoJObject obj = mJavaFrame->frame(env); + if (!obj.get()) + return 0; + WebCore::String urlStr = request.url().string(); int colon = urlStr.find(':'); bool allLower = true; @@ -373,7 +377,7 @@ WebFrame::startLoadingResource(WebCore::ResourceHandle* loader, jobject jLoadListener = - env->CallObjectMethod(mJavaFrame->frame(env).get(), mJavaFrame->mStartLoadingResource, + env->CallObjectMethod(obj.get(), mJavaFrame->mStartLoadingResource, (int)loader, jUrlStr, jMethodStr, jHeaderMap, jPostDataStr, cacheMode, synchronous); @@ -400,10 +404,13 @@ WebFrame::reportError(int errorCode, const WebCore::String& description, #endif LOGV("::WebCore:: reportError(%d, %s)", errorCode, description.ascii().data()); JNIEnv* env = JSC::Bindings::getJNIEnv(); + AutoJObject obj = mJavaFrame->frame(env); + if (!obj.get()) + return; jstring descStr = env->NewString((unsigned short*)description.characters(), description.length()); jstring failUrl = env->NewString((unsigned short*)failingUrl.characters(), failingUrl.length()); - env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mReportError, errorCode, descStr, failUrl); + env->CallVoidMethod(obj.get(), mJavaFrame->mReportError, errorCode, descStr, failUrl); env->DeleteLocalRef(descStr); env->DeleteLocalRef(failUrl); } @@ -429,6 +436,9 @@ WebFrame::loadStarted(WebCore::Frame* frame) return; JNIEnv* env = JSC::Bindings::getJNIEnv(); + AutoJObject obj = mJavaFrame->frame(env); + if (!obj.get()) + return; WebCore::String urlString(url.string()); // If this is the main frame and we already have a favicon in the database, // send it along with the page started notification. @@ -441,7 +451,7 @@ WebFrame::loadStarted(WebCore::Frame* frame) } jstring urlStr = env->NewString((unsigned short*)urlString.characters(), urlString.length()); - env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mLoadStarted, urlStr, favicon, + env->CallVoidMethod(obj.get(), mJavaFrame->mLoadStarted, urlStr, favicon, (int)loadType, isMainFrame); checkException(env); env->DeleteLocalRef(urlStr); @@ -466,9 +476,12 @@ WebFrame::transitionToCommitted(WebCore::Frame* frame) TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif JNIEnv* env = JSC::Bindings::getJNIEnv(); + AutoJObject obj = mJavaFrame->frame(env); + if (!obj.get()) + return; WebCore::FrameLoadType loadType = frame->loader()->loadType(); bool isMainFrame = (!frame->tree() || !frame->tree()->parent()); - env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mTransitionToCommitted, + env->CallVoidMethod(obj.get(), mJavaFrame->mTransitionToCommitted, (int)loadType, isMainFrame); checkException(env); } @@ -480,6 +493,9 @@ WebFrame::didFinishLoad(WebCore::Frame* frame) TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif JNIEnv* env = JSC::Bindings::getJNIEnv(); + AutoJObject obj = mJavaFrame->frame(env); + if (!obj.get()) + return; WebCore::FrameLoader* loader = frame->loader(); const WebCore::KURL& url = loader->activeDocumentLoader()->url(); if (url.isEmpty()) @@ -490,7 +506,7 @@ WebFrame::didFinishLoad(WebCore::Frame* frame) WebCore::FrameLoadType loadType = loader->loadType(); WebCore::String urlString(url.string()); jstring urlStr = env->NewString((unsigned short*)urlString.characters(), urlString.length()); - env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mLoadFinished, urlStr, + env->CallVoidMethod(obj.get(), mJavaFrame->mLoadFinished, urlStr, (int)loadType, isMainFrame); checkException(env); env->DeleteLocalRef(urlStr); @@ -539,9 +555,12 @@ WebFrame::setTitle(const WebCore::String& title) LOGV("setTitle(%s)", title.ascii().data()); #endif JNIEnv* env = JSC::Bindings::getJNIEnv(); + AutoJObject obj = mJavaFrame->frame(env); + if (!obj.get()) + return; jstring jTitleStr = env->NewString((unsigned short *)title.characters(), title.length()); - env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mSetTitle, + env->CallVoidMethod(obj.get(), mJavaFrame->mSetTitle, jTitleStr); checkException(env); env->DeleteLocalRef(jTitleStr); @@ -555,8 +574,11 @@ WebFrame::windowObjectCleared(WebCore::Frame* frame) #endif LOGV("::WebCore:: windowObjectCleared"); JNIEnv* env = JSC::Bindings::getJNIEnv(); + AutoJObject obj = mJavaFrame->frame(env); + if (!obj.get()) + return; - env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mWindowObjectCleared, (int)frame); + env->CallVoidMethod(obj.get(), mJavaFrame->mWindowObjectCleared, (int)frame); checkException(env); } @@ -567,8 +589,11 @@ WebFrame::setProgress(float newProgress) TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif JNIEnv* env = JSC::Bindings::getJNIEnv(); + AutoJObject obj = mJavaFrame->frame(env); + if (!obj.get()) + return; int progress = (int) (100 * newProgress); - env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mSetProgress, progress); + env->CallVoidMethod(obj.get(), mJavaFrame->mSetProgress, progress); checkException(env); } @@ -586,11 +611,14 @@ WebFrame::didReceiveIcon(WebCore::Image* icon) #endif LOG_ASSERT(icon, "DidReceiveIcon called without an image!"); JNIEnv* env = JSC::Bindings::getJNIEnv(); + AutoJObject obj = mJavaFrame->frame(env); + if (!obj.get()) + return; jobject bitmap = webcoreImageToJavaBitmap(env, icon); if (!bitmap) return; - env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mDidReceiveIcon, bitmap); + env->CallVoidMethod(obj.get(), mJavaFrame->mDidReceiveIcon, bitmap); env->DeleteLocalRef(bitmap); checkException(env); } @@ -602,10 +630,13 @@ WebFrame::didReceiveTouchIconURL(const WebCore::String& url, bool precomposed) TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif JNIEnv* env = JSC::Bindings::getJNIEnv(); + AutoJObject obj = mJavaFrame->frame(env); + if (!obj.get()) + return; jstring jUrlStr = env->NewString((unsigned short*)url.characters(), url.length()); - env->CallVoidMethod(mJavaFrame->frame(env).get(), + env->CallVoidMethod(obj.get(), mJavaFrame->mDidReceiveTouchIconUrl, jUrlStr, precomposed); checkException(env); } @@ -618,9 +649,13 @@ WebFrame::updateVisitedHistory(const WebCore::KURL& url, bool reload) #endif WebCore::String urlStr(url.string()); JNIEnv* env = JSC::Bindings::getJNIEnv(); + AutoJObject obj = mJavaFrame->frame(env); + if (!obj.get()) + return; + jstring jUrlStr = env->NewString((unsigned short*)urlStr.characters(), urlStr.length()); - env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mUpdateVisitedHistory, jUrlStr, reload); + env->CallVoidMethod(obj.get(), mJavaFrame->mUpdateVisitedHistory, jUrlStr, reload); checkException(env); } @@ -644,11 +679,14 @@ WebFrame::canHandleRequest(const WebCore::ResourceRequest& request) if (url.isEmpty()) return true; JNIEnv* env = JSC::Bindings::getJNIEnv(); + AutoJObject obj = mJavaFrame->frame(env); + if (!obj.get()) + return true; jstring jUrlStr = env->NewString((unsigned short *)url.characters(), url.length()); // check to see whether browser app wants to hijack url loading. // if browser app handles the url, we will return false to bail out WebCore loading - jboolean ret = env->CallBooleanMethod(mJavaFrame->frame(env).get(), mJavaFrame->mHandleUrl, jUrlStr); + jboolean ret = env->CallBooleanMethod(obj.get(), mJavaFrame->mHandleUrl, jUrlStr); checkException(env); return (ret == 0); } @@ -660,10 +698,13 @@ WebFrame::createWindow(bool dialog, bool userGesture) TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif JNIEnv* env = JSC::Bindings::getJNIEnv(); - jobject obj = env->CallObjectMethod(mJavaFrame->frame(env).get(), + AutoJObject obj = mJavaFrame->frame(env); + if (!obj.get()) + return NULL; + jobject jobj = env->CallObjectMethod(obj.get(), mJavaFrame->mCreateWindow, dialog, userGesture); - if (obj) { - WebCore::Frame* frame = GET_NATIVE_FRAME(env, obj); + if (jobj) { + WebCore::Frame* frame = GET_NATIVE_FRAME(env, jobj); return frame; } return NULL; @@ -676,7 +717,10 @@ WebFrame::requestFocus() const TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif JNIEnv* env = JSC::Bindings::getJNIEnv(); - env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mRequestFocus); + AutoJObject obj = mJavaFrame->frame(env); + if (!obj.get()) + return; + env->CallVoidMethod(obj.get(), mJavaFrame->mRequestFocus); checkException(env); } @@ -688,7 +732,10 @@ WebFrame::closeWindow(WebViewCore* webViewCore) #endif assert(webViewCore); JNIEnv* env = JSC::Bindings::getJNIEnv(); - env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mCloseWindow, + AutoJObject obj = mJavaFrame->frame(env); + if (!obj.get()) + return; + env->CallVoidMethod(obj.get(), mJavaFrame->mCloseWindow, webViewCore->getJavaObject().get()); } @@ -703,16 +750,22 @@ WebFrame::decidePolicyForFormResubmission(WebCore::FramePolicyFunction func) TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter); #endif JNIEnv* env = JSC::Bindings::getJNIEnv(); + AutoJObject obj = mJavaFrame->frame(env); + if (!obj.get()) + return; PolicyFunctionWrapper* p = new PolicyFunctionWrapper; p->func = func; - env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mDecidePolicyForFormResubmission, p); + env->CallVoidMethod(obj.get(), mJavaFrame->mDecidePolicyForFormResubmission, p); } WebCore::String WebFrame::getRawResourceFilename(RAW_RES_ID id) const { JNIEnv* env = JSC::Bindings::getJNIEnv(); - jstring ret = (jstring) env->CallObjectMethod(mJavaFrame->frame(env).get(), + AutoJObject obj = mJavaFrame->frame(env); + if (!obj.get()) + return WebCore::String(); + jstring ret = (jstring) env->CallObjectMethod(obj.get(), mJavaFrame->mGetRawResFilename, (int)id); return to_string(env, ret); @@ -722,7 +775,10 @@ float WebFrame::density() const { JNIEnv* env = JSC::Bindings::getJNIEnv(); - jfloat dpi = env->CallFloatMethod(mJavaFrame->frame(env).get(), mJavaFrame->mDensity); + AutoJObject obj = mJavaFrame->frame(env); + if (!obj.get()) + return 1.0; + jfloat dpi = env->CallFloatMethod(obj.get(), mJavaFrame->mDensity); checkException(env); return dpi; } |