Permalink
Browse files

Adding an onError method to the ChildBrowser

  • Loading branch information...
1 parent 29135b1 commit e75e09848d7cf07d28d89bd5f323cb765d7e85df @macdonst macdonst committed with Jesse MacFadyen Nov 21, 2011
@@ -67,6 +67,11 @@ public PluginResult execute(String action, JSONArray args, String callbackId) {
if (action.equals("showWebPage")) {
this.browserCallbackId = callbackId;
+ // If the ChildBrowser is already open then throw an error
+ if (dialog != null && dialog.isShowing()) {
+ return new PluginResult(PluginResult.Status.ERROR, "ChildBrowser is already open");
+ }
+
result = this.showWebPage(args.getString(0), args.optJSONObject(1));
if (result.length() > 0) {
@@ -132,7 +137,7 @@ public String openExternal(String url, boolean usePhoneGap) {
this.ctx.startActivity(intent);
return "";
} catch (android.content.ActivityNotFoundException e) {
- System.out.println("ChildBrowser: Error loading url "+url+":"+ e.toString());
+ Log.d(LOG_TAG, "ChildBrowser: Error loading url "+url+":"+ e.toString());
return e.toString();
}
}
@@ -27,7 +27,7 @@ ChildBrowser.prototype.showWebPage = function(url, options) {
var options = new Object();
options.showLocationBar = true;
}
- PhoneGap.exec(this._onEvent, null, "ChildBrowser", "showWebPage", [url, options]);
+ PhoneGap.exec(this._onEvent, this._onError, "ChildBrowser", "showWebPage", [url, options]);
};
/**
@@ -54,22 +54,27 @@ ChildBrowser.prototype.openExternal = function(url, usePhoneGap) {
};
/**
- * Method called when the child browser is closed.
+ * Method called when the child browser has an event.
*/
ChildBrowser.prototype._onEvent = function(data) {
- console.log("In _onEvent");
- console.log("data type = " + data.type);
if (data.type == ChildBrowser.CLOSE_EVENT && typeof window.plugins.childBrowser.onClose === "function") {
- console.log("Calling onClose");
window.plugins.childBrowser.onClose();
}
if (data.type == ChildBrowser.LOCATION_CHANGED_EVENT && typeof window.plugins.childBrowser.onLocationChange === "function") {
- console.log("Calling onLocChange");
window.plugins.childBrowser.onLocationChange(data.location);
}
};
/**
+ * Method called when the child browser has an error.
+ */
+ChildBrowser.prototype._onError = function(data) {
+ if (typeof window.plugins.childBrowser.onError === "function") {
+ window.plugins.childBrowser.onError(data);
+ }
+};
+
+/**
* Maintain API consistency with iOS
*/
ChildBrowser.prototype.install = function(){

0 comments on commit e75e098

Please sign in to comment.