From c34b72183e85e7c615ca65381d8591cdca23faf2 Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Mon, 25 Nov 2013 15:38:24 +0100 Subject: [Widgets] wire the file pickers Introduce a new version of chooseFiles in QWebEnginePage. The existing API in WebKit1 seemed a bit dusty in any case (multiple only supported via extensions). Changes are: * oldFile becomes oldFiles, so that we could at a later stage expose the already selected files in the "multiple" case. * a type is introduced, for now limited to multiple selection, but over time, we might consider additions such as directory upload. Change-Id: I14cfea64ce95e892a0a1877c8cb914c5a421409f Reviewed-by: Jocelyn Turcotte --- src/core/web_contents_delegate_qt.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/core/web_contents_delegate_qt.cpp') diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index 5c5026f78..6dd8121dd 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -50,6 +50,7 @@ #include "content/public/browser/web_contents.h" #include "content/public/browser/invalidate_type.h" #include "content/public/common/favicon_url.h" +#include "content/public/common/file_chooser_params.h" WebContentsDelegateQt::WebContentsDelegateQt(content::WebContents *webContents, WebContentsAdapterClient *adapterClient) : m_viewClient(adapterClient) @@ -130,3 +131,17 @@ content::JavaScriptDialogManager *WebContentsDelegateQt::GetJavaScriptDialogMana { return JavaScriptDialogManagerQt::GetInstance(); } + +Q_STATIC_ASSERT_X(static_cast(WebContentsAdapterClient::Open) == static_cast(content::FileChooserParams::Open), "Enums out of sync"); +Q_STATIC_ASSERT_X(static_cast(WebContentsAdapterClient::Save) == static_cast(content::FileChooserParams::Save), "Enums out of sync"); + +void WebContentsDelegateQt::RunFileChooser(content::WebContents *web_contents, const content::FileChooserParams ¶ms) +{ + Q_UNUSED(web_contents) + QStringList acceptedMimeTypes; + acceptedMimeTypes.reserve(params.accept_types.size()); + for (std::vector::const_iterator it = params.accept_types.begin(); it < params.accept_types.end(); ++it) + acceptedMimeTypes.append(toQt(*it)); + + m_viewClient->runFileChooser(static_cast(params.mode), toQt(params.default_file_name.value()), acceptedMimeTypes); +} -- cgit v1.2.3