You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2015/09/11 10:22:53 UTC

ios commit: CB-9636 - only load a WebView engine if the url to load passes the engine's canLoadRequest filter

Repository: cordova-ios
Updated Branches:
  refs/heads/master 0f571e354 -> a56ff479f


CB-9636 - only load a WebView engine if the url to load passes the engine's canLoadRequest filter


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

Branch: refs/heads/master
Commit: a56ff479fcd9053e141ef4bb3779491987b49bc4
Parents: 0f571e3
Author: Shazron Abdullah <sh...@apache.org>
Authored: Fri Sep 11 01:22:09 2015 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Fri Sep 11 01:22:35 2015 -0700

----------------------------------------------------------------------
 .../Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m     | 5 +++++
 CordovaLib/Classes/Public/CDVViewController.m                   | 4 ++--
 CordovaLib/Classes/Public/CDVWebViewEngineProtocol.h            | 1 +
 3 files changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/a56ff479/CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m b/CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m
index 57df822..ef0356c 100644
--- a/CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m
+++ b/CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m
@@ -91,6 +91,11 @@
     return [[(UIWebView*)_engineWebView request] URL];
 }
 
+- (BOOL) canLoadRequest:(NSURLRequest*)request
+{
+    return (request != nil);
+}
+
 - (void)updateSettings:(NSDictionary*)settings
 {
     UIWebView* uiWebView = (UIWebView*)_engineWebView;

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/a56ff479/CordovaLib/Classes/Public/CDVViewController.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/Public/CDVViewController.m b/CordovaLib/Classes/Public/CDVViewController.m
index 830e3ed..299fb6c 100644
--- a/CordovaLib/Classes/Public/CDVViewController.m
+++ b/CordovaLib/Classes/Public/CDVViewController.m
@@ -395,8 +395,8 @@
     // Find webViewEngine
     if (NSClassFromString(webViewEngineClass)) {
         self.webViewEngine = [[NSClassFromString(webViewEngineClass) alloc] initWithFrame:bounds];
-        // if a webView engine returns nil (not supported by the current iOS version) or doesn't conform to the protocol, we use UIWebView
-        if (!self.webViewEngine || ![self.webViewEngine conformsToProtocol:@protocol(CDVWebViewEngineProtocol)]) {
+        // if a webView engine returns nil (not supported by the current iOS version) or doesn't conform to the protocol, or can't load the request, we use UIWebView
+        if (!self.webViewEngine || ![self.webViewEngine conformsToProtocol:@protocol(CDVWebViewEngineProtocol)] || ![self.webViewEngine canLoadRequest:[NSURLRequest requestWithURL:self.appUrl]]) {
             self.webViewEngine = [[NSClassFromString(defaultWebViewEngineClass) alloc] initWithFrame:bounds];
         }
     } else {

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/a56ff479/CordovaLib/Classes/Public/CDVWebViewEngineProtocol.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/Public/CDVWebViewEngineProtocol.h b/CordovaLib/Classes/Public/CDVWebViewEngineProtocol.h
index 18c1831..34d07f3 100644
--- a/CordovaLib/Classes/Public/CDVWebViewEngineProtocol.h
+++ b/CordovaLib/Classes/Public/CDVWebViewEngineProtocol.h
@@ -34,6 +34,7 @@
 - (void)evaluateJavaScript:(NSString*)javaScriptString completionHandler:(void (^)(id, NSError*))completionHandler;
 
 - (NSURL*)URL;
+- (BOOL)canLoadRequest:(NSURLRequest*)request;
 
 - (instancetype)initWithFrame:(CGRect)frame;
 - (void)updateWithInfo:(NSDictionary*)info;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org