Title: [217252] trunk/Source/WebKit2
Revision
217252
Author
commit-qu...@webkit.org
Date
2017-05-22 15:41:02 -0700 (Mon, 22 May 2017)

Log Message

Need a way to allow WKWebView to load request with ShouldOpenExternalURLsPolicy::ShouldAllow.
https://bugs.webkit.org/show_bug.cgi?id=172460

Add an new method [WKWebView _loadRequest:shouldOpenExternalURLs:] to WKWebView; a WebKit client
can use this to load request that allows opening external URLs.

Patch by Yongjun Zhang <yongjun_zh...@apple.com> on 2017-05-22
Reviewed by Tim Horton.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _loadRequest:shouldOpenExternalURLs:]): When calling WebPageProxy::loadRequest, also
    set ShouldOpenExternalURLsPolicy based on the value of shouldOpenExternalURLs.
* UIProcess/API/Cocoa/WKWebViewPrivate.h: Add [WKWebView _loadRequest:shouldOpenExternalURLs:].

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (217251 => 217252)


--- trunk/Source/WebKit2/ChangeLog	2017-05-22 22:19:50 UTC (rev 217251)
+++ trunk/Source/WebKit2/ChangeLog	2017-05-22 22:41:02 UTC (rev 217252)
@@ -1,3 +1,18 @@
+2017-05-22  Yongjun Zhang  <yongjun_zh...@apple.com>
+
+        Need a way to allow WKWebView to load request with ShouldOpenExternalURLsPolicy::ShouldAllow.
+        https://bugs.webkit.org/show_bug.cgi?id=172460
+
+        Add an new method [WKWebView _loadRequest:shouldOpenExternalURLs:] to WKWebView; a WebKit client
+        can use this to load request that allows opening external URLs.
+
+        Reviewed by Tim Horton.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _loadRequest:shouldOpenExternalURLs:]): When calling WebPageProxy::loadRequest, also
+            set ShouldOpenExternalURLsPolicy based on the value of shouldOpenExternalURLs.
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h: Add [WKWebView _loadRequest:shouldOpenExternalURLs:].
+
 2017-05-22  Youenn Fablet  <you...@apple.com>
 
         Remove AVAudioCaptureSource

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (217251 => 217252)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2017-05-22 22:19:50 UTC (rev 217251)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2017-05-22 22:41:02 UTC (rev 217252)
@@ -3702,6 +3702,15 @@
     return [wrapper(*navigation.leakRef()) autorelease];
 }
 
+- (WKNavigation *)_loadRequest:(NSURLRequest *)request shouldOpenExternalURLs:(BOOL)shouldOpenExternalURLs
+{
+    auto navigation = _page->loadRequest(request, shouldOpenExternalURLs ? WebCore::ShouldOpenExternalURLsPolicy::ShouldAllow : WebCore::ShouldOpenExternalURLsPolicy::ShouldNotAllow);
+    if (!navigation)
+        return nil;
+
+    return [wrapper(*navigation.leakRef()) autorelease];
+}
+
 - (NSArray *)_certificateChain
 {
     if (WebKit::WebFrameProxy* mainFrame = _page->mainFrame())

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h (217251 => 217252)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h	2017-05-22 22:19:50 UTC (rev 217251)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h	2017-05-22 22:41:02 UTC (rev 217252)
@@ -103,6 +103,7 @@
 
 - (void)_loadAlternateHTMLString:(NSString *)string baseURL:(NSURL *)baseURL forUnreachableURL:(NSURL *)unreachableURL;
 - (WKNavigation *)_loadData:(NSData *)data MIMEType:(NSString *)MIMEType characterEncodingName:(NSString *)characterEncodingName baseURL:(NSURL *)baseURL userData:(id)userData WK_API_AVAILABLE(macosx(10.12), ios(10.0));
+- (WKNavigation *)_loadRequest:(NSURLRequest *)request shouldOpenExternalURLs:(BOOL)shouldOpenExternalURLs WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 @property (nonatomic, readonly) NSArray *_certificateChain WK_API_DEPRECATED_WITH_REPLACEMENT("certificateChain", macosx(10.10, 10.11), ios(8.0, 9.0));
 @property (nonatomic, readonly) NSURL *_committedURL;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to