[Mac] Add API for open panel handling to WKWebView
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Apr 2016 22:07:00 +0000 (22:07 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Apr 2016 22:07:00 +0000 (22:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=137759
rdar://problem/23278623

Reviewed by Tim Horton.

Source/WebKit2:

Based on a patch by Brian Michel.

* Shared/API/Cocoa/WebKit.h:
Import WKOpenPanelParameters.h.

* Shared/Cocoa/APIObject.mm:
(API::Object::newObject):
Create a WKOpenPanelParameters for Type::OpenPanelParameters.

* UIProcess/API/APIOpenPanelParameters.cpp: Renamed from Source/WebKit2/Shared/WebOpenPanelParameters.cpp.
* UIProcess/API/APIOpenPanelParameters.h: Renamed from Source/WebKit2/Shared/WebOpenPanelParameters.h.
Rename WebKit::WebOpenPanelParameters to API::OpenPanelParameters.

* UIProcess/API/APIUIClient.h:
(API::UIClient::runOpenPanel):
Change this to take a SecurityOriginData.

* UIProcess/API/C/WKAPICast.h:
* UIProcess/API/C/WKOpenPanelParametersRef.cpp:
(WKOpenPanelParametersGetTypeID):
Rename WebKit::WebOpenPanelParameters to API::OpenPanelParameters.

* UIProcess/API/C/WKOpenPanelResultListener.cpp:
(filePathsFromFileURLs):
(WKOpenPanelResultListenerChooseFiles):
* UIProcess/API/C/WKPage.cpp:
(WKPageSetPageUIClient):
Change chooseFiles to take a Vector<String> instead of an API::Array of URLs.

* UIProcess/API/Cocoa/WKOpenPanelParameters.h: Added.
* UIProcess/API/Cocoa/WKOpenPanelParameters.mm: Added.
(-[WKOpenPanelParameters allowsMultipleSelection]):
(-[WKOpenPanelParameters _apiObject]):
* UIProcess/API/Cocoa/WKOpenPanelParametersInternal.h:
Add a WKOpenPanelParameters class which contains information about a file upload control.

* UIProcess/API/Cocoa/WKUIDelegate.h:
Add new delegate method.

* UIProcess/Cocoa/UIDelegate.h:
* UIProcess/Cocoa/UIDelegate.mm:
(WebKit::UIDelegate::setDelegate):
Record whether the UI delegate implements the new delegate method.

(WebKit::UIDelegate::UIClient::runOpenPanel):
Invoke the new delegate method.

* UIProcess/PageClient.h:
(WebKit::PageClient::handleRunOpenPanel):
Rename WebKit::WebOpenPanelParameters to API::OpenPanelParameters.

* UIProcess/WebOpenPanelResultListenerProxy.cpp:
(WebKit::WebOpenPanelResultListenerProxy::chooseFiles):
* UIProcess/WebOpenPanelResultListenerProxy.h:
Change chooseFiles to take a Vector<String> instead of an API::Array of URLs.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::runOpenPanel):
* UIProcess/WebPageProxy.h:
Change this to take a SecurityOriginData.

* UIProcess/WebPageProxy.messages.in:
Change RunOpenPanel to take a SecurityOriginData.

* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::handleRunOpenPanel):
Rename WebKit::WebOpenPanelParameters to API::OpenPanelParameters.

* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _showRunOpenPanel:resultListener:]):
Change chooseFiles to take a Vector<String> instead of an API::Array of URLs.

* UIProcess/ios/forms/WKFileUploadPanel.h:
* UIProcess/ios/forms/WKFileUploadPanel.mm:
(-[WKFileUploadPanel _chooseFiles:displayString:iconImage:]):
Change chooseFiles to take a Vector<String> instead of an API::Array of URLs.

(-[WKFileUploadPanel presentWithParameters:resultListener:]):
Rename WebKit::WebOpenPanelParameters to API::OpenPanelParameters.

* WebKit2.xcodeproj/project.pbxproj:
Add new file.

* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::runOpenPanel):
Pass the security origin of the frame along.

Tools:

Have MiniBrowser implement the new delegate method.

* MiniBrowser/mac/WK2BrowserWindowController.m:
(-[WK2BrowserWindowController webView:runOpenPanelWithParameters:initiatedByFrame:completionHandler:]):

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

32 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/API/Cocoa/WebKit.h
Source/WebKit2/Shared/Cocoa/APIObject.mm
Source/WebKit2/UIProcess/API/APIOpenPanelParameters.cpp [moved from Source/WebKit2/Shared/WebOpenPanelParameters.cpp with 77% similarity]
Source/WebKit2/UIProcess/API/APIOpenPanelParameters.h [moved from Source/WebKit2/Shared/WebOpenPanelParameters.h with 78% similarity]
Source/WebKit2/UIProcess/API/APIUIClient.h
Source/WebKit2/UIProcess/API/C/WKAPICast.h
Source/WebKit2/UIProcess/API/C/WKOpenPanelParametersRef.cpp
Source/WebKit2/UIProcess/API/C/WKOpenPanelResultListener.cpp
Source/WebKit2/UIProcess/API/C/WKPage.cpp
Source/WebKit2/UIProcess/API/Cocoa/WKOpenPanelParameters.h [new file with mode: 0644]
Source/WebKit2/UIProcess/API/Cocoa/WKOpenPanelParameters.mm [new file with mode: 0644]
Source/WebKit2/UIProcess/API/Cocoa/WKOpenPanelParametersInternal.h [new file with mode: 0644]
Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegate.h
Source/WebKit2/UIProcess/Cocoa/UIDelegate.h
Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm
Source/WebKit2/UIProcess/PageClient.h
Source/WebKit2/UIProcess/WebOpenPanelResultListenerProxy.cpp
Source/WebKit2/UIProcess/WebOpenPanelResultListenerProxy.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPageProxy.messages.in
Source/WebKit2/UIProcess/ios/PageClientImplIOS.h
Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm
Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h
Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit2/UIProcess/ios/forms/WKFileUploadPanel.h
Source/WebKit2/UIProcess/ios/forms/WKFileUploadPanel.mm
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
Tools/ChangeLog
Tools/MiniBrowser/mac/WK2BrowserWindowController.m

