diff --git a/dom/plugins/base/nsPluginInstanceOwner.cpp b/dom/plugins/base/nsPluginInstanceOwner.cpp index 8f2c92cbc56..a1aa4d20b7d 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.cpp +++ b/dom/plugins/base/nsPluginInstanceOwner.cpp @@ -1815,17 +1815,7 @@ void nsPluginInstanceOwner::RemovePluginView() if (!surface) return; - JNIEnv* env = GetJNIForThread(); - if (!env) - return; - - AndroidBridge::AutoLocalJNIFrame frame(env, 1); - - jclass cls = env->FindClass("org/mozilla/gecko/GeckoAppShell"); - jmethodID method = env->GetStaticMethodID(cls, - "removePluginView", - "(Landroid/view/View;)V"); - env->CallStaticVoidMethod(cls, method, surface); + AndroidBridge::RemovePluginView(surface); } void nsPluginInstanceOwner::Invalidate() { diff --git a/widget/android/AndroidBridge.cpp b/widget/android/AndroidBridge.cpp index 35952840e5d..4db678877b5 100644 --- a/widget/android/AndroidBridge.cpp +++ b/widget/android/AndroidBridge.cpp @@ -165,6 +165,7 @@ AndroidBridge::Init(JNIEnv *jEnv, jEnableBatteryNotifications = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "enableBatteryNotifications", "()V"); jDisableBatteryNotifications = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "disableBatteryNotifications", "()V"); jGetCurrentBatteryInformation = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getCurrentBatteryInformation", "()[D"); + jRemovePluginView = jEnv->GetStaticMethodID(jGeckoAppShellClass, "removePluginView", "(Landroid/view/View;)V"); jGetAccessibilityEnabled = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getAccessibilityEnabled", "()Z"); jHandleGeckoMessage = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "handleGeckoMessage", "(Ljava/lang/String;)Ljava/lang/String;"); @@ -2143,6 +2144,17 @@ NS_IMETHODIMP nsAndroidBridge::SetBrowserApp(nsIAndroidBrowserApp *aBrowserApp) return NS_OK; } +void +AndroidBridge::RemovePluginView(void* surface) { + JNIEnv *env = AndroidBridge::GetJNIEnv(); + if (!env) + return; + + AndroidBridge::AutoLocalJNIFrame frame(env, 1); + env->CallStaticVoidMethod(sBridge->mGeckoAppShellClass, + sBridge->jRemovePluginView, surface); +} + extern "C" __attribute__ ((visibility("default"))) jobject JNICALL diff --git a/widget/android/AndroidBridge.h b/widget/android/AndroidBridge.h index 555e2f64042..3922a770c8e 100644 --- a/widget/android/AndroidBridge.h +++ b/widget/android/AndroidBridge.h @@ -181,6 +181,8 @@ public: static void NotifyIMEChange(const PRUnichar *aText, PRUint32 aTextLen, int aStart, int aEnd, int aNewEnd); + static void RemovePluginView(void* surface); + nsresult TakeScreenshot(nsIDOMWindow *window, PRInt32 srcX, PRInt32 srcY, PRInt32 srcW, PRInt32 srcH, PRInt32 dstW, PRInt32 dstH, PRInt32 tabId, float scale); void AcknowledgeEventSync(); @@ -526,6 +528,7 @@ protected: jmethodID jCheckUriVisited; jmethodID jMarkUriVisited; jmethodID jEmitGeckoAccessibilityEvent; + jmethodID jRemovePluginView; jmethodID jNumberOfMessages; jmethodID jSendMessage;