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 2014/11/12 16:05:53 UTC

cordova-plugins git commit: Changes in CDWKWebViewEngine to reflect changes in CDVWebViewEngineProtocol.

Repository: cordova-plugins
Updated Branches:
  refs/heads/master 2780b526e -> 6ac14219c


Changes in CDWKWebViewEngine to reflect changes in CDVWebViewEngineProtocol.

Made loadHTMLString and loadRequest explicit - loadRequest implicitly handles file urls by attempting to use loadFileURL if available.


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

Branch: refs/heads/master
Commit: 6ac14219c9bc7008ee4084724251d8c4b2a46666
Parents: 2780b52
Author: Shazron Abdullah <sh...@apache.org>
Authored: Wed Nov 12 07:05:52 2014 -0800
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Wed Nov 12 07:05:52 2014 -0800

----------------------------------------------------------------------
 wkwebview-engine/src/ios/CDVWKWebViewEngine.m | 33 ++++++++++++----------
 1 file changed, 18 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/6ac14219/wkwebview-engine/src/ios/CDVWKWebViewEngine.m
----------------------------------------------------------------------
diff --git a/wkwebview-engine/src/ios/CDVWKWebViewEngine.m b/wkwebview-engine/src/ios/CDVWKWebViewEngine.m
index fd81e37..de69ddd 100644
--- a/wkwebview-engine/src/ios/CDVWKWebViewEngine.m
+++ b/wkwebview-engine/src/ios/CDVWKWebViewEngine.m
@@ -86,22 +86,25 @@
     [self updateSettings:self.commandDelegate.settings];
 }
 
-// We implement this here because certain versions of iOS 8 do not implement this
-// in WKWebView, so we need to test for this during runtime.
-// It is speculated that this selector will be available in iOS 8.2 for WKWebView
-- (void)loadFileURL:(NSURL*)url allowingReadAccessToURL:(NSURL*)readAccessURL
+- (id)loadRequest:(NSURLRequest*)request
 {
-    SEL wk_sel = @selector(loadFileURL:allowingReadAccessToURL:);
-    __weak CDVWKWebViewEngine* weakSelf = self;
-
-    // UIKit operations have to be on the main thread. This method does not need to be synchronous
-    dispatch_async(dispatch_get_main_queue(), ^{
-        if ([_engineWebView respondsToSelector:wk_sel] && [[url scheme] isEqualToString:@"file"]) {
-            ((id (*)(id, SEL, id, id))objc_msgSend)(_engineWebView, wk_sel, url, readAccessURL);
-        } else {
-            [weakSelf loadRequest:[NSURLRequest requestWithURL:url]];
-        }
-    });
+    SEL wk_sel = NSSelectorFromString(@"loadFileURL:allowingReadAccessToURL:");
+
+    // the URL needs to be a file reference
+    NSURL* url = request.URL;
+    
+    if ([_engineWebView respondsToSelector:wk_sel] && [url isFileReferenceURL]) {
+        // allow the folder containing the file reference to be read as well
+        NSURL* readAccessUrl = [request.URL URLByDeletingLastPathComponent];
+        return ((id (*)(id, SEL, id, id))objc_msgSend)(_engineWebView, wk_sel, url, readAccessUrl);
+    } else {
+        return [(WKWebView*)_engineWebView loadRequest:request];
+    }
+}
+
+- (id)loadHTMLString:(NSString*)string baseURL:(NSURL*)baseURL
+{
+    return [(WKWebView*)_engineWebView loadHTMLString:string baseURL:baseURL];
 }
 
 - (void)updateSettings:(NSDictionary*)settings


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