You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/10/10 14:08:56 UTC

git commit: CB-5021 Expose closeDialog() as a public function and make it safe to call multiple times.

Updated Branches:
  refs/heads/dev ef5eddac9 -> 8cd786b60


CB-5021 Expose closeDialog() as a public function and make it safe to call multiple times.


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/commit/8cd786b6
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/tree/8cd786b6
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/diff/8cd786b6

Branch: refs/heads/dev
Commit: 8cd786b6035d1da9b58ecafd6752df690058ca6b
Parents: ef5edda
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Oct 10 08:07:46 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Oct 10 08:07:46 2013 -0400

----------------------------------------------------------------------
 src/android/InAppBrowser.java | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/8cd786b6/src/android/InAppBrowser.java
----------------------------------------------------------------------
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");