You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ia...@apache.org on 2014/10/30 19:14:54 UTC

[1/2] ios commit: Document use of new plugin network policy (whitelist) hooks

Repository: cordova-ios
Updated Branches:
  refs/heads/unplug-whitelist cc7c53deb -> 960c809e6


Document use of new plugin network policy (whitelist) hooks


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

Branch: refs/heads/unplug-whitelist
Commit: 0a551a52f912a1ad36dea30ae675532e4d628f29
Parents: cc7c53d
Author: Ian Clelland <ic...@chromium.org>
Authored: Thu Oct 30 14:12:45 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Thu Oct 30 14:12:45 2014 -0400

----------------------------------------------------------------------
 CordovaLib/Classes/CDVPlugin.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/0a551a52/CordovaLib/Classes/CDVPlugin.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVPlugin.h b/CordovaLib/Classes/CDVPlugin.h
index 5e8b283..d1c8003 100644
--- a/CordovaLib/Classes/CDVPlugin.h
+++ b/CordovaLib/Classes/CDVPlugin.h
@@ -56,6 +56,26 @@ extern NSString* const CDVRemoteNotificationError;
  - (void)didReceiveLocalNotification:(NSNotification *)notification;
  */
 
+ /*
+ // These methods may optionally be implemented. If present, they will be called by CVDViewController when network-policy (whitelist) decisions need to be made.
+
+    This method, if present, will be called by CDVURLProtocol to determine whether to block a request for a web resource. If all plugins which implement this method return true, then the request will be allowed. If any plugin returns false, the request will be blocked. If no plugins implement this method, then the default policy will be followed. (See [CDVViewController defaultResourcePolicyForURL:])
+
+    Note that this method will *not* be called for some resources, such as WebSocket connections, and will not be called by WKWebView at all. Please use CSP headers to handle those situations if needed.
+
+ - (BOOL)shouldAllowRequestForURL:(NSURL *)url
+
+
+    This method, if present, will be called by CDVViewController to determine whether webview navigation to a web page should be allowed. If all plugins which implement this method return true, then the navigation will be allowed. If any plugin returns false, the navigation will be blocked. If no plugins implement this method, then the default policy will be followed. (See [CDVViewController defaultResourcePolicyForURL:])
+
+ - (BOOL)shouldAllowNavigationToURL:(NSURL *)url
+
+
+    This method, if present, will be called by CDVViewController to determine whether a web page which is otherwise blocked should be opened in the system browser. If all plugins which implement this method return true, then the page will be opened. If any plugin returns false, the page will not be opened. If no plugins implement this method, then the default policy will be followed. (See [CDVViewController shouldOpenExternalURL:] and [CDVViewController webView:shouldStartLoadWithRequest:navigationType:])
+
+ - (BOOL)shouldOpenExternalURL:(NSURL *)url
+ */
+
 - (id)appDelegate;
 
 - (NSString*)writeJavascript:(NSString*)javascript CDV_DEPRECATED(3.6, "Use the CDVCommandDelegate equivalent of evalJs:. This will be removed in 4.0.0");


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


[2/2] ios commit: Replace explicit boolean comparisons with implicit ones

Posted by ia...@apache.org.
Replace explicit boolean comparisons with implicit ones

(Avoids the "== YES" failing on (BOOL)2 problem)


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

Branch: refs/heads/unplug-whitelist
Commit: 960c809e6ce46c1441e2daf9a5c49dc2e34e3841
Parents: 0a551a5
Author: Ian Clelland <ic...@chromium.org>
Authored: Thu Oct 30 14:13:17 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Thu Oct 30 14:13:25 2014 -0400

----------------------------------------------------------------------
 CordovaLib/Classes/CDVViewController.m | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/960c809e/CordovaLib/Classes/CDVViewController.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVViewController.m b/CordovaLib/Classes/CDVViewController.m
index e4e683f..17207d2 100644
--- a/CordovaLib/Classes/CDVViewController.m
+++ b/CordovaLib/Classes/CDVViewController.m
@@ -283,7 +283,7 @@
     if ([allowInlineMediaPlayback boolValue] && [self.webView respondsToSelector:@selector(allowsInlineMediaPlayback)]) {
         self.webView.allowsInlineMediaPlayback = YES;
     }
-    if ((mediaPlaybackRequiresUserAction == NO) && [self.webView respondsToSelector:@selector(mediaPlaybackRequiresUserAction)]) {
+    if ((!mediaPlaybackRequiresUserAction) && [self.webView respondsToSelector:@selector(mediaPlaybackRequiresUserAction)]) {
         self.webView.mediaPlaybackRequiresUserAction = NO;
     }
 
@@ -705,7 +705,7 @@
         CDVPlugin* plugin = [pluginObjects objectForKey:pluginName];
         SEL selector = NSSelectorFromString(@"shouldOverrideLoadWithRequest:navigationType:");
         if ([plugin respondsToSelector:selector]) {
-            if (((BOOL (*)(id, SEL, id, int))objc_msgSend)(plugin, selector, request, navigationType) == YES) {
+            if (((BOOL (*)(id, SEL, id, int))objc_msgSend)(plugin, selector, request, navigationType)) {
                 return NO;
             }
         }
@@ -714,7 +714,7 @@
     /*
      *    If we loaded the HTML from a string, we let the app handle it
      */
-    if (self.loadFromString == YES) {
+    if (self.loadFromString) {
         self.loadFromString = NO;
         return YES;
     }
@@ -780,7 +780,7 @@
         if ([plugin respondsToSelector:selector]) {
             anyPluginsResponded = YES;
             shouldAllowRequest = ((BOOL (*)(id, SEL, id))objc_msgSend)(plugin, selector, url);
-            if (shouldAllowRequest == NO) {
+            if (!shouldAllowRequest) {
                 break;
             }
         }
@@ -804,7 +804,7 @@
         if ([plugin respondsToSelector:selector]) {
             anyPluginsResponded = YES;
             shouldAllowNavigation = ((BOOL (*)(id, SEL, id))objc_msgSend)(plugin, selector, url);
-            if (shouldAllowNavigation == NO) {
+            if (!shouldAllowNavigation) {
                 break;
             }
         }
@@ -827,7 +827,7 @@
         if ([plugin respondsToSelector:selector]) {
             anyPluginsResponded = YES;
             shouldOpenExternalURL = ((BOOL (*)(id, SEL, id))objc_msgSend)(plugin, selector, url);
-            if (shouldOpenExternalURL == NO) {
+            if (!shouldOpenExternalURL) {
                 break;
             }
         }


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