Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bcdf40b4 authored by Steve Block's avatar Steve Block Committed by Android (Google) Code Review
Browse files

Merge "Update WebView.addJavascriptInterface() to ignore null instances"

parents cbdfd0fc 544295ee
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -571,11 +571,14 @@ class BrowserFrame extends Handler {
            Iterator iter = mJSInterfaceMap.keySet().iterator();
            while (iter.hasNext())  {
                String interfaceName = (String) iter.next();
                Object object = mJSInterfaceMap.get(interfaceName);
                if (object != null) {
                    nativeAddJavascriptInterface(nativeFramePointer,
                            mJSInterfaceMap.get(interfaceName), interfaceName);
                }
            }
        }
    }

    /**
     * This method is called by WebCore to check whether application
@@ -595,6 +598,7 @@ class BrowserFrame extends Handler {
    }

    public void addJavascriptInterface(Object obj, String interfaceName) {
        assert obj != null;
        if (mJSInterfaceMap == null) {
            mJSInterfaceMap = new HashMap<String, Object>();
        }
+6 −2
Original line number Diff line number Diff line
@@ -3492,10 +3492,14 @@ public class WebView extends AbsoluteLayout
     * <li> The Java object that is bound runs in another thread and not in
     * the thread that it was constructed in.</li>
     * </ul></p>
     * @param obj The class instance to bind to Javascript
     * @param interfaceName The name to used to expose the class in Javascript
     * @param obj The class instance to bind to Javascript, null instances are
     *            ignored.
     * @param interfaceName The name to used to expose the class in JavaScript.
     */
    public void addJavascriptInterface(Object obj, String interfaceName) {
        if (obj == null) {
            return;
        }
        WebViewCore.JSInterfaceData arg = new WebViewCore.JSInterfaceData();
        arg.mObject = obj;
        arg.mInterfaceName = interfaceName;