WebKit2: Can't add files to an <input type=file>
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Dec 2010 21:52:51 +0000 (21:52 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Dec 2010 21:52:51 +0000 (21:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=51087

Reviewed by Anders Carlsson.

WebCore:

Add exported function.

* WebCore.exp.in:

WebKit2:

* Scripts/webkit2/messages.py:
Adds new types.

* Shared/API/c/WKBase.h:
Adds WKOpenPanelParametersRef and WKOpenPanelResultListenerRef.

* Shared/APIObject.h:
Adds TypeOpenPanelParameters and TypeOpenPanelResultListener.

* Shared/WebOpenPanelParameters.cpp: Added.
(WebKit::WebOpenPanelParameters::create):
(WebKit::WebOpenPanelParameters::WebOpenPanelParameters):
(WebKit::WebOpenPanelParameters::~WebOpenPanelParameters):
(WebKit::WebOpenPanelParameters::Data::encode):
(WebKit::WebOpenPanelParameters::Data::decode):
* Shared/WebOpenPanelParameters.h: Added.
(WebKit::WebOpenPanelParameters::allowMultipleFiles):
(WebKit::WebOpenPanelParameters::type):
Class representing options one can pass to open panel.

* UIProcess/API/C/WKAPICast.h:
Add casts for WebOpenPanelParameters and WebOpenPanelResultListenerProxy.

* UIProcess/API/C/WKOpenPanelParameters.cpp: Added.
(WKOpenPanelParametersGetTypeID):
(WKOpenPanelParametersGetAllowsMultipleFiles):
* UIProcess/API/C/WKOpenPanelParameters.h: Added.
* UIProcess/API/C/WKOpenPanelResultListener.cpp: Added.
(WKOpenPanelResultListenerGetTypeID):
(WKOpenPanelResultListenerChooseFiles):
(WKOpenPanelResultListenerCancel):
* UIProcess/API/C/WKOpenPanelResultListener.h: Added.
Add API wrappers.

* UIProcess/API/C/WKPage.h:
Add new UI callback, WKPageRunOpenPanelCallback.

* UIProcess/API/C/WebKit2.h:
Add includes for new API headers.

* UIProcess/API/qt/qwkpage.cpp:
(QWKPage::QWKPage):
Stub out the runOpenPanel callback.

* UIProcess/WebOpenPanelResultListenerProxy.cpp: Added.
(WebKit::WebOpenPanelResultListenerProxy::WebOpenPanelResultListenerProxy):
(WebKit::WebOpenPanelResultListenerProxy::~WebOpenPanelResultListenerProxy):
(WebKit::WebOpenPanelResultListenerProxy::chooseFiles):
(WebKit::WebOpenPanelResultListenerProxy::cancel):
(WebKit::WebOpenPanelResultListenerProxy::invalidate):
* UIProcess/WebOpenPanelResultListenerProxy.h: Added.
(WebKit::WebOpenPanelResultListenerProxy::create):
(WebKit::WebOpenPanelResultListenerProxy::type):
Adds the listener used to choose files for <input type=file>

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::runOpenPanel):
(WebKit::WebPageProxy::didChooseFilesForOpenPanel):
(WebKit::WebPageProxy::didCancelForOpenPanel):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/WebUIClient.cpp:
(WebKit::WebUIClient::runOpenPanel):
* UIProcess/WebUIClient.h:
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::runOpenPanel):
* WebProcess/WebPage/WebOpenPanelResultListener.cpp: Added.
(WebKit::WebOpenPanelResultListener::create):
(WebKit::WebOpenPanelResultListener::WebOpenPanelResultListener):
(WebKit::WebOpenPanelResultListener::~WebOpenPanelResultListener):
(WebKit::WebOpenPanelResultListener::didChooseFiles):
* WebProcess/WebPage/WebOpenPanelResultListener.h: Added.
(WebKit::WebOpenPanelResultListener::disconnectFromPage):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::close):
(WebKit::WebPage::setActiveOpenPanelResultListener):
(WebKit::WebPage::didChooseFilesForOpenPanel):
(WebKit::WebPage::didCancelForOpenPanel):
* WebProcess/WebPage/WebPage.h:
(WebKit::WebPage::activeOpenPanelResultListener):
* WebProcess/WebPage/WebPage.messages.in:
Pipe through file choosing.

* WebKit2.pro:
* WebKit2.xcodeproj/project.pbxproj:
* win/WebKit2.vcproj:
* win/WebKit2Generated.make:
Add new files.

WebKitTools:

* MiniBrowser/mac/BrowserWindowController.m:
(runOpenPanel):
(-[BrowserWindowController awakeFromNib]):
Add simple implementation of runOpenPanel callback.

* MiniBrowser/win/BrowserView.cpp:
(BrowserView::create):
* WebKitTestRunner/TestController.cpp:
(WTR::createOtherPage):
(WTR::TestController::initialize):
Stub out runOpenPanel callback.

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

37 files changed:
WebCore/ChangeLog
WebCore/WebCore.exp.in
WebKit2/ChangeLog
WebKit2/Scripts/webkit2/messages.py
WebKit2/Shared/API/c/WKBase.h
WebKit2/Shared/APIObject.h
WebKit2/Shared/WebOpenPanelParameters.cpp [new file with mode: 0644]
WebKit2/Shared/WebOpenPanelParameters.h [new file with mode: 0644]
WebKit2/UIProcess/API/C/WKAPICast.h
WebKit2/UIProcess/API/C/WKOpenPanelParameters.cpp [new file with mode: 0644]
WebKit2/UIProcess/API/C/WKOpenPanelParameters.h [new file with mode: 0644]
WebKit2/UIProcess/API/C/WKOpenPanelResultListener.cpp [new file with mode: 0644]
WebKit2/UIProcess/API/C/WKOpenPanelResultListener.h [new file with mode: 0644]
WebKit2/UIProcess/API/C/WKPage.h
WebKit2/UIProcess/API/C/WebKit2.h
WebKit2/UIProcess/API/qt/qwkpage.cpp
WebKit2/UIProcess/WebOpenPanelResultListenerProxy.cpp [new file with mode: 0644]
WebKit2/UIProcess/WebOpenPanelResultListenerProxy.h [new file with mode: 0644]
WebKit2/UIProcess/WebPageProxy.cpp
WebKit2/UIProcess/WebPageProxy.h
WebKit2/UIProcess/WebPageProxy.messages.in
WebKit2/UIProcess/WebUIClient.cpp
WebKit2/UIProcess/WebUIClient.h
WebKit2/WebKit2.pro
WebKit2/WebKit2.xcodeproj/project.pbxproj
WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
WebKit2/WebProcess/WebPage/WebOpenPanelResultListener.cpp [new file with mode: 0644]
WebKit2/WebProcess/WebPage/WebOpenPanelResultListener.h [new file with mode: 0644]
WebKit2/WebProcess/WebPage/WebPage.cpp
WebKit2/WebProcess/WebPage/WebPage.h
WebKit2/WebProcess/WebPage/WebPage.messages.in
WebKit2/win/WebKit2.vcproj
WebKit2/win/WebKit2Generated.make
WebKitTools/ChangeLog
WebKitTools/MiniBrowser/mac/BrowserWindowController.m
WebKitTools/MiniBrowser/win/BrowserView.cpp
WebKitTools/WebKitTestRunner/TestController.cpp

index 63ac79a..b645203 100644 (file)
@@ -1,3 +1,14 @@
+2010-12-15  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Anders Carlsson.
+
+        WebKit2: Can't add files to an <input type=file>
+        https://bugs.webkit.org/show_bug.cgi?id=51087
+
+        Add exported function.
+
+        * WebCore.exp.in:
+
 2010-12-15  Andreas Kling  <andreas.kling@nokia.com>
 
         Reviewed by Antonio Gomes.
index f9480aa..2e41cd8 100644 (file)
@@ -223,10 +223,10 @@ __ZN7WebCore12EventHandler15handleAccessKeyERKNS_21PlatformKeyboardEventE
 __ZN7WebCore12EventHandler15sendScrollEventEv
 __ZN7WebCore12EventHandler16handleWheelEventERNS_18PlatformWheelEventE
 __ZN7WebCore12EventHandler17scrollRecursivelyENS_15ScrollDirectionENS_17ScrollGranularityEPNS_4NodeE
-__ZN7WebCore12EventHandler24logicalScrollRecursivelyENS_22ScrollLogicalDirectionENS_17ScrollGranularityEPNS_4NodeE
 __ZN7WebCore12EventHandler20hitTestResultAtPointERKNS_8IntPointEbbNS_17HitTestScrollbarsEjRKNS_7IntSizeE
 __ZN7WebCore12EventHandler21handleMousePressEventERKNS_18PlatformMouseEventE
 __ZN7WebCore12EventHandler23handleMouseReleaseEventERKNS_18PlatformMouseEventE
