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

Commit 544295ee authored by Steve Block's avatar Steve Block
Browse files

Update WebView.addJavascriptInterface() to ignore null instances

Bug: 3247571
Change-Id: If6a108fe926e45dc3e298f197f6534c575c560e2
parent edebb2fe
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;