cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [1/2] ios commit: [CB-2308] [ios] Report errors when InAppBrowser fails to load page
Date Wed, 20 Mar 2013 19:40:44 GMT
Updated Branches:
  refs/heads/master 66caa6a21 -> ebb1e346f


[CB-2308] [ios] Report errors when InAppBrowser fails to load page


Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/ebb1e346
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/ebb1e346
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/ebb1e346

Branch: refs/heads/master
Commit: ebb1e346f32283b15ab71d2deb28024d9749eeba
Parents: 93c1416
Author: Ian Clelland <iclelland@chromium.org>
Authored: Thu Mar 14 13:32:00 2013 -0400
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Wed Mar 20 15:40:31 2013 -0400

----------------------------------------------------------------------
 CordovaLib/Classes/CDVInAppBrowser.h |    1 +
 CordovaLib/Classes/CDVInAppBrowser.m |   16 ++++++++++++++++
 2 files changed, 17 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/ebb1e346/CordovaLib/Classes/CDVInAppBrowser.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVInAppBrowser.h b/CordovaLib/Classes/CDVInAppBrowser.h
index 297d946..f63250a 100644
--- a/CordovaLib/Classes/CDVInAppBrowser.h
+++ b/CordovaLib/Classes/CDVInAppBrowser.h
@@ -28,6 +28,7 @@
 
 - (void)browserLoadStart:(NSURL*)url;
 - (void)browserLoadStop:(NSURL*)url;
+- (void)browserLoadError:(NSError*)error forUrl:(NSURL*)url;
 - (void)browserExit;
 
 @end

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/ebb1e346/CordovaLib/Classes/CDVInAppBrowser.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVInAppBrowser.m b/CordovaLib/Classes/CDVInAppBrowser.m
index 345ec02..d001dfd 100644
--- a/CordovaLib/Classes/CDVInAppBrowser.m
+++ b/CordovaLib/Classes/CDVInAppBrowser.m
@@ -183,6 +183,17 @@
     }
 }
 
+- (void)browserLoadError:(NSError*)error forUrl:(NSURL*)url
+{
+    if (self.callbackId != nil) {
+        CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
+                                                      messageAsDictionary:@{@"type":@"loaderror",
@"url":[url absoluteString], @"code": [NSNumber numberWithInt:error.code], @"message": error.localizedDescription}];
+        [pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
+
+        [self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
+    }
+}
+
 - (void)browserExit
 {
     if (self.callbackId != nil) {
@@ -476,6 +487,11 @@
     [self.spinner stopAnimating];
 
     self.addressLabel.text = @"Load Error";
+
+    if ((self.navigationDelegate != nil) && [self.navigationDelegate respondsToSelector:@selector(browserLoadError:forUrl:)])
{
+        NSURL* url = theWebView.request.URL;
+        [self.navigationDelegate browserLoadError:error forUrl:url];
+    }
 }
 
 #pragma mark CDVScreenOrientationDelegate


Mime
View raw message