+__ZN7WebCore12EventHandler24logicalScrollRecursivelyENS_22ScrollLogicalDirectionENS_17ScrollGranularityEPNS_4NodeE
 __ZN7WebCore12EventHandler27capsLockStateMayHaveChangedEv
 __ZN7WebCore12EventHandler7mouseUpEP7NSEvent
 __ZN7WebCore12EventHandler8keyEventEP7NSEvent
@@ -273,6 +273,7 @@ __ZN7WebCore12SharedBuffer12createNSDataEv
 __ZN7WebCore12SharedBuffer24createWithContentsOfFileERKN3WTF6StringE
 __ZN7WebCore12SharedBufferC1EPKci
 __ZN7WebCore12SharedBufferD1Ev
+__ZN7WebCore12SpellChecker8didCheckEiRKN3WTF6VectorINS_19SpellCheckingResultELm0EEE
 __ZN7WebCore12TextEncodingC1ERKN3WTF6StringE
 __ZN7WebCore12TextIterator11rangeLengthEPKNS_5RangeEb
 __ZN7WebCore12TextIterator26rangeFromLocationAndLengthEPNS_7ElementEiib
@@ -519,9 +520,9 @@ __ZN7WebCore23ReplaceSelectionCommandC1EPNS_8DocumentEN3WTF10PassRefPtrINS_16Doc
 __ZN7WebCore23createFragmentFromNodesEPNS_8DocumentERKN3WTF6VectorIPNS_4NodeELm0EEE
 __ZN7WebCore23overrideDefaultLanguageERKN3WTF6StringE
 __ZN7WebCore24BinaryPropertyListWriter17writePropertyListEv
-__ZN7WebCore24DocumentMarkerController14markersForNodeEPNS_4NodeE
 __ZN7WebCore24DocumentMarkerController13removeMarkersENS_14DocumentMarker10MarkerTypeE
 __ZN7WebCore24DocumentMarkerController14markersForNodeEPNS_4NodeE
+__ZN7WebCore24DocumentMarkerController14markersForNodeEPNS_4NodeE
 __ZN7WebCore24DocumentMarkerController23renderedRectsForMarkersENS_14DocumentMarker10MarkerTypeE
 __ZN7WebCore24contextMenuItemTagItalicEv
 __ZN7WebCore24contextMenuItemTagStylesEv
@@ -924,7 +925,6 @@ __ZN7WebCore9makeRangeERKNS_15VisiblePositionES2_
 __ZN7WebCore9pageCacheEv
 __ZN7WebCore9plainTextEPKNS_5RangeENS_20TextIteratorBehaviorE
 __ZN7WebCore9toElementEN3JSC7JSValueE
-__ZN7WebCore12SpellChecker8didCheckEiRKN3WTF6VectorINS_19SpellCheckingResultELm0EEE
 __ZNK3JSC8Bindings10RootObject12globalObjectEv
 __ZNK3WTF6String14createCFStringEv
 __ZNK7WebCore10Credential11persistenceEv
@@ -1090,6 +1090,7 @@ __ZNK7WebCore4Font10floatWidthERKNS_7TextRunEPN3WTF7HashSetIPKNS_14SimpleFontDat
 __ZNK7WebCore4Font8drawTextEPNS_15GraphicsContextERKNS_7TextRunERKNS_10FloatPointEii
 __ZNK7WebCore4KURL11createCFURLEv
 __ZNK7WebCore4KURL11isLocalFileEv
+__ZNK7WebCore4KURL14fileSystemPathEv
 __ZNK7WebCore4KURL17lastPathComponentEv
 __ZNK7WebCore4KURL4hostEv
 __ZNK7WebCore4KURL4pathEv
index aa8c33e..ee22d95 100644 (file)
@@ -1,3 +1,99 @@
+2010-12-15  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Anders Carlsson.
+
+        WebKit2: Can't add files to an <input type=file>
+        https://bugs.webkit.org/show_bug.cgi?id=51087
+
+        * Scripts/webkit2/messages.py:
+        Adds new types.
+
+        * Shared/API/c/WKBase.h:
+        Adds WKOpenPanelParametersRef and WKOpenPanelResultListenerRef.
+
+        * Shared/APIObject.h:
+        Adds TypeOpenPanelParameters and TypeOpenPanelResultListener.
+
+        * Shared/WebOpenPanelParameters.cpp: Added.
+        (WebKit::WebOpenPanelParameters::create):
+        (WebKit::WebOpenPanelParameters::WebOpenPanelParameters):
+        (WebKit::WebOpenPanelParameters::~WebOpenPanelParameters):
+        (WebKit::WebOpenPanelParameters::Data::encode):
+        (WebKit::WebOpenPanelParameters::Data::decode):
+        * Shared/WebOpenPanelParameters.h: Added.
+        (WebKit::WebOpenPanelParameters::allowMultipleFiles):
+        (WebKit::WebOpenPanelParameters::type):
+        Class representing options one can pass to open panel.
+
+        * UIProcess/API/C/WKAPICast.h:
+        Add casts for WebOpenPanelParameters and WebOpenPanelResultListenerProxy.
+
+        * UIProcess/API/C/WKOpenPanelParameters.cpp: Added.
+        (WKOpenPanelParametersGetTypeID):
+        (WKOpenPanelParametersGetAllowsMultipleFiles):
+        * UIProcess/API/C/WKOpenPanelParameters.h: Added.
+        * UIProcess/API/C/WKOpenPanelResultListener.cpp: Added.
+        (WKOpenPanelResultListenerGetTypeID):
+        (WKOpenPanelResultListenerChooseFiles):
+        (WKOpenPanelResultListenerCancel):
+        * UIProcess/API/C/WKOpenPanelResultListener.h: Added.
+        Add API wrappers.
+
+        * UIProcess/API/C/WKPage.h:
+        Add new UI callback, WKPageRunOpenPanelCallback.
+
+        * UIProcess/API/C/WebKit2.h:
+        Add includes for new API headers.
+
+        * UIProcess/API/qt/qwkpage.cpp:
+        (QWKPage::QWKPage):
+        Stub out the runOpenPanel callback.
+
+        * UIProcess/WebOpenPanelResultListenerProxy.cpp: Added.
+        (WebKit::WebOpenPanelResultListenerProxy::WebOpenPanelResultListenerProxy):
+        (WebKit::WebOpenPanelResultListenerProxy::~WebOpenPanelResultListenerProxy):
+        (WebKit::WebOpenPanelResultListenerProxy::chooseFiles):
+        (WebKit::WebOpenPanelResultListenerProxy::cancel):
+        (WebKit::WebOpenPanelResultListenerProxy::invalidate):
+        * UIProcess/WebOpenPanelResultListenerProxy.h: Added.
+        (WebKit::WebOpenPanelResultListenerProxy::create):
+        (WebKit::WebOpenPanelResultListenerProxy::type):
+        Adds the listener used to choose files for <input type=file>
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::runOpenPanel):
+        (WebKit::WebPageProxy::didChooseFilesForOpenPanel):
+        (WebKit::WebPageProxy::didCancelForOpenPanel):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/WebUIClient.cpp:
+        (WebKit::WebUIClient::runOpenPanel):
+        * UIProcess/WebUIClient.h:
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::runOpenPanel):
+        * WebProcess/WebPage/WebOpenPanelResultListener.cpp: Added.
+        (WebKit::WebOpenPanelResultListener::create):
+        (WebKit::WebOpenPanelResultListener::WebOpenPanelResultListener):
+        (WebKit::WebOpenPanelResultListener::~WebOpenPanelResultListener):
+        (WebKit::WebOpenPanelResultListener::didChooseFiles):
+        * WebProcess/WebPage/WebOpenPanelResultListener.h: Added.
+        (WebKit::WebOpenPanelResultListener::disconnectFromPage):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::close):
+        (WebKit::WebPage::setActiveOpenPanelResultListener):
+        (WebKit::WebPage::didChooseFilesForOpenPanel):
+        (WebKit::WebPage::didCancelForOpenPanel):
+        * WebProcess/WebPage/WebPage.h:
+        (WebKit::WebPage::activeOpenPanelResultListener):
+        * WebProcess/WebPage/WebPage.messages.in:
+        Pipe through file choosing.
+
+        * WebKit2.pro:
+        * WebKit2.xcodeproj/project.pbxproj:
+        * win/WebKit2.vcproj:
+        * win/WebKit2Generated.make:
+        Add new files.
+
 2010-12-15  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Maciej Stachowiak.
