From ab7494faa059a8e90fb8f88c5c5ef40e8a154478 Mon Sep 17 00:00:00 2001 From: sgrebnov Date: Mon, 21 Apr 2014 15:28:03 -0700 Subject: [PATCH] CB-6482 InAppBrowser calls incorrect callback on WP8 --- src/wp/InAppBrowser.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/wp/InAppBrowser.cs b/src/wp/InAppBrowser.cs index 454464d..9d49165 100644 --- a/src/wp/InAppBrowser.cs +++ b/src/wp/InAppBrowser.cs @@ -41,6 +41,8 @@ namespace WPCordovaClassLib.Cordova.Commands protected bool ShowLocation {get;set;} protected bool StartHidden {get;set;} + protected string NavigationCallbackId { get; set; } + public void open(string options) { // reset defaults on ShowLocation + StartHidden features @@ -52,6 +54,7 @@ namespace WPCordovaClassLib.Cordova.Commands string urlLoc = args[0]; string target = args[1]; string featString = args[2]; + this.NavigationCallbackId = args[3]; string[] features = featString.Split(','); foreach (string str in features) @@ -367,7 +370,7 @@ namespace WPCordovaClassLib.Cordova.Commands string message = "{\"type\":\"exit\"}"; PluginResult result = new PluginResult(PluginResult.Status.OK, message); result.KeepCallback = false; - this.DispatchCommandResult(result); + this.DispatchCommandResult(result, NavigationCallbackId); }); } } @@ -385,7 +388,7 @@ namespace WPCordovaClassLib.Cordova.Commands string message = "{\"type\":\"loadstop\", \"url\":\"" + e.Uri.OriginalString + "\"}"; PluginResult result = new PluginResult(PluginResult.Status.OK, message); result.KeepCallback = true; - this.DispatchCommandResult(result); + this.DispatchCommandResult(result, NavigationCallbackId); } void browser_NavigationFailed(object sender, System.Windows.Navigation.NavigationFailedEventArgs e) @@ -393,7 +396,7 @@ namespace WPCordovaClassLib.Cordova.Commands string message = "{\"type\":\"error\",\"url\":\"" + e.Uri.OriginalString + "\"}"; PluginResult result = new PluginResult(PluginResult.Status.ERROR, message); result.KeepCallback = true; - this.DispatchCommandResult(result); + this.DispatchCommandResult(result, NavigationCallbackId); } void browser_Navigating(object sender, NavigatingEventArgs e) @@ -401,7 +404,7 @@ namespace WPCordovaClassLib.Cordova.Commands string message = "{\"type\":\"loadstart\",\"url\":\"" + e.Uri.OriginalString + "\"}"; PluginResult result = new PluginResult(PluginResult.Status.OK, message); result.KeepCallback = true; - this.DispatchCommandResult(result); + this.DispatchCommandResult(result, NavigationCallbackId); } }