Changeset 199554 in webkit


Ignore:
Timestamp:
Apr 14, 2016 2:21:57 PM (8 years ago)
Author:
andersca@apple.com
Message:

[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.

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:]):

Location:
trunk
Files:
27 edited
3 copied
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r199532 r199554  
     12016-04-14  Anders Carlsson  <andersca@apple.com>
     2
     3        [Mac] Add API for open panel handling to WKWebView
     4        https://bugs.webkit.org/show_bug.cgi?id=137759
     5        rdar://problem/23278623
     6
     7        Reviewed by Tim Horton.
     8
     9        Based on a patch by Brian Michel.
     10
     11        * Shared/API/Cocoa/WebKit.h:
     12        Import WKOpenPanelParameters.h.
     13
     14        * Shared/Cocoa/APIObject.mm:
     15        (API::Object::newObject):
     16        Create a WKOpenPanelParameters for Type::OpenPanelParameters.
     17
     18        * UIProcess/API/APIOpenPanelParameters.cpp: Renamed from Source/WebKit2/Shared/WebOpenPanelParameters.cpp.
     19        * UIProcess/API/APIOpenPanelParameters.h: Renamed from Source/WebKit2/Shared/WebOpenPanelParameters.h.
     20        Rename WebKit::WebOpenPanelParameters to API::OpenPanelParameters.
     21
     22        * UIProcess/API/APIUIClient.h:
     23        (API::UIClient::runOpenPanel):
     24        Change this to take a SecurityOriginData.
     25
     26        * UIProcess/API/C/WKAPICast.h:
     27        * UIProcess/API/C/WKOpenPanelParametersRef.cpp:
     28        (WKOpenPanelParametersGetTypeID):
     29        Rename WebKit::WebOpenPanelParameters to API::OpenPanelParameters.
     30
     31        * UIProcess/API/C/WKOpenPanelResultListener.cpp:
     32        (filePathsFromFileURLs):
     33        (WKOpenPanelResultListenerChooseFiles):
     34        * UIProcess/API/C/WKPage.cpp:
     35        (WKPageSetPageUIClient):
     36        Change chooseFiles to take a Vector<String> instead of an API::Array of URLs.
     37
     38        * UIProcess/API/Cocoa/WKOpenPanelParameters.h: Added.
     39        * UIProcess/API/Cocoa/WKOpenPanelParameters.mm: Added.
     40        (-[WKOpenPanelParameters allowsMultipleSelection]):
     41        (-[WKOpenPanelParameters _apiObject]):
     42        * UIProcess/API/Cocoa/WKOpenPanelParametersInternal.h:
     43        Add a WKOpenPanelParameters class which contains information about a file upload control.
     44
     45        * UIProcess/API/Cocoa/WKUIDelegate.h:
     46        Add new delegate method.
     47
     48        * UIProcess/Cocoa/UIDelegate.h:
     49        * UIProcess/Cocoa/UIDelegate.mm:
     50        (WebKit::UIDelegate::setDelegate):
     51        Record whether the UI delegate implements the new delegate method.
     52
     53        (WebKit::UIDelegate::UIClient::runOpenPanel):
     54        Invoke the new delegate method.
     55
     56        * UIProcess/PageClient.h:
     57        (WebKit::PageClient::handleRunOpenPanel):
     58        Rename WebKit::WebOpenPanelParameters to API::OpenPanelParameters.
     59
     60        * UIProcess/WebOpenPanelResultListenerProxy.cpp:
     61        (WebKit::WebOpenPanelResultListenerProxy::chooseFiles):
     62        * UIProcess/WebOpenPanelResultListenerProxy.h:
     63        Change chooseFiles to take a Vector<String> instead of an API::Array of URLs.
     64
     65        * UIProcess/WebPageProxy.cpp:
     66        (WebKit::WebPageProxy::runOpenPanel):
     67        * UIProcess/WebPageProxy.h:
     68        Change this to take a SecurityOriginData.
     69
     70        * UIProcess/WebPageProxy.messages.in:
     71        Change RunOpenPanel to take a SecurityOriginData.
     72
     73        * UIProcess/ios/PageClientImplIOS.h:
     74        * UIProcess/ios/PageClientImplIOS.mm:
     75        (WebKit::PageClientImpl::handleRunOpenPanel):
     76        Rename WebKit::WebOpenPanelParameters to API::OpenPanelParameters.
     77
     78        * UIProcess/ios/WKContentViewInteraction.h:
     79        * UIProcess/ios/WKContentViewInteraction.mm:
     80        (-[WKContentView _showRunOpenPanel:resultListener:]):
     81        Change chooseFiles to take a Vector<String> instead of an API::Array of URLs.
     82
     83        * UIProcess/ios/forms/WKFileUploadPanel.h:
     84        * UIProcess/ios/forms/WKFileUploadPanel.mm:
     85        (-[WKFileUploadPanel _chooseFiles:displayString:iconImage:]):
     86        Change chooseFiles to take a Vector<String> instead of an API::Array of URLs.
     87
     88        (-[WKFileUploadPanel presentWithParameters:resultListener:]):
     89        Rename WebKit::WebOpenPanelParameters to API::OpenPanelParameters.
     90
     91        * WebKit2.xcodeproj/project.pbxproj:
     92        Add new file.
     93
     94        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
     95        (WebKit::WebChromeClient::runOpenPanel):
     96        Pass the security origin of the frame along.
     97
    1982016-04-14  Alex Christensen  <achristensen@webkit.org>
    299
  • trunk/Source/WebKit2/Shared/API/Cocoa/WebKit.h

    r198070 r199554  
    3434#import <WebKit/WKNavigationDelegate.h>
    3535#import <WebKit/WKNavigationResponse.h>
     36#import <WebKit/WKOpenPanelParameters.h>
    3637#import <WebKit/WKPreferences.h>
    3738#import <WebKit/WKPreviewActionItem.h>
  • trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm

    r197172 r199554  
    4747#import "WKNavigationInternal.h"
    4848#import "WKNavigationResponseInternal.h"
     49#import "WKOpenPanelParametersInternal.h"
    4950#import "WKPreferencesInternal.h"
    5051#import "WKProcessPoolInternal.h"
     
    182183        break;
    183184
     185    case Type::OpenPanelParameters:
     186        wrapper = [WKOpenPanelParameters alloc];
     187        break;
     188
    184189    case Type::PageGroup:
    185190        wrapper = [WKBrowsingContextGroup alloc];
  • trunk/Source/WebKit2/UIProcess/API/APIOpenPanelParameters.cpp

    r199552 r199554  
    2626
    2727#include "config.h"
    28 #include "WebOpenPanelParameters.h"
     28#include "APIOpenPanelParameters.h"
    2929
    3030#include "APIArray.h"
     
    3434using namespace WebCore;
    3535
    36 namespace WebKit {
     36namespace API {
    3737
    38 PassRefPtr<WebOpenPanelParameters> WebOpenPanelParameters::create(const FileChooserSettings& settings)
     38Ref<OpenPanelParameters> OpenPanelParameters::create(const FileChooserSettings& settings)
    3939{
    40     return adoptRef(new WebOpenPanelParameters(settings));
     40    return adoptRef(*new OpenPanelParameters(settings));
    4141}
    4242
    43 WebOpenPanelParameters::WebOpenPanelParameters(const FileChooserSettings& settings)
     43OpenPanelParameters::OpenPanelParameters(const FileChooserSettings& settings)
    4444    : m_settings(settings)
    4545{
    4646}
    4747
    48 WebOpenPanelParameters::~WebOpenPanelParameters()
     48OpenPanelParameters::~OpenPanelParameters()
    4949{
    5050}
    5151
    52 Ref<API::Array> WebOpenPanelParameters::acceptMIMETypes() const
     52Ref<API::Array> OpenPanelParameters::acceptMIMETypes() const
    5353{
    5454    return API::Array::createStringArray(m_settings.acceptMIMETypes);
     
    5656
    5757#if ENABLE(MEDIA_CAPTURE)
    58 bool WebOpenPanelParameters::capture() const
     58bool OpenPanelParameters::capture() const
    5959{
    6060    return m_settings.capture;
     
    6262#endif
    6363
    64 Ref<API::Array> WebOpenPanelParameters::selectedFileNames() const
     64Ref<API::Array> OpenPanelParameters::selectedFileNames() const
    6565{
    6666    return API::Array::createStringArray(m_settings.selectedFiles);
  • trunk/Source/WebKit2/UIProcess/API/APIOpenPanelParameters.h

    r199552 r199554  
    2525 */
    2626
    27 #ifndef WebOpenPanelParameters_h
    28 #define WebOpenPanelParameters_h
     27#pragma once
    2928
    3029#include "APIObject.h"
    3130#include <WebCore/FileChooser.h>
    32 #include <wtf/Vector.h>
    33 #include <wtf/text/WTFString.h>
    3431
    3532namespace API {
     33
    3634class Array;
    37 }
    3835
    39 namespace WebKit {
    40 
    41 class WebOpenPanelParameters : public API::ObjectImpl<API::Object::Type::OpenPanelParameters> {
     36class OpenPanelParameters : public API::ObjectImpl<API::Object::Type::OpenPanelParameters> {
    4237public:
    43     static PassRefPtr<WebOpenPanelParameters> create(const WebCore::FileChooserSettings&);
    44     ~WebOpenPanelParameters();
     38    static Ref<OpenPanelParameters> create(const WebCore::FileChooserSettings&);
     39    ~OpenPanelParameters();
    4540
    4641    bool allowMultipleFiles() const { return m_settings.allowsMultipleFiles; }
     
    5247
    5348private:
    54     explicit WebOpenPanelParameters(const WebCore::FileChooserSettings&);
     49    explicit OpenPanelParameters(const WebCore::FileChooserSettings&);
    5550
    5651    WebCore::FileChooserSettings m_settings;
    5752};
    5853
    59 } // namespace WebKit
    60 
    61 #endif // WebOpenPanelParameters_h
     54} // namespace API
  • trunk/Source/WebKit2/UIProcess/API/APIUIClient.h

    r197114 r199554  
    5656class WebColorPickerResultListenerProxy;
    5757class WebFrameProxy;
    58 class WebOpenPanelParameters;
    5958class WebOpenPanelResultListenerProxy;
    6059class WebPageProxy;
     
    7170class Dictionary;
    7271class Object;
     72class OpenPanelParameters;
    7373class SecurityOrigin;
    7474
     
    131131    }
    132132
    133     virtual bool runOpenPanel(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, WebKit::WebOpenPanelParameters*, WebKit::WebOpenPanelResultListenerProxy*) { return false; }
     133    virtual bool runOpenPanel(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, const WebCore::SecurityOriginData&, OpenPanelParameters*, WebKit::WebOpenPanelResultListenerProxy*) { return false; }
    134134    virtual bool decidePolicyForGeolocationPermissionRequest(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, SecurityOrigin*, WebKit::GeolocationPermissionRequestProxy*) { return false; }
    135135    virtual bool decidePolicyForUserMediaPermissionRequest(WebKit::WebPageProxy&, WebKit::WebFrameProxy&, SecurityOrigin&, SecurityOrigin&, WebKit::UserMediaPermissionRequestProxy&) { return false; }
  • trunk/Source/WebKit2/UIProcess/API/C/WKAPICast.h

    r197114 r199554  
    5959class NavigationData;
    6060class NavigationResponse;
     61class OpenPanelParameters;
    6162class PageConfiguration;
    6263class ProcessPoolConfiguration;
     
    9899class WebNotificationManagerProxy;
    99100class WebNotificationProvider;
    100 class WebOpenPanelParameters;
    101101class WebOpenPanelResultListenerProxy;
    102102class WebPageGroup;
     
    147147WK_ADD_API_MAPPING(WKNotificationProviderRef, WebNotificationProvider)
    148148WK_ADD_API_MAPPING(WKNotificationRef, WebNotification)
    149 WK_ADD_API_MAPPING(WKOpenPanelParametersRef, WebOpenPanelParameters)
     149WK_ADD_API_MAPPING(WKOpenPanelParametersRef, API::OpenPanelParameters)
    150150WK_ADD_API_MAPPING(WKOpenPanelResultListenerRef, WebOpenPanelResultListenerProxy)
    151151WK_ADD_API_MAPPING(WKPageGroupRef, WebPageGroup)
  • trunk/Source/WebKit2/UIProcess/API/C/WKOpenPanelParametersRef.cpp

    r199311 r199554  
    2929
    3030#include "APIArray.h"
     31#include "APIOpenPanelParameters.h"
    3132#include "WKAPICast.h"
    32 #include "WebOpenPanelParameters.h"
    3333
    3434using namespace WebKit;
     
    3636WKTypeID WKOpenPanelParametersGetTypeID()
    3737{
    38     return toAPI(WebOpenPanelParameters::APIType);
     38    return toAPI(API::OpenPanelParameters::APIType);
    3939}
    4040
  • trunk/Source/WebKit2/UIProcess/API/C/WKOpenPanelResultListener.cpp

    r95901 r199554  
    2929#include "WKAPICast.h"
    3030#include "WebOpenPanelResultListenerProxy.h"
     31#include <WebCore/URL.h>
    3132
    3233using namespace WebKit;
     
    3738}
    3839
     40static Vector<String> filePathsFromFileURLs(const API::Array& fileURLs)
     41{
     42    Vector<String> filePaths;
     43
     44    size_t size = fileURLs.size();
     45    filePaths.reserveInitialCapacity(size);
     46
     47    for (size_t i = 0; i < size; ++i) {
     48        API::URL* apiURL = fileURLs.at<API::URL>(i);
     49        if (apiURL)
     50            filePaths.uncheckedAppend(WebCore::URL(WebCore::URL(), apiURL->string()).fileSystemPath());
     51    }
     52
     53    return filePaths;
     54}
     55
    3956void WKOpenPanelResultListenerChooseFiles(WKOpenPanelResultListenerRef listenerRef, WKArrayRef fileURLsRef)
    4057{
    41     toImpl(listenerRef)->chooseFiles(toImpl(fileURLsRef));
     58    toImpl(listenerRef)->chooseFiles(filePathsFromFileURLs(*toImpl(fileURLsRef)));
    4259}
    4360
  • trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp

    r198476 r199554  
    4141#include "APINavigationClient.h"
    4242#include "APINavigationResponse.h"
     43#include "APIOpenPanelParameters.h"
    4344#include "APIPageConfiguration.h"
    4445#include "APIPolicyClient.h"
     
    6263#include "WebImage.h"
    6364#include "WebInspectorProxy.h"
    64 #include "WebOpenPanelParameters.h"
    6565#include "WebOpenPanelResultListenerProxy.h"
    6666#include "WebPageGroup.h"
     
    20542054        }
    20552055
    2056         bool runOpenPanel(WebPageProxy* page, WebFrameProxy* frame, WebOpenPanelParameters* parameters, WebOpenPanelResultListenerProxy* listener) override
     2056        bool runOpenPanel(WebPageProxy* page, WebFrameProxy* frame, const WebCore::SecurityOriginData&, API::OpenPanelParameters* parameters, WebOpenPanelResultListenerProxy* listener) override
    20572057        {
    20582058            if (!m_client.runOpenPanel)
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKOpenPanelParameters.h

    r199552 r199554  
    11/*
    2  * Copyright (C) 2010 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #include "config.h"
    27 #include "WKOpenPanelResultListener.h"
     26#import <WebKit/WKFoundation.h>
    2827
    29 #include "WKAPICast.h"
    30 #include "WebOpenPanelResultListenerProxy.h"
     28#if WK_API_ENABLED
    3129
    32 using namespace WebKit;
     30#import <Foundation/Foundation.h>
    3331
    34 WKTypeID WKOpenPanelResultListenerGetTypeID()
    35 {
    36     return toAPI(WebOpenPanelResultListenerProxy::APIType);
    37 }
     32NS_ASSUME_NONNULL_BEGIN
    3833
    39 void WKOpenPanelResultListenerChooseFiles(WKOpenPanelResultListenerRef listenerRef, WKArrayRef fileURLsRef)
    40 {
    41     toImpl(listenerRef)->chooseFiles(toImpl(fileURLsRef));
    42 }
     34/*! WKOpenPanelParameters contains parameters that a file upload control has specified.
     35 */
     36WK_CLASS_AVAILABLE(WK_MAC_TBA, NA)
     37@interface WKOpenPanelParameters : NSObject
    4338
    44 void WKOpenPanelResultListenerCancel(WKOpenPanelResultListenerRef listenerRef)
    45 {
    46     toImpl(listenerRef)->cancel();
    47 }
     39/*! @abstract Whether the file upload control supports multiple files.
     40 */
     41@property (nonatomic, readonly) BOOL allowsMultipleSelection;
     42
     43@end
     44
     45NS_ASSUME_NONNULL_END
     46
     47#endif
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKOpenPanelParameters.mm

    r199552 r199554  
    11/*
    2  * Copyright (C) 2010 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #include "config.h"
    27 #include "WKOpenPanelResultListener.h"
     26#import "config.h"
     27#import "WKOpenPanelParametersInternal.h"
    2828
    29 #include "WKAPICast.h"
    30 #include "WebOpenPanelResultListenerProxy.h"
     29#if WK_API_ENABLED
    3130
    32 using namespace WebKit;
     31@implementation WKOpenPanelParameters
    3332
    34 WKTypeID WKOpenPanelResultListenerGetTypeID()
     33- (BOOL)allowsMultipleSelection
    3534{
    36     return toAPI(WebOpenPanelResultListenerProxy::APIType);
     35    return _openPanelParameters->allowMultipleFiles();
    3736}
    3837
    39 void WKOpenPanelResultListenerChooseFiles(WKOpenPanelResultListenerRef listenerRef, WKArrayRef fileURLsRef)
     38#pragma mark WKObject protocol implementation
     39
     40- (API::Object&)_apiObject
    4041{
    41     toImpl(listenerRef)->chooseFiles(toImpl(fileURLsRef));
     42    return *_openPanelParameters;
    4243}
    4344
    44 void WKOpenPanelResultListenerCancel(WKOpenPanelResultListenerRef listenerRef)
    45 {
    46     toImpl(listenerRef)->cancel();
    47 }
     45@end
     46
     47#endif
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKOpenPanelParametersInternal.h

    r199552 r199554  
    11/*
    2  * Copyright (C) 2010 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #include "config.h"
    27 #include "WKOpenPanelResultListener.h"
     26#import "WKOpenPanelParameters.h"
    2827
    29 #include "WKAPICast.h"
    30 #include "WebOpenPanelResultListenerProxy.h"
     28#if WK_API_ENABLED
    3129
    32 using namespace WebKit;
     30#import "APIOpenPanelParameters.h"
     31#import "WKObject.h"
    3332
    34 WKTypeID WKOpenPanelResultListenerGetTypeID()
     33namespace API {
     34
     35inline WKOpenPanelParameters *wrapper(OpenPanelParameters& openPanelParameters)
    3536{
    36     return toAPI(WebOpenPanelResultListenerProxy::APIType);
     37    ASSERT([openPanelParameters.wrapper() isKindOfClass:[WKOpenPanelParameters class]]);
     38
     39    return (WKOpenPanelParameters *)openPanelParameters.wrapper();
    3740}
    3841
    39 void WKOpenPanelResultListenerChooseFiles(WKOpenPanelResultListenerRef listenerRef, WKArrayRef fileURLsRef)
    40 {
    41     toImpl(listenerRef)->chooseFiles(toImpl(fileURLsRef));
    4242}
    4343
    44 void WKOpenPanelResultListenerCancel(WKOpenPanelResultListenerRef listenerRef)
    45 {
    46     toImpl(listenerRef)->cancel();
     44@interface WKOpenPanelParameters () <WKObject> {
     45@package
     46    API::ObjectStorage<API::OpenPanelParameters> _openPanelParameters;
    4747}
     48@end
     49
     50#endif
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegate.h

    r198070 r199554  
    3535@class WKFrameInfo;
    3636@class WKNavigationAction;
     37@class WKOpenPanelParameters;
    3738@class WKPreviewElementInfo;
    3839@class WKWebViewConfiguration;
     
    144145 if a non-nil view controller was returned.
    145146 */
    146 - (nullable UIViewController *)webView:(WKWebView *)webView previewingViewControllerForElement:(WKPreviewElementInfo *)elementInfo defaultActions:(NSArray <id <WKPreviewActionItem>> *)previewActions WK_AVAILABLE(NA, WK_IOS_TBA);
     147- (nullable UIViewController *)webView:(WKWebView *)webView previewingViewControllerForElement:(WKPreviewElementInfo *)elementInfo defaultActions:(NSArray<id <WKPreviewActionItem>> *)previewActions WK_AVAILABLE(NA, WK_IOS_TBA);
    147148
    148149/*! @abstract Allows your app to pop to the view controller it created.
     
    154155#endif // TARGET_OS_IPHONE
    155156
     157#if !TARGET_OS_IPHONE
     158
     159/*! @abstract Displays a file upload panel.
     160 @param webView The web view invoking the delegate method.
     161 @param parameters Parameters describing the file upload control.
     162 @param frame Information about the frame whose file upload control initiated this call.
     163 @param completionHandler The completion handler to call after open panel has been dismissed. Pass the selected URLs if the user chose OK, otherwise nil.
     164
     165 If you do not implement this method, the web view will behave as if the user selected the Cancel button.
     166 */
     167- (void)webView:(WKWebView *)webView runOpenPanelWithParameters:(WKOpenPanelParameters *)parameters initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(NSArray<NSURL *> * WK_NULLABLE_SPECIFIER URLs))completionHandler WK_AVAILABLE(WK_MAC_TBA, NA);
     168
     169#endif
     170
    156171@end
    157172
  • trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.h

    r197563 r199554  
    8787        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;
    8888        void reachedApplicationCacheOriginQuota(WebPageProxy*, const WebCore::SecurityOrigin&, uint64_t currentQuota, uint64_t totalBytesNeeded, std::function<void (unsigned long long)> completionHandler) override;
     89#if PLATFORM(MAC)
     90        bool runOpenPanel(WebPageProxy*, WebFrameProxy*, const WebCore::SecurityOriginData&, API::OpenPanelParameters*, WebOpenPanelResultListenerProxy*) override;
     91#endif
    8992        void printFrame(WebKit::WebPageProxy*, WebKit::WebFrameProxy*) override;
    9093#if PLATFORM(IOS)
     
    109112        bool webViewRunJavaScriptConfirmPanelWithMessageInitiatedByFrameCompletionHandler : 1;
    110113        bool webViewRunJavaScriptTextInputPanelWithPromptDefaultTextInitiatedByFrameCompletionHandler : 1;
     114#if PLATFORM(MAC)
     115        bool webViewRunOpenPanelWithParametersInitiatedByFrameCompletionHandler : 1;
     116#endif
    111117        bool webViewDecideDatabaseQuotaForSecurityOriginCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler : 1;
    112118        bool webViewDecideWebApplicationCacheQuotaForSecurityOriginCurrentQuotaTotalBytesNeeded : 1;
  • trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm

    r195623 r199554  
    3333#import "WKFrameInfoInternal.h"
    3434#import "WKNavigationActionInternal.h"
     35#import "WKOpenPanelParametersInternal.h"
    3536#import "WKSecurityOriginInternal.h"
    3637#import "WKWebViewConfigurationInternal.h"
     
    3839#import "WKWindowFeaturesInternal.h"
    3940#import "WKUIDelegatePrivate.h"
     41#import "WebOpenPanelResultListenerProxy.h"
    4042#import "_WKContextMenuElementInfo.h"
    4143#import "_WKFrameHandleInternal.h"
     
    7981    m_delegateMethods.webViewRunJavaScriptConfirmPanelWithMessageInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(webView:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:completionHandler:)];
    8082    m_delegateMethods.webViewRunJavaScriptTextInputPanelWithPromptDefaultTextInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(webView:runJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame:completionHandler:)];
     83
     84#if PLATFORM(MAC)
     85    m_delegateMethods.webViewRunOpenPanelWithParametersInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(webView:runOpenPanelWithParameters:initiatedByFrame:completionHandler:)];
     86#endif
     87
    8188    m_delegateMethods.webViewDecideDatabaseQuotaForSecurityOriginCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler = [delegate respondsToSelector:@selector(_webView:decideDatabaseQuotaForSecurityOrigin:currentQuota:currentOriginUsage:currentDatabaseUsage:expectedUsage:decisionHandler:)];
    8289    m_delegateMethods.webViewDecideWebApplicationCacheQuotaForSecurityOriginCurrentQuotaTotalBytesNeeded = [delegate respondsToSelector:@selector(_webView:decideWebApplicationCacheQuotaForSecurityOrigin:currentQuota:totalBytesNeeded:decisionHandler:)];
     
    251258}
    252259
     260#if PLATFORM(MAC)
     261bool UIDelegate::UIClient::runOpenPanel(WebPageProxy*, WebFrameProxy* webFrameProxy, const WebCore::SecurityOriginData& securityOriginData, API::OpenPanelParameters* openPanelParameters, WebOpenPanelResultListenerProxy* listener)
     262{
     263    if (!m_uiDelegate.m_delegateMethods.webViewRunOpenPanelWithParametersInitiatedByFrameCompletionHandler)
     264        return false;
     265
     266    auto delegate = m_uiDelegate.m_delegate.get();
     267    if (!delegate)
     268        return false;
     269
     270    auto frame = API::FrameInfo::create(*webFrameProxy, securityOriginData.securityOrigin());
     271    RefPtr<WebOpenPanelResultListenerProxy> resultListener = listener;
     272
     273    RefPtr<CompletionHandlerCallChecker> checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(webView:runOpenPanelWithParameters:initiatedByFrame:completionHandler:));
     274
     275    [delegate webView:m_uiDelegate.m_webView runOpenPanelWithParameters:wrapper(*openPanelParameters) initiatedByFrame:wrapper(frame) completionHandler:[checker, resultListener](NSArray<NSURL *> *URLs) {
     276        checker->didCallCompletionHandler();
     277
     278        if (!URLs) {
     279            resultListener->cancel();
     280            return;
     281        }
     282
     283        Vector<String> filenames;
     284        for (NSURL *url in URLs)
     285            filenames.append(url.fileSystemRepresentation);
     286
     287        resultListener->chooseFiles(filenames);
     288    }];
     289
     290    return true;
     291}
     292#endif
     293
    253294void UIDelegate::UIClient::reachedApplicationCacheOriginQuota(WebPageProxy*, const WebCore::SecurityOrigin& securityOrigin, uint64_t currentQuota, uint64_t totalBytesNeeded, std::function<void (unsigned long long)> completionHandler)
    254295{
  • trunk/Source/WebKit2/UIProcess/PageClient.h

    r199233 r199554  
    152152    virtual void handleDownloadRequest(DownloadProxy*) = 0;
    153153
    154     virtual bool handleRunOpenPanel(WebPageProxy*, WebFrameProxy*, WebOpenPanelParameters*, WebOpenPanelResultListenerProxy*) { return false; }
     154    virtual bool handleRunOpenPanel(WebPageProxy*, WebFrameProxy*, API::OpenPanelParameters*, WebOpenPanelResultListenerProxy*) { return false; }
    155155
    156156    virtual void didChangeContentSize(const WebCore::IntSize&) = 0;
  • trunk/Source/WebKit2/UIProcess/WebOpenPanelResultListenerProxy.cpp

    r186279 r199554  
    4646}
    4747
    48 static Vector<String> filePathsFromFileURLs(const API::Array& fileURLs)
    49 {
    50     Vector<String> filePaths;
    51 
    52     size_t size = fileURLs.size();
    53     filePaths.reserveInitialCapacity(size);
    54 
    55     for (size_t i = 0; i < size; ++i) {
    56         API::URL* apiURL = fileURLs.at<API::URL>(i);
    57         if (apiURL)
    58             filePaths.uncheckedAppend(URL(URL(), apiURL->string()).fileSystemPath());
    59     }
    60 
    61     return filePaths;
    62 }
    63 
    6448#if PLATFORM(IOS)
    65 void WebOpenPanelResultListenerProxy::chooseFiles(API::Array* fileURLsArray, API::String* displayString, const API::Data* iconImageData)
     49void WebOpenPanelResultListenerProxy::chooseFiles(const Vector<WTF::String>& filenames, const String& displayString, const API::Data* iconImageData)
    6650{
    6751    if (!m_page)
    6852        return;
    6953
    70     m_page->didChooseFilesForOpenPanelWithDisplayStringAndIcon(filePathsFromFileURLs(*fileURLsArray), displayString ? displayString->string() : String(), iconImageData);
     54    m_page->didChooseFilesForOpenPanelWithDisplayStringAndIcon(filenames, displayString, iconImageData);
    7155}
    7256#endif
    7357
    74 void WebOpenPanelResultListenerProxy::chooseFiles(API::Array* fileURLsArray)
     58void WebOpenPanelResultListenerProxy::chooseFiles(const Vector<String>& filenames)
    7559{
    7660    if (!m_page)
    7761        return;
    7862
    79     m_page->didChooseFilesForOpenPanel(filePathsFromFileURLs(*fileURLsArray));
     63    m_page->didChooseFilesForOpenPanel(filenames);
    8064}
    8165
  • trunk/Source/WebKit2/UIProcess/WebOpenPanelResultListenerProxy.h

    r168180 r199554  
    2828
    2929#include "APIObject.h"
     30#include <wtf/Forward.h>
    3031#include <wtf/PassRefPtr.h>
    3132#include <wtf/RefPtr.h>
     33#include <wtf/Vector.h>
    3234
    3335namespace API {
     
    5153
    5254#if PLATFORM(IOS)
    53     void chooseFiles(API::Array*, API::String* displayString, const API::Data* iconImageData);
     55    void chooseFiles(const Vector<String>& filenames, const String& displayString, const API::Data* iconImageData);
    5456#endif
    55     void chooseFiles(API::Array*);
     57    void chooseFiles(const Vector<String>& filenames);
    5658    void cancel();
    5759
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r199286 r199554  
    4343#include "APINavigationClient.h"
    4444#include "APINavigationResponse.h"
     45#include "APIOpenPanelParameters.h"
    4546#include "APIPageConfiguration.h"
    4647#include "APIPolicyClient.h"
     
    9192#include "WebNavigationState.h"
    9293#include "WebNotificationManagerProxy.h"
    93 #include "WebOpenPanelParameters.h"
    9494#include "WebOpenPanelResultListenerProxy.h"
    9595#include "WebPageCreationParameters.h"
     
    38543854}
    38553855
    3856 void WebPageProxy::runOpenPanel(uint64_t frameID, const FileChooserSettings& settings)
     3856void WebPageProxy::runOpenPanel(uint64_t frameID, const SecurityOriginData& frameSecurityOrigin, const FileChooserSettings& settings)
    38573857{
    38583858    if (m_openPanelResultListener) {
     
    38643864    MESSAGE_CHECK(frame);
    38653865
    3866     RefPtr<WebOpenPanelParameters> parameters = WebOpenPanelParameters::create(settings);
     3866    Ref<API::OpenPanelParameters> parameters = API::OpenPanelParameters::create(settings);
    38673867    m_openPanelResultListener = WebOpenPanelResultListenerProxy::create(this);
    38683868
     
    38703870    m_process->responsivenessTimer().stop();
    38713871
    3872     if (!m_uiClient->runOpenPanel(this, frame, parameters.get(), m_openPanelResultListener.get())) {
    3873         if (!m_pageClient.handleRunOpenPanel(this, frame, parameters.get(), m_openPanelResultListener.get()))
     3872
     3873    if (!m_uiClient->runOpenPanel(this, frame, frameSecurityOrigin, parameters.ptr(), m_openPanelResultListener.get())) {
     3874        if (!m_pageClient.handleRunOpenPanel(this, frame, parameters.ptr(), m_openPanelResultListener.get()))
    38743875            didCancelForOpenPanel();
    38753876    }
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r199399 r199554  
    12111211    void didChangeViewportProperties(const WebCore::ViewportAttributes&);
    12121212    void pageDidScroll();
    1213     void runOpenPanel(uint64_t frameID, const WebCore::FileChooserSettings&);
     1213    void runOpenPanel(uint64_t frameID, const WebCore::SecurityOriginData&, const WebCore::FileChooserSettings&);
    12141214    void printFrame(uint64_t frameID);
    12151215    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>);
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in

    r199399 r199554  
    7272    RunBeforeUnloadConfirmPanel(String message, uint64_t frameID) -> (bool shouldClose) Delayed
    7373    PageDidScroll()
    74     RunOpenPanel(uint64_t frameID, struct WebCore::FileChooserSettings parameters)
     74    RunOpenPanel(uint64_t frameID, struct WebCore::SecurityOriginData frameSecurityOrigin, struct WebCore::FileChooserSettings parameters)
    7575    PrintFrame(uint64_t frameID) -> ()
    7676    RunModal()
  • trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h

    r199233 r199554  
    133133    void showPlaybackTargetPicker(bool hasVideo, const WebCore::IntRect& elementRect) override;
    134134
    135     bool handleRunOpenPanel(WebPageProxy*, WebFrameProxy*, WebOpenPanelParameters*, WebOpenPanelResultListenerProxy*) override;
     135    bool handleRunOpenPanel(WebPageProxy*, WebFrameProxy*, API::OpenPanelParameters*, WebOpenPanelResultListenerProxy*) override;
    136136    void disableDoubleTapGesturesDuringTapIfNecessary(uint64_t requestID) override;
    137137    double minimumZoomScale() const override;
  • trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm

    r199233 r199554  
    561561}
    562562
    563 bool PageClientImpl::handleRunOpenPanel(WebPageProxy*, WebFrameProxy*, WebOpenPanelParameters* parameters, WebOpenPanelResultListenerProxy* listener)
     563bool PageClientImpl::handleRunOpenPanel(WebPageProxy*, WebFrameProxy*, API::OpenPanelParameters* parameters, WebOpenPanelResultListenerProxy* listener)
    564564{
    565565    [m_contentView _showRunOpenPanel:parameters resultListener:listener];
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h

    r198147 r199554  
    4545#import <wtf/text/WTFString.h>
    4646
     47namespace API {
     48class OpenPanelParameters;
     49}
     50
    4751namespace WebCore {
    4852class Color;
     
    5458class NativeWebTouchEvent;
    5559class SmartMagnificationController;
    56 class WebOpenPanelParameters;
    5760class WebOpenPanelResultListenerProxy;
    5861class WebPageProxy;
     
    210213- (void)_didUpdateBlockSelectionWithTouch:(WebKit::SelectionTouch)touch withFlags:(WebKit::SelectionFlags)flags growThreshold:(CGFloat)growThreshold shrinkThreshold:(CGFloat)shrinkThreshold;
    211214- (void)_showPlaybackTargetPicker:(BOOL)hasVideo fromRect:(const WebCore::IntRect&)elementRect;
    212 - (void)_showRunOpenPanel:(WebKit::WebOpenPanelParameters*)parameters resultListener:(WebKit::WebOpenPanelResultListenerProxy*)listener;
     215- (void)_showRunOpenPanel:(API::OpenPanelParameters*)parameters resultListener:(WebKit::WebOpenPanelResultListenerProxy*)listener;
    213216- (void)accessoryDone;
    214217- (void)_didHandleKeyEvent:(WebIOSEvent *)event eventWasHandled:(BOOL)eventWasHandled;
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm

    r199399 r199554  
    36623662}
    36633663
    3664 - (void)_showRunOpenPanel:(WebOpenPanelParameters*)parameters resultListener:(WebOpenPanelResultListenerProxy*)listener
     3664- (void)_showRunOpenPanel:(API::OpenPanelParameters*)parameters resultListener:(WebOpenPanelResultListenerProxy*)listener
    36653665{
    36663666    ASSERT(!_fileUploadPanel);
  • trunk/Source/WebKit2/UIProcess/ios/forms/WKFileUploadPanel.h

    r168180 r199554  
    3131@protocol WKFileUploadPanelDelegate;
    3232
     33namespace API {
     34class OpenPanelParameters;
     35}
     36
    3337namespace WebKit {
    34 class WebOpenPanelParameters;
    3538class WebOpenPanelResultListenerProxy;
    3639}
     
    3942@property (nonatomic, assign) id <WKFileUploadPanelDelegate> delegate;
    4043- (instancetype)initWithView:(WKContentView *)view;
    41 - (void)presentWithParameters:(WebKit::WebOpenPanelParameters*)parameters resultListener:(WebKit::WebOpenPanelResultListenerProxy*)listener;
     44- (void)presentWithParameters:(API::OpenPanelParameters*)parameters resultListener:(WebKit::WebOpenPanelResultListenerProxy*)listener;
    4245- (void)dismiss;
    4346@end
  • trunk/Source/WebKit2/UIProcess/ios/forms/WKFileUploadPanel.mm

    r195971 r199554  
    3131#import "APIArray.h"
    3232#import "APIData.h"
     33#import "APIOpenPanelParameters.h"
    3334#import "APIString.h"
    3435#import "UIKitSPI.h"
     
    3738#import "WKStringCF.h"
    3839#import "WKURLCF.h"
    39 #import "WebOpenPanelParameters.h"
    4040#import "WebOpenPanelResultListenerProxy.h"
    4141#import "WebPageProxy.h"
     
    334334    }
    335335
    336     Vector<RefPtr<API::Object>> urls;
    337     urls.reserveInitialCapacity(count);
     336    Vector<String> filenames;
     337    filenames.reserveInitialCapacity(count);
    338338    for (NSURL *fileURL in fileURLs)
    339         urls.uncheckedAppend(adoptRef(toImpl(WKURLCreateWithCFURL((CFURLRef)fileURL))));
    340     Ref<API::Array> fileURLsRef = API::Array::create(WTFMove(urls));
     339        filenames.uncheckedAppend(fileURL.fileSystemRepresentation);
    341340
    342341    NSData *jpeg = UIImageJPEGRepresentation(iconImage, 1.0);
    343342    RefPtr<API::Data> iconImageDataRef = adoptRef(toImpl(WKDataCreate(reinterpret_cast<const unsigned char*>([jpeg bytes]), [jpeg length])));
    344343
    345     RefPtr<API::String> displayStringRef = adoptRef(toImpl(WKStringCreateWithCFString((CFStringRef)displayString)));
    346 
    347     _listener->chooseFiles(fileURLsRef.ptr(), displayStringRef.get(), iconImageDataRef.get());
     344    _listener->chooseFiles(filenames, displayString, iconImageDataRef.get());
    348345    [self _dispatchDidDismiss];
    349346}
     
    351348#pragma mark - Present / Dismiss API
    352349
    353 - (void)presentWithParameters:(WebKit::WebOpenPanelParameters*)parameters resultListener:(WebKit::WebOpenPanelResultListenerProxy*)listener
     350- (void)presentWithParameters:(API::OpenPanelParameters*)parameters resultListener:(WebKit::WebOpenPanelResultListenerProxy*)listener
    354351{
    355352    ASSERT(!_listener);
  • trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj

    r199401 r199554  
    286286                1A6563E51B7A8C50009CF787 /* APIWindowFeatures.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A6563E31B7A8C50009CF787 /* APIWindowFeatures.h */; };
    287287                1A66BF8F18A052ED002071B4 /* WKWebViewInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A66BF8E18A052ED002071B4 /* WKWebViewInternal.h */; };
     288                1A67CD2E1CBC513F00BFE3EA /* WKOpenPanelParametersInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A67CD2D1CBC513F00BFE3EA /* WKOpenPanelParametersInternal.h */; };
    288289                1A6F9F9011E13EFC00DB1371 /* CommandLine.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A6F9F8E11E13EFC00DB1371 /* CommandLine.h */; };
    289290                1A6F9FB711E1408500DB1371 /* CommandLinePOSIX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A6F9FB611E1408500DB1371 /* CommandLinePOSIX.cpp */; };
     
    437438                1AC75A1B1B3368270056745B /* HangDetectionDisabler.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AC75A1A1B3368270056745B /* HangDetectionDisabler.h */; };
    438439                1AC75A1E1B33695E0056745B /* HangDetectionDisablerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AC75A1C1B33695E0056745B /* HangDetectionDisablerMac.mm */; };
     440                1ACC50F11CBC381D003C7D03 /* WKOpenPanelParameters.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1ACC50EF1CBC381D003C7D03 /* WKOpenPanelParameters.mm */; };
     441                1ACC50F21CBC381D003C7D03 /* WKOpenPanelParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ACC50F01CBC381D003C7D03 /* WKOpenPanelParameters.h */; settings = {ATTRIBUTES = (Public, ); }; };
    439442                1ACC87BA1981C341003D1AF4 /* WKNavigationPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ACC87B91981C341003D1AF4 /* WKNavigationPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
    440443                1ACECD2417162DB1001FC9EF /* StorageAreaMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1ACECD2217162DB1001FC9EF /* StorageAreaMap.cpp */; };
     
    15051508                BC857F8512B82D0B00EDEB2E /* WebOpenPanelResultListener.h in Headers */ = {isa = PBXBuildFile; fileRef = BC857F8312B82D0B00EDEB2E /* WebOpenPanelResultListener.h */; };
    15061509                BC857F8612B82D0B00EDEB2E /* WebOpenPanelResultListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC857F8412B82D0B00EDEB2E /* WebOpenPanelResultListener.cpp */; };
    1507                 BC857FB512B830E600EDEB2E /* WebOpenPanelParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = BC857FB312B830E600EDEB2E /* WebOpenPanelParameters.h */; };
    1508                 BC857FB612B830E600EDEB2E /* WebOpenPanelParameters.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC857FB412B830E600EDEB2E /* WebOpenPanelParameters.cpp */; };
     1510                BC857FB512B830E600EDEB2E /* APIOpenPanelParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = BC857FB312B830E600EDEB2E /* APIOpenPanelParameters.h */; };
     1511                BC857FB612B830E600EDEB2E /* APIOpenPanelParameters.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC857FB412B830E600EDEB2E /* APIOpenPanelParameters.cpp */; };
    15091512                BC857FE612B843D800EDEB2E /* WKOpenPanelParametersRef.h in Headers */ = {isa = PBXBuildFile; fileRef = BC857FE412B843D800EDEB2E /* WKOpenPanelParametersRef.h */; settings = {ATTRIBUTES = (Private, ); }; };
    15101513                BC85806212B8505700EDEB2E /* WKOpenPanelResultListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC1DFE8E12B31CA8005DF730 /* WKOpenPanelResultListener.cpp */; };
     
    22312234                1A6563E31B7A8C50009CF787 /* APIWindowFeatures.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIWindowFeatures.h; sourceTree = "<group>"; };
    22322235                1A66BF8E18A052ED002071B4 /* WKWebViewInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebViewInternal.h; sourceTree = "<group>"; };
     2236                1A67CD2D1CBC513F00BFE3EA /* WKOpenPanelParametersInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKOpenPanelParametersInternal.h; sourceTree = "<group>"; };
    22332237                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>"; };
    22342238                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; };
     
    24052409                1AC75A1A1B3368270056745B /* HangDetectionDisabler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HangDetectionDisabler.h; sourceTree = "<group>"; };
    24062410                1AC75A1C1B33695E0056745B /* HangDetectionDisablerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HangDetectionDisablerMac.mm; sourceTree = "<group>"; };
     2411                1ACC50EF1CBC381D003C7D03 /* WKOpenPanelParameters.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKOpenPanelParameters.mm; sourceTree = "<group>"; };
     2412                1ACC50F01CBC381D003C7D03 /* WKOpenPanelParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKOpenPanelParameters.h; sourceTree = "<group>"; };
    24072413                1ACC87B91981C341003D1AF4 /* WKNavigationPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKNavigationPrivate.h; sourceTree = "<group>"; };
    24082414                1ACECD2217162DB1001FC9EF /* StorageAreaMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StorageAreaMap.cpp; sourceTree = "<group>"; };
     
    35643570                BC857F8312B82D0B00EDEB2E /* WebOpenPanelResultListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebOpenPanelResultListener.h; sourceTree = "<group>"; };
    35653571                BC857F8412B82D0B00EDEB2E /* WebOpenPanelResultListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebOpenPanelResultListener.cpp; sourceTree = "<group>"; };
    3566                 BC857FB312B830E600EDEB2E /* WebOpenPanelParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebOpenPanelParameters.h; sourceTree = "<group>"; };
    3567                 BC857FB412B830E600EDEB2E /* WebOpenPanelParameters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebOpenPanelParameters.cpp; sourceTree = "<group>"; };
     3572                BC857FB312B830E600EDEB2E /* APIOpenPanelParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIOpenPanelParameters.h; sourceTree = "<group>"; };
     3573                BC857FB412B830E600EDEB2E /* APIOpenPanelParameters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = APIOpenPanelParameters.cpp; sourceTree = "<group>"; };
    35683574                BC857FE412B843D800EDEB2E /* WKOpenPanelParametersRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKOpenPanelParametersRef.h; sourceTree = "<group>"; };
    35693575                BC857FE512B843D800EDEB2E /* WKOpenPanelParametersRef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKOpenPanelParametersRef.cpp; sourceTree = "<group>"; };
     
    45134519                                C0337DAF127A28D0008FF4F4 /* WebMouseEvent.cpp */,
    45144520                                BCF69F981176CED600471A52 /* WebNavigationDataStore.h */,
    4515                                 BC857FB412B830E600EDEB2E /* WebOpenPanelParameters.cpp */,
    4516                                 BC857FB312B830E600EDEB2E /* WebOpenPanelParameters.h */,
    45174521                                C06C6093124C14430001682F /* WebPageCreationParameters.cpp */,
    45184522                                C06C6094124C14430001682F /* WebPageCreationParameters.h */,
     
    51375141                                1AD60F5B18E20F4C0020C034 /* WKWindowFeatures.mm */,
    51385142                                1AD60F5F18E20F740020C034 /* WKWindowFeaturesInternal.h */,
     5143                                1ACC50EF1CBC381D003C7D03 /* WKOpenPanelParameters.mm */,
     5144                                1ACC50F01CBC381D003C7D03 /* WKOpenPanelParameters.h */,
     5145                                1A67CD2D1CBC513F00BFE3EA /* WKOpenPanelParametersInternal.h */,
    51395146                        );
    51405147                        path = Cocoa;
     
    59835990                                99C81D5B1C20E817005C4C82 /* APIAutomationClient.h */,
    59845991                                990D28B31C6526D400986977 /* APIAutomationSessionClient.h */,
     5992                                BC857FB412B830E600EDEB2E /* APIOpenPanelParameters.cpp */,
     5993                                BC857FB312B830E600EDEB2E /* APIOpenPanelParameters.h */,
    59855994                                076E884D1A13CADF005E90FC /* APIContextMenuClient.h */,
    59865995                                83891B621A68B3420030F386 /* APIDiagnosticLoggingClient.h */,
     
    73487357                                A1DF631318E0B7C8003A3E2A /* DownloadClient.h in Headers */,
    73497358                                1AB7D4CA1288AAA700CFD08C /* DownloadProxy.h in Headers */,
     7359                                1ACC50F21CBC381D003C7D03 /* WKOpenPanelParameters.h in Headers */,
    73507360                                1AD25E96167AB08100EA9BCD /* DownloadProxyMap.h in Headers */,
    73517361                                1AB7D61A1288B9D900CFD08C /* DownloadProxyMessages.h in Headers */,
     
    77087718                                31A2EC4B148997C200810D71 /* WebNotificationManagerProxy.h in Headers */,
    77097719                                31A2EC4E148997C200810D71 /* WebNotificationProvider.h in Headers */,
    7710                                 BC857FB512B830E600EDEB2E /* WebOpenPanelParameters.h in Headers */,
     7720                                BC857FB512B830E600EDEB2E /* APIOpenPanelParameters.h in Headers */,
    77117721                                BC857F8512B82D0B00EDEB2E /* WebOpenPanelResultListener.h in Headers */,
    77127722                                BC1DFEA412B31F87005DF730 /* WebOpenPanelResultListenerProxy.h in Headers */,
     
    78257835                                51A728DE1B1BAD3800102EEE /* WKBundleNavigationActionPrivate.h in Headers */,
    78267836                                BC4BEFE1120A1A4C00FBA0C7 /* WKBundleNodeHandle.h in Headers */,
     7837                                1A67CD2E1CBC513F00BFE3EA /* WKOpenPanelParametersInternal.h in Headers */,
    78277838                                BC57450C1263B155006F0F12 /* WKBundleNodeHandlePrivate.h in Headers */,
    78287839                                BC20528111C94284008F3375 /* WKBundlePage.h in Headers */,
     
    90369047                                1A6420E412DCE2FF00CAAE2C /* ShareableBitmap.cpp in Sources */,
    90379048                                C01A260112662F2100C9ED55 /* ShareableBitmapCG.cpp in Sources */,
     9049                                1ACC50F11CBC381D003C7D03 /* WKOpenPanelParameters.mm in Sources */,
    90389050                                51217460164C20E30037A5C1 /* ShareableResource.cpp in Sources */,
    90399051                                1A24BF3A120896A600FBB059 /* SharedMemoryMac.cpp in Sources */,
     
    91919203                                31A2EC4A148997C200810D71 /* WebNotificationManagerProxy.cpp in Sources */,
    91929204                                31A2EC4D148997C200810D71 /* WebNotificationProvider.cpp in Sources */,
    9193                                 BC857FB612B830E600EDEB2E /* WebOpenPanelParameters.cpp in Sources */,
     9205                                BC857FB612B830E600EDEB2E /* APIOpenPanelParameters.cpp in Sources */,
    91949206                                BC857F8612B82D0B00EDEB2E /* WebOpenPanelResultListener.cpp in Sources */,
    91959207                                BC857F7E12B82CEE00EDEB2E /* WebOpenPanelResultListenerProxy.cpp in Sources */,
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp

    r199286 r199554  
    4444#include "WebHitTestResultData.h"
    4545#include "WebImage.h"
    46 #include "WebOpenPanelParameters.h"
    4746#include "WebOpenPanelResultListener.h"
    4847#include "WebPage.h"
     
    719718    ASSERT(webFrame);
    720719
    721     m_page->send(Messages::WebPageProxy::RunOpenPanel(webFrame->frameID(), fileChooser->settings()));
     720    m_page->send(Messages::WebPageProxy::RunOpenPanel(webFrame->frameID(), SecurityOriginData::fromFrame(frame), fileChooser->settings()));
    722721}
    723722
  • trunk/Tools/ChangeLog

    r199550 r199554  
     12016-04-14  Anders Carlsson  <andersca@apple.com>
     2
     3        [Mac] Add API for open panel handling to WKWebView
     4        https://bugs.webkit.org/show_bug.cgi?id=137759
     5        rdar://problem/23278623
     6
     7        Reviewed by Tim Horton.
     8
     9        Have MiniBrowser implement the new delegate method.
     10
     11        * MiniBrowser/mac/WK2BrowserWindowController.m:
     12        (-[WK2BrowserWindowController webView:runOpenPanelWithParameters:initiatedByFrame:completionHandler:]):
     13
    1142016-04-14  Jon Lee  <jonlee@apple.com>
    215
  • trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m

    r198289 r199554  
    449449}
    450450
     451- (void)webView:(WKWebView *)webView runOpenPanelWithParameters:(WKOpenPanelParameters *)parameters initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(NSArray<NSURL *> * _Nullable result))completionHandler
     452{
     453    NSOpenPanel *openPanel = [NSOpenPanel openPanel];
     454
     455    openPanel.allowsMultipleSelection = parameters.allowsMultipleSelection;
     456
     457    [openPanel beginSheetModalForWindow:webView.window completionHandler:^(NSInteger result) {
     458        if (result == NSFileHandlingPanelOKButton)
     459            completionHandler(openPanel.URLs);
     460        else
     461            completionHandler(@[]);
     462    }];
     463}
     464
    451465- (void)updateTextFieldFromURL:(NSURL *)URL
    452466{
Note: See TracChangeset for help on using the changeset viewer.