index 8fb6f8c..4adabae 100644 (file)
@@ -249,8 +249,8 @@ def message_to_struct_declaration(message):
 
 def struct_or_class(namespace, type):
     structs = frozenset([
-        'WebCore::KeypressCommand',
         'WebCore::CompositionUnderline',
+        'WebCore::KeypressCommand',
         'WebCore::PluginInfo',
         'WebCore::ViewportArguments',
         'WebCore::WindowFeatures',
@@ -258,6 +258,7 @@ def struct_or_class(namespace, type):
         'WebKit::PlatformPopupMenuData',
         'WebKit::PluginProcessCreationParameters',
         'WebKit::WebNavigationDataStore',
+        'WebKit::WebOpenPanelParameters::Data',
         'WebKit::WebPageCreationParameters',
         'WebKit::WebPreferencesStore',
         'WebKit::WebProcessCreationParameters',
@@ -411,13 +412,13 @@ def headers_for_type(type):
 
     special_cases = {
         'WTF::String': '<wtf/text/WTFString.h>',
+        'WebCore::CompositionUnderline': '<WebCore/Editor.h>',
         'WebCore::KeypressCommand': '<WebCore/KeyboardEvent.h>',
         'WebCore::PluginInfo': '<WebCore/PluginData.h>',
-        'WebCore::CompositionUnderline': '<WebCore/Editor.h>',
         'WebKit::WebKeyboardEvent': '"WebEvent.h"',
         'WebKit::WebMouseEvent': '"WebEvent.h"',
-        'WebKit::WebWheelEvent': '"WebEvent.h"',
         'WebKit::WebTouchEvent': '"WebEvent.h"',
+        'WebKit::WebWheelEvent': '"WebEvent.h"',
     }
     if type in special_cases:
         return [special_cases[type]]
index 08eb5e3..cf5bb5b 100644 (file)
@@ -73,6 +73,8 @@ typedef const struct OpaqueWKFrame* WKFrameRef;
 typedef const struct OpaqueWKFramePolicyListener* WKFramePolicyListenerRef;
 typedef const struct OpaqueWKInspector* WKInspectorRef;
 typedef const struct OpaqueWKNavigationData* WKNavigationDataRef;
+typedef const struct OpaqueWKOpenPanelParameters* WKOpenPanelParametersRef;
+typedef const struct OpaqueWKOpenPanelResultListener* WKOpenPanelResultListenerRef;
 typedef const struct OpaqueWKPage* WKPageRef;
 typedef const struct OpaqueWKPageGroup* WKPageGroupRef;
 typedef const struct OpaqueWKPreferences* WKPreferencesRef;
index 52b7a57..e625b3a 100644 (file)
@@ -69,6 +69,8 @@ public:
         TypeFramePolicyListener,
         TypeInspector,
         TypeNavigationData,
+        TypeOpenPanelParameters,
+        TypeOpenPanelResultListener,
         TypePage,
         TypePageGroup,
         TypePreferences,
diff --git a/WebKit2/Shared/WebOpenPanelParameters.cpp b/WebKit2/Shared/WebOpenPanelParameters.cpp
new file mode 100644 (file)
index 0000000..821477b
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include "WebOpenPanelParameters.h"
+
+#include "WebCoreArgumentCoders.h"
+
+namespace WebKit {
+
+PassRefPtr<WebOpenPanelParameters> WebOpenPanelParameters::create(const Data& data)
+{
+    return adoptRef(new WebOpenPanelParameters(data));
+}
+
+WebOpenPanelParameters::WebOpenPanelParameters(const Data& data)
+    : m_data(data)
+{
+}
+
+WebOpenPanelParameters::~WebOpenPanelParameters()
+{
+}
+
+void WebOpenPanelParameters::Data::encode(CoreIPC::ArgumentEncoder* encoder) const
+{
+    encoder->encode(CoreIPC::In(allowMultipleFiles, allowsDirectoryUpload, acceptTypes, filenames));
+}
+
+bool WebOpenPanelParameters::Data::decode(CoreIPC::ArgumentDecoder* decoder, Data& result)
+{
+    return decoder->decode(CoreIPC::Out(result.allowMultipleFiles, result.allowsDirectoryUpload, result.acceptTypes, result.filenames));
+}
+
+} // namespace WebCore
diff --git a/WebKit2/Shared/WebOpenPanelParameters.h b/WebKit2/Shared/WebOpenPanelParameters.h
new file mode 100644 (file)
index 0000000..e8546dc
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef WebOpenPanelParameters_h
+#define WebOpenPanelParameters_h
+
+#include "APIObject.h"
+#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
+
+namespace CoreIPC {
+    class ArgumentDecoder;
+    class ArgumentEncoder;
+}
+
+namespace WebKit {
+
+class WebOpenPanelParameters : public APIObject {
+public:
+    static const Type APIType = TypeOpenPanelParameters;
+
+    struct Data {
+        void encode(CoreIPC::ArgumentEncoder*) const;
+        static bool decode(CoreIPC::ArgumentDecoder*, Data&);
+
+        bool allowMultipleFiles;
+        bool allowsDirectoryUpload;
+        String acceptTypes;
+        Vector<String> filenames;
+    };
+
+    static PassRefPtr<WebOpenPanelParameters> create(const Data&);
+    ~WebOpenPanelParameters();
+
+    bool allowMultipleFiles() const { return m_data.allowMultipleFiles; } 
+
+private:
+    explicit WebOpenPanelParameters(const Data&);
+
+    virtual Type type() const { return APIType; }
+
+    Data m_data;
+};
+
+} // namespace WebKit
+
+#endif // WebOpenPanelParameters_h
index 93c28a6..b8ffcc4 100644 (file)
@@ -53,6 +53,8 @@ class WebFramePolicyListenerProxy;
 class WebFrameProxy;
 class WebInspectorProxy;
 class WebNavigationData;
+class WebOpenPanelParameters;
+class WebOpenPanelResultListenerProxy;
 class WebPageGroup;
 class WebPageProxy;
 class WebPreferences;
@@ -70,6 +72,8 @@ WK_ADD_API_MAPPING(WKFormSubmissionListenerRef, WebFormSubmissionListenerProxy)
 WK_ADD_API_MAPPING(WKFramePolicyListenerRef, WebFramePolicyListenerProxy)
 WK_ADD_API_MAPPING(WKFrameRef, WebFrameProxy)
 WK_ADD_API_MAPPING(WKNavigationDataRef, WebNavigationData)
+WK_ADD_API_MAPPING(WKOpenPanelParametersRef, WebOpenPanelParameters)
+WK_ADD_API_MAPPING(WKOpenPanelResultListenerRef, WebOpenPanelResultListenerProxy)
 WK_ADD_API_MAPPING(WKPageGroupRef, WebPageGroup)
 WK_ADD_API_MAPPING(WKPageRef, WebPageProxy)
 WK_ADD_API_MAPPING(WKPreferencesRef, WebPreferences)
diff --git a/WebKit2/UIProcess/API/C/WKOpenPanelParameters.cpp b/WebKit2/UIProcess/API/C/WKOpenPanelParameters.cpp
new file mode 100644 (file)
index 0000000..3cf89cf
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include "WKOpenPanelParameters.h"
+
+#include "WKAPICast.h"
+#include "WebOpenPanelParameters.h"
+
+using namespace WebKit;
+
+WKTypeID WKOpenPanelParametersGetTypeID()
+{
+    return toAPI(WebOpenPanelParameters::APIType);
+}
+
+bool WKOpenPanelParametersGetAllowsMultipleFiles(WKOpenPanelParametersRef parametersRef)
+{
+    return toImpl(parametersRef)->allowMultipleFiles();
+}
diff --git a/WebKit2/UIProcess/API/C/WKOpenPanelParameters.h b/WebKit2/UIProcess/API/C/WKOpenPanelParameters.h
new file mode 100644 (file)
index 0000000..f32731c
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef WKOpenPanelParameters_h
+#define WKOpenPanelParameters_h
+
+#include <WebKit2/WKBase.h>
+
+#ifndef __cplusplus
+#include <stdbool.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKOpenPanelParametersGetTypeID();
+
+WK_EXPORT bool WKOpenPanelParametersGetAllowsMultipleFiles(WKOpenPanelParametersRef parameters);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKOpenPanelParameters_h */
diff --git a/WebKit2/UIProcess/API/C/WKOpenPanelResultListener.cpp b/WebKit2/UIProcess/API/C/WKOpenPanelResultListener.cpp
new file mode 100644 (file)
index 0000000..5b143f2
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include "WKOpenPanelResultListener.h"
+
+#include "WKAPICast.h"
+#include "WebOpenPanelResultListenerProxy.h"
+
+using namespace WebKit;
+
+WKTypeID WKOpenPanelResultListenerGetTypeID()
+{
+    return toAPI(WebOpenPanelResultListenerProxy::APIType);
+}
+
+void WKOpenPanelResultListenerChooseFiles(WKOpenPanelResultListenerRef listenerRef, WKArrayRef fileURLsRef)
+{
+    toImpl(listenerRef)->chooseFiles(toImpl(fileURLsRef));
+}
+
+void WKOpenPanelResultListenerCancel(WKOpenPanelResultListenerRef listenerRef)
+{
+    toImpl(listenerRef)->cancel();
+}
diff --git a/WebKit2/UIProcess/API/C/WKOpenPanelResultListener.h b/WebKit2/UIProcess/API/C/WKOpenPanelResultListener.h
new file mode 100644 (file)
index 0000000..d581738
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef WKOpenPanelResultListener_h
+#define WKOpenPanelResultListener_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKOpenPanelResultListenerGetTypeID();
+
+WK_EXPORT void WKOpenPanelResultListenerChooseFiles(WKOpenPanelResultListenerRef listener, WKArrayRef fileURLs);
+WK_EXPORT void WKOpenPanelResultListenerCancel(WKOpenPanelResultListenerRef listener);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKOpenPanelResultListener_h */
index 8a82b81..7b2919a 100644 (file)
@@ -154,7 +154,7 @@ typedef bool (*WKPageRunBeforeUnloadConfirmPanelCallback)(WKPageRef page, WKStri
 typedef void (*WKPageDidDrawCallback)(WKPageRef page, const void *clientInfo);
 typedef void (*WKPageDidScrollCallback)(WKPageRef page, const void *clientInfo);
 typedef unsigned long long (*WKPageExceededDatabaseQuotaCallback)(WKPageRef page, WKFrameRef frame, WKSecurityOriginRef origin, WKStringRef databaseName, WKStringRef displayName, unsigned long long currentQuota, unsigned long long currentUsage, unsigned long long expectedUsage, const void *clientInfo);
-
+typedef void (*WKPageRunOpenPanelCallback)(WKPageRef page, WKFrameRef frame, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener, const void *clientInfo);
 
 struct WKPageUIClient {
     int                                                                 version;
@@ -182,6 +182,7 @@ struct WKPageUIClient {
     WKPageDidDrawCallback                                               didDraw;
     WKPageDidScrollCallback                                             pageDidScroll;
     WKPageExceededDatabaseQuotaCallback                                 exceededDatabaseQuota;
+    WKPageRunOpenPanelCallback                                          runOpenPanel;
 };
 typedef struct WKPageUIClient WKPageUIClient;
 
index 70d8aaf..5c56722 100644 (file)
@@ -43,6 +43,8 @@
 #include <WebKit2/WKMutableDictionary.h>
 #include <WebKit2/WKNavigationData.h>
 #include <WebKit2/WKNumber.h>
+#include <WebKit2/WKOpenPanelParameters.h>
+#include <WebKit2/WKOpenPanelResultListener.h>
 #include <WebKit2/WKPage.h>
 #include <WebKit2/WKPageGroup.h>
 #include <WebKit2/WKPreferences.h>
index f445d2f..3f6d15e 100644 (file)
@@ -360,7 +360,8 @@ QWKPage::QWKPage(QWKContext* context)
         0,  /* runBeforeUnloadConfirmPanel */
         0,  /* didDraw */
         0,  /* pageDidScroll */
-        0   /* exceededDatabaseQuota */
+        0,  /* exceededDatabaseQuota */
+        0   /* runOpenPanel */
     };
     WKPageSetPageUIClient(pageRef(), &uiClient);
 }
diff --git a/WebKit2/UIProcess/WebOpenPanelResultListenerProxy.cpp b/WebKit2/UIProcess/WebOpenPanelResultListenerProxy.cpp
new file mode 100644 (file)
index 0000000..de2d174
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include "WebOpenPanelResultListenerProxy.h"
+
+#include "ImmutableArray.h"
+#include "WebPageProxy.h"
+#include <WebCore/KURL.h>
+#include <wtf/Vector.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebOpenPanelResultListenerProxy::WebOpenPanelResultListenerProxy(WebPageProxy* page)
+    : m_page(page)
+{
+}
+
+WebOpenPanelResultListenerProxy::~WebOpenPanelResultListenerProxy()
+{
+}
+
+void WebOpenPanelResultListenerProxy::chooseFiles(ImmutableArray* fileURLsArray)
+{
+    if (!m_page)
+        return;
+
+    size_t size = fileURLsArray->size();
+
+    Vector<String> filePaths;
+    filePaths.reserveInitialCapacity(size);
+
+    for (size_t i = 0; i < size; ++i) {
+        WebURL* webURL = fileURLsArray->at<WebURL>(i);
+        if (webURL) {
+            KURL url(KURL(), webURL->string()); 
+            filePaths.uncheckedAppend(url.fileSystemPath());
+        }
+    }
+
+    m_page->didChooseFilesForOpenPanel(filePaths);
+}
+
+void WebOpenPanelResultListenerProxy::cancel()
+{
+    if (!m_page)
+        return;
+
+    m_page->didCancelForOpenPanel();
+}
+
+void WebOpenPanelResultListenerProxy::invalidate()
+{
+    m_page = 0;
+}
+
+} // namespace WebKit
diff --git a/WebKit2/UIProcess/WebOpenPanelResultListenerProxy.h b/WebKit2/UIProcess/WebOpenPanelResultListenerProxy.h
new file mode 100644 (file)
index 0000000..ba931dc
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef WebOpenPanelResultListenerProxy_h
+#define WebOpenPanelResultListenerProxy_h
+
+#include "APIObject.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebKit {
+
+class ImmutableArray;
+class WebPageProxy;
+
+class WebOpenPanelResultListenerProxy : public APIObject {
+public:
+    static const Type APIType = TypeFramePolicyListener;
+
+    static PassRefPtr<WebOpenPanelResultListenerProxy> create(WebPageProxy* page)
+    {
+        return adoptRef(new WebOpenPanelResultListenerProxy(page));
+    }
+
+    virtual ~WebOpenPanelResultListenerProxy();
+
+    void chooseFiles(ImmutableArray*);
+    void cancel();
+
+    void invalidate();
+
+private:
+    WebOpenPanelResultListenerProxy(WebPageProxy*);
+
+    virtual Type type() const { return APIType; }
+
+    RefPtr<WebPageProxy> m_page;
+};
+
+} // namespace WebKit
+
+#endif // WebOpenPanelResultListenerProxy_h
index a3f2fea..8f6c298 100644 (file)
@@ -47,6 +47,7 @@
 #include "WebEvent.h"
 #include "WebFormSubmissionListenerProxy.h"
 #include "WebFramePolicyListenerProxy.h"
