cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [3/3] ios commit: Fix NPE when PDF is opened in InAppBrowser.
Date Fri, 18 Jan 2013 19:48:36 GMT
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 <agrieve@chromium.org>
Authored: Thu Jan 17 15:07:32 2013 -0500
Committer: Andrew Grieve <agrieve@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];
     }
 }
 


Mime
View raw message