index 7d3d4e8..d0c0826 100644 (file)
@@ -1,3 +1,100 @@
+2016-04-14  Anders Carlsson  <andersca@apple.com>
+
+        [Mac] Add API for open panel handling to WKWebView
+        https://bugs.webkit.org/show_bug.cgi?id=137759
+        rdar://problem/23278623
+
+        Reviewed by Tim Horton.
+
+        Based on a patch by Brian Michel.
+
+        * Shared/API/Cocoa/WebKit.h:
+        Import WKOpenPanelParameters.h.
+
+        * Shared/Cocoa/APIObject.mm:
+        (API::Object::newObject):
+        Create a WKOpenPanelParameters for Type::OpenPanelParameters.
+
+        * UIProcess/API/APIOpenPanelParameters.cpp: Renamed from Source/WebKit2/Shared/WebOpenPanelParameters.cpp.
+        * UIProcess/API/APIOpenPanelParameters.h: Renamed from Source/WebKit2/Shared/WebOpenPanelParameters.h.
+        Rename WebKit::WebOpenPanelParameters to API::OpenPanelParameters.
+
+        * UIProcess/API/APIUIClient.h:
+        (API::UIClient::runOpenPanel):
+        Change this to take a SecurityOriginData.
+
+        * UIProcess/API/C/WKAPICast.h:
+        * UIProcess/API/C/WKOpenPanelParametersRef.cpp:
+        (WKOpenPanelParametersGetTypeID):
+        Rename WebKit::WebOpenPanelParameters to API::OpenPanelParameters.
+
+        * UIProcess/API/C/WKOpenPanelResultListener.cpp:
+        (filePathsFromFileURLs):
+        (WKOpenPanelResultListenerChooseFiles):
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageSetPageUIClient):
+        Change chooseFiles to take a Vector<String> instead of an API::Array of URLs.
+
+        * UIProcess/API/Cocoa/WKOpenPanelParameters.h: Added.
+        * UIProcess/API/Cocoa/WKOpenPanelParameters.mm: Added.
+        (-[WKOpenPanelParameters allowsMultipleSelection]):
+        (-[WKOpenPanelParameters _apiObject]):
+        * UIProcess/API/Cocoa/WKOpenPanelParametersInternal.h:
+        Add a WKOpenPanelParameters class which contains information about a file upload control.
+
+        * UIProcess/API/Cocoa/WKUIDelegate.h:
+        Add new delegate method.
+
+        * UIProcess/Cocoa/UIDelegate.h:
+        * UIProcess/Cocoa/UIDelegate.mm:
+        (WebKit::UIDelegate::setDelegate):
+        Record whether the UI delegate implements the new delegate method.
+
+        (WebKit::UIDelegate::UIClient::runOpenPanel):
+        Invoke the new delegate method.
+
+        * UIProcess/PageClient.h:
+        (WebKit::PageClient::handleRunOpenPanel):
+        Rename WebKit::WebOpenPanelParameters to API::OpenPanelParameters.
+
+        * UIProcess/WebOpenPanelResultListenerProxy.cpp:
+        (WebKit::WebOpenPanelResultListenerProxy::chooseFiles):
+        * UIProcess/WebOpenPanelResultListenerProxy.h:
+        Change chooseFiles to take a Vector<String> instead of an API::Array of URLs.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::runOpenPanel):
+        * UIProcess/WebPageProxy.h:
+        Change this to take a SecurityOriginData.
+
+        * UIProcess/WebPageProxy.messages.in:
+        Change RunOpenPanel to take a SecurityOriginData.
+
+        * UIProcess/ios/PageClientImplIOS.h:
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::handleRunOpenPanel):
+        Rename WebKit::WebOpenPanelParameters to API::OpenPanelParameters.
+
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _showRunOpenPanel:resultListener:]):
+        Change chooseFiles to take a Vector<String> instead of an API::Array of URLs.
+
+        * UIProcess/ios/forms/WKFileUploadPanel.h:
+        * UIProcess/ios/forms/WKFileUploadPanel.mm:
+        (-[WKFileUploadPanel _chooseFiles:displayString:iconImage:]):
+        Change chooseFiles to take a Vector<String> instead of an API::Array of URLs.
+
+        (-[WKFileUploadPanel presentWithParameters:resultListener:]):
+        Rename WebKit::WebOpenPanelParameters to API::OpenPanelParameters.
+
+        * WebKit2.xcodeproj/project.pbxproj:
+        Add new file.
+
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::runOpenPanel):
+        Pass the security origin of the frame along.
+
 2016-04-14  Jiewen Tan  <jiewen_tan@apple.com>
 
         Unreviewed, rolling out r199554.
index db38a30..e63ff93 100644 (file)
@@ -33,6 +33,7 @@
 #import <WebKit/WKNavigationAction.h>
 #import <WebKit/WKNavigationDelegate.h>
 #import <WebKit/WKNavigationResponse.h>
+#import <WebKit/WKOpenPanelParameters.h>
 #import <WebKit/WKPreferences.h>
 #import <WebKit/WKPreviewActionItem.h>
 #import <WebKit/WKPreviewActionItemIdentifiers.h>
index b2f6a64..157189e 100644 (file)
@@ -46,6 +46,7 @@
 #import "WKNavigationDataInternal.h"
 #import "WKNavigationInternal.h"
 #import "WKNavigationResponseInternal.h"
+#import "WKOpenPanelParametersInternal.h"
 #import "WKPreferencesInternal.h"
 #import "WKProcessPoolInternal.h"
 #import "WKSecurityOriginInternal.h"
@@ -181,6 +182,10 @@ void* Object::newObject(size_t size, Type type)
         wrapper = [WKNavigationResponse alloc];
         break;
 
+    case Type::OpenPanelParameters:
+        wrapper = [WKOpenPanelParameters alloc];
+        break;
+
     case Type::PageGroup:
         wrapper = [WKBrowsingContextGroup alloc];
         break;
@@ -25,7 +25,7 @@
  */
 
 #include "config.h"
-#include "WebOpenPanelParameters.h"
+#include "APIOpenPanelParameters.h"
 
 #include "APIArray.h"
 #include "APIString.h"
 
 using namespace WebCore;
 