+#include "WebOpenPanelResultListenerProxy.h"
 #include "WebPageCreationParameters.h"
 #include "WebPageGroup.h"
 #include "WebPageGroupData.h"
@@ -231,6 +232,11 @@ void WebPageProxy::close()
     }
 #endif
 
+    if (m_openPanelResultListener) {
+        m_openPanelResultListener->invalidate();
+        m_openPanelResultListener = 0;
+    }
+
     m_pageTitle = String();
     m_toolTip = String();
 
@@ -1251,6 +1257,19 @@ void WebPageProxy::pageDidScroll()
     m_uiClient.pageDidScroll(this);
 }
 
+void WebPageProxy::runOpenPanel(uint64_t frameID, const WebOpenPanelParameters::Data& data)
+{
+    if (m_openPanelResultListener) {
+        m_openPanelResultListener->invalidate();
+        m_openPanelResultListener = 0;
+    }
+
+    m_openPanelResultListener = WebOpenPanelResultListenerProxy::create(this);
+
+    if (!m_uiClient.runOpenPanel(this, process()->webFrame(frameID), data, m_openPanelResultListener.get()))
+        didCancelForOpenPanel();
+}
+
 #if PLATFORM(QT)
 void WebPageProxy::didChangeContentsSize(const WebCore::IntSize& size)
 {
@@ -1433,6 +1452,29 @@ void WebPageProxy::contextMenuItemSelected(const WebContextMenuItemData& item)
     process()->send(Messages::WebPage::DidSelectItemFromActiveContextMenu(item), m_pageID);
 }
 
+void WebPageProxy::didChooseFilesForOpenPanel(const Vector<String>& fileURLs)
+{
+    if (!isValid())
+        return;
+
+    // FIXME: This also needs to send a sandbox extension for these paths.
+    process()->send(Messages::WebPage::DidChooseFilesForOpenPanel(fileURLs), m_pageID);
+
+    m_openPanelResultListener->invalidate();
+    m_openPanelResultListener = 0;
+}
+
+void WebPageProxy::didCancelForOpenPanel()
+{
+    if (!isValid())
+        return;
+
+    process()->send(Messages::WebPage::DidCancelForOpenPanel(), m_pageID);
+    
+    m_openPanelResultListener->invalidate();
+    m_openPanelResultListener = 0;
+}
+
 void WebPageProxy::registerEditCommand(PassRefPtr<WebEditCommandProxy> commandProxy, UndoOrRedo undoOrRedo)
 {
     m_pageClient->registerEditCommand(commandProxy, undoOrRedo);
@@ -1617,6 +1659,11 @@ void WebPageProxy::processDidCrash()
     }
 #endif
 
+    if (m_openPanelResultListener) {
+        m_openPanelResultListener->invalidate();
+        m_openPanelResultListener = 0;
+    }
+
     m_pageTitle = String();
     m_toolTip = String();
 
index d8f0cb2..977ef2b 100644 (file)
@@ -78,6 +78,7 @@ class NativeWebKeyboardEvent;
 class PageClient;
 class PlatformCertificateInfo;
 class StringPairVector;
