diff options
Diffstat (limited to 'src/webenginewidgets')
19 files changed, 514 insertions, 123 deletions
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.cpp b/src/webenginewidgets/api/qwebenginedownloaditem.cpp index dc1a48360..8f097df6c 100644 --- a/src/webenginewidgets/api/qwebenginedownloaditem.cpp +++ b/src/webenginewidgets/api/qwebenginedownloaditem.cpp @@ -115,7 +115,7 @@ QWebEngineDownloadItemPrivate::QWebEngineDownloadItemPrivate(QWebEngineProfilePr , downloadId(-1) , downloadState(QWebEngineDownloadItem::DownloadCancelled) , savePageFormat(QWebEngineDownloadItem::MimeHtmlSaveFormat) - , type(QWebEngineDownloadItem::Attachment) + , isSavePageDownload(false) , interruptReason(QWebEngineDownloadItem::NoReason) , downloadUrl(url) , downloadPaused(false) @@ -318,20 +318,9 @@ quint32 QWebEngineDownloadItem::id() const /*! \enum QWebEngineDownloadItem::DownloadType \since 5.8 + \obsolete Describes the requested download's type. - - \value Attachment The web server's response includes a - \c Content-Disposition header with the \c attachment directive. If \c Content-Disposition - is present in the reply, the web server is indicating that the client should prompt the - user to save the content regardless of the content type. - See \l {RFC 2616 section 19.5.1} for details. - \value DownloadAttribute The user clicked a link with the \c download - attribute. See \l {HTML download attribute} for details. - \value UserRequested The user initiated the download, for example by - selecting a web action. - \value SavePage Saving of the current page was requested (for example by - the \l{QWebEnginePage::WebAction}{QWebEnginePage::SavePage} web action). */ /*! @@ -513,13 +502,26 @@ void QWebEngineDownloadItem::setSavePageFormat(QWebEngineDownloadItem::SavePageF /*! Returns the requested download's type. \since 5.8 + \obsolete + Unfortunately, this property only ever worked correctly for \c SavePage + downloads. In other cases, it followed the documented semantics rather + loosely, sometimes non-deterministically. Use \l isSavePageDownload instead. */ QWebEngineDownloadItem::DownloadType QWebEngineDownloadItem::type() const { + return isSavePageDownload() ? SavePage : UserRequested; +} + +/*! + Returns \c true if this is a download request for saving a web page. + \since 5.11 + */ +bool QWebEngineDownloadItem::isSavePageDownload() const +{ Q_D(const QWebEngineDownloadItem); - return d->type; + return d->isSavePageDownload; } /*! diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.h b/src/webenginewidgets/api/qwebenginedownloaditem.h index 2aca2bb2a..073b97170 100644 --- a/src/webenginewidgets/api/qwebenginedownloaditem.h +++ b/src/webenginewidgets/api/qwebenginedownloaditem.h @@ -123,9 +123,10 @@ public: bool isPaused() const; SavePageFormat savePageFormat() const; void setSavePageFormat(SavePageFormat format); - DownloadType type() const; + DownloadType Q_DECL_DEPRECATED type() const; DownloadInterruptReason interruptReason() const; QString interruptReasonString() const; + bool isSavePageDownload() const; public Q_SLOTS: void accept(); diff --git a/src/webenginewidgets/api/qwebenginedownloaditem_p.h b/src/webenginewidgets/api/qwebenginedownloaditem_p.h index da765e5c5..812a3f98b 100644 --- a/src/webenginewidgets/api/qwebenginedownloaditem_p.h +++ b/src/webenginewidgets/api/qwebenginedownloaditem_p.h @@ -72,7 +72,7 @@ public: quint32 downloadId; QWebEngineDownloadItem::DownloadState downloadState; QWebEngineDownloadItem::SavePageFormat savePageFormat; - QWebEngineDownloadItem::DownloadType type; + bool isSavePageDownload; QWebEngineDownloadItem::DownloadInterruptReason interruptReason; QString downloadPath; const QUrl downloadUrl; diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index ac8e9c667..a81c749f6 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -53,6 +53,7 @@ #include "qwebenginehistory_p.h" #include "qwebengineprofile.h" #include "qwebengineprofile_p.h" +#include "qwebenginequotapermissionrequest.h" #include "qwebenginescriptcollection_p.h" #include "qwebenginesettings.h" #include "qwebengineview.h" @@ -572,6 +573,13 @@ void QWebEnginePagePrivate::runMouseLockPermissionRequest(const QUrl &securityOr Q_EMIT q->featurePermissionRequested(securityOrigin, QWebEnginePage::MouseLock); } +void QWebEnginePagePrivate::runQuotaPermissionRequest(QSharedPointer<QtWebEngineCore::QuotaPermissionController> controller) +{ + Q_Q(QWebEnginePage); + QWebEngineQuotaPermissionRequest request(controller); + Q_EMIT q->quotaPermissionRequested(request); +} + QObject *QWebEnginePagePrivate::accessibilityParentObject() { return view; @@ -733,6 +741,17 @@ QWebEnginePage::QWebEnginePage(QObject* parent) */ /*! + \fn QWebEnginePage::quotaPermissionRequested(QWebEngineQuotaPermissionRequest request) + \since 5.11 + + This signal is emitted when the web page requests larger persistent storage + than the application's current allocation in File System API. The default quota + is 0 bytes. + + The request object \a request can be used to accept or reject the request. +*/ + +/*! \fn void QWebEnginePage::pdfPrintingFinished(const QString &filePath, bool success) \since 5.9 @@ -819,6 +838,7 @@ QWebEnginePage::QWebEnginePage(QWebEngineProfile *profile, QObject* parent) QWebEnginePage::~QWebEnginePage() { Q_D(QWebEnginePage); + setDevToolsPage(nullptr); if (d->adapter) d->adapter->stopFinding(); QWebEngineViewPrivate::bind(d->view, 0); @@ -1592,10 +1612,11 @@ void QWebEnginePagePrivate::renderProcessTerminated(RenderProcessTerminationStat terminationStatus), exitCode); } -void QWebEnginePagePrivate::requestGeometryChange(const QRect &geometry) +void QWebEnginePagePrivate::requestGeometryChange(const QRect &geometry, const QRect &frameGeometry) { + Q_UNUSED(geometry); Q_Q(QWebEnginePage); - Q_EMIT q->geometryChangeRequested(geometry); + Q_EMIT q->geometryChangeRequested(frameGeometry); } void QWebEnginePagePrivate::startDragging(const content::DropData &dropData, @@ -1993,6 +2014,94 @@ QWebEnginePage *QWebEnginePage::createWindow(WebWindowType type) return 0; } +/*! + \since 5.11 + Returns the page this page is inspecting, if any. + + Returns \c nullptr if this page is not a developer tools page. + + \sa setInspectedPage(), devToolsPage() +*/ + +QWebEnginePage *QWebEnginePage::inspectedPage() const +{ + Q_D(const QWebEnginePage); + return d->inspectedPage; +} + +/*! + \since 5.11 + Navigates this page to an internal URL that is the developer + tools of \a page. + + This is the same as calling setDevToolsPage() on \a page + with \c this as argument. + + \sa inspectedPage(), setDevToolsPage() +*/ + +void QWebEnginePage::setInspectedPage(QWebEnginePage *page) +{ + Q_D(QWebEnginePage); + if (d->inspectedPage == page) + return; + QWebEnginePage *oldPage = d->inspectedPage; + d->inspectedPage = nullptr; + if (oldPage) + oldPage->setDevToolsPage(nullptr); + d->inspectedPage = page; + if (page) + page->setDevToolsPage(this); +} + +/*! + \since 5.11 + Returns the page that is hosting the developer tools + of this page, if any. + + Returns \c nullptr if no developer tools page is set. + + \sa setDevToolsPage(), inspectedPage() +*/ + +QWebEnginePage *QWebEnginePage::devToolsPage() const +{ + Q_D(const QWebEnginePage); + return d->devToolsPage; +} + +/*! + \since 5.11 + Binds \a devToolsPage to be the developer tools of this page. + Triggers \a devToolsPage to navigate to an internal URL + with the developer tools. + + This is the same as calling setInspectedPage() on \a devToolsPage + with \c this as argument. + + \sa devToolsPage(), setInspectedPage() +*/ + +void QWebEnginePage::setDevToolsPage(QWebEnginePage *devToolsPage) +{ + Q_D(QWebEnginePage); + if (d->devToolsPage == devToolsPage) + return; + QWebEnginePage *oldDevTools = d->devToolsPage; + d->devToolsPage = nullptr; + if (oldDevTools) + oldDevTools->setInspectedPage(nullptr); + d->devToolsPage = devToolsPage; + if (devToolsPage) + devToolsPage->setInspectedPage(this); + if (d->adapter) { + if (devToolsPage) + d->adapter->openDevToolsFrontend(devToolsPage->d_ptr->adapter); + else + d->adapter->closeDevToolsFrontend(); + } +} + ASSERT_ENUMS_MATCH(FilePickerController::Open, QWebEnginePage::FileSelectOpen) ASSERT_ENUMS_MATCH(FilePickerController::OpenMultiple, QWebEnginePage::FileSelectOpenMultiple) diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h index 295527e74..531eef6e9 100644 --- a/src/webenginewidgets/api/qwebenginepage.h +++ b/src/webenginewidgets/api/qwebenginepage.h @@ -64,6 +64,7 @@ class QWebEngineHistory; class QWebEnginePage; class QWebEnginePagePrivate; class QWebEngineProfile; +class QWebEngineQuotaPermissionRequest; class QWebEngineScriptCollection; class QWebEngineSettings; @@ -315,6 +316,11 @@ public: void print(QPrinter *printer, const QWebEngineCallback<bool> &resultCallback); #endif // QDOC + void setInspectedPage(QWebEnginePage *page); + QWebEnginePage *inspectedPage() const; + void setDevToolsPage(QWebEnginePage *page); + QWebEnginePage *devToolsPage() const; + const QWebEngineContextMenuData &contextMenuData() const; Q_SIGNALS: @@ -330,6 +336,7 @@ Q_SIGNALS: void featurePermissionRequested(const QUrl &securityOrigin, QWebEnginePage::Feature feature); void featurePermissionRequestCanceled(const QUrl &securityOrigin, QWebEnginePage::Feature feature); void fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest); + void quotaPermissionRequested(QWebEngineQuotaPermissionRequest quotaPermissionRequest); void authenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator); void proxyAuthenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator, const QString &proxyHost); diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h index 12bad1351..270849aee 100644 --- a/src/webenginewidgets/api/qwebenginepage_p.h +++ b/src/webenginewidgets/api/qwebenginepage_p.h @@ -57,7 +57,9 @@ #include "qwebenginecontextmenudata.h" #include "qwebenginescriptcollection.h" #include "web_contents_adapter_client.h" + #include <QtCore/qcompilerdetection.h> +#include <QtCore/QPointer> namespace QtWebEngineCore { class RenderWidgetHostViewQtDelegate; @@ -82,69 +84,69 @@ public: QWebEnginePagePrivate(QWebEngineProfile *profile = 0); ~QWebEnginePagePrivate(); - virtual QtWebEngineCore::RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegate(QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client) Q_DECL_OVERRIDE; - virtual QtWebEngineCore::RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegateForPopup(QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client) Q_DECL_OVERRIDE { return CreateRenderWidgetHostViewQtDelegate(client); } - virtual void titleChanged(const QString&) Q_DECL_OVERRIDE; - virtual void urlChanged(const QUrl&) Q_DECL_OVERRIDE; - virtual void iconChanged(const QUrl&) Q_DECL_OVERRIDE; - virtual void loadProgressChanged(int progress) Q_DECL_OVERRIDE; - virtual void didUpdateTargetURL(const QUrl&) Q_DECL_OVERRIDE; - virtual void selectionChanged() Q_DECL_OVERRIDE; - virtual void recentlyAudibleChanged(bool recentlyAudible) Q_DECL_OVERRIDE; - virtual QRectF viewportRect() const Q_DECL_OVERRIDE; - virtual qreal dpiScale() const Q_DECL_OVERRIDE; - virtual QColor backgroundColor() const Q_DECL_OVERRIDE; - virtual void loadStarted(const QUrl &provisionalUrl, bool isErrorPage = false) Q_DECL_OVERRIDE; - virtual void loadCommitted() Q_DECL_OVERRIDE; - virtual void loadVisuallyCommitted() Q_DECL_OVERRIDE { } - virtual void loadFinished(bool success, const QUrl &url, bool isErrorPage = false, int errorCode = 0, const QString &errorDescription = QString()) Q_DECL_OVERRIDE; - virtual void focusContainer() Q_DECL_OVERRIDE; - virtual void unhandledKeyEvent(QKeyEvent *event) Q_DECL_OVERRIDE; - virtual void adoptNewWindow(QSharedPointer<QtWebEngineCore::WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &initialGeometry, const QUrl &targetUrl) Q_DECL_OVERRIDE; + QtWebEngineCore::RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegate(QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client) override; + QtWebEngineCore::RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegateForPopup(QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client) override { return CreateRenderWidgetHostViewQtDelegate(client); } + void titleChanged(const QString&) override; + void urlChanged(const QUrl&) override; + void iconChanged(const QUrl&) override; + void loadProgressChanged(int progress) override; + void didUpdateTargetURL(const QUrl&) override; + void selectionChanged() override; + void recentlyAudibleChanged(bool recentlyAudible) override; + QRectF viewportRect() const override; + qreal dpiScale() const override; + QColor backgroundColor() const override; + void loadStarted(const QUrl &provisionalUrl, bool isErrorPage = false) override; + void loadCommitted() override; + void loadVisuallyCommitted() override { } + void loadFinished(bool success, const QUrl &url, bool isErrorPage = false, int errorCode = 0, const QString &errorDescription = QString()) override; + void focusContainer() override; + void unhandledKeyEvent(QKeyEvent *event) override; + void adoptNewWindow(QSharedPointer<QtWebEngineCore::WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &initialGeometry, const QUrl &targetUrl) override; void adoptNewWindowImpl(QWebEnginePage *newPage, const QSharedPointer<QtWebEngineCore::WebContentsAdapter> &newWebContents, const QRect &initialGeometry); - virtual bool isBeingAdopted() Q_DECL_OVERRIDE; - virtual void close() Q_DECL_OVERRIDE; - virtual void windowCloseRejected() Q_DECL_OVERRIDE; - virtual void contextMenuRequested(const QtWebEngineCore::WebEngineContextMenuData &data) Q_DECL_OVERRIDE; - virtual void navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame) Q_DECL_OVERRIDE; - virtual void requestFullScreenMode(const QUrl &origin, bool fullscreen) Q_DECL_OVERRIDE; - virtual bool isFullScreenMode() const Q_DECL_OVERRIDE; - virtual void javascriptDialog(QSharedPointer<QtWebEngineCore::JavaScriptDialogController>) Q_DECL_OVERRIDE; - virtual void runFileChooser(QSharedPointer<QtWebEngineCore::FilePickerController>) Q_DECL_OVERRIDE; - virtual void showColorDialog(QSharedPointer<QtWebEngineCore::ColorChooserController>) Q_DECL_OVERRIDE; - virtual void didRunJavaScript(quint64 requestId, const QVariant& result) Q_DECL_OVERRIDE; - virtual void didFetchDocumentMarkup(quint64 requestId, const QString& result) Q_DECL_OVERRIDE; - virtual void didFetchDocumentInnerText(quint64 requestId, const QString& result) Q_DECL_OVERRIDE; - virtual void didFindText(quint64 requestId, int matchCount) Q_DECL_OVERRIDE; - virtual void didPrintPage(quint64 requestId, const QByteArray &result) Q_DECL_OVERRIDE; - virtual void didPrintPageToPdf(const QString &filePath, bool success) Q_DECL_OVERRIDE; - virtual void passOnFocus(bool reverse) Q_DECL_OVERRIDE; - virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID) Q_DECL_OVERRIDE; - virtual void authenticationRequired(QSharedPointer<QtWebEngineCore::AuthenticationDialogController>) Q_DECL_OVERRIDE; - virtual void runMediaAccessPermissionRequest(const QUrl &securityOrigin, MediaRequestFlags requestFlags) Q_DECL_OVERRIDE; - virtual void runGeolocationPermissionRequest(const QUrl &securityOrigin) Q_DECL_OVERRIDE; - virtual void runMouseLockPermissionRequest(const QUrl &securityOrigin) Q_DECL_OVERRIDE; - virtual QObject *accessibilityParentObject() Q_DECL_OVERRIDE; - virtual QtWebEngineCore::WebEngineSettings *webEngineSettings() const Q_DECL_OVERRIDE; - virtual void allowCertificateError(const QSharedPointer<CertificateErrorController> &controller) Q_DECL_OVERRIDE; - virtual void showValidationMessage(const QRect &anchor, const QString &mainText, const QString &subText) Q_DECL_OVERRIDE; - virtual void hideValidationMessage() Q_DECL_OVERRIDE; - virtual void moveValidationMessage(const QRect &anchor) Q_DECL_OVERRIDE; - virtual void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, - int exitCode) Q_DECL_OVERRIDE; - virtual void requestGeometryChange(const QRect &geometry) Q_DECL_OVERRIDE; - virtual void updateScrollPosition(const QPointF &position) Q_DECL_OVERRIDE; - virtual void updateContentsSize(const QSizeF &size) Q_DECL_OVERRIDE; + bool isBeingAdopted() override; + void close() override; + void windowCloseRejected() override; + void contextMenuRequested(const QtWebEngineCore::WebEngineContextMenuData &data) override; + void navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame) override; + void requestFullScreenMode(const QUrl &origin, bool fullscreen) override; + bool isFullScreenMode() const override; + void javascriptDialog(QSharedPointer<QtWebEngineCore::JavaScriptDialogController>) override; + void runFileChooser(QSharedPointer<QtWebEngineCore::FilePickerController>) override; + void showColorDialog(QSharedPointer<QtWebEngineCore::ColorChooserController>) override; + void didRunJavaScript(quint64 requestId, const QVariant& result) override; + void didFetchDocumentMarkup(quint64 requestId, const QString& result) override; + void didFetchDocumentInnerText(quint64 requestId, const QString& result) override; + void didFindText(quint64 requestId, int matchCount) override; + void didPrintPage(quint64 requestId, const QByteArray &result) override; + void didPrintPageToPdf(const QString &filePath, bool success) override; + void passOnFocus(bool reverse) override; + void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID) override; + void authenticationRequired(QSharedPointer<QtWebEngineCore::AuthenticationDialogController>) override; + void runMediaAccessPermissionRequest(const QUrl &securityOrigin, MediaRequestFlags requestFlags) override; + void runGeolocationPermissionRequest(const QUrl &securityOrigin) override; + void runMouseLockPermissionRequest(const QUrl &securityOrigin) override; + void runQuotaPermissionRequest(QSharedPointer<QtWebEngineCore::QuotaPermissionController>) override; + QObject *accessibilityParentObject() override; + QtWebEngineCore::WebEngineSettings *webEngineSettings() const override; + void allowCertificateError(const QSharedPointer<CertificateErrorController> &controller) override; + void showValidationMessage(const QRect &anchor, const QString &mainText, const QString &subText) override; + void hideValidationMessage() override; + void moveValidationMessage(const QRect &anchor) override; + void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, int exitCode) override; + void requestGeometryChange(const QRect &geometry, const QRect &frameGeometry) override; + void updateScrollPosition(const QPointF &position) override; + void updateContentsSize(const QSizeF &size) override; void startDragging(const content::DropData &dropData, Qt::DropActions allowedActions, - const QPixmap &pixmap, const QPoint &offset) Q_DECL_OVERRIDE; - virtual bool isEnabled() const Q_DECL_OVERRIDE; - virtual void setToolTip(const QString &toolTipText) Q_DECL_OVERRIDE; - const QObject *holdingQObject() const Q_DECL_OVERRIDE; + const QPixmap &pixmap, const QPoint &offset) override; + bool isEnabled() const override; + void setToolTip(const QString &toolTipText) override; + const QObject *holdingQObject() const override; - virtual QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContextAdapter() Q_DECL_OVERRIDE; - QtWebEngineCore::WebContentsAdapter *webContentsAdapter() Q_DECL_OVERRIDE; + QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContextAdapter() override; + QtWebEngineCore::WebContentsAdapter *webContentsAdapter() override; void updateAction(QWebEnginePage::WebAction) const; void updateNavigationActions(); @@ -174,6 +176,8 @@ public: unsigned int webChannelWorldId; QUrl iconUrl; bool m_navigationActionTriggered; + QPointer<QWebEnginePage> inspectedPage; + QPointer<QWebEnginePage> devToolsPage; mutable QtWebEngineCore::CallbackDirectory m_callbacks; mutable QAction *actions[QWebEnginePage::WebActionCount]; diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp index 2897d9798..737326c24 100644 --- a/src/webenginewidgets/api/qwebengineprofile.cpp +++ b/src/webenginewidgets/api/qwebengineprofile.cpp @@ -191,7 +191,7 @@ void QWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info) itemPrivate->downloadPath = info.path; itemPrivate->mimeType = info.mimeType; itemPrivate->savePageFormat = static_cast<QWebEngineDownloadItem::SavePageFormat>(info.savePageFormat); - itemPrivate->type = static_cast<QWebEngineDownloadItem::DownloadType>(info.downloadType); + itemPrivate->isSavePageDownload = info.isSavePageDownload; QWebEngineDownloadItem *download = new QWebEngineDownloadItem(itemPrivate, q); diff --git a/src/webenginewidgets/api/qwebengineprofile_p.h b/src/webenginewidgets/api/qwebengineprofile_p.h index 8d9e5011f..72fa904e4 100644 --- a/src/webenginewidgets/api/qwebengineprofile_p.h +++ b/src/webenginewidgets/api/qwebengineprofile_p.h @@ -81,8 +81,8 @@ public: void downloadDestroyed(quint32 downloadId); - void downloadRequested(DownloadItemInfo &info) Q_DECL_OVERRIDE; - void downloadUpdated(const DownloadItemInfo &info) Q_DECL_OVERRIDE; + void downloadRequested(DownloadItemInfo &info) override; + void downloadUpdated(const DownloadItemInfo &info) override; private: QWebEngineProfile *q_ptr; diff --git a/src/webenginewidgets/api/qwebenginequotapermissionrequest.cpp b/src/webenginewidgets/api/qwebenginequotapermissionrequest.cpp new file mode 100644 index 000000000..0841854ea --- /dev/null +++ b/src/webenginewidgets/api/qwebenginequotapermissionrequest.cpp @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwebenginequotapermissionrequest.h" + +#include "quota_permission_controller.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QWebEngineQuotaPermissionRequest + \brief The QWebEngineQuotaPermissionRequest class enables accepting or rejecting + requests for larger persistent storage than the application's current allocation + in File System API. + + \since 5.11 + + \inmodule QtWebEngineWidgets +*/ + +QWebEngineQuotaPermissionRequest::QWebEngineQuotaPermissionRequest(QSharedPointer<QtWebEngineCore::QuotaPermissionController> controller) + : d_ptr(controller) +{ +} + +/*! + Rejects a request for larger persistent storage. +*/ +void QWebEngineQuotaPermissionRequest::reject() +{ + d_ptr->cancel(); +} + +/*! + Accepts a request for larger persistent storage. +*/ +void QWebEngineQuotaPermissionRequest::accept() +{ + d_ptr->accept(); +} + +/*! + \property QWebEngineQuotaPermissionRequest::origin + \brief The URL of the web page that issued the quota permission request. +*/ + +QUrl QWebEngineQuotaPermissionRequest::origin() const +{ + return d_ptr->origin(); +} + +/*! + \property QWebEngineQuotaPermissionRequest::requestedSize + \brief Contains the size of the requested disk space in bytes. +*/ + +qint64 QWebEngineQuotaPermissionRequest::requestedSize() const +{ + return d_ptr->requestedSize(); +} + +QT_END_NAMESPACE diff --git a/src/webenginewidgets/api/qwebenginequotapermissionrequest.h b/src/webenginewidgets/api/qwebenginequotapermissionrequest.h new file mode 100644 index 000000000..aa0184fad --- /dev/null +++ b/src/webenginewidgets/api/qwebenginequotapermissionrequest.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWEBENGINEQUOTAPERMISSIONREQUEST_H +#define QWEBENGINEQUOTAPERMISSIONREQUEST_H + +#include <QtCore/qsharedpointer.h> +#include <QtCore/qurl.h> +#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h> + +namespace QtWebEngineCore { + class QuotaPermissionController; +} + +QT_BEGIN_NAMESPACE + +class QWEBENGINEWIDGETS_EXPORT QWebEngineQuotaPermissionRequest { + Q_GADGET + Q_PROPERTY(QUrl origin READ origin) + Q_PROPERTY(qint64 requestedSize READ requestedSize) +public: + Q_INVOKABLE void accept(); + Q_INVOKABLE void reject(); + QUrl origin() const; + qint64 requestedSize() const; + +private: + QWebEngineQuotaPermissionRequest(QSharedPointer<QtWebEngineCore::QuotaPermissionController> controller); + QSharedPointer<QtWebEngineCore::QuotaPermissionController> d_ptr; + friend class QWebEnginePagePrivate; +}; + +QT_END_NAMESPACE + +#endif // QWEBENGINEQUOTAPERMISSIONREQUEST_H diff --git a/src/webenginewidgets/api/qwebenginesettings.cpp b/src/webenginewidgets/api/qwebenginesettings.cpp index 1def61cb6..b829c5799 100644 --- a/src/webenginewidgets/api/qwebenginesettings.cpp +++ b/src/webenginewidgets/api/qwebenginesettings.cpp @@ -101,6 +101,10 @@ static WebEngineSettings::Attribute toWebEngineAttribute(QWebEngineSettings::Web return WebEngineSettings::AllowWindowActivationFromJavaScript; case QWebEngineSettings::ShowScrollBars: return WebEngineSettings::ShowScrollBars; + case QWebEngineSettings::PlaybackRequiresUserGesture: + return WebEngineSettings::PlaybackRequiresUserGesture; + case QWebEngineSettings::WebRTCPublicInterfacesOnly: + return WebEngineSettings::WebRTCPublicInterfacesOnly; default: return WebEngineSettings::UnsupportedInCoreSettings; @@ -182,7 +186,6 @@ void QWebEngineSettings::resetFontSize(QWebEngineSettings::FontSize type) d->resetFontSize(static_cast<WebEngineSettings::FontSize>(type)); } - void QWebEngineSettings::setDefaultTextEncoding(const QString &encoding) { Q_D(QWebEngineSettings); @@ -195,6 +198,30 @@ QString QWebEngineSettings::defaultTextEncoding() const return d->defaultTextEncoding(); } +ASSERT_ENUMS_MATCH(WebEngineSettings::DisallowUnknownUrlSchemes, QWebEngineSettings::DisallowUnknownUrlSchemes) +ASSERT_ENUMS_MATCH(WebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction, QWebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction) +ASSERT_ENUMS_MATCH(WebEngineSettings::AllowAllUnknownUrlSchemes, QWebEngineSettings::AllowAllUnknownUrlSchemes) + +QWebEngineSettings::UnknownUrlSchemePolicy QWebEngineSettings::unknownUrlSchemePolicy() const +{ + Q_D(const QWebEngineSettings); + WebEngineSettings::UnknownUrlSchemePolicy result = d->unknownUrlSchemePolicy(); + Q_ASSERT(result != WebEngineSettings::InheritedUnknownUrlSchemePolicy); + return static_cast<QWebEngineSettings::UnknownUrlSchemePolicy>(result); +} + +void QWebEngineSettings::setUnknownUrlSchemePolicy(QWebEngineSettings::UnknownUrlSchemePolicy policy) +{ + Q_D(QWebEngineSettings); + d->setUnknownUrlSchemePolicy(static_cast<WebEngineSettings::UnknownUrlSchemePolicy>(policy)); +} + +void QWebEngineSettings::resetUnknownUrlSchemePolicy() +{ + Q_D(QWebEngineSettings); + d->setUnknownUrlSchemePolicy(WebEngineSettings::InheritedUnknownUrlSchemePolicy); +} + void QWebEngineSettings::setAttribute(QWebEngineSettings::WebAttribute attr, bool on) { Q_D(QWebEngineSettings); diff --git a/src/webenginewidgets/api/qwebenginesettings.h b/src/webenginewidgets/api/qwebenginesettings.h index 470609227..81b6c2937 100644 --- a/src/webenginewidgets/api/qwebenginesettings.h +++ b/src/webenginewidgets/api/qwebenginesettings.h @@ -91,7 +91,9 @@ public: AllowRunningInsecureContent, AllowGeolocationOnInsecureOrigins, AllowWindowActivationFromJavaScript, - ShowScrollBars + ShowScrollBars, + PlaybackRequiresUserGesture, + WebRTCPublicInterfacesOnly, }; enum FontSize { @@ -101,6 +103,12 @@ public: DefaultFixedFontSize }; + enum UnknownUrlSchemePolicy { + DisallowUnknownUrlSchemes = 1, + AllowUnknownUrlSchemesFromUserInteraction, + AllowAllUnknownUrlSchemes + }; + #if QT_DEPRECATED_SINCE(5, 5) static QWebEngineSettings *globalSettings(); #endif @@ -121,6 +129,10 @@ public: void setDefaultTextEncoding(const QString &encoding); QString defaultTextEncoding() const; + UnknownUrlSchemePolicy unknownUrlSchemePolicy() const; + void setUnknownUrlSchemePolicy(UnknownUrlSchemePolicy policy); + void resetUnknownUrlSchemePolicy(); + private: Q_DISABLE_COPY(QWebEngineSettings) typedef ::QtWebEngineCore::WebEngineSettings QWebEngineSettingsPrivate; diff --git a/src/webenginewidgets/api/qwebengineview.h b/src/webenginewidgets/api/qwebengineview.h index 487cc2316..795e011ad 100644 --- a/src/webenginewidgets/api/qwebengineview.h +++ b/src/webenginewidgets/api/qwebengineview.h @@ -103,7 +103,7 @@ public: void findText(const QString &subString, QWebEnginePage::FindFlags options = QWebEnginePage::FindFlags(), const QWebEngineCallback<bool> &resultCallback = QWebEngineCallback<bool>()); #endif - virtual QSize sizeHint() const Q_DECL_OVERRIDE; + QSize sizeHint() const override; QWebEngineSettings *settings() const; public Q_SLOTS: @@ -126,14 +126,14 @@ Q_SIGNALS: protected: virtual QWebEngineView *createWindow(QWebEnginePage::WebWindowType type); - virtual void contextMenuEvent(QContextMenuEvent*) Q_DECL_OVERRIDE; - virtual bool event(QEvent*) Q_DECL_OVERRIDE; - virtual void showEvent(QShowEvent *) Q_DECL_OVERRIDE; - virtual void hideEvent(QHideEvent *) Q_DECL_OVERRIDE; - void dragEnterEvent(QDragEnterEvent *e) Q_DECL_OVERRIDE; - void dragLeaveEvent(QDragLeaveEvent *e) Q_DECL_OVERRIDE; - void dragMoveEvent(QDragMoveEvent *e) Q_DECL_OVERRIDE; - void dropEvent(QDropEvent *e) Q_DECL_OVERRIDE; + void contextMenuEvent(QContextMenuEvent*) override; + bool event(QEvent*) override; + void showEvent(QShowEvent *) override; + void hideEvent(QHideEvent *) override; + void dragEnterEvent(QDragEnterEvent *e) override; + void dragLeaveEvent(QDragLeaveEvent *e) override; + void dragMoveEvent(QDragMoveEvent *e) override; + void dropEvent(QDropEvent *e) override; private: Q_DISABLE_COPY(QWebEngineView) diff --git a/src/webenginewidgets/api/qwebengineview_p.h b/src/webenginewidgets/api/qwebengineview_p.h index f3a37225b..7f0cdac45 100644 --- a/src/webenginewidgets/api/qwebengineview_p.h +++ b/src/webenginewidgets/api/qwebengineview_p.h @@ -80,9 +80,9 @@ public: QWebEngineViewAccessible(QWebEngineView *o) : QAccessibleWidget(o) {} - int childCount() const Q_DECL_OVERRIDE; - QAccessibleInterface *child(int index) const Q_DECL_OVERRIDE; - int indexOfChild(const QAccessibleInterface *child) const Q_DECL_OVERRIDE; + int childCount() const override; + QAccessibleInterface *child(int index) const override; + int indexOfChild(const QAccessibleInterface *child) const override; private: QWebEngineView *view() const { return static_cast<QWebEngineView*>(object()); } diff --git a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc index 23b280b6d..2c161e2df 100644 --- a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc +++ b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc @@ -584,6 +584,14 @@ This signal is emitted whenever the document wants to change the position and size of the page to \a geom. This can happen for example through JavaScript. + + \note \l{QWindow::}{setGeometry()} expects a size excluding the window + decoration, while \a geom includes it. You have to remove the size of the frame margins + from \a geom to handle this signal correctly. + + \code + window->setGeometry(geom.marginsRemoved(window->frameMargins())); + \endcode */ /*! diff --git a/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc index 3fe87082a..cde26f66b 100644 --- a/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc +++ b/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc @@ -169,7 +169,34 @@ \value ShowScrollBars Shows scroll bars. Enabled by default. (Added in Qt 5.10) + \value PlaybackRequiresUserGesture + Inhibits playback of media content until the user interacts with + the page. This is similar to how Chrome on Android behaves, while + the default behavior when it is disabled is similar to Chrome on desktops. + Disabled by default. (Added in Qt 5.11) + \value WebRTCPublicInterfacesOnly + Limits WebRTC to public IP addresses only. When disabled WebRTC may also use + local network IP addresses, but remote hosts can also see your local network + IP address. + Disabled by default. (Added in Qt 5.11) +*/ + +/*! + \enum QWebEngineSettings::UnknownUrlSchemePolicy + \since Qt 5.11 + + This enum describes how navigation requests to URLs with unknown schemes are handled. + \value DisallowUnknownUrlSchemes + Disallows all navigation requests to URLs with unknown schemes. + \value AllowUnknownUrlSchemesFromUserInteraction + Allows navigation requests to URLs with unknown schemes that are issued from + user-interaction (like a mouse-click), whereas other navigation requests (for example + from JavaScript) are suppressed. + \value AllowAllUnknownUrlSchemes + Allows all navigation requests to URLs with unknown schemes. + + \sa unknownUrlSchemePolicy setUnknownUrlSchemePolicy resetUnknownUrlSchemePolicy */ /*! @@ -225,6 +252,29 @@ */ /*! + \fn QWebEngineSettings::UnknownUrlSchemePolicy QWebEngineSettings::unknownUrlSchemePolicy() const + \since Qt 5.11 + Returns the currently selected policy for handling navigation requests to URLs with + unknown schemes. Default is \l{QWebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction}. + \sa setUnknownUrlSchemePolicy resetUnknownUrlSchemePolicy +*/ + +/*! + \fn void QWebEngineSettings::setUnknownUrlSchemePolicy(QWebEngineSettings::UnknownUrlSchemePolicy policy) + \since Qt 5.11 + Sets the policy for handling navigation requests to URLs with unknown schemes to \a policy. + Default is \l{QWebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction}. + \sa unknownUrlSchemePolicy resetUnknownUrlSchemePolicy +*/ + +/*! + \fn void QWebEngineSettings::resetUnknownUrlSchemePolicy() + \since Qt 5.11 + Removes the policy for handling navigation requests to URLs with unknown schemes. + \sa unknownUrlSchemePolicy setUnknownUrlSchemePolicy +*/ + +/*! \fn void QWebEngineSettings::setAttribute(WebAttribute attribute, bool on) Enables or disables the specified \a attribute feature depending on the diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h index f3e9da2cc..79958132c 100644 --- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h +++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h @@ -53,38 +53,38 @@ class RenderWidgetHostViewQtDelegateWidget : public QQuickWidget, public RenderW public: RenderWidgetHostViewQtDelegateWidget(RenderWidgetHostViewQtDelegateClient *client, QWidget *parent = 0); - virtual void initAsChild(WebContentsAdapterClient* container) Q_DECL_OVERRIDE; - virtual void initAsPopup(const QRect&) Q_DECL_OVERRIDE; - virtual QRectF screenRect() const Q_DECL_OVERRIDE; - virtual QRectF contentsRect() const Q_DECL_OVERRIDE; - virtual void setKeyboardFocus() Q_DECL_OVERRIDE; - virtual bool hasKeyboardFocus() Q_DECL_OVERRIDE; - virtual void lockMouse() Q_DECL_OVERRIDE; - virtual void unlockMouse() Q_DECL_OVERRIDE; - virtual void show() Q_DECL_OVERRIDE; - virtual void hide() Q_DECL_OVERRIDE; - virtual bool isVisible() const Q_DECL_OVERRIDE; - virtual QWindow* window() const Q_DECL_OVERRIDE; - virtual QSGTexture *createTextureFromImage(const QImage &) Q_DECL_OVERRIDE; - virtual QSGLayer *createLayer() Q_DECL_OVERRIDE; - virtual QSGInternalImageNode *createImageNode() Q_DECL_OVERRIDE; - virtual QSGTextureNode *createTextureNode() Q_DECL_OVERRIDE; - virtual QSGRectangleNode *createRectangleNode() Q_DECL_OVERRIDE; - virtual void update() Q_DECL_OVERRIDE; - virtual void updateCursor(const QCursor &) Q_DECL_OVERRIDE; - virtual void resize(int width, int height) Q_DECL_OVERRIDE; - virtual void move(const QPoint &screenPos) Q_DECL_OVERRIDE; - virtual void inputMethodStateChanged(bool editorVisible, bool passwordInput) Q_DECL_OVERRIDE; - virtual void setInputMethodHints(Qt::InputMethodHints) Q_DECL_OVERRIDE; - virtual void setClearColor(const QColor &color) Q_DECL_OVERRIDE; + void initAsChild(WebContentsAdapterClient* container) override; + void initAsPopup(const QRect&) override; + QRectF screenRect() const override; + QRectF contentsRect() const override; + void setKeyboardFocus() override; + bool hasKeyboardFocus() override; + void lockMouse() override; + void unlockMouse() override; + void show() override; + void hide() override; + bool isVisible() const override; + QWindow* window() const override; + QSGTexture *createTextureFromImage(const QImage &) override; + QSGLayer *createLayer() override; + QSGInternalImageNode *createImageNode() override; + QSGTextureNode *createTextureNode() override; + QSGRectangleNode *createRectangleNode() override; + void update() override; + void updateCursor(const QCursor &) override; + void resize(int width, int height) override; + void move(const QPoint &screenPos) override; + void inputMethodStateChanged(bool editorVisible, bool passwordInput) override; + void setInputMethodHints(Qt::InputMethodHints) override; + void setClearColor(const QColor &color) override; protected: - bool event(QEvent *event) Q_DECL_OVERRIDE; - void resizeEvent(QResizeEvent *resizeEvent) Q_DECL_OVERRIDE; - void showEvent(QShowEvent *) Q_DECL_OVERRIDE; - void hideEvent(QHideEvent *) Q_DECL_OVERRIDE; + bool event(QEvent *event) override; + void resizeEvent(QResizeEvent *resizeEvent) override; + void showEvent(QShowEvent *) override; + void hideEvent(QHideEvent *) override; - QVariant inputMethodQuery(Qt::InputMethodQuery query) const Q_DECL_OVERRIDE; + QVariant inputMethodQuery(Qt::InputMethodQuery query) const override; private slots: void onWindowPosChanged(); diff --git a/src/webenginewidgets/ui/messagebubblewidget_p.h b/src/webenginewidgets/ui/messagebubblewidget_p.h index 8815d1ba4..6898aea13 100644 --- a/src/webenginewidgets/ui/messagebubblewidget_p.h +++ b/src/webenginewidgets/ui/messagebubblewidget_p.h @@ -73,7 +73,7 @@ public: static void moveBubble(QWebEngineView *view, const QRect &anchor); protected: - void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) override; private: void createBubble(const int maxWidth, const QString &mainText, const QString &subText); diff --git a/src/webenginewidgets/webenginewidgets.pro b/src/webenginewidgets/webenginewidgets.pro index 540c4d538..37cb7a1f0 100644 --- a/src/webenginewidgets/webenginewidgets.pro +++ b/src/webenginewidgets/webenginewidgets.pro @@ -19,6 +19,7 @@ SOURCES = \ api/qwebenginehistory.cpp \ api/qwebenginepage.cpp \ api/qwebengineprofile.cpp \ + api/qwebenginequotapermissionrequest.cpp \ api/qwebenginescript.cpp \ api/qwebenginescriptcollection.cpp \ api/qwebenginesettings.cpp \ @@ -37,6 +38,7 @@ HEADERS = \ api/qwebenginepage_p.h \ api/qwebengineprofile.h \ api/qwebengineprofile_p.h \ + api/qwebenginequotapermissionrequest.h \ api/qwebenginescriptcollection.h \ api/qwebenginescriptcollection_p.h \ api/qwebenginesettings.h \ |