-namespace WebKit {
+namespace API {
 
-PassRefPtr<WebOpenPanelParameters> WebOpenPanelParameters::create(const FileChooserSettings& settings)
+Ref<OpenPanelParameters> OpenPanelParameters::create(const FileChooserSettings& settings)
 {
-    return adoptRef(new WebOpenPanelParameters(settings));
+    return adoptRef(*new OpenPanelParameters(settings));
 }
 
-WebOpenPanelParameters::WebOpenPanelParameters(const FileChooserSettings& settings)
+OpenPanelParameters::OpenPanelParameters(const FileChooserSettings& settings)
     : m_settings(settings)
 {
 }
 
-WebOpenPanelParameters::~WebOpenPanelParameters()
+OpenPanelParameters::~OpenPanelParameters()
 {
 }
 
-Ref<API::Array> WebOpenPanelParameters::acceptMIMETypes() const
+Ref<API::Array> OpenPanelParameters::acceptMIMETypes() const
 {
     return API::Array::createStringArray(m_settings.acceptMIMETypes);
 }
 
 #if ENABLE(MEDIA_CAPTURE)
-bool WebOpenPanelParameters::capture() const
+bool OpenPanelParameters::capture() const
 {
     return m_settings.capture;
 }
 #endif
 
-Ref<API::Array> WebOpenPanelParameters::selectedFileNames() const
+Ref<API::Array> OpenPanelParameters::selectedFileNames() const
 {
     return API::Array::createStringArray(m_settings.selectedFiles);
 }
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef WebOpenPanelParameters_h
-#define WebOpenPanelParameters_h
+#pragma once
 
 #include "APIObject.h"
 #include <WebCore/FileChooser.h>
-#include <wtf/Vector.h>
-#include <wtf/text/WTFString.h>
 
 namespace API {
-class Array;
-}
 
-namespace WebKit {
+class Array;
 
-class WebOpenPanelParameters : public API::ObjectImpl<API::Object::Type::OpenPanelParameters> {
+class OpenPanelParameters : public API::ObjectImpl<API::Object::Type::OpenPanelParameters> {
 public:
-    static PassRefPtr<WebOpenPanelParameters> create(const WebCore::FileChooserSettings&);
-    ~WebOpenPanelParameters();
+    static Ref<OpenPanelParameters> create(const WebCore::FileChooserSettings&);
+    ~OpenPanelParameters();
 
     bool allowMultipleFiles() const { return m_settings.allowsMultipleFiles; }
     Ref<API::Array> acceptMIMETypes() const;
@@ -51,11 +46,9 @@ public:
 #endif
 
 private:
-    explicit WebOpenPanelParameters(const WebCore::FileChooserSettings&);
+    explicit OpenPanelParameters(const WebCore::FileChooserSettings&);
 
     WebCore::FileChooserSettings m_settings;
 };
 
-} // namespace WebKit
-
-#endif // WebOpenPanelParameters_h
+} // namespace API
index 0a9699a..6a8facd 100644 (file)
@@ -55,7 +55,6 @@ class UserMediaPermissionCheckProxy;
 class UserMediaPermissionRequestProxy;
 class WebColorPickerResultListenerProxy;
 class WebFrameProxy;
-class WebOpenPanelParameters;
 class WebOpenPanelResultListenerProxy;
 class WebPageProxy;
 struct NavigationActionData;
@@ -70,6 +69,7 @@ namespace API {
 class Data;
 class Dictionary;
 class Object;
+class OpenPanelParameters;
 class SecurityOrigin;
 
 class UIClient {
@@ -130,7 +130,7 @@ public:
         completionHandler(currentQuota);
     }
 
-    virtual bool runOpenPanel(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, WebKit::WebOpenPanelParameters*, WebKit::WebOpenPanelResultListenerProxy*) { return false; }
+    virtual bool runOpenPanel(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, const WebCore::SecurityOriginData&, OpenPanelParameters*, WebKit::WebOpenPanelResultListenerProxy*) { return false; }
     virtual bool decidePolicyForGeolocationPermissionRequest(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, SecurityOrigin*, WebKit::GeolocationPermissionRequestProxy*) { return false; }
     virtual bool decidePolicyForUserMediaPermissionRequest(WebKit::WebPageProxy&, WebKit::WebFrameProxy&, SecurityOrigin&, SecurityOrigin&, WebKit::UserMediaPermissionRequestProxy&) { return false; }
     virtual bool checkUserMediaPermissionForOrigin(WebKit::WebPageProxy&, WebKit::WebFrameProxy&, SecurityOrigin&, SecurityOrigin&, WebKit::UserMediaPermissionCheckProxy&) { return false; }
index ad58d69..787e992 100644 (file)
@@ -58,6 +58,7 @@ class Navigation;
 class NavigationAction;
 class NavigationData;
 class NavigationResponse;
+class OpenPanelParameters;
 class PageConfiguration;
 class ProcessPoolConfiguration;
 class SessionState;
@@ -97,7 +98,6 @@ class WebMediaSessionMetadata;
 class WebNotification;
 class WebNotificationManagerProxy;
 class WebNotificationProvider;
-class WebOpenPanelParameters;
 class WebOpenPanelResultListenerProxy;
 class WebPageGroup;
 class WebPageProxy;
@@ -146,7 +146,7 @@ WK_ADD_API_MAPPING(WKNotificationManagerRef, WebNotificationManagerProxy)
 WK_ADD_API_MAPPING(WKNotificationPermissionRequestRef, NotificationPermissionRequest)
 WK_ADD_API_MAPPING(WKNotificationProviderRef, WebNotificationProvider)
 WK_ADD_API_MAPPING(WKNotificationRef, WebNotification)
-WK_ADD_API_MAPPING(WKOpenPanelParametersRef, WebOpenPanelParameters)
+WK_ADD_API_MAPPING(WKOpenPanelParametersRef, API::OpenPanelParameters)
 WK_ADD_API_MAPPING(WKOpenPanelResultListenerRef, WebOpenPanelResultListenerProxy)
 WK_ADD_API_MAPPING(WKPageGroupRef, WebPageGroup)
 WK_ADD_API_MAPPING(WKPageConfigurationRef, API::PageConfiguration)
index f7ba08b..9ea3f60 100644 (file)
 #include "WKOpenPanelParametersRef.h"
 
 #include "APIArray.h"
+#include "APIOpenPanelParameters.h"
 #include "WKAPICast.h"
-#include "WebOpenPanelParameters.h"
 
 using namespace WebKit;
 
 WKTypeID WKOpenPanelParametersGetTypeID()
 {
-    return toAPI(WebOpenPanelParameters::APIType);
+    return toAPI(API::OpenPanelParameters::APIType);
 }
 
 bool WKOpenPanelParametersGetAllowsMultipleFiles(WKOpenPanelParametersRef parametersRef)
index 8c79318..b5c48af 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "WKAPICast.h"
 #include "WebOpenPanelResultListenerProxy.h"
+#include <WebCore/URL.h>
 
 using namespace WebKit;
 
@@ -36,9 +37,25 @@ WKTypeID WKOpenPanelResultListenerGetTypeID()
     return toAPI(WebOpenPanelResultListenerProxy::APIType);
 }
 
+static Vector<String> filePathsFromFileURLs(const API::Array& fileURLs)
+{
+    Vector<String> filePaths;
+
+    size_t size = fileURLs.size();
+    filePaths.reserveInitialCapacity(size);
+
+    for (size_t i = 0; i < size; ++i) {
+        API::URL* apiURL = fileURLs.at<API::URL>(i);
+        if (apiURL)
+            filePaths.uncheckedAppend(WebCore::URL(WebCore::URL(), apiURL->string()).fileSystemPath());
+    }
+
+    return filePaths;
+}
+
 void WKOpenPanelResultListenerChooseFiles(WKOpenPanelResultListenerRef listenerRef, WKArrayRef fileURLsRef)
 {
-    toImpl(listenerRef)->chooseFiles(toImpl(fileURLsRef));
+    toImpl(listenerRef)->chooseFiles(filePathsFromFileURLs(*toImpl(fileURLsRef)));
 }
 
 void WKOpenPanelResultListenerCancel(WKOpenPanelResultListenerRef listenerRef)
index a2aafb3..8e3033e 100644 (file)
@@ -40,6 +40,7 @@
 #include "APINavigationAction.h"
 #include "APINavigationClient.h"
 #include "APINavigationResponse.h"
+#include "APIOpenPanelParameters.h"
 #include "APIPageConfiguration.h"
 #include "APIPolicyClient.h"
 #include "APISessionState.h"
@@ -61,7 +62,6 @@
 #include "WebFormClient.h"
 #include "WebImage.h"
 #include "WebInspectorProxy.h"
-#include "WebOpenPanelParameters.h"
 #include "WebOpenPanelResultListenerProxy.h"
 #include "WebPageGroup.h"
 #include "WebPageMessages.h"
@@ -2053,7 +2053,7 @@ void WKPageSetPageUIClient(WKPageRef pageRef, const WKPageUIClientBase* wkClient
             completionHandler(m_client.exceededDatabaseQuota(toAPI(page), toAPI(frame), toAPI(origin), toAPI(databaseName.impl()), toAPI(databaseDisplayName.impl()), currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage, m_client.base.clientInfo));
         }
 
-        bool runOpenPanel(WebPageProxy* page, WebFrameProxy* frame, WebOpenPanelParameters* parameters, WebOpenPanelResultListenerProxy* listener) override
+        bool runOpenPanel(WebPageProxy* page, WebFrameProxy* frame, const WebCore::SecurityOriginData&, API::OpenPanelParameters* parameters, WebOpenPanelResultListenerProxy* listener) override
         {
             if (!m_client.runOpenPanel)
                 return false;
diff --git a/Source/WebKit2/UIProcess/API/Cocoa/WKOpenPanelParameters.h b/Source/WebKit2/UIProcess/API/Cocoa/WKOpenPanelParameters.h
new file mode 100644 (file)
index 0000000..75faedc
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2016 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>
+
+#if WK_API_ENABLED
+
+#import <Foundation/Foundation.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+/*! WKOpenPanelParameters contains parameters that a file upload control has specified.
+ */
+WK_CLASS_AVAILABLE(WK_MAC_TBA, NA)
+@interface WKOpenPanelParameters : NSObject
+
+/*! @abstract Whether the file upload control supports multiple files.
+ */
+@property (nonatomic, readonly) BOOL allowsMultipleSelection;
+
+@end
+
+NS_ASSUME_NONNULL_END
+
+#endif
diff --git a/Source/WebKit2/UIProcess/API/Cocoa/WKOpenPanelParameters.mm b/Source/WebKit2/UIProcess/API/Cocoa/WKOpenPanelParameters.mm
new file mode 100644 (file)
index 0000000..f77cc6e
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2016 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 "WKOpenPanelParametersInternal.h"
+
+#if WK_API_ENABLED
+
+@implementation WKOpenPanelParameters
+
+- (BOOL)allowsMultipleSelection
+{
+    return _openPanelParameters->allowMultipleFiles();
+}
+
+#pragma mark WKObject protocol implementation
+
+- (API::Object&)_apiObject
+{
+    return *_openPanelParameters;
+}
+
+@end
+
+#endif
diff --git a/Source/WebKit2/UIProcess/API/Cocoa/WKOpenPanelParametersInternal.h b/Source/WebKit2/UIProcess/API/Cocoa/WKOpenPanelParametersInternal.h
new file mode 100644 (file)
index 0000000..0292eeb
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2016 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 "WKOpenPanelParameters.h"
+
+#if WK_API_ENABLED
+
+#import "APIOpenPanelParameters.h"
+#import "WKObject.h"
+
+namespace API {
+
+inline WKOpenPanelParameters *wrapper(OpenPanelParameters& openPanelParameters)
+{
+    ASSERT([openPanelParameters.wrapper() isKindOfClass:[WKOpenPanelParameters class]]);
+
+    return (WKOpenPanelParameters *)openPanelParameters.wrapper();
+}
+
+}
+
+@interface WKOpenPanelParameters () <WKObject> {
+@package
+    API::ObjectStorage<API::OpenPanelParameters> _openPanelParameters;
+}
+@end
+
+#endif
index d9d8621..9456294 100644 (file)
@@ -34,6 +34,7 @@ NS_ASSUME_NONNULL_BEGIN
 
 @class WKFrameInfo;
 @class WKNavigationAction;
+@class WKOpenPanelParameters;
 @class WKPreviewElementInfo;
 @class WKWebViewConfiguration;
 @class WKWindowFeatures;
@@ -143,7 +144,7 @@ NS_ASSUME_NONNULL_BEGIN
  Returning nil will result in WebKit's default preview behavior. webView:commitPreviewingViewController: will only be invoked
  if a non-nil view controller was returned.
  */
-- (nullable UIViewController *)webView:(WKWebView *)webView previewingViewControllerForElement:(WKPreviewElementInfo *)elementInfo defaultActions:(NSArray <id <WKPreviewActionItem>> *)previewActions WK_AVAILABLE(NA, WK_IOS_TBA);
+- (nullable UIViewController *)webView:(WKWebView *)webView previewingViewControllerForElement:(WKPreviewElementInfo *)elementInfo defaultActions:(NSArray<id <WKPreviewActionItem>> *)previewActions WK_AVAILABLE(NA, WK_IOS_TBA);
 
 /*! @abstract Allows your app to pop to the view controller it created.
  @param webView The web view invoking the delegate method.
@@ -153,6 +154,20 @@ NS_ASSUME_NONNULL_BEGIN
 
 #endif // TARGET_OS_IPHONE
 
+#if !TARGET_OS_IPHONE
+
+/*! @abstract Displays a file upload panel.
+ @param webView The web view invoking the delegate method.
+ @param parameters Parameters describing the file upload control.
+ @param frame Information about the frame whose file upload control initiated this call.
+ @param completionHandler The completion handler to call after open panel has been dismissed. Pass the selected URLs if the user chose OK, otherwise nil.
+
+ If you do not implement this method, the web view will behave as if the user selected the Cancel button.
+ */
+- (void)webView:(WKWebView *)webView runOpenPanelWithParameters:(WKOpenPanelParameters *)parameters initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(WK_ARRAY(NSURL *) * WK_NULLABLE_SPECIFIER URLs))completionHandler WK_AVAILABLE(WK_MAC_TBA, NA);
+
+#endif
+
 @end
 
 NS_ASSUME_NONNULL_END
index 20df12b..083c1f9 100644 (file)
@@ -86,6 +86,9 @@ private:
         void runJavaScriptPrompt(WebKit::WebPageProxy*, const WTF::String&, const WTF::String&, WebKit::WebFrameProxy*, const WebCore::SecurityOriginData&, std::function<void (const WTF::String&)> completionHandler) override;
         void exceededDatabaseQuota(WebPageProxy*, WebFrameProxy*, API::SecurityOrigin*, const WTF::String& databaseName, const WTF::String& displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentUsage, unsigned long long expectedUsage, std::function<void (unsigned long long)>) override;
         void reachedApplicationCacheOriginQuota(WebPageProxy*, const WebCore::SecurityOrigin&, uint64_t currentQuota, uint64_t totalBytesNeeded, std::function<void (unsigned long long)> completionHandler) override;
+#if PLATFORM(MAC)
+        bool runOpenPanel(WebPageProxy*, WebFrameProxy*, const WebCore::SecurityOriginData&, API::OpenPanelParameters*, WebOpenPanelResultListenerProxy*) override;
+#endif
         void printFrame(WebKit::WebPageProxy*, WebKit::WebFrameProxy*) override;
 #if PLATFORM(IOS)
 #if HAVE(APP_LINKS)
@@ -108,6 +111,9 @@ private:
         bool webViewRunJavaScriptAlertPanelWithMessageInitiatedByFrameCompletionHandler : 1;
         bool webViewRunJavaScriptConfirmPanelWithMessageInitiatedByFrameCompletionHandler : 1;
         bool webViewRunJavaScriptTextInputPanelWithPromptDefaultTextInitiatedByFrameCompletionHandler : 1;
+#if PLATFORM(MAC)
+        bool webViewRunOpenPanelWithParametersInitiatedByFrameCompletionHandler : 1;
+#endif
         bool webViewDecideDatabaseQuotaForSecurityOriginCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler : 1;
         bool webViewDecideWebApplicationCacheQuotaForSecurityOriginCurrentQuotaTotalBytesNeeded : 1;
         bool webViewPrintFrame : 1;
index 3ff5031..9c6b6bc 100644 (file)
 #import "NavigationActionData.h"
 #import "WKFrameInfoInternal.h"
 #import "WKNavigationActionInternal.h"
+#import "WKOpenPanelParametersInternal.h"
 #import "WKSecurityOriginInternal.h"
 #import "WKWebViewConfigurationInternal.h"
 #import "WKWebViewInternal.h"
 #import "WKWindowFeaturesInternal.h"
 #import "WKUIDelegatePrivate.h"
+#import "WebOpenPanelResultListenerProxy.h"
 #import "_WKContextMenuElementInfo.h"
 #import "_WKFrameHandleInternal.h"
 #import <WebCore/SecurityOriginData.h>
@@ -78,6 +80,11 @@ void UIDelegate::setDelegate(id <WKUIDelegate> delegate)
     m_delegateMethods.webViewRunJavaScriptAlertPanelWithMessageInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:)];
     m_delegateMethods.webViewRunJavaScriptConfirmPanelWithMessageInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(webView:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:completionHandler:)];
     m_delegateMethods.webViewRunJavaScriptTextInputPanelWithPromptDefaultTextInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(webView:runJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame:completionHandler:)];