+class WebOpenPanelResultListenerProxy;
 class WebBackForwardList;
 class WebBackForwardListItem;
 class WebContextMenuProxy;
@@ -270,8 +271,13 @@ public:
     void setResizesToContentsUsingLayoutSize(const WebCore::IntSize&);
 #endif
 
+    // Called by the WebContextMenuProxy.
     void contextMenuItemSelected(const WebContextMenuItemData&);
 
+    // Called by the WebOpenPanelResultListenerProxy.
+    void didChooseFilesForOpenPanel(const Vector<String>&);
+    void didCancelForOpenPanel();
+
     WebPageCreationParameters creationParameters(const WebCore::IntSize&) const;
 
 #if PLATFORM(QT)
@@ -338,6 +344,8 @@ private:
     void runBeforeUnloadConfirmPanel(const String& message, uint64_t frameID, bool& shouldClose);
     void didChangeViewportData(const WebCore::ViewportArguments&);
     void pageDidScroll();
+    void runOpenPanel(uint64_t frameID, const WebOpenPanelParameters::Data&);
+
 #if ENABLE(TILED_BACKING_STORE)
     void pageDidRequestScroll(const WebCore::IntSize&);
 #endif
@@ -438,6 +446,7 @@ private:
 
     RefPtr<WebPopupMenuProxy> m_activePopupMenu;
     RefPtr<WebContextMenuProxy> m_activeContextMenu;
+    RefPtr<WebOpenPanelResultListenerProxy> m_openPanelResultListener;
 
     double m_estimatedProgress;
 
index 446b907..d450c14 100644 (file)
@@ -50,6 +50,8 @@ messages -> WebPageProxy {
     CanRunBeforeUnloadConfirmPanel() -> (bool canRun)
     RunBeforeUnloadConfirmPanel(WTF::String message, uint64_t frameID) -> (bool shouldClose)
     PageDidScroll()
+    RunOpenPanel(uint64_t frameID, WebKit::WebOpenPanelParameters::Data parameters)
+
 #if ENABLE(TILED_BACKING_STORE)
     PageDidRequestScroll(WebCore::IntSize delta)
 #endif
index 4782311..36fafae 100644 (file)
@@ -29,6 +29,7 @@
 #include "NativeWebKeyboardEvent.h"
 #include "WKAPICast.h"
 #include "WebNumber.h"
+#include "WebOpenPanelResultListenerProxy.h"
 #include "WebPageProxy.h"
 #include <WebCore/FloatRect.h>
 #include <WebCore/IntSize.h>
@@ -245,4 +246,14 @@ unsigned long long WebUIClient::exceededDatabaseQuota(WebPageProxy* page, WebFra
     return m_client.exceededDatabaseQuota(toAPI(page), toAPI(frame), toAPI(origin), toAPI(databaseName.impl()), toAPI(databaseDisplayName.impl()), currentQuota, currentUsage, expectedUsage, m_client.clientInfo);
 }
 
+bool WebUIClient::runOpenPanel(WebPageProxy* page, WebFrameProxy* frame, const WebOpenPanelParameters::Data& parameterData, WebOpenPanelResultListenerProxy* listener)
+{
+    if (!m_client.runOpenPanel)
+        return false;
+
+    RefPtr<WebOpenPanelParameters> parameters = WebOpenPanelParameters::create(parameterData);
+    m_client.runOpenPanel(toAPI(page), toAPI(frame), toAPI(parameters.get()), toAPI(listener), m_client.clientInfo);
+    return true;
+}
+
 } // namespace WebKit
index fe701d2..477a81c 100644 (file)
@@ -29,6 +29,7 @@
 #include "APIClient.h"
 #include "WKPage.h"
 #include "WebEvent.h"
+#include "WebOpenPanelParameters.h"
 #include <wtf/Forward.h>
 #include <wtf/PassRefPtr.h>
 
@@ -45,6 +46,7 @@ class NativeWebKeyboardEvent;
 class WebFrameProxy;
 class WebPageProxy;
 class WebSecurityOrigin;
+class WebOpenPanelResultListenerProxy;
 
 class WebUIClient : public APIClient<WKPageUIClient> {
 public:
@@ -80,6 +82,8 @@ public:
     void pageDidScroll(WebPageProxy*);
 
     unsigned long long exceededDatabaseQuota(WebPageProxy*, WebFrameProxy*, WebSecurityOrigin*, const String& databaseName, const String& databaseDisplayName, unsigned long long currentQuota, unsigned long long currentUsage, unsigned long long expectedUsage);
+
+    bool runOpenPanel(WebPageProxy*, WebFrameProxy*, const WebOpenPanelParameters::Data&, WebOpenPanelResultListenerProxy*);
 };
 
 } // namespace WebKit
index c61c0b7..60d6ea5 100644 (file)
@@ -261,6 +261,7 @@ HEADERS += \
     Shared/WebFindOptions.h \
     Shared/WebNavigationDataStore.h \
     Shared/WebNumber.h \
+    Shared/WebOpenPanelParameters.h \
     Shared/WebPageCreationParameters.h \
     Shared/WebPageGroupData.h \
     Shared/WebPopupItem.h \
@@ -288,6 +289,8 @@ HEADERS += \
     UIProcess/API/C/WKFrame.h \
     UIProcess/API/C/WKFramePolicyListener.h \
     UIProcess/API/C/WKInspector.h \
+    UIProcess/API/C/WKOpenPanelParameters.h \
+    UIProcess/API/C/WKOpenPanelResultListener.h \
     UIProcess/API/C/WKNavigationData.h \
     UIProcess/API/C/WKPage.h \
     UIProcess/API/C/WKPageGroup.h \
@@ -345,6 +348,7 @@ HEADERS += \
     UIProcess/WebLoaderClient.h \
     UIProcess/WebNavigationData.h \
     UIProcess/WebPageContextMenuClient.h \
+    UIProcess/WebOpenPanelResultListenerProxy.h \
     UIProcess/WebPageGroup.h \
     UIProcess/WebPageProxy.h \
     UIProcess/WebPolicyClient.h \
@@ -407,6 +411,7 @@ HEADERS += \
     WebProcess/WebPage/WebEditCommand.h \
     WebProcess/WebPage/WebFrame.h \
     WebProcess/WebPage/WebInspector.h \
+    WebProcess/WebPage/WebOpenPanelResultListener.h \
     WebProcess/WebPage/WebPage.h \
     WebProcess/WebPage/WebPageGroupProxy.h \
     WebProcess/WebProcess.h \
@@ -458,6 +463,7 @@ SOURCES += \
     Shared/WebEventConversion.cpp \
     Shared/WebKeyboardEvent.cpp \
     Shared/WebMouseEvent.cpp \
+    Shared/WebOpenPanelParameters.cpp \
     Shared/WebPageCreationParameters.cpp \
     Shared/WebPageGroupData.cpp \
     Shared/WebPlatformTouchPoint.cpp \
@@ -487,6 +493,8 @@ SOURCES += \
     UIProcess/API/C/WKFrame.cpp \
     UIProcess/API/C/WKFramePolicyListener.cpp \
     UIProcess/API/C/WKInspector.cpp \
+    UIProcess/API/C/WKOpenPanelParameters.cpp \
+    UIProcess/API/C/WKOpenPanelResultListener.cpp \
     UIProcess/API/C/WKNavigationData.cpp \
     UIProcess/API/C/WKPage.cpp \
     UIProcess/API/C/WKPageGroup.cpp \
@@ -536,6 +544,7 @@ SOURCES += \
     UIProcess/WebLoaderClient.cpp \
     UIProcess/WebNavigationData.cpp \
     UIProcess/WebPageContextMenuClient.cpp \
+    UIProcess/WebOpenPanelResultListenerProxy.cpp \
     UIProcess/WebPageGroup.cpp \
     UIProcess/WebPageProxy.cpp \
     UIProcess/WebPolicyClient.cpp \
@@ -617,9 +626,10 @@ SOURCES += \
     WebProcess/WebPage/WebEditCommand.cpp \
     WebProcess/WebPage/WebFrame.cpp \
     WebProcess/WebPage/WebInspector.cpp \
-    WebProcess/WebPage/qt/WebInspectorQt.cpp \
+    WebProcess/WebPage/WebOpenPanelResultListener.cpp \
     WebProcess/WebPage/WebPage.cpp \
     WebProcess/WebPage/WebPageGroupProxy.cpp \
+    WebProcess/WebPage/qt/WebInspectorQt.cpp \
     WebProcess/WebPage/qt/ChunkedUpdateDrawingAreaQt.cpp \
     WebProcess/WebPage/qt/TiledDrawingAreaQt.cpp \
     WebProcess/WebPage/qt/WebPageQt.cpp \
