Add SPI for WKOpenPanelParameters._acceptedMIMETypes and _acceptedFileExtensions
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Jan 2018 02:56:05 +0000 (02:56 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Jan 2018 02:56:05 +0000 (02:56 +0000)
https://bugs.webkit.org/show_bug.cgi?id=181408
<rdar://problem/35884960>

Reviewed by Tim Horton.

Source/WebKit:

* UIProcess/API/Cocoa/WKOpenPanelParameters.mm:
(-[WKOpenPanelParameters _acceptedMIMETypes]):
(-[WKOpenPanelParameters _acceptedFileExtensions]):
* UIProcess/API/Cocoa/WKOpenPanelParametersInternal.h:
* UIProcess/API/Cocoa/WKOpenPanelParametersPrivate.h: Added.
* WebKit.xcodeproj/project.pbxproj:

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/RunOpenPanel.mm:
(-[RunOpenPanelUIDelegate webView:runOpenPanelWithParameters:initiatedByFrame:completionHandler:]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226607 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/Cocoa/WKOpenPanelParameters.mm
Source/WebKit/UIProcess/API/Cocoa/WKOpenPanelParametersInternal.h
Source/WebKit/UIProcess/API/Cocoa/WKOpenPanelParametersPrivate.h [new file with mode: 0644]
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKitCocoa/RunOpenPanel.mm

index cf8b1a9..0882495 100644 (file)
@@ -1,3 +1,18 @@
+2018-01-08  Alex Christensen  <achristensen@webkit.org>
+
+        Add SPI for WKOpenPanelParameters._acceptedMIMETypes and _acceptedFileExtensions
+        https://bugs.webkit.org/show_bug.cgi?id=181408
+        <rdar://problem/35884960>
+
+        Reviewed by Tim Horton.
+
+        * UIProcess/API/Cocoa/WKOpenPanelParameters.mm:
+        (-[WKOpenPanelParameters _acceptedMIMETypes]):
+        (-[WKOpenPanelParameters _acceptedFileExtensions]):
+        * UIProcess/API/Cocoa/WKOpenPanelParametersInternal.h:
+        * UIProcess/API/Cocoa/WKOpenPanelParametersPrivate.h: Added.
+        * WebKit.xcodeproj/project.pbxproj:
+
 2018-01-08  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r226532 and r226540.
index 3c36ab5..3dbd545 100644 (file)
@@ -28,6 +28,8 @@
 
 #if WK_API_ENABLED && PLATFORM(MAC)
 
+#import "WKNSArray.h"
+
 @implementation WKOpenPanelParameters
 
 - (BOOL)allowsMultipleSelection
 
 @end
 
+@implementation WKOpenPanelParameters (WKPrivate)
+
+- (NSArray<NSString *> *)_acceptedMIMETypes
+{
+    return wrapper(_openPanelParameters->acceptMIMETypes());
+}
+
+- (NSArray<NSString *> *)_acceptedFileExtensions
+{
+    return wrapper(_openPanelParameters->acceptFileExtensions());
+}
+
+@end
+
 #endif
index b530eaa..3d6b41d 100644 (file)
@@ -23,7 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#import "WKOpenPanelParameters.h"
+#import "WKOpenPanelParametersPrivate.h"
 
 #if WK_API_ENABLED && PLATFORM(MAC)
 
diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKOpenPanelParametersPrivate.h b/Source/WebKit/UIProcess/API/Cocoa/WKOpenPanelParametersPrivate.h
new file mode 100644 (file)
index 0000000..9cddf60
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2018 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/WKOpenPanelParameters.h>
+
+#if WK_API_ENABLED && !TARGET_OS_IPHONE
+
+@interface WKOpenPanelParameters (WKPrivate)
+
+@property (nonatomic, readonly, copy) NSArray<NSString *> *_acceptedMIMETypes WK_API_AVAILABLE(macosx(WK_MAC_TBA));
+@property (nonatomic, readonly, copy) NSArray<NSString *> *_acceptedFileExtensions WK_API_AVAILABLE(macosx(WK_MAC_TBA));
+
+@end
+
+#endif
index bcbf881..1d5b906 100644 (file)
                5C19A5211FD0B29A00EEA323 /* URLSchemeTaskParameters.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C19A51E1FD0B14600EEA323 /* URLSchemeTaskParameters.cpp */; };
                5C20CB9D1BB0DCFA00895BB1 /* NetworkSessionCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C20CB9B1BB0DCD200895BB1 /* NetworkSessionCocoa.mm */; };
                5C20CBA01BB1ECD800895BB1 /* NetworkSession.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C20CB9E1BB0DD1800895BB1 /* NetworkSession.h */; };