+
+#if PLATFORM(MAC)
+    m_delegateMethods.webViewRunOpenPanelWithParametersInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(webView:runOpenPanelWithParameters:initiatedByFrame:completionHandler:)];
+#endif
+
     m_delegateMethods.webViewDecideDatabaseQuotaForSecurityOriginCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler = [delegate respondsToSelector:@selector(_webView:decideDatabaseQuotaForSecurityOrigin:currentQuota:currentOriginUsage:currentDatabaseUsage:expectedUsage:decisionHandler:)];
     m_delegateMethods.webViewDecideWebApplicationCacheQuotaForSecurityOriginCurrentQuotaTotalBytesNeeded = [delegate respondsToSelector:@selector(_webView:decideWebApplicationCacheQuotaForSecurityOrigin:currentQuota:totalBytesNeeded:decisionHandler:)];
     m_delegateMethods.webViewPrintFrame = [delegate respondsToSelector:@selector(_webView:printFrame:)];
@@ -250,6 +257,40 @@ void UIDelegate::UIClient::exceededDatabaseQuota(WebPageProxy*, WebFrameProxy*,
     }];
 }
 
+#if PLATFORM(MAC)
+bool UIDelegate::UIClient::runOpenPanel(WebPageProxy*, WebFrameProxy* webFrameProxy, const WebCore::SecurityOriginData& securityOriginData, API::OpenPanelParameters* openPanelParameters, WebOpenPanelResultListenerProxy* listener)
+{
+    if (!m_uiDelegate.m_delegateMethods.webViewRunOpenPanelWithParametersInitiatedByFrameCompletionHandler)
+        return false;
+
+    auto delegate = m_uiDelegate.m_delegate.get();
+    if (!delegate)
+        return false;
+
+    auto frame = API::FrameInfo::create(*webFrameProxy, securityOriginData.securityOrigin());
+    RefPtr<WebOpenPanelResultListenerProxy> resultListener = listener;
+
+    RefPtr<CompletionHandlerCallChecker> checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(webView:runOpenPanelWithParameters:initiatedByFrame:completionHandler:));
+
+    [delegate webView:m_uiDelegate.m_webView runOpenPanelWithParameters:wrapper(*openPanelParameters) initiatedByFrame:wrapper(frame) completionHandler:[checker, resultListener](NSArray<NSURL *> *URLs) {
+        checker->didCallCompletionHandler();
+
+        if (!URLs) {
+            resultListener->cancel();
+            return;
+        }
+
+        Vector<String> filenames;
+        for (NSURL *url in URLs)
+            filenames.append(url.fileSystemRepresentation);
+
+        resultListener->chooseFiles(filenames);
+    }];
+
+    return true;
+}
+#endif
+
 void UIDelegate::UIClient::reachedApplicationCacheOriginQuota(WebPageProxy*, const WebCore::SecurityOrigin& securityOrigin, uint64_t currentQuota, uint64_t totalBytesNeeded, std::function<void (unsigned long long)> completionHandler)
 {
     if (!m_uiDelegate.m_delegateMethods.webViewDecideWebApplicationCacheQuotaForSecurityOriginCurrentQuotaTotalBytesNeeded) {
index 21239db..8b21d7f 100644 (file)
@@ -151,7 +151,7 @@ public:
 
     virtual void handleDownloadRequest(DownloadProxy*) = 0;
 
-    virtual bool handleRunOpenPanel(WebPageProxy*, WebFrameProxy*, WebOpenPanelParameters*, WebOpenPanelResultListenerProxy*) { return false; }
+    virtual bool handleRunOpenPanel(WebPageProxy*, WebFrameProxy*, API::OpenPanelParameters*, WebOpenPanelResultListenerProxy*) { return false; }
 
     virtual void didChangeContentSize(const WebCore::IntSize&) = 0;
 
index a377e4a..d503e6a 100644 (file)
@@ -45,38 +45,22 @@ WebOpenPanelResultListenerProxy::~WebOpenPanelResultListenerProxy()
 {
 }
 
-static Vector<String> filePathsFromFileURLs(const API::Array& fileURLs)
-{
-    Vector<String> filePaths;
-
-    size_t size = fileURLs.size();
-    filePaths.reserveInitialCapacity(size);
-
-    for (size_t i = 0; i < size; ++i) {
-        API::URL* apiURL = fileURLs.at<API::URL>(i);
-        if (apiURL)
-            filePaths.uncheckedAppend(URL(URL(), apiURL->string()).fileSystemPath());
-    }
-
-    return filePaths;
-}
-
 #if PLATFORM(IOS)
-void WebOpenPanelResultListenerProxy::chooseFiles(API::Array* fileURLsArray, API::String* displayString, const API::Data* iconImageData)
+void WebOpenPanelResultListenerProxy::chooseFiles(const Vector<WTF::String>& filenames, const String& displayString, const API::Data* iconImageData)
 {
     if (!m_page)
         return;
 
-    m_page->didChooseFilesForOpenPanelWithDisplayStringAndIcon(filePathsFromFileURLs(*fileURLsArray), displayString ? displayString->string() : String(), iconImageData);
+    m_page->didChooseFilesForOpenPanelWithDisplayStringAndIcon(filenames, displayString, iconImageData);
 }
 #endif
 
-void WebOpenPanelResultListenerProxy::chooseFiles(API::Array* fileURLsArray)
+void WebOpenPanelResultListenerProxy::chooseFiles(const Vector<String>& filenames)
 {
     if (!m_page)
         return;
 
-    m_page->didChooseFilesForOpenPanel(filePathsFromFileURLs(*fileURLsArray));
+    m_page->didChooseFilesForOpenPanel(filenames);
 }
 
 void WebOpenPanelResultListenerProxy::cancel()
index ae6eaf7..ef50023 100644 (file)
 #define WebOpenPanelResultListenerProxy_h
 
 #include "APIObject.h"
+#include <wtf/Forward.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
+#include <wtf/Vector.h>
 
 namespace API {
 class Array;
@@ -50,9 +52,9 @@ public:
     virtual ~WebOpenPanelResultListenerProxy();
 
 #if PLATFORM(IOS)
-    void chooseFiles(API::Array*, API::String* displayString, const API::Data* iconImageData);
+    void chooseFiles(const Vector<String>& filenames, const String& displayString, const API::Data* iconImageData);
 #endif
-    void chooseFiles(API::Array*);
+    void chooseFiles(const Vector<String>& filenames);
     void cancel();
 
     void invalidate();
index b9a1ccd..ec01593 100644 (file)
@@ -42,6 +42,7 @@
 #include "APINavigationAction.h"
 #include "APINavigationClient.h"
 #include "APINavigationResponse.h"
+#include "APIOpenPanelParameters.h"
 #include "APIPageConfiguration.h"
 #include "APIPolicyClient.h"
 #include "APISecurityOrigin.h"
@@ -90,7 +91,6 @@
 #include "WebInspectorProxyMessages.h"
 #include "WebNavigationState.h"
 #include "WebNotificationManagerProxy.h"
-#include "WebOpenPanelParameters.h"
 #include "WebOpenPanelResultListenerProxy.h"
 #include "WebPageCreationParameters.h"
 #include "WebPageGroup.h"
@@ -3853,7 +3853,7 @@ void WebPageProxy::pageDidScroll()
     m_uiClient->pageDidScroll(this);
 }
 
-void WebPageProxy::runOpenPanel(uint64_t frameID, const FileChooserSettings& settings)
+void WebPageProxy::runOpenPanel(uint64_t frameID, const SecurityOriginData& frameSecurityOrigin, const FileChooserSettings& settings)
 {
     if (m_openPanelResultListener) {
         m_openPanelResultListener->invalidate();
@@ -3863,14 +3863,15 @@ void WebPageProxy::runOpenPanel(uint64_t frameID, const FileChooserSettings& set
     WebFrameProxy* frame = m_process->webFrame(frameID);
     MESSAGE_CHECK(frame);
 
-    RefPtr<WebOpenPanelParameters> parameters = WebOpenPanelParameters::create(settings);
+    Ref<API::OpenPanelParameters> parameters = API::OpenPanelParameters::create(settings);
     m_openPanelResultListener = WebOpenPanelResultListenerProxy::create(this);
 
     // Since runOpenPanel() can spin a nested run loop we need to turn off the responsiveness timer.
     m_process->responsivenessTimer().stop();
 
-    if (!m_uiClient->runOpenPanel(this, frame, parameters.get(), m_openPanelResultListener.get())) {
-        if (!m_pageClient.handleRunOpenPanel(this, frame, parameters.get(), m_openPanelResultListener.get()))
+
+    if (!m_uiClient->runOpenPanel(this, frame, frameSecurityOrigin, parameters.ptr(), m_openPanelResultListener.get())) {
+        if (!m_pageClient.handleRunOpenPanel(this, frame, parameters.ptr(), m_openPanelResultListener.get()))
             didCancelForOpenPanel();
     }
 }
index 5ba9892..3c9ba37 100644 (file)
@@ -1210,7 +1210,7 @@ private:
     void runBeforeUnloadConfirmPanel(const String& message, uint64_t frameID, RefPtr<Messages::WebPageProxy::RunBeforeUnloadConfirmPanel::DelayedReply>);
     void didChangeViewportProperties(const WebCore::ViewportAttributes&);
     void pageDidScroll();
-    void runOpenPanel(uint64_t frameID, const WebCore::FileChooserSettings&);
+    void runOpenPanel(uint64_t frameID, const WebCore::SecurityOriginData&, const WebCore::FileChooserSettings&);
     void printFrame(uint64_t frameID);
     void exceededDatabaseQuota(uint64_t frameID, const String& originIdentifier, const String& databaseName, const String& displayName, uint64_t currentQuota, uint64_t currentOriginUsage, uint64_t currentDatabaseUsage, uint64_t expectedUsage, PassRefPtr<Messages::WebPageProxy::ExceededDatabaseQuota::DelayedReply>);
     void reachedApplicationCacheOriginQuota(const String& originIdentifier, uint64_t currentQuota, uint64_t totalBytesNeeded, PassRefPtr<Messages::WebPageProxy::ReachedApplicationCacheOriginQuota::DelayedReply>);
index dc51259..ca88d60 100644 (file)
@@ -71,7 +71,7 @@ messages -> WebPageProxy {
 
     RunBeforeUnloadConfirmPanel(String message, uint64_t frameID) -> (bool shouldClose) Delayed
     PageDidScroll()
-    RunOpenPanel(uint64_t frameID, struct WebCore::FileChooserSettings parameters)
+    RunOpenPanel(uint64_t frameID, struct WebCore::SecurityOriginData frameSecurityOrigin, struct WebCore::FileChooserSettings parameters)
     PrintFrame(uint64_t frameID) -> ()
     RunModal()
     NotifyScrollerThumbIsVisibleInRect(WebCore::IntRect scrollerThumb)
index 2de8f1e..907b17d 100644 (file)
@@ -132,7 +132,7 @@ private:
     void didUpdateBlockSelectionWithTouch(uint32_t touch, uint32_t flags, float growThreshold, float shrinkThreshold) override;
     void showPlaybackTargetPicker(bool hasVideo, const WebCore::IntRect& elementRect) override;
 
-    bool handleRunOpenPanel(WebPageProxy*, WebFrameProxy*, WebOpenPanelParameters*, WebOpenPanelResultListenerProxy*) override;
+    bool handleRunOpenPanel(WebPageProxy*, WebFrameProxy*, API::OpenPanelParameters*, WebOpenPanelResultListenerProxy*) override;
     void disableDoubleTapGesturesDuringTapIfNecessary(uint64_t requestID) override;
     double minimumZoomScale() const override;
     WebCore::FloatRect documentRect() const override;
index a0f227f..6cf7f11 100644 (file)
@@ -560,7 +560,7 @@ void PageClientImpl::showPlaybackTargetPicker(bool hasVideo, const IntRect& elem
     [m_contentView _showPlaybackTargetPicker:hasVideo fromRect:elementRect];
 }
 
-bool PageClientImpl::handleRunOpenPanel(WebPageProxy*, WebFrameProxy*, WebOpenPanelParameters* parameters, WebOpenPanelResultListenerProxy* listener)
+bool PageClientImpl::handleRunOpenPanel(WebPageProxy*, WebFrameProxy*, API::OpenPanelParameters* parameters, WebOpenPanelResultListenerProxy* listener)
 {
     [m_contentView _showRunOpenPanel:parameters resultListener:listener];
     return true;
index 74a6a1a..be0121c 100644 (file)
 #import <wtf/Vector.h>
 #import <wtf/text/WTFString.h>
 
+namespace API {
+class OpenPanelParameters;
+}
+
 namespace WebCore {
 class Color;
 class FloatQuad;
@@ -53,7 +57,6 @@ class IntSize;
 namespace WebKit {
 class NativeWebTouchEvent;
 class SmartMagnificationController;
-class WebOpenPanelParameters;
 class WebOpenPanelResultListenerProxy;
 class WebPageProxy;
 }
@@ -209,7 +212,7 @@ struct WKAutoCorrectionData {
 - (void)_overflowScrollingDidEnd;
 - (void)_didUpdateBlockSelectionWithTouch:(WebKit::SelectionTouch)touch withFlags:(WebKit::SelectionFlags)flags growThreshold:(CGFloat)growThreshold shrinkThreshold:(CGFloat)shrinkThreshold;
 - (void)_showPlaybackTargetPicker:(BOOL)hasVideo fromRect:(const WebCore::IntRect&)elementRect;
-- (void)_showRunOpenPanel:(WebKit::WebOpenPanelParameters*)parameters resultListener:(WebKit::WebOpenPanelResultListenerProxy*)listener;
+- (void)_showRunOpenPanel:(API::OpenPanelParameters*)parameters resultListener:(WebKit::WebOpenPanelResultListenerProxy*)listener;
 - (void)accessoryDone;
 - (void)_didHandleKeyEvent:(WebIOSEvent *)event eventWasHandled:(BOOL)eventWasHandled;
 - (Vector<WebKit::OptionItem>&) assistedNodeSelectOptions;
index 6f42620..d3d1f9d 100644 (file)
@@ -3661,7 +3661,7 @@ static bool isAssistableInputType(InputType type)
     [_airPlayRoutePicker show:hasVideo fromRect:elementRect];
 }
 
-- (void)_showRunOpenPanel:(WebOpenPanelParameters*)parameters resultListener:(WebOpenPanelResultListenerProxy*)listener
+- (void)_showRunOpenPanel:(API::OpenPanelParameters*)parameters resultListener:(WebOpenPanelResultListenerProxy*)listener
 {
     ASSERT(!_fileUploadPanel);
     if (_fileUploadPanel)
index 69d7497..77ac20a 100644 (file)
 @class WKContentView;
 @protocol WKFileUploadPanelDelegate;
 
+namespace API {
+class OpenPanelParameters;
+}
+
 namespace WebKit {
-class WebOpenPanelParameters;
 class WebOpenPanelResultListenerProxy;
 }
 
 @interface WKFileUploadPanel : UIViewController
 @property (nonatomic, assign) id <WKFileUploadPanelDelegate> delegate;
 - (instancetype)initWithView:(WKContentView *)view;
-- (void)presentWithParameters:(WebKit::WebOpenPanelParameters*)parameters resultListener:(WebKit::WebOpenPanelResultListenerProxy*)listener;
+- (void)presentWithParameters:(API::OpenPanelParameters*)parameters resultListener:(WebKit::WebOpenPanelResultListenerProxy*)listener;
 - (void)dismiss;
 @end
 
index 72d2b98..c1524d5 100644 (file)
 
 #import "APIArray.h"
 #import "APIData.h"
+#import "APIOpenPanelParameters.h"
 #import "APIString.h"
 #import "UIKitSPI.h"
 #import "WKContentViewInteraction.h"
 #import "WKData.h"
 #import "WKStringCF.h"
 #import "WKURLCF.h"
-#import "WebOpenPanelParameters.h"
 #import "WebOpenPanelResultListenerProxy.h"
 #import "WebPageProxy.h"
 #import <AVFoundation/AVFoundation.h>
@@ -333,24 +333,21 @@ static UIImage* iconForFile(NSURL *file)
         return;
     }
 
-    Vector<RefPtr<API::Object>> urls;
-    urls.reserveInitialCapacity(count);
+    Vector<String> filenames;
+    filenames.reserveInitialCapacity(count);
     for (NSURL *fileURL in fileURLs)
-        urls.uncheckedAppend(adoptRef(toImpl(WKURLCreateWithCFURL((CFURLRef)fileURL))));
-    Ref<API::Array> fileURLsRef = API::Array::create(WTFMove(urls));
+        filenames.uncheckedAppend(fileURL.fileSystemRepresentation);
 
     NSData *jpeg = UIImageJPEGRepresentation(iconImage, 1.0);
     RefPtr<API::Data> iconImageDataRef = adoptRef(toImpl(WKDataCreate(reinterpret_cast<const unsigned char*>([jpeg bytes]), [jpeg length])));
 
-    RefPtr<API::String> displayStringRef = adoptRef(toImpl(WKStringCreateWithCFString((CFStringRef)displayString)));
-
-    _listener->chooseFiles(fileURLsRef.ptr(), displayStringRef.get(), iconImageDataRef.get());
+    _listener->chooseFiles(filenames, displayString, iconImageDataRef.get());
     [self _dispatchDidDismiss];
 }
 
 #pragma mark - Present / Dismiss API
 
-- (void)presentWithParameters:(WebKit::WebOpenPanelParameters*)parameters resultListener:(WebKit::WebOpenPanelResultListenerProxy*)listener
+- (void)presentWithParameters:(API::OpenPanelParameters*)parameters resultListener:(WebKit::WebOpenPanelResultListenerProxy*)listener
 {
     ASSERT(!_listener);
 
index a20d509..b652bbc 100644 (file)
                1A6563E41B7A8C50009CF787 /* APIWindowFeatures.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A6563E21B7A8C50009CF787 /* APIWindowFeatures.cpp */; };
                1A6563E51B7A8C50009CF787 /* APIWindowFeatures.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A6563E31B7A8C50009CF787 /* APIWindowFeatures.h */; };
                1A66BF8F18A052ED002071B4 /* WKWebViewInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A66BF8E18A052ED002071B4 /* WKWebViewInternal.h */; };
+               1A67CD2E1CBC513F00BFE3EA /* WKOpenPanelParametersInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A67CD2D1CBC513F00BFE3EA /* WKOpenPanelParametersInternal.h */; };
                1A6F9F9011E13EFC00DB1371 /* CommandLine.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A6F9F8E11E13EFC00DB1371 /* CommandLine.h */; };
                1A6F9FB711E1408500DB1371 /* CommandLinePOSIX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A6F9FB611E1408500DB1371 /* CommandLinePOSIX.cpp */; };
                1A6FA21E1BD0435B00AAA650 /* WKFrameInfoPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A6FA21D1BD0435B00AAA650 /* WKFrameInfoPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
                1AC75380183BE50F0072CB15 /* DataReference.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AC7537E183BE50F0072CB15 /* DataReference.h */; };
                1AC75A1B1B3368270056745B /* HangDetectionDisabler.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AC75A1A1B3368270056745B /* HangDetectionDisabler.h */; };
                1AC75A1E1B33695E0056745B /* HangDetectionDisablerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AC75A1C1B33695E0056745B /* HangDetectionDisablerMac.mm */; };