index dffa5c9..cec3215 100644 (file)
                BC1A7C581136E19C00FB7167 /* ProcessLauncher.h in Headers */ = {isa = PBXBuildFile; fileRef = BC1A7C571136E19C00FB7167 /* ProcessLauncher.h */; };
                BC1B419811D41D570011E8DD /* WKBundlePagePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = BC1B419711D41D570011E8DD /* WKBundlePagePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
                BC1DD7B2114DC396005ADAF3 /* WebCoreArgumentCoders.h in Headers */ = {isa = PBXBuildFile; fileRef = BC1DD7B1114DC396005ADAF3 /* WebCoreArgumentCoders.h */; };
+               BC1DFE8F12B31CA8005DF730 /* WKOpenPanelResultListener.h in Headers */ = {isa = PBXBuildFile; fileRef = BC1DFE8D12B31CA8005DF730 /* WKOpenPanelResultListener.h */; settings = {ATTRIBUTES = (Public, ); }; };
+               BC1DFEA412B31F87005DF730 /* WebOpenPanelResultListenerProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = BC1DFEA212B31F87005DF730 /* WebOpenPanelResultListenerProxy.h */; };
                BC204EE211C83E98008F3375 /* InjectedBundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC204EE011C83E98008F3375 /* InjectedBundle.cpp */; };
                BC204EE311C83E98008F3375 /* InjectedBundle.h in Headers */ = {isa = PBXBuildFile; fileRef = BC204EE111C83E98008F3375 /* InjectedBundle.h */; };
                BC204EE611C83EA9008F3375 /* InjectedBundleMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC204EE511C83EA9008F3375 /* InjectedBundleMac.cpp */; };
                BC8452A81162C80900CAB9B5 /* DrawingArea.h in Headers */ = {isa = PBXBuildFile; fileRef = BC8452A61162C80900CAB9B5 /* DrawingArea.h */; };
                BC84EB1812A7100C0083F2DA /* WebPreferencesMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC84EB1712A7100C0083F2DA /* WebPreferencesMac.mm */; };
                BC857E8712B71EBB00EDEB2E /* WebPageProxyMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC857E8512B71EBB00EDEB2E /* WebPageProxyMac.mm */; };
+               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 */; };
+               BC857FE612B843D800EDEB2E /* WKOpenPanelParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = BC857FE412B843D800EDEB2E /* WKOpenPanelParameters.h */; settings = {ATTRIBUTES = (Public, ); }; };
+               BC85806212B8505700EDEB2E /* WKOpenPanelResultListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC1DFE8E12B31CA8005DF730 /* WKOpenPanelResultListener.cpp */; };
+               BC85806312B8505700EDEB2E /* WKOpenPanelParameters.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC857FE512B843D800EDEB2E /* WKOpenPanelParameters.cpp */; };
                BC8699B5116AADAA002A925B /* WKView.h in Headers */ = {isa = PBXBuildFile; fileRef = BC8699B2116AADAA002A925B /* WKView.h */; settings = {ATTRIBUTES = (Public, ); }; };
                BC8699B6116AADAA002A925B /* WKView.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC8699B3116AADAA002A925B /* WKView.mm */; };
                BC8699B7116AADAA002A925B /* WKViewInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = BC8699B4116AADAA002A925B /* WKViewInternal.h */; };
                BC1A7C571136E19C00FB7167 /* ProcessLauncher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProcessLauncher.h; sourceTree = "<group>"; };
                BC1B419711D41D570011E8DD /* WKBundlePagePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBundlePagePrivate.h; sourceTree = "<group>"; };
                BC1DD7B1114DC396005ADAF3 /* WebCoreArgumentCoders.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreArgumentCoders.h; sourceTree = "<group>"; };
+               BC1DFE8D12B31CA8005DF730 /* WKOpenPanelResultListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKOpenPanelResultListener.h; sourceTree = "<group>"; };
+               BC1DFE8E12B31CA8005DF730 /* WKOpenPanelResultListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKOpenPanelResultListener.cpp; sourceTree = "<group>"; };
+               BC1DFEA212B31F87005DF730 /* WebOpenPanelResultListenerProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebOpenPanelResultListenerProxy.h; sourceTree = "<group>"; };
+               BC1DFEA312B31F87005DF730 /* WebOpenPanelResultListenerProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebOpenPanelResultListenerProxy.cpp; sourceTree = "<group>"; };
                BC204EE011C83E98008F3375 /* InjectedBundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundle.cpp; sourceTree = "<group>"; };
                BC204EE111C83E98008F3375 /* InjectedBundle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundle.h; sourceTree = "<group>"; };
                BC204EE511C83EA9008F3375 /* InjectedBundleMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleMac.cpp; sourceTree = "<group>"; };
                BC8452A61162C80900CAB9B5 /* DrawingArea.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DrawingArea.h; sourceTree = "<group>"; };
                BC84EB1712A7100C0083F2DA /* WebPreferencesMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebPreferencesMac.mm; 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>"; };
+               BC857FE412B843D800EDEB2E /* WKOpenPanelParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKOpenPanelParameters.h; sourceTree = "<group>"; };
+               BC857FE512B843D800EDEB2E /* WKOpenPanelParameters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKOpenPanelParameters.cpp; sourceTree = "<group>"; };
                BC8699B2116AADAA002A925B /* WKView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKView.h; sourceTree = "<group>"; };
                BC8699B3116AADAA002A925B /* WKView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKView.mm; sourceTree = "<group>"; };
                BC8699B4116AADAA002A925B /* WKViewInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKViewInternal.h; sourceTree = "<group>"; };
                                BC33DD671238464600360F3F /* WebNumber.h */,
                                BC5744ED12638FB3006F0F12 /* WebPopupItem.cpp */,
                                BC5744EE12638FB3006F0F12 /* WebPopupItem.h */,
+                               BC857FB412B830E600EDEB2E /* WebOpenPanelParameters.cpp */,
+                               BC857FB312B830E600EDEB2E /* WebOpenPanelParameters.h */,
                                C06C6093124C14430001682F /* WebPageCreationParameters.cpp */,
                                C06C6094124C14430001682F /* WebPageCreationParameters.h */,
                                BC7B625112A43C9600D174A4 /* WebPageGroupData.cpp */,
                                1C8E281F1275D15400BC7BD0 /* WebInspector.cpp */,
                                1C8E281E1275D15400BC7BD0 /* WebInspector.h */,
                                1C8E2A1C1277833F00BC7BD0 /* WebInspector.messages.in */,
+                               BC857F8412B82D0B00EDEB2E /* WebOpenPanelResultListener.cpp */,
+                               BC857F8312B82D0B00EDEB2E /* WebOpenPanelResultListener.h */,
                                BC963D6A113DD19200574BE2 /* WebPage.cpp */,
                                BC032D8B10F437A00058C15A /* WebPage.h */,
                                C0CE72581247E4DA00BC0EC4 /* WebPage.messages.in */,
                                BC59534010FC04520098F82D /* WebLoaderClient.h */,
                                BCF69FA11176D01400471A52 /* WebNavigationData.cpp */,
                                BCF69FA01176D01400471A52 /* WebNavigationData.h */,
+                               BC1DFEA312B31F87005DF730 /* WebOpenPanelResultListenerProxy.cpp */,
+                               BC1DFEA212B31F87005DF730 /* WebOpenPanelResultListenerProxy.h */,
                                5153569A1291B1D2000749DC /* WebPageContextMenuClient.cpp */,
                                5153569B1291B1D2000749DC /* WebPageContextMenuClient.h */,
                                BC7B6205129A0A6700D174A4 /* WebPageGroup.cpp */,
                                1AB7D78B1288CD9A00CFD08C /* WKDownload.h */,
                                BCE469571214EDF4000B98EB /* WKFormSubmissionListener.cpp */,
                                BCE469581214EDF4000B98EB /* WKFormSubmissionListener.h */,
+                               BC1DFE8E12B31CA8005DF730 /* WKOpenPanelResultListener.cpp */,
+                               BC1DFE8D12B31CA8005DF730 /* WKOpenPanelResultListener.h */,
+                               BC857FE512B843D800EDEB2E /* WKOpenPanelParameters.cpp */,
+                               BC857FE412B843D800EDEB2E /* WKOpenPanelParameters.h */,
                                BCD01398110FA420003B8A67 /* WKFrame.cpp */,
                                BCD01397110FA420003B8A67 /* WKFrame.h */,
                                BCB9F6A41123DD0D00A137E0 /* WKFramePolicyListener.cpp */,
                                F62A766212B1ABED0005F1B6 /* WKDatabaseManager.h in Headers */,
                                F62A76B712B1B25F0005F1B6 /* WebDatabaseManagerMessages.h in Headers */,
                                F62A76B912B1B25F0005F1B6 /* WebDatabaseManagerProxyMessages.h in Headers */,
