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/24 19:41:51 UTC
[2/3] ios commit: CB-2225 Take Two
CB-2225 Take Two
The original fix didn't correctly detect if the load was a PDF and was
applying the "fix" to all InAppBrowser loads. This cause the
InAppBrowser to be affected by the whitelist when it shouldn't be.
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/b8f7515b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/b8f7515b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/b8f7515b
Branch: refs/heads/master
Commit: b8f7515bdb840be4619ecee2f6ed71a0a57dbad1
Parents: 70dad32
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Jan 24 13:33:55 2013 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Jan 24 13:39:21 2013 -0500
----------------------------------------------------------------------
CordovaLib/Classes/CDVInAppBrowser.h | 1 -
CordovaLib/Classes/CDVInAppBrowser.m | 10 ++++------
2 files changed, 4 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/b8f7515b/CordovaLib/Classes/CDVInAppBrowser.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVInAppBrowser.h b/CordovaLib/Classes/CDVInAppBrowser.h
index 0a3ef70..a36a62a 100644
--- a/CordovaLib/Classes/CDVInAppBrowser.h
+++ b/CordovaLib/Classes/CDVInAppBrowser.h
@@ -46,7 +46,6 @@
NSURL* _requestedURL;
NSString* _userAgent;
NSString* _prevUserAgent;
- BOOL _isPDF;
}
@property (nonatomic, strong) IBOutlet UIWebView* webView;
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/b8f7515b/CordovaLib/Classes/CDVInAppBrowser.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVInAppBrowser.m b/CordovaLib/Classes/CDVInAppBrowser.m
index 5be3769..fde68b8 100644
--- a/CordovaLib/Classes/CDVInAppBrowser.m
+++ b/CordovaLib/Classes/CDVInAppBrowser.m
@@ -399,6 +399,7 @@
NSURLRequest* request = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:request];
+ _requestedURL = url;
}
- (void)goBack:(id)sender
@@ -423,12 +424,8 @@
[self.spinner startAnimating];
- NSURL* url = theWebView.request.URL;
- // This is probably a bug, but it works on iOS 5 and 6 to know when a PDF
- // is being loaded.
- _isPDF = [[url absoluteString] length] == 0;
-
if ((self.navigationDelegate != nil) && [self.navigationDelegate respondsToSelector:@selector(browserLoadStart:)]) {
+ NSURL* url = theWebView.request.URL;
if (url == nil) {
url = _requestedURL;
}
@@ -457,7 +454,8 @@
// from it must pass through its white-list. This *does* break PDFs that
// contain links to other remote PDF/websites.
// More info at https://issues.apache.org/jira/browse/CB-2225
- if (_isPDF) {
+ BOOL isPDF = [@"true" isEqualToString:[theWebView stringByEvaluatingJavaScriptFromString:@"document.body==null"]];
+ if (isPDF) {
[CDVUserAgentUtil setUserAgent:_prevUserAgent];
}