+               1ACC50F11CBC381D003C7D03 /* WKOpenPanelParameters.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1ACC50EF1CBC381D003C7D03 /* WKOpenPanelParameters.mm */; };
+               1ACC50F21CBC381D003C7D03 /* WKOpenPanelParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ACC50F01CBC381D003C7D03 /* WKOpenPanelParameters.h */; settings = {ATTRIBUTES = (Public, ); }; };
                1ACC87BA1981C341003D1AF4 /* WKNavigationPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ACC87B91981C341003D1AF4 /* WKNavigationPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
                1ACECD2417162DB1001FC9EF /* StorageAreaMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1ACECD2217162DB1001FC9EF /* StorageAreaMap.cpp */; };
                1ACECD2517162DB1001FC9EF /* StorageAreaMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ACECD2317162DB1001FC9EF /* StorageAreaMap.h */; };
                BC857F7E12B82CEE00EDEB2E /* WebOpenPanelResultListenerProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC1DFEA312B31F87005DF730 /* WebOpenPanelResultListenerProxy.cpp */; };
                BC857F8512B82D0B00EDEB2E /* WebOpenPanelResultListener.h in Headers */ = {isa = PBXBuildFile; fileRef = BC857F8312B82D0B00EDEB2E /* WebOpenPanelResultListener.h */; };
                BC857F8612B82D0B00EDEB2E /* WebOpenPanelResultListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC857F8412B82D0B00EDEB2E /* WebOpenPanelResultListener.cpp */; };