+                               BC1DFE8F12B31CA8005DF730 /* WKOpenPanelResultListener.h in Headers */,
+                               BC1DFEA412B31F87005DF730 /* WebOpenPanelResultListenerProxy.h in Headers */,
+                               BC857F8512B82D0B00EDEB2E /* WebOpenPanelResultListener.h in Headers */,
+                               BC857FB512B830E600EDEB2E /* WebOpenPanelParameters.h in Headers */,
+                               BC857FE612B843D800EDEB2E /* WKOpenPanelParameters.h in Headers */,
                                1A4A9AA812B7E796008FE984 /* WKTextInputWindowController.h in Headers */,
                                1A4A9C5612B816CF008FE984 /* NetscapePluginModule.h in Headers */,
                                1A4A9F3312B844E2008FE984 /* PluginQuirks.h in Headers */,
                                F62A76B612B1B25F0005F1B6 /* WebDatabaseManagerMessageReceiver.cpp in Sources */,
                                F62A76B812B1B25F0005F1B6 /* WebDatabaseManagerProxyMessageReceiver.cpp in Sources */,
                                BC857E8712B71EBB00EDEB2E /* WebPageProxyMac.mm in Sources */,
+                               BC857F7E12B82CEE00EDEB2E /* WebOpenPanelResultListenerProxy.cpp in Sources */,
+                               BC857F8612B82D0B00EDEB2E /* WebOpenPanelResultListener.cpp in Sources */,
+                               BC857FB612B830E600EDEB2E /* WebOpenPanelParameters.cpp in Sources */,
+                               BC85806212B8505700EDEB2E /* WKOpenPanelResultListener.cpp in Sources */,
+                               BC85806312B8505700EDEB2E /* WKOpenPanelParameters.cpp in Sources */,
                                1A4A9AA912B7E796008FE984 /* WKTextInputWindowController.mm in Sources */,
                                1A4A9C5512B816CF008FE984 /* NetscapePluginModule.cpp in Sources */,
                                1A4A9C9A12B821CD008FE984 /* NetscapePluginModuleMac.mm in Sources */,
index c1925ba..a112c55 100644 (file)
@@ -35,6 +35,8 @@
 #include "WebCoreArgumentCoders.h"
 #include "WebFrame.h"
 #include "WebFrameLoaderClient.h"
+#include "WebOpenPanelParameters.h"
+#include "WebOpenPanelResultListener.h"
 #include "WebPage.h"
 #include "WebPageCreationParameters.h"
 #include "WebPageProxyMessages.h"
@@ -508,9 +510,26 @@ void WebChromeClient::cancelGeolocationPermissionRequestForFrame(Frame*, Geoloca
     notImplemented();
 }
 
-void WebChromeClient::runOpenPanel(Frame*, PassRefPtr<FileChooser>)
+void WebChromeClient::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> prpFileChooser)
 {
-    notImplemented();
+    if (m_page->activeOpenPanelResultListener())
+        return;
+
+    RefPtr<FileChooser> fileChooser = prpFileChooser;
+
+    m_page->setActiveOpenPanelResultListener(WebOpenPanelResultListener::create(m_page, fileChooser.get()));
+    
+    WebOpenPanelParameters::Data parameters;
+    parameters.allowMultipleFiles = fileChooser->allowsMultipleFiles();
+#if ENABLE(DIRECTORY_UPLOAD)
+    parameters.allowsDirectoryUpload = fileChooser->allowsDirectoryUpload();
+#else
+    parameters.allowsDirectoryUpload = false;
+#endif
+    parameters.acceptTypes = fileChooser->acceptTypes();
+    parameters.filenames = fileChooser->filenames();
+
+    m_page->send(Messages::WebPageProxy::RunOpenPanel(static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame()->frameID(), parameters));
 }
 
 void WebChromeClient::chooseIconForFiles(const Vector<String>&, FileChooser*)
diff --git a/WebKit2/WebProcess/WebPage/WebOpenPanelResultListener.cpp b/WebKit2/WebProcess/WebPage/WebOpenPanelResultListener.cpp
new file mode 100644 (file)
index 0000000..d42e313
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include "WebOpenPanelResultListener.h"
+
+namespace WebKit {
+
+PassRefPtr<WebOpenPanelResultListener> WebOpenPanelResultListener::create(WebPage* page, PassRefPtr<WebCore::FileChooser> fileChooser)
+{
+    return adoptRef(new WebOpenPanelResultListener(page, fileChooser));
+}
+
+WebOpenPanelResultListener::WebOpenPanelResultListener(WebPage* page, PassRefPtr<WebCore::FileChooser> fileChooser)
+    : m_page(page)
+    , m_fileChooser(fileChooser)
+{
+}
+
+WebOpenPanelResultListener::~WebOpenPanelResultListener()
+{
+}
+
+void WebOpenPanelResultListener::didChooseFiles(const Vector<String>& files)
+{
+    m_fileChooser->chooseFiles(files);
+}
+
+} // namespace WebKit
diff --git a/WebKit2/WebProcess/WebPage/WebOpenPanelResultListener.h b/WebKit2/WebProcess/WebPage/WebOpenPanelResultListener.h
new file mode 100644 (file)
index 0000000..073d66a
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef WebOpenPanelResultListener_h
+#define WebOpenPanelResultListener_h
+
+#include <wtf/RefCounted.h>
+#include <WebCore/FileChooser.h>
+
+namespace WebKit {
+
+class WebPage;
+
+class WebOpenPanelResultListener : public RefCounted<WebOpenPanelResultListener> {
+public:
+    static PassRefPtr<WebOpenPanelResultListener> create(WebPage*, PassRefPtr<WebCore::FileChooser>);
+    ~WebOpenPanelResultListener();
+
+    void disconnectFromPage() { m_page = 0; }
+    void didChooseFiles(const Vector<String>&);
+
+private:
+    WebOpenPanelResultListener(WebPage*, PassRefPtr<WebCore::FileChooser>);
+
+    WebPage* m_page;
+    RefPtr<WebCore::FileChooser> m_fileChooser;
+};
+
+} // namespace WebKit
+
+
+#endif // WebOpenPanelResultListener_h
index e8c77ed..de4f099 100644 (file)
@@ -42,6 +42,7 @@
 #include "WebContextMenuClient.h"
 #include "WebContextMessages.h"
 #include "WebCoreArgumentCoders.h"
+#include "WebOpenPanelResultListener.h"
 #include "WebDragClient.h"
 #include "WebEditorClient.h"
 #include "WebEvent.h"
@@ -328,6 +329,11 @@ void WebPage::close()
         m_activePopupMenu = 0;
     }
 
+    if (m_activeOpenPanelResultListener) {
+        m_activeOpenPanelResultListener->disconnectFromPage();
+        m_activeOpenPanelResultListener = 0;
+    }
+
     m_sandboxExtensionTracker.invalidate();
 
     m_mainFrame->coreFrame()->loader()->detachFromParent();
@@ -1065,6 +1071,11 @@ void WebPage::setActivePopupMenu(WebPopupMenu* menu)
     m_activePopupMenu = menu;
 }
 
+void WebPage::setActiveOpenPanelResultListener(PassRefPtr<WebOpenPanelResultListener> openPanelResultListener)
+{
+    m_activeOpenPanelResultListener = openPanelResultListener;
+}
+
 bool WebPage::findStringFromInjectedBundle(const String& target, FindOptions options)
 {
     return m_page->findString(target, options);
@@ -1094,6 +1105,20 @@ void WebPage::didChangeSelectedIndexForActivePopupMenu(int32_t newIndex)
     m_activePopupMenu = 0;
 }
 
