Title: [184982] trunk/Source/WebKit2
Revision
184982
Author
beid...@apple.com
Date
2015-05-28 23:38:22 -0700 (Thu, 28 May 2015)

Log Message

Change method of signaling "should open external urls" to WebKit.
https://bugs.webkit.org/show_bug.cgi?id=145454

Reviewed by Dan Bernstein.

Making this a property on the request was never a good idea.

Adding a new extensible load SPI seems much better.

* Shared/API/Cocoa/_WKNSURLRequestExtras.h: Removed.
* Shared/API/Cocoa/_WKNSURLRequestExtras.mm: Removed.

* UIProcess/API/Cocoa/WKBrowsingContextController.mm:
(-[WKBrowsingContextController loadRequest:userData:]): Since this API is deprecated,
  it always gets the default restrictive behavior.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView loadRequest:]):
(-[WKWebView loadRequest:withOptions:]): Take an options dictionary that, for now,
  only supports one option.
* UIProcess/API/Cocoa/WKWebViewPrivate.h:

* WebKit2.xcodeproj/project.pbxproj:

Modified Paths

Removed Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (184981 => 184982)


--- trunk/Source/WebKit2/ChangeLog	2015-05-29 06:17:10 UTC (rev 184981)
+++ trunk/Source/WebKit2/ChangeLog	2015-05-29 06:38:22 UTC (rev 184982)
@@ -1,3 +1,29 @@
+2015-05-28  Brady Eidson  <beid...@apple.com>
+
+        Change method of signaling "should open external urls" to WebKit.
+        https://bugs.webkit.org/show_bug.cgi?id=145454
+
+        Reviewed by Dan Bernstein.
+
+        Making this a property on the request was never a good idea.
+
+        Adding a new extensible load SPI seems much better.
+
+        * Shared/API/Cocoa/_WKNSURLRequestExtras.h: Removed.
+        * Shared/API/Cocoa/_WKNSURLRequestExtras.mm: Removed.
+
+        * UIProcess/API/Cocoa/WKBrowsingContextController.mm:
+        (-[WKBrowsingContextController loadRequest:userData:]): Since this API is deprecated,
+          it always gets the default restrictive behavior.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView loadRequest:]):
+        (-[WKWebView loadRequest:withOptions:]): Take an options dictionary that, for now, 
+          only supports one option.
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+
+        * WebKit2.xcodeproj/project.pbxproj:
+
 2015-05-28  Anders Carlsson  <ander...@apple.com>
 
         Make sure that we create the private WebKit.framework symlinks last

Deleted: trunk/Source/WebKit2/Shared/API/Cocoa/_WKNSURLRequestExtras.h (184981 => 184982)


--- trunk/Source/WebKit2/Shared/API/Cocoa/_WKNSURLRequestExtras.h	2015-05-29 06:17:10 UTC (rev 184981)
+++ trunk/Source/WebKit2/Shared/API/Cocoa/_WKNSURLRequestExtras.h	2015-05-29 06:38:22 UTC (rev 184982)
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <WebKit/WKFoundation.h>
-
-@interface NSURLRequest (WKExtras)
-
-- (BOOL)_web_shouldOpenExternalURLs;
-
-@end
-
-@interface NSMutableURLRequest (WKExtras)
-
-- (void)_web_setShouldOpenExternalURLs:(BOOL)shouldOpenExternalURLs;
-
-@end

Deleted: trunk/Source/WebKit2/Shared/API/Cocoa/_WKNSURLRequestExtras.mm (184981 => 184982)


--- trunk/Source/WebKit2/Shared/API/Cocoa/_WKNSURLRequestExtras.mm	2015-05-29 06:17:10 UTC (rev 184981)
+++ trunk/Source/WebKit2/Shared/API/Cocoa/_WKNSURLRequestExtras.mm	2015-05-29 06:38:22 UTC (rev 184982)
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "_WKNSURLRequestExtras.h"
-
-@implementation NSURLRequest (WKExtras)
-
-- (BOOL)_web_shouldOpenExternalURLs
-{
-    NSNumber *shouldOpenExternalURLs = [NSURLProtocol propertyForKey:@"WKNSURLRequestShouldOpenExternalURLsKey" inRequest:self];
-    return shouldOpenExternalURLs.boolValue;
-}
-
-@end
-
-@implementation NSMutableURLRequest (WKExtras)
-
-- (void)_web_setShouldOpenExternalURLs:(BOOL)shouldOpenExternalURLs
-{
-    [NSURLProtocol setProperty:shouldOpenExternalURLs ? @YES : @NO forKey:@"WKNSURLRequestShouldOpenExternalURLsKey" inRequest:self];
-}
-
-@end

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.mm (184981 => 184982)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.mm	2015-05-29 06:17:10 UTC (rev 184981)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.mm	2015-05-29 06:38:22 UTC (rev 184982)
@@ -55,7 +55,6 @@
 #import "WebPageProxy.h"
 #import "WebProcessPool.h"
 #import "WebProtectionSpace.h"