-               BC857FB512B830E600EDEB2E /* WebOpenPanelParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = BC857FB312B830E600EDEB2E /* WebOpenPanelParameters.h */; };
-               BC857FB612B830E600EDEB2E /* WebOpenPanelParameters.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC857FB412B830E600EDEB2E /* WebOpenPanelParameters.cpp */; };
+               BC857FB512B830E600EDEB2E /* APIOpenPanelParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = BC857FB312B830E600EDEB2E /* APIOpenPanelParameters.h */; };
+               BC857FB612B830E600EDEB2E /* APIOpenPanelParameters.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC857FB412B830E600EDEB2E /* APIOpenPanelParameters.cpp */; };
                BC857FE612B843D800EDEB2E /* WKOpenPanelParametersRef.h in Headers */ = {isa = PBXBuildFile; fileRef = BC857FE412B843D800EDEB2E /* WKOpenPanelParametersRef.h */; settings = {ATTRIBUTES = (Private, ); }; };
                BC85806212B8505700EDEB2E /* WKOpenPanelResultListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC1DFE8E12B31CA8005DF730 /* WKOpenPanelResultListener.cpp */; };
                BC85806312B8505700EDEB2E /* WKOpenPanelParametersRef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC857FE512B843D800EDEB2E /* WKOpenPanelParametersRef.cpp */; };
                1A6563E21B7A8C50009CF787 /* APIWindowFeatures.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = APIWindowFeatures.cpp; sourceTree = "<group>"; };
                1A6563E31B7A8C50009CF787 /* APIWindowFeatures.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIWindowFeatures.h; sourceTree = "<group>"; };
                1A66BF8E18A052ED002071B4 /* WKWebViewInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebViewInternal.h; sourceTree = "<group>"; };
+               1A67CD2D1CBC513F00BFE3EA /* WKOpenPanelParametersInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKOpenPanelParametersInternal.h; sourceTree = "<group>"; };
                1A6D141F1B0167D500785FF0 /* Info-OSX-10.9-10.10.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Info-OSX-10.9-10.10.plist"; sourceTree = "<group>"; };
                1A6D14211B01681600785FF0 /* PluginService.32-64-10.9-10.10.Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "PluginService.32-64-10.9-10.10.Info.plist"; path = "PluginProcess/EntryPoint/mac/XPCService/PluginService.32-64-10.9-10.10.Info.plist"; sourceTree = SOURCE_ROOT; };
                1A6F9F8E11E13EFC00DB1371 /* CommandLine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommandLine.h; sourceTree = "<group>"; };
                1AC7537E183BE50F0072CB15 /* DataReference.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataReference.h; sourceTree = "<group>"; };
                1AC75A1A1B3368270056745B /* HangDetectionDisabler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HangDetectionDisabler.h; sourceTree = "<group>"; };
                1AC75A1C1B33695E0056745B /* HangDetectionDisablerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HangDetectionDisablerMac.mm; sourceTree = "<group>"; };
+               1ACC50EF1CBC381D003C7D03 /* WKOpenPanelParameters.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKOpenPanelParameters.mm; sourceTree = "<group>"; };
+               1ACC50F01CBC381D003C7D03 /* WKOpenPanelParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKOpenPanelParameters.h; sourceTree = "<group>"; };
                1ACC87B91981C341003D1AF4 /* WKNavigationPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKNavigationPrivate.h; sourceTree = "<group>"; };
                1ACECD2217162DB1001FC9EF /* StorageAreaMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StorageAreaMap.cpp; sourceTree = "<group>"; };
                1ACECD2317162DB1001FC9EF /* StorageAreaMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StorageAreaMap.h; sourceTree = "<group>"; };
                BC857E8512B71EBB00EDEB2E /* WebPageProxyMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebPageProxyMac.mm; sourceTree = "<group>"; };
                BC857F8312B82D0B00EDEB2E /* WebOpenPanelResultListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebOpenPanelResultListener.h; sourceTree = "<group>"; };
                BC857F8412B82D0B00EDEB2E /* WebOpenPanelResultListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebOpenPanelResultListener.cpp; sourceTree = "<group>"; };
-               BC857FB312B830E600EDEB2E /* WebOpenPanelParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebOpenPanelParameters.h; sourceTree = "<group>"; };
-               BC857FB412B830E600EDEB2E /* WebOpenPanelParameters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebOpenPanelParameters.cpp; sourceTree = "<group>"; };
+               BC857FB312B830E600EDEB2E /* APIOpenPanelParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIOpenPanelParameters.h; sourceTree = "<group>"; };
+               BC857FB412B830E600EDEB2E /* APIOpenPanelParameters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = APIOpenPanelParameters.cpp; sourceTree = "<group>"; };
                BC857FE412B843D800EDEB2E /* WKOpenPanelParametersRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKOpenPanelParametersRef.h; sourceTree = "<group>"; };
                BC857FE512B843D800EDEB2E /* WKOpenPanelParametersRef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKOpenPanelParametersRef.cpp; sourceTree = "<group>"; };
                BC8699B2116AADAA002A925B /* WKView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKView.h; sourceTree = "<group>"; };
                                905620E912BC248B000799B6 /* WebMemorySampler.h */,
                                C0337DAF127A28D0008FF4F4 /* WebMouseEvent.cpp */,
                                BCF69F981176CED600471A52 /* WebNavigationDataStore.h */,