+void WebPage::didChooseFilesForOpenPanel(const Vector<String>& files)
+{
+    if (!m_activeOpenPanelResultListener)
+        return;
+
+    m_activeOpenPanelResultListener->didChooseFiles(files);
+    m_activeOpenPanelResultListener = 0;
+}
+
+void WebPage::didCancelForOpenPanel()
+{
+    m_activeOpenPanelResultListener = 0;
+}
+
 void WebPage::didSelectItemFromActiveContextMenu(const WebContextMenuItemData& item)
 {
     ASSERT(m_contextMenu);
index cb10bba..bc87a99 100644 (file)
@@ -77,6 +77,7 @@ class WebFrame;
 class WebInspector;
 class WebKeyboardEvent;
 class WebMouseEvent;
+class WebOpenPanelResultListener;
 class WebPageGroupProxy;
 class WebPopupMenu;
 class WebWheelEvent;
@@ -136,6 +137,9 @@ public:
     bool isInRedo() const { return m_isInRedo; }
 
     void setActivePopupMenu(WebPopupMenu*);
+    
+    WebOpenPanelResultListener* activeOpenPanelResultListener() const { return m_activeOpenPanelResultListener.get(); }
+    void setActiveOpenPanelResultListener(PassRefPtr<WebOpenPanelResultListener>);
 
     // -- Called from WebProcess.
     void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
@@ -327,6 +331,9 @@ private:
 
     void didChangeSelectedIndexForActivePopupMenu(int32_t newIndex);
 
+    void didChooseFilesForOpenPanel(const Vector<String>&);
+    void didCancelForOpenPanel();
+
 #if ENABLE(CONTEXT_MENUS)
     void didSelectItemFromActiveContextMenu(const WebContextMenuItemData&);
 #endif
@@ -389,6 +396,7 @@ private:
 #endif
     RefPtr<WebPopupMenu> m_activePopupMenu;
     RefPtr<WebContextMenu> m_contextMenu;
+    RefPtr<WebOpenPanelResultListener> m_activeOpenPanelResultListener;
 
     SandboxExtensionTracker m_sandboxExtensionTracker;
     uint64_t m_pageID;
index 01c279a..0380b67 100644 (file)
@@ -54,7 +54,6 @@ messages -> WebPage {
     GetSourceForFrame(uint64_t frameID, uint64_t callbackID)
     RunJavaScriptInMainFrame(WTF::String script, uint64_t callbackID)
 
-
     PreferencesDidChange(WebKit::WebPreferencesStore store)
 
     SetUserAgent(WTF::String userAgent)
@@ -91,6 +90,10 @@ messages -> WebPage {
     # Context menu.
     DidSelectItemFromActiveContextMenu(WebKit::WebContextMenuItemData menuItem);
 
+    # Open panel.
+    DidChooseFilesForOpenPanel(Vector<WTF::String> fileURLs)
+    DidCancelForOpenPanel()
+
     SetWindowResizerSize(WebCore::IntSize intersectsView)
 
 #if PLATFORM(MAC)
@@ -103,10 +106,12 @@ messages -> WebPage {
     CharacterIndexForPoint(WebCore::IntPoint point) -> (uint64_t result)
     FirstRectForCharacterRange(uint64_t location, uint64_t length) -> (WebCore::IntRect resultRect)
 #endif
-       // This is a dummy message to avoid breaking the build for platforms that don't require 
-       // synchronous messages.
-       Dummy() -> (bool dummyReturn)
+
 #if PLATFORM(QT)
     FindZoomableAreaForPoint(WebCore::IntPoint point)
 #endif
+
+    // This is a dummy message to avoid breaking the build for platforms that don't require 
+    // synchronous messages.
+    Dummy() -> (bool dummyReturn)
 }
index 14db338..9c174d6 100755 (executable)
                                >
                        </File>
                        <File
+                               RelativePath="..\Shared\WebOpenPanelParameters.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\Shared\WebOpenPanelParameters.h"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\Shared\WebPageCreationParameters.cpp"
                                >
                        </File>
                                        >
                                </File>
                                <File
+                                       RelativePath="..\WebProcess\WebPage\WebOpenPanelResultListener.cpp"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\WebProcess\WebPage\WebOpenPanelResultListener.h"
+                                       >
+                               </File>
+                               <File
                                        RelativePath="..\WebProcess\WebPage\WebPage.cpp"
                                        >
                                </File>
                                >
                        </File>
                        <File
+                               RelativePath="..\UIProcess\WebOpenPanelResultListenerProxy.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\UIProcess\WebOpenPanelResultListenerProxy.h"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\UIProcess\WebPageContextMenuClient.cpp"
                                >
                        </File>
                                                >
                                        </File>
                                        <File
+                                               RelativePath="..\UIProcess\API\C\WKOpenPanelParameters.cpp"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath="..\UIProcess\API\C\WKOpenPanelParameters.h"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath="..\UIProcess\API\C\WKOpenPanelResultListener.cpp"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath="..\UIProcess\API\C\WKOpenPanelResultListener.h"
+                                               >
+                                       </File>
+                                       <File
                                                RelativePath="..\UIProcess\API\C\WKPage.cpp"
                                                >
                                        </File>
index 32977b8..94b7a1a 100644 (file)
@@ -49,6 +49,8 @@ all:
     xcopy /y /d "..\UIProcess\API\c\WKInspector.h" "$(WEBKITOUTPUTDIR)\include\WebKit2"
     xcopy /y /d "..\UIProcess\API\C\WKNativeEvent.h" "$(WEBKITOUTPUTDIR)\include\WebKit2"
     xcopy /y /d "..\UIProcess\API\C\WKNavigationData.h" "$(WEBKITOUTPUTDIR)\include\WebKit2"
+    xcopy /y /d "..\UIProcess\API\C\WKOpenPanelParameters.h" "$(WEBKITOUTPUTDIR)\include\WebKit2"
+    xcopy /y /d "..\UIProcess\API\C\WKOpenPanelResultListener.h" "$(WEBKITOUTPUTDIR)\include\WebKit2"
     xcopy /y /d "..\UIProcess\API\C\WKPage.h" "$(WEBKITOUTPUTDIR)\include\WebKit2"
     xcopy /y /d "..\UIProcess\API\C\WKPageGroup.h" "$(WEBKITOUTPUTDIR)\include\WebKit2"
     xcopy /y /d "..\UIProcess\API\C\WKPreferences.h" "$(WEBKITOUTPUTDIR)\include\WebKit2"
index c115679..afc65aa 100644 (file)
@@ -1,3 +1,22 @@
+2010-12-15  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Anders Carlsson.
+
+        WebKit2: Can't add files to an <input type=file>
+        https://bugs.webkit.org/show_bug.cgi?id=51087
+
+        * MiniBrowser/mac/BrowserWindowController.m:
+        (runOpenPanel):
+        (-[BrowserWindowController awakeFromNib]):
+        Add simple implementation of runOpenPanel callback.
+
+        * MiniBrowser/win/BrowserView.cpp:
+        (BrowserView::create):
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::createOtherPage):
+        (WTR::TestController::initialize):
+        Stub out runOpenPanel callback. 
+
 2010-12-14  Eric Seidel  <eric@webkit.org>
 
         Reviewed by Adam Barth.
index c900a27..b813f29 100644 (file)
@@ -535,6 +535,34 @@ static bool runBeforeUnloadConfirmPanel(WKPageRef page, WKStringRef message, WKF
     return button == NSAlertFirstButtonReturn;
 }
 
+static void runOpenPanel(WKPageRef page, WKFrameRef frame, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener, const void* clientInfo)
+{
+    NSOpenPanel *openPanel = [NSOpenPanel openPanel];
+    [openPanel setAllowsMultipleSelection:WKOpenPanelParametersGetAllowsMultipleFiles(parameters)];
+
+    WKRetain(listener);
+
+    [openPanel beginSheetModalForWindow:[(BrowserWindowController *)clientInfo window] completionHandler:^(NSInteger result) {
+        if (result == NSFileHandlingPanelOKButton) {
+            WKMutableArrayRef fileURLs = WKMutableArrayCreate();
+
+            NSURL *nsURL;
+            for (nsURL in [openPanel URLs]) {
+                WKURLRef wkURL = WKURLCreateWithCFURL((CFURLRef)nsURL);
+                WKArrayAppendItem(fileURLs, wkURL);
+                WKRelease(wkURL);
+            }
+
+            WKOpenPanelResultListenerChooseFiles(listener, fileURLs);
+
+            WKRelease(fileURLs);
+        } else
+            WKOpenPanelResultListenerCancel(listener);
+        
+        WKRelease(listener);
+    }];
+}
+
 - (void)awakeFromNib
 {
     _webView = [[WKView alloc] initWithFrame:[containerView frame] contextRef:_context];
@@ -607,7 +635,8 @@ static bool runBeforeUnloadConfirmPanel(WKPageRef page, WKStringRef message, WKF
         runBeforeUnloadConfirmPanel,
         0,          /* didDraw */
         0,          /* pageDidScroll */
-        0           /* exceededDatabaseQuota */
+        0,          /* exceededDatabaseQuota */
+        runOpenPanel
     };
     WKPageSetPageUIClient(_webView.pageRef, &uiClient);
 }
index c89e10c..a93ca96 100644 (file)
@@ -117,7 +117,8 @@ void BrowserView::create(RECT webViewRect, BrowserWindow* parentWindow)
         0,          /* runBeforeUnloadConfirmPanel */
         0,          /* didDraw */
         0,          /* pageDidScroll */
-        0           /* exceededDatabaseQuota */
+        0,          /* exceededDatabaseQuota */
+        0           /* runOpenPanel */
     };
 
     WKPageSetPageUIClient(WKViewGetPage(m_webView), &uiClient);
index 8f37387..a8ad1f2 100644 (file)
@@ -136,7 +136,8 @@ static WKPageRef createOtherPage(WKPageRef oldPage, WKDictionaryRef, WKEventModi
         0, // runBeforeUnloadConfirmPanel
         0, // didDraw
         0, // pageDidScroll
-        0  // exceededDatabaseQuota
+        0, // exceededDatabaseQuota
+        0  // runOpenPanel
     };
     WKPageSetPageUIClient(newPage, &otherPageUIClient);
 
@@ -238,7 +239,8 @@ void TestController::initialize(int argc, const char* argv[])
         0, // runBeforeUnloadConfirmPanel
         0, // didDraw
         0, // pageDidScroll
-        0  // exceededDatabaseQuota
+        0, // exceededDatabaseQuota
+        0  // runOpenPanel
     };
     WKPageSetPageUIClient(m_mainWebView->page(), &pageUIClient);