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

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

Issue 353163002: [Android] Switch to Gin Java Bridge implementation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed AwSettingsTest#testBlockNetworkLoadsWithAudio Created 6 years, 5 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 f574fcf48eec6ec81a954fefb2b11bbbfbf8031c..34400bc406f8a0c6d06b4c3f3f3335e781a6d669 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
@@ -29,6 +29,7 @@ import android.text.Editable;
import android.text.Selection;
import android.text.TextUtils;
import android.util.Log;
+import android.util.Pair;
import android.view.ActionMode;
import android.view.HapticFeedbackConstants;
import android.view.InputDevice;
@@ -118,9 +119,12 @@ public class ContentViewCore
// native side. However we still need a strong reference on the Java side to
// prevent garbage collection if the embedder doesn't maintain their own ref to the
// interface object - the Java side ref won't create a new GC root.
- // This map stores those refernces. We put into the map on addJavaScriptInterface()
- // and remove from it in removeJavaScriptInterface().
- private final Map<String, Object> mJavaScriptInterfaces = new HashMap<String, Object>();
+ // This map stores those references. We put into the map on addJavaScriptInterface()
+ // and remove from it in removeJavaScriptInterface(). The annotation class is stored for
+ // the purpose of migrating injected objects from one instance of CVC to another, which
+ // is used by Android WebView to support WebChromeClient.onCreateWindow scenario.
+ private final Map<String, Pair<Object, Class>> mJavaScriptInterfaces =
+ new HashMap<String, Pair<Object, Class>>();
// Additionally, we keep track of all Java bound JS objects that are in use on the
// current page to ensure that they are not garbage collected until the page is
@@ -2677,6 +2681,16 @@ public class ContentViewCore
}
/**
+ * Returns JavaScript interface objects previously injected via
+ * {@link #addJavascriptInterface(Object, String)}.
+ *
+ * @return the mapping of names to interface objects and corresponding annotation classes
+ */
+ public Map<String, Pair<Object, Class>> getJavascriptInterfaces() {
+ return mJavaScriptInterfaces;
+ }
+
+ /**
* This will mimic {@link #addPossiblyUnsafeJavascriptInterface(Object, String, Class)}
* and automatically pass in {@link JavascriptInterface} as the required annotation.
*
@@ -2733,7 +2747,7 @@ public class ContentViewCore
public void addPossiblyUnsafeJavascriptInterface(Object object, String name,
Class<? extends Annotation> requiredAnnotation) {
if (mNativeContentViewCore != 0 && object != null) {
- mJavaScriptInterfaces.put(name, object);
+ mJavaScriptInterfaces.put(name, new Pair<Object, Class>(object, requiredAnnotation));
nativeAddJavascriptInterface(mNativeContentViewCore, object, name, requiredAnnotation);
}
}

Powered by Google App Engine
This is Rietveld 408576698