From 8cd786b6035d1da9b58ecafd6752df690058ca6b Mon Sep 17 00:00:00 2001 From: Andrew Grieve Date: Thu, 10 Oct 2013 08:07:46 -0400 Subject: [PATCH] CB-5021 Expose closeDialog() as a public function and make it safe to call multiple times. --- src/android/InAppBrowser.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java index 3be0316..dfe1a50 100644 --- a/src/android/InAppBrowser.java +++ b/src/android/InAppBrowser.java @@ -157,7 +157,7 @@ public class InAppBrowser extends CordovaPlugin { } else if (action.equals("close")) { closeDialog(); - this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK)); + this.callbackContext.success(); } else if (action.equals("injectScriptCode")) { String jsWrapper = null; @@ -311,11 +311,15 @@ public class InAppBrowser extends CordovaPlugin { /** * Closes the dialog */ - private void closeDialog() { + public void closeDialog() { + final WebView childView = this.inAppWebView; + // The JS protects against multiple calls, so this should happen only when + // closeDialog() is called by other native code. + if (childView == null) { + return; + } try { - final WebView childView = this.inAppWebView; Runnable runnable = new Runnable() { - @Override public void run() { childView.loadUrl("about:blank");