Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java

Issue 11802002: [Android] Fix leak in Java Bridge. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
index e19ae11858a2df90c41b5d196005e7b8306606b0..c739a106317edbbdcc56672321b6f1c0f40b5453 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
@@ -47,6 +47,8 @@ import org.chromium.content.common.TraceEvent;
import org.chromium.ui.gfx.NativeWindow;
import java.lang.annotation.Annotation;
+import java.util.HashMap;
+import java.util.Map;
/**
* Provides a Java-side 'wrapper' around a WebContent (native) instance.
@@ -73,6 +75,8 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient {
// Personality of the ContentView.
private final int mPersonality;
+ private Map<String, Object> mJavaScriptObjects = new HashMap<String, Object>();
joth 2013/01/07 19:32:41 comment what this is for / why the native side onl
benm (inactive) 2013/01/08 14:43:05 Done.
+
/**
* Interface that consumers of {@link ContentViewCore} must implement to allow the proper
* dispatching of view methods through the containing view.
@@ -2193,6 +2197,7 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient {
public void addPossiblyUnsafeJavascriptInterface(Object object, String name,
Class<? extends Annotation> requiredAnnotation) {
if (mNativeContentViewCore != 0 && object != null) {
+ mJavaScriptObjects.put(name, object);
nativeAddJavascriptInterface(mNativeContentViewCore, object, name, requiredAnnotation);
}
}
@@ -2204,6 +2209,7 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient {
*/
public void removeJavascriptInterface(String name) {
if (mNativeContentViewCore != 0) {
+ mJavaScriptObjects.remove(name);
nativeRemoveJavascriptInterface(mNativeContentViewCore, name);
joth 2013/01/07 19:32:41 I'd rather nativeRemoveJavascriptInterface returne
}
}

Powered by Google App Engine
This is Rietveld 408576698