-                               BC857FB412B830E600EDEB2E /* WebOpenPanelParameters.cpp */,
-                               BC857FB312B830E600EDEB2E /* WebOpenPanelParameters.h */,
                                C06C6093124C14430001682F /* WebPageCreationParameters.cpp */,
                                C06C6094124C14430001682F /* WebPageCreationParameters.h */,
                                BC7B625112A43C9600D174A4 /* WebPageGroupData.cpp */,
                                1AD60F5C18E20F4C0020C034 /* WKWindowFeatures.h */,
                                1AD60F5B18E20F4C0020C034 /* WKWindowFeatures.mm */,
                                1AD60F5F18E20F740020C034 /* WKWindowFeaturesInternal.h */,
+                               1ACC50EF1CBC381D003C7D03 /* WKOpenPanelParameters.mm */,
+                               1ACC50F01CBC381D003C7D03 /* WKOpenPanelParameters.h */,
+                               1A67CD2D1CBC513F00BFE3EA /* WKOpenPanelParametersInternal.h */,
                        );
                        path = Cocoa;
                        sourceTree = "<group>";
                                BC111B47112F616900337BAB /* mac */,
                                99C81D5B1C20E817005C4C82 /* APIAutomationClient.h */,
                                990D28B31C6526D400986977 /* APIAutomationSessionClient.h */,
+                               BC857FB412B830E600EDEB2E /* APIOpenPanelParameters.cpp */,
+                               BC857FB312B830E600EDEB2E /* APIOpenPanelParameters.h */,
                                076E884D1A13CADF005E90FC /* APIContextMenuClient.h */,
                                83891B621A68B3420030F386 /* APIDiagnosticLoggingClient.h */,
                                1F7D36C018DA513F00D9D659 /* APIDownloadClient.h */,
                                83891B6C1A68C30B0030F386 /* DiagnosticLoggingClient.h in Headers */,
                                A1DF631318E0B7C8003A3E2A /* DownloadClient.h in Headers */,
                                1AB7D4CA1288AAA700CFD08C /* DownloadProxy.h in Headers */,
+                               1ACC50F21CBC381D003C7D03 /* WKOpenPanelParameters.h in Headers */,
                                1AD25E96167AB08100EA9BCD /* DownloadProxyMap.h in Headers */,
                                1AB7D61A1288B9D900CFD08C /* DownloadProxyMessages.h in Headers */,
                                C517388112DF8F4F00EE3F47 /* DragControllerAction.h in Headers */,
                                31BA924E148831260062EDB5 /* WebNotificationManagerMessages.h in Headers */,
                                31A2EC4B148997C200810D71 /* WebNotificationManagerProxy.h in Headers */,
                                31A2EC4E148997C200810D71 /* WebNotificationProvider.h in Headers */,
-                               BC857FB512B830E600EDEB2E /* WebOpenPanelParameters.h in Headers */,
+                               BC857FB512B830E600EDEB2E /* APIOpenPanelParameters.h in Headers */,
                                BC857F8512B82D0B00EDEB2E /* WebOpenPanelResultListener.h in Headers */,
                                BC1DFEA412B31F87005DF730 /* WebOpenPanelResultListenerProxy.h in Headers */,
                                BC032D8F10F437A00058C15A /* WebPage.h in Headers */,
                                BC7043CC12F75EE0006472B9 /* WKBundleNavigationAction.h in Headers */,
                                51A728DE1B1BAD3800102EEE /* WKBundleNavigationActionPrivate.h in Headers */,
                                BC4BEFE1120A1A4C00FBA0C7 /* WKBundleNodeHandle.h in Headers */,
+                               1A67CD2E1CBC513F00BFE3EA /* WKOpenPanelParametersInternal.h in Headers */,
                                BC57450C1263B155006F0F12 /* WKBundleNodeHandlePrivate.h in Headers */,
                                BC20528111C94284008F3375 /* WKBundlePage.h in Headers */,
                                7CF47FF717275B71008ACB91 /* WKBundlePageBanner.h in Headers */,
                                753E3E0D1887398500188496 /* SessionTracker.cpp in Sources */,
                                1A6420E412DCE2FF00CAAE2C /* ShareableBitmap.cpp in Sources */,
                                C01A260112662F2100C9ED55 /* ShareableBitmapCG.cpp in Sources */,
+                               1ACC50F11CBC381D003C7D03 /* WKOpenPanelParameters.mm in Sources */,
                                51217460164C20E30037A5C1 /* ShareableResource.cpp in Sources */,
                                1A24BF3A120896A600FBB059 /* SharedMemoryMac.cpp in Sources */,
                                2DAF06D718BD1A470081CEB1 /* SmartMagnificationController.mm in Sources */,
                                31BA924D148831260062EDB5 /* WebNotificationManagerMessageReceiver.cpp in Sources */,
                                31A2EC4A148997C200810D71 /* WebNotificationManagerProxy.cpp in Sources */,
                                31A2EC4D148997C200810D71 /* WebNotificationProvider.cpp in Sources */,
-                               BC857FB612B830E600EDEB2E /* WebOpenPanelParameters.cpp in Sources */,
+                               BC857FB612B830E600EDEB2E /* APIOpenPanelParameters.cpp in Sources */,
                                BC857F8612B82D0B00EDEB2E /* WebOpenPanelResultListener.cpp in Sources */,
                                BC857F7E12B82CEE00EDEB2E /* WebOpenPanelResultListenerProxy.cpp in Sources */,
                                9955A6F61C7986E300EB6A93 /* AutomationProtocolObjects.cpp in Sources */,
index 27d0928..f4183af 100644 (file)
@@ -43,7 +43,6 @@
 #include "WebFullScreenManager.h"
 #include "WebHitTestResultData.h"
 #include "WebImage.h"
-#include "WebOpenPanelParameters.h"
 #include "WebOpenPanelResultListener.h"
 #include "WebPage.h"
 #include "WebPageCreationParameters.h"
@@ -718,7 +717,7 @@ void WebChromeClient::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> prpFile
     WebFrame* webFrame = WebFrame::fromCoreFrame(*frame);
     ASSERT(webFrame);
 
-    m_page->send(Messages::WebPageProxy::RunOpenPanel(webFrame->frameID(), fileChooser->settings()));
+    m_page->send(Messages::WebPageProxy::RunOpenPanel(webFrame->frameID(), SecurityOriginData::fromFrame(frame), fileChooser->settings()));
 }
 
 void WebChromeClient::loadIconForFiles(const Vector<String>& filenames, FileIconLoader* loader)
index 8a0463c..3bf927b 100644 (file)
@@ -1,3 +1,16 @@
+2016-04-14  Anders Carlsson  <andersca@apple.com>
+
+        [Mac] Add API for open panel handling to WKWebView
+        https://bugs.webkit.org/show_bug.cgi?id=137759
+        rdar://problem/23278623
+
+        Reviewed by Tim Horton.
+
+        Have MiniBrowser implement the new delegate method.
+
+        * MiniBrowser/mac/WK2BrowserWindowController.m:
+        (-[WK2BrowserWindowController webView:runOpenPanelWithParameters:initiatedByFrame:completionHandler:]):
+
 2016-04-14  Jiewen Tan  <jiewen_tan@apple.com>
 
         Unreviewed, rolling out r199554.
index 4f5dfa6..a3bc85e 100644 (file)
@@ -448,6 +448,24 @@ static CGFloat viewScaleForMenuItemTag(NSInteger tag)
     }];
 }
 
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
+- (void)webView:(WKWebView *)webView runOpenPanelWithParameters:(WKOpenPanelParameters *)parameters initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(NSArray<NSURL *> * URLs))completionHandler
+#else
+- (void)webView:(WKWebView *)webView runOpenPanelWithParameters:(WKOpenPanelParameters *)parameters initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(NSArray* _Nullable result))completionHandler
+#endif
+{
+    NSOpenPanel *openPanel = [NSOpenPanel openPanel];
+
+    openPanel.allowsMultipleSelection = parameters.allowsMultipleSelection;
+
+    [openPanel beginSheetModalForWindow:webView.window completionHandler:^(NSInteger result) {
+        if (result == NSFileHandlingPanelOKButton)
+            completionHandler(openPanel.URLs);
+        else
+            completionHandler(nil);
+    }];
+}
+
 - (void)updateTextFieldFromURL:(NSURL *)URL
 {
     if (!URL)