+               5C26958520043212005C439B /* WKOpenPanelParametersPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C26958420042F12005C439B /* WKOpenPanelParametersPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
                5C298DA01C3DF02100470AFE /* PendingDownload.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C298D9E1C3DEF2900470AFE /* PendingDownload.h */; };
                5C3AEA8F1FE1F21F002318D3 /* WebsitePoliciesData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C3AEA8E1FE1F1DF002318D3 /* WebsitePoliciesData.cpp */; };
                5C62FDF91EFC271C00CE072E /* WKURLSchemeTaskPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C62FDF81EFC263C00CE072E /* WKURLSchemeTaskPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
                5C19A51F1FD0B14700EEA323 /* URLSchemeTaskParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = URLSchemeTaskParameters.h; sourceTree = "<group>"; };
                5C20CB9B1BB0DCD200895BB1 /* NetworkSessionCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = NetworkSessionCocoa.mm; path = NetworkProcess/cocoa/NetworkSessionCocoa.mm; sourceTree = "<group>"; };
                5C20CB9E1BB0DD1800895BB1 /* NetworkSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkSession.h; path = NetworkProcess/NetworkSession.h; sourceTree = "<group>"; };
+               5C26958420042F12005C439B /* WKOpenPanelParametersPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKOpenPanelParametersPrivate.h; sourceTree = "<group>"; };
                5C298D9E1C3DEF2900470AFE /* PendingDownload.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PendingDownload.h; path = NetworkProcess/Downloads/PendingDownload.h; sourceTree = "<group>"; };
                5C3AEA8E1FE1F1DF002318D3 /* WebsitePoliciesData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebsitePoliciesData.cpp; sourceTree = "<group>"; };
                5C62FDF81EFC263C00CE072E /* WKURLSchemeTaskPrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKURLSchemeTaskPrivate.h; sourceTree = "<group>"; };
                                1ACC50F01CBC381D003C7D03 /* WKOpenPanelParameters.h */,
                                1ACC50EF1CBC381D003C7D03 /* WKOpenPanelParameters.mm */,
                                1A67CD2D1CBC513F00BFE3EA /* WKOpenPanelParametersInternal.h */,
+                               5C26958420042F12005C439B /* WKOpenPanelParametersPrivate.h */,
                                1AFDD3161891C94700153970 /* WKPreferences.h */,
                                1AFDD3181891CA1200153970 /* WKPreferences.mm */,
                                1A3C887F18A5ABAE00C4C962 /* WKPreferencesInternal.h */,
                                378E1A40181EDA010031007A /* WKObject.h in Headers */,
                                1ACC50F21CBC381D003C7D03 /* WKOpenPanelParameters.h in Headers */,
                                1A67CD2E1CBC513F00BFE3EA /* WKOpenPanelParametersInternal.h in Headers */,
+                               5C26958520043212005C439B /* WKOpenPanelParametersPrivate.h in Headers */,
                                BC857FE612B843D800EDEB2E /* WKOpenPanelParametersRef.h in Headers */,
                                BC1DFE8F12B31CA8005DF730 /* WKOpenPanelResultListener.h in Headers */,
                                BCD597D7112B56DC00EC8C23 /* WKPage.h in Headers */,
index a5e9192..dc04be2 100644 (file)
@@ -1,3 +1,14 @@
+2018-01-08  Alex Christensen  <achristensen@webkit.org>
+
+        Add SPI for WKOpenPanelParameters._acceptedMIMETypes and _acceptedFileExtensions
+        https://bugs.webkit.org/show_bug.cgi?id=181408
+        <rdar://problem/35884960>
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/RunOpenPanel.mm:
+        (-[RunOpenPanelUIDelegate webView:runOpenPanelWithParameters:initiatedByFrame:completionHandler:]):
+
 2018-01-08  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         [Attachment Support] Expose file name and content type of WKAttachment
index 2104bc4..3a16d57 100644 (file)
@@ -31,6 +31,7 @@
 #import "TestNavigationDelegate.h"
 #import "Utilities.h"
 #import <AppKit/AppKit.h>
+#import <WebKit/WKOpenPanelParametersPrivate.h>
 #import <WebKit/WebKit.h>
 #import <wtf/RetainPtr.h>
 
@@ -44,6 +45,10 @@ static NSString * const expectedFileName = @"这是中文";
 
 - (void)webView:(WKWebView *)webView runOpenPanelWithParameters:(WKOpenPanelParameters *)parameters initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(NSArray<NSURL *> * _Nullable))completionHandler
 {
+    EXPECT_FALSE(parameters.allowsMultipleSelection);
+    EXPECT_FALSE(parameters.allowsDirectories);
+    EXPECT_EQ(0ull, parameters._acceptedMIMETypes.count);
+    EXPECT_EQ(0ull, parameters._acceptedFileExtensions.count);
     completionHandler(@[ [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:expectedFileName]] ]);
     fileSelected = true;
 }