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/01/18 20:48:36 UTC

[3/3] ios commit: Fix NPE when PDF is opened in InAppBrowser.

Updated Branches:
  refs/heads/master 27ab0659e -> 07a223ee6


Fix NPE when PDF is opened in InAppBrowser.


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

Branch: refs/heads/master
Commit: f3929376ee1e305294c00e5c93e41cb9a7a43f27
Parents: 27ab065
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Jan 17 15:07:32 2013 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Jan 18 14:48:07 2013 -0500

----------------------------------------------------------------------
 CordovaLib/Classes/CDVInAppBrowser.h |    5 ++++-
 CordovaLib/Classes/CDVInAppBrowser.m |   14 ++++++++++++--
 2 files changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f3929376/CordovaLib/Classes/CDVInAppBrowser.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVInAppBrowser.h b/CordovaLib/Classes/CDVInAppBrowser.h
index ed0beaf..1d44c58 100644
--- a/CordovaLib/Classes/CDVInAppBrowser.h
+++ b/CordovaLib/Classes/CDVInAppBrowser.h
@@ -41,7 +41,10 @@
 
 @end
 
-@interface CDVInAppBrowserViewController : UIViewController <UIWebViewDelegate>{}
+@interface CDVInAppBrowserViewController : UIViewController <UIWebViewDelegate>{
+    @private
+    NSURL* _requestedURL;
+}
 
 @property (nonatomic, strong) IBOutlet UIWebView* webView;
 @property (nonatomic, strong) IBOutlet UIBarButtonItem* closeButton;

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f3929376/CordovaLib/Classes/CDVInAppBrowser.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVInAppBrowser.m b/CordovaLib/Classes/CDVInAppBrowser.m
index c8afa34..1411d2c 100644
--- a/CordovaLib/Classes/CDVInAppBrowser.m
+++ b/CordovaLib/Classes/CDVInAppBrowser.m
@@ -420,7 +420,12 @@
     [self.spinner startAnimating];
 
     if ((self.navigationDelegate != nil) && [self.navigationDelegate respondsToSelector:@selector(browserLoadStart:)]) {
-        [self.navigationDelegate browserLoadStart:theWebView.request.URL];
+        NSURL* url = theWebView.request.URL;
+        // URL is nil when opening PDFs.
+        if (url == nil) {
+            url = _requestedURL;
+        }
+        [self.navigationDelegate browserLoadStart:url];
     }
 }
 
@@ -435,7 +440,12 @@
     [self.spinner stopAnimating];
 
     if ((self.navigationDelegate != nil) && [self.navigationDelegate respondsToSelector:@selector(browserLoadStop:)]) {
-        [self.navigationDelegate browserLoadStop:theWebView.request.URL];
+        NSURL* url = theWebView.request.URL;
+        // URL is nil when opening PDFs.
+        if (url == nil) {
+            url = _requestedURL;
+        }
+        [self.navigationDelegate browserLoadStop:url];
     }
 }