-#import "_WKNSURLRequestExtras.h"
 #import "_WKRemoteObjectRegistryInternal.h"
 #import <wtf/NeverDestroyed.h>
 
@@ -192,7 +191,7 @@
     if (userData)
         wkUserData = ObjCObjectGraph::create(userData);
 
-    _page->loadRequest(request, [request _web_shouldOpenExternalURLs] ? ShouldOpenExternalURLsPolicy::ShouldAllow : ShouldOpenExternalURLsPolicy::ShouldNotAllow, wkUserData.get());
+    _page->loadRequest(request, ShouldOpenExternalURLsPolicy::ShouldNotAllow, wkUserData.get());
 }
 
 - (void)loadFileURL:(NSURL *)URL restrictToFilesWithin:(NSURL *)allowedDirectory

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


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2015-05-29 06:17:10 UTC (rev 184981)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2015-05-29 06:38:22 UTC (rev 184982)
@@ -73,7 +73,6 @@
 #import "_WKDiagnosticLoggingDelegate.h"
 #import "_WKFindDelegate.h"
 #import "_WKFormDelegate.h"
-#import "_WKNSURLRequestExtras.h"
 #import "_WKRemoteObjectRegistryInternal.h"
 #import "_WKSessionStateInternal.h"
 #import "_WKVisitedLinkProviderInternal.h"
@@ -142,6 +141,7 @@
 #import <WebCore/ColorMac.h>
 #endif
 
+NSString * const _WKShouldOpenExternalURLsKey = @"_WKShouldOpenExternalURLsKey";
 
 static HashMap<WebKit::WebPageProxy*, WKWebView *>& pageToViewMap()
 {
@@ -447,12 +447,7 @@
 
 - (WKNavigation *)loadRequest:(NSURLRequest *)request
 {
-    WebCore::ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicy = [request _web_shouldOpenExternalURLs] ? WebCore::ShouldOpenExternalURLsPolicy::ShouldAllow : WebCore::ShouldOpenExternalURLsPolicy::ShouldNotAllow;
-    auto navigation = _page->loadRequest(request, shouldOpenExternalURLsPolicy);
-    if (!navigation)
-        return nil;
-
-    return [wrapper(*navigation.release().leakRef()) autorelease];
+    return [self _loadRequest:request withOptions:nil];
 }
 
 - (WKNavigation *)loadFileURL:(NSURL *)URL allowingReadAccessToURL:(NSURL *)readAccessURL
@@ -1777,6 +1772,18 @@
 
 @implementation WKWebView (WKPrivate)
 
+- (WKNavigation *)_loadRequest:(NSURLRequest *)request withOptions:(NSDictionary *)loadOptions
+{
+    bool shouldOpenExternalURLs = [loadOptions[_WKShouldOpenExternalURLsKey] boolValue];
+    WebCore::ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicy = shouldOpenExternalURLs ? WebCore::ShouldOpenExternalURLsPolicy::ShouldAllow : WebCore::ShouldOpenExternalURLsPolicy::ShouldNotAllow;
+
+    auto navigation = _page->loadRequest(request, shouldOpenExternalURLsPolicy);
+    if (!navigation)
+        return nil;
+
+    return [wrapper(*navigation.release().leakRef()) autorelease];
+}
+
 - (BOOL)_isEditable
 {
     return _page->isEditable();

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


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h	2015-05-29 06:17:10 UTC (rev 184981)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h	2015-05-29 06:38:22 UTC (rev 184982)
@@ -39,6 +39,8 @@
     _WKPaginationModeBottomToTop,
 } WK_ENUM_AVAILABLE(10_10, 8_0);
 
+WK_EXTERN NSString * const _WKShouldOpenExternalURLsKey WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
+
 @class WKBrowsingContextHandle;
 @class _WKRemoteObjectRegistry;
 @class _WKSessionState;
@@ -200,6 +202,8 @@
 @property (nonatomic, setter=_setScrollPerformanceDataCollectionEnabled:) BOOL _scrollPerformanceDataCollectionEnabled WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
 @property (nonatomic, readonly) NSArray *_scrollPerformanceData WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
 
+- (WKNavigation *)_loadRequest:(NSURLRequest *)request withOptions:(NSDictionary *)loadOptions WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
+
 @end
 
 #endif

Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (184981 => 184982)


--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2015-05-29 06:17:10 UTC (rev 184981)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2015-05-29 06:38:22 UTC (rev 184982)
@@ -1014,8 +1014,6 @@
 		51AD35731AD2F3940057B38E /* WebHitTestResult.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51AD35721AD2F3750057B38E /* WebHitTestResult.mm */; };
 		51B15A8413843A3900321AD8 /* EnvironmentUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51B15A8213843A3900321AD8 /* EnvironmentUtilities.cpp */; };
 		51B15A8513843A3900321AD8 /* EnvironmentUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 51B15A8313843A3900321AD8 /* EnvironmentUtilities.h */; };
-		51B8F4831B0E539A008FC4BD /* _WKNSURLRequestExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 51B8F47F1B0E530C008FC4BD /* _WKNSURLRequestExtras.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		51B8F4841B0E53A1008FC4BD /* _WKNSURLRequestExtras.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51B8F4801B0E530C008FC4BD /* _WKNSURLRequestExtras.mm */; };
 		51BA24441858EE3000EA2811 /* AsyncTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 51BA24431858EE3000EA2811 /* AsyncTask.h */; };
 		51BA24461858F55D00EA2811 /* WebCrossThreadCopier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51BA24451858F41500EA2811 /* WebCrossThreadCopier.cpp */; };
 		51C96118183D294700D2002E /* WebIDBServerConnectionMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51C96116183D294700D2002E /* WebIDBServerConnectionMessageReceiver.cpp */; };
@@ -3222,8 +3220,6 @@
 		51AD35721AD2F3750057B38E /* WebHitTestResult.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebHitTestResult.mm; sourceTree = "<group>"; };
 		51B15A8213843A3900321AD8 /* EnvironmentUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = EnvironmentUtilities.cpp; path = unix/EnvironmentUtilities.cpp; sourceTree = "<group>"; };
 		51B15A8313843A3900321AD8 /* EnvironmentUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EnvironmentUtilities.h; path = unix/EnvironmentUtilities.h; sourceTree = "<group>"; };
-		51B8F47F1B0E530C008FC4BD /* _WKNSURLRequestExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKNSURLRequestExtras.h; sourceTree = "<group>"; };
-		51B8F4801B0E530C008FC4BD /* _WKNSURLRequestExtras.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKNSURLRequestExtras.mm; sourceTree = "<group>"; };
 		51BA24431858EE3000EA2811 /* AsyncTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AsyncTask.h; sourceTree = "<group>"; };
 		51BA24451858F41500EA2811 /* WebCrossThreadCopier.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebCrossThreadCopier.cpp; sourceTree = "<group>"; };
 		51C96115183C95FF00D2002E /* WebIDBServerConnection.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebIDBServerConnection.messages.in; sourceTree = "<group>"; };
@@ -5514,8 +5510,6 @@
 				373D122618A473F60066D9CC /* _WKFrameHandleInternal.h */,
 				A118A9F11908B8EA00F7C92B /* _WKNSFileManagerExtras.h */,
 				A118A9F01908B8EA00F7C92B /* _WKNSFileManagerExtras.mm */,
-				51B8F47F1B0E530C008FC4BD /* _WKNSURLRequestExtras.h */,
-				51B8F4801B0E530C008FC4BD /* _WKNSURLRequestExtras.mm */,
 				1A9E328B182165A900F5D04C /* _WKRemoteObjectInterface.h */,
 				1A9E328C182165A900F5D04C /* _WKRemoteObjectInterface.mm */,
 				1AABFE391829C1ED005B070E /* _WKRemoteObjectInterfaceInternal.h */,
@@ -7840,7 +7834,6 @@
 				1A4A9C5612B816CF008FE984 /* NetscapePluginModule.h in Headers */,
 				1AA5889211EE70400061B882 /* NetscapePluginStream.h in Headers */,
 				E1798C7A16E6818800240139 /* NetworkBlobRegistry.h in Headers */,
-				51B8F4831B0E539A008FC4BD /* _WKNSURLRequestExtras.h in Headers */,
 				E4436ECC1A0D040B00EAD204 /* NetworkCache.h in Headers */,
 				E49D40D71AD3FB170066B7B9 /* NetworkCacheBlobStorage.h in Headers */,
 				E489D28A1A0A2DB80078C06A /* NetworkCacheCoder.h in Headers */,
@@ -9580,7 +9573,6 @@
 				1A1D8BA11731A36300141DA4 /* LocalStorageDatabase.cpp in Sources */,
 				1A8C728C1738477C000A6554 /* LocalStorageDatabaseTracker.cpp in Sources */,
 				51A7F2F5125BF8D4008AEB1D /* Logging.cpp in Sources */,
-				51B8F4841B0E53A1008FC4BD /* _WKNSURLRequestExtras.mm in Sources */,
 				5160BFE113381DF900918999 /* LoggingFoundation.mm in Sources */,
 				1A24B5F211F531E800C38269 /* MachUtilities.cpp in Sources */,
 				51933DF01965EB31008AC3EA /* MenuUtilities.mm in Sources */,
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to