diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-10-23 14:20:07 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-10-23 14:20:07 +0200 |
commit | dffe673c3044a6351aa72b69a5bf60429259c08c (patch) | |
tree | e0feba0056896b981a287704b2ef7383f9b95266 /src/webenginewidgets/api | |
parent | 9be23eb946580519b2b0600cc854ec8050b90659 (diff) | |
parent | 8f32ce028a48ddc6a7333b7af635424c78437ed7 (diff) | |
download | qtwebengine-dffe673c3044a6351aa72b69a5bf60429259c08c.tar.gz |
Merge remote-tracking branch 'origin/5.6' into dev
Change-Id: I5d0d5f65575256673c35558e0fcbf749a1439793
Diffstat (limited to 'src/webenginewidgets/api')
-rw-r--r-- | src/webenginewidgets/api/qwebenginefullscreenrequest.cpp | 59 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginefullscreenrequest.h | 68 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginepage.cpp | 47 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginepage.h | 11 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginepage_p.h | 8 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebengineprofile.cpp | 52 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebengineprofile.h | 6 |
7 files changed, 193 insertions, 58 deletions
diff --git a/src/webenginewidgets/api/qwebenginefullscreenrequest.cpp b/src/webenginewidgets/api/qwebenginefullscreenrequest.cpp new file mode 100644 index 000000000..6223c070d --- /dev/null +++ b/src/webenginewidgets/api/qwebenginefullscreenrequest.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwebenginefullscreenrequest.h" +#include "qwebenginepage_p.h" + +QT_BEGIN_NAMESPACE + +QWebEngineFullScreenRequest::QWebEngineFullScreenRequest(QWebEnginePagePrivate *pagePrivate, const QUrl &origin, bool fullscreen) + : m_pagePrivate(pagePrivate) + , m_origin(origin) + , m_toggleOn(fullscreen) +{ +} + +void QWebEngineFullScreenRequest::reject() const +{ + m_pagePrivate->setFullScreenMode(!m_toggleOn); +} + +void QWebEngineFullScreenRequest::accept() const +{ + m_pagePrivate->setFullScreenMode(m_toggleOn); +} + +QT_END_NAMESPACE diff --git a/src/webenginewidgets/api/qwebenginefullscreenrequest.h b/src/webenginewidgets/api/qwebenginefullscreenrequest.h new file mode 100644 index 000000000..c6768f4d6 --- /dev/null +++ b/src/webenginewidgets/api/qwebenginefullscreenrequest.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWEBENGINEFULLSCREENREQUEST_H +#define QWEBENGINEFULLSCREENREQUEST_H + +#include <qtwebenginewidgetsglobal.h> +#include <qwebenginepage.h> +#include <QtCore/qurl.h> + +QT_BEGIN_NAMESPACE +class QWebEnginePagePrivate; + +class QWEBENGINEWIDGETS_EXPORT QWebEngineFullScreenRequest { + Q_GADGET + Q_PROPERTY(bool toggleOn READ toggleOn) + Q_PROPERTY(QUrl origin READ origin) +public: + Q_INVOKABLE void reject() const; + Q_INVOKABLE void accept() const; + bool toggleOn() const { return m_toggleOn; } + const QUrl &origin() const { return m_origin; } + +private: + Q_DISABLE_COPY(QWebEngineFullScreenRequest) + QWebEngineFullScreenRequest(QWebEnginePagePrivate *pagePrivate, const QUrl &origin, bool toggleOn); + QWebEnginePagePrivate *m_pagePrivate; + const QUrl m_origin; + const bool m_toggleOn; + friend class QWebEnginePagePrivate; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index e13b5d319..dd71db6a0 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -28,6 +28,7 @@ #include "certificate_error_controller.h" #include "file_picker_controller.h" #include "javascript_dialog_controller.h" +#include "qwebenginefullscreenrequest.h" #include "qwebenginehistory.h" #include "qwebenginehistory_p.h" #include "qwebengineprofile.h" @@ -89,7 +90,7 @@ QWebEnginePagePrivate::QWebEnginePagePrivate(QWebEngineProfile *_profile) , isLoading(false) , scriptCollection(new QWebEngineScriptCollectionPrivate(browserContextAdapter()->userScriptController(), adapter.data())) , m_backgroundColor(Qt::white) - , m_fullscreenRequested(false) + , fullscreenMode(false) { memset(actions, 0, sizeof(actions)); } @@ -384,6 +385,14 @@ void QWebEnginePagePrivate::updateContentsSize(const QSizeF &size) Q_EMIT q->contentsSizeChanged(size); } +void QWebEnginePagePrivate::setFullScreenMode(bool fullscreen) +{ + if (fullscreenMode != fullscreen) { + fullscreenMode = fullscreen; + adapter->changedFullScreen(); + } +} + BrowserContextAdapter *QWebEnginePagePrivate::browserContextAdapter() { return profile->d_ptr->browserContext(); @@ -422,13 +431,18 @@ QWebEnginePage::QWebEnginePage(QObject* parent) */ /*! - \fn QWebEnginePage::fullScreenRequested(bool fullScreen) + \fn QWebEnginePage::fullScreenRequested(const QWebEngineFullScreenRequest &request) + + This signal is emitted when the web page issues the request to enter fullscreen mode for + a web-element, usually a video element. + + The request object \a request can be used to accept or reject the request. - This signal is emitted when the web page issues the request to enter or exit fullscreen mode. - If \a fullScreen is \c true, the page wants to enter the mode and if it is \c false, the page - wants to exit the mode. + If the request is accepted the element requesting fullscreen will fill the viewport, + but it is up to the application to make the view fullscreen or move the page to a view + that is fullscreen. - \sa isFullScreen(), QWebEngineSettings::FullScreenSupportEnabled + \sa QWebEngineSettings::FullScreenSupportEnabled */ /*! @@ -903,16 +917,16 @@ void QWebEnginePagePrivate::navigationRequested(int navigationType, const QUrl & navigationRequestAction = accepted ? WebContentsAdapterClient::AcceptRequest : WebContentsAdapterClient::IgnoreRequest; } -void QWebEnginePagePrivate::requestFullScreen(bool fullScreen) +void QWebEnginePagePrivate::requestFullScreenMode(const QUrl &origin, bool fullscreen) { Q_Q(QWebEnginePage); - m_fullscreenRequested = fullScreen; - Q_EMIT q->fullScreenRequested(fullScreen); + QWebEngineFullScreenRequest request(this, origin, fullscreen); + Q_EMIT q->fullScreenRequested(request); } -bool QWebEnginePagePrivate::isFullScreen() const +bool QWebEnginePagePrivate::isFullScreenMode() const { - return m_fullscreenRequested && q_ptr->isFullScreen(); + return fullscreenMode; } void QWebEnginePagePrivate::javascriptDialog(QSharedPointer<JavaScriptDialogController> controller) @@ -1060,7 +1074,7 @@ QMenu *QWebEnginePage::createStandardContextMenu() if (d->adapter->hasInspector()) menu->addAction(QWebEnginePage::action(InspectElement)); - if (d->isFullScreen()) + if (d->isFullScreenMode()) menu->addAction(QWebEnginePage::action(ExitFullScreen)); return menu; @@ -1315,15 +1329,6 @@ bool QWebEnginePage::acceptNavigationRequest(const QUrl &url, NavigationType typ } /*! - Returns \c true if the web view is in fullscreen mode, \c false otherwise. -*/ -bool QWebEnginePage::isFullScreen() -{ - Q_D(const QWebEnginePage); - return d->view ? d->view->isFullScreen() : false; -} - -/*! \since 5.7 Returns the scroll position of the page contents. diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h index a5930b396..9740c89c9 100644 --- a/src/webenginewidgets/api/qwebenginepage.h +++ b/src/webenginewidgets/api/qwebenginepage.h @@ -37,9 +37,9 @@ #ifndef QWEBENGINEPAGE_H #define QWEBENGINEPAGE_H -#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h> -#include <QtWebEngineWidgets/qwebenginecertificateerror.h> -#include <QtWebEngineCore/qwebenginecallback.h> +#include <qtwebenginewidgetsglobal.h> +#include <qwebenginecertificateerror.h> +#include <qwebenginecallback.h> #include <QtCore/qobject.h> #include <QtCore/qurl.h> @@ -50,6 +50,7 @@ QT_BEGIN_NAMESPACE class QMenu; class QWebChannel; +class QWebEngineFullScreenRequest; class QWebEngineHistory; class QWebEnginePage; class QWebEnginePagePrivate; @@ -252,12 +253,12 @@ Q_SIGNALS: void linkHovered(const QString &url); void selectionChanged(); - void fullScreenRequested(bool fullScreen); void geometryChangeRequested(const QRect& geom); void windowCloseRequested(); void featurePermissionRequested(const QUrl &securityOrigin, QWebEnginePage::Feature feature); void featurePermissionRequestCanceled(const QUrl &securityOrigin, QWebEnginePage::Feature feature); + void fullScreenRequested(const QWebEngineFullScreenRequest &fullScreenRequest); void authenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator); void proxyAuthenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator, const QString &proxyHost); @@ -282,7 +283,7 @@ protected: virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID); virtual bool certificateError(const QWebEngineCertificateError &certificateError); virtual bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame); - virtual bool isFullScreen(); + private: Q_DISABLE_COPY(QWebEnginePage) Q_DECLARE_PRIVATE(QWebEnginePage) diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h index 0ddca3874..66a2cf35b 100644 --- a/src/webenginewidgets/api/qwebenginepage_p.h +++ b/src/webenginewidgets/api/qwebenginepage_p.h @@ -98,8 +98,8 @@ public: virtual void windowCloseRejected() Q_DECL_OVERRIDE; virtual bool 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 requestFullScreen(bool) Q_DECL_OVERRIDE; - virtual bool isFullScreen() const 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(QtWebEngineCore::FilePickerController *controller) Q_DECL_OVERRIDE; virtual void didRunJavaScript(quint64 requestId, const QVariant& result) Q_DECL_OVERRIDE; @@ -134,6 +134,8 @@ public: QtWebEngineCore::WebContentsAdapter *webContents() { return adapter.data(); } void recreateFromSerializedHistory(QDataStream &input); + void setFullScreenMode(bool); + QExplicitlySharedDataPointer<QtWebEngineCore::WebContentsAdapter> adapter; QWebEngineHistory *history; QWebEngineProfile *profile; @@ -144,7 +146,7 @@ public: bool isLoading; QWebEngineScriptCollection scriptCollection; QColor m_backgroundColor; - bool m_fullscreenRequested; + bool fullscreenMode; 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 b98aa3a61..2edebdfeb 100644 --- a/src/webenginewidgets/api/qwebengineprofile.cpp +++ b/src/webenginewidgets/api/qwebengineprofile.cpp @@ -443,19 +443,6 @@ QWebEngineCookieStoreClient* QWebEngineProfile::cookieStoreClient() return d->browserContext()->cookieStoreClient(); } -/*! - Registers a cookie store client singleton \a client to access Chromium's cookies. - - The profile does not take ownership of the pointer. - - \sa QWebEngineCookieStoreClient -*/ - -void QWebEngineProfile::setCookieStoreClient(QWebEngineCookieStoreClient *client) -{ - Q_D(QWebEngineProfile); - d->browserContext()->setCookieStoreClient(client); -} /*! Registers a request interceptor singleton \a interceptor to intercept URL requests. @@ -562,43 +549,56 @@ static bool checkInternalScheme(const QByteArray &scheme) /*! \since 5.6 - Installs the custom URL scheme handler \a handler in the profile. + Registers a handler \a handler for custom URL scheme \a scheme in the profile. */ -void QWebEngineProfile::installUrlSchemeHandler(QWebEngineUrlSchemeHandler *handler) +void QWebEngineProfile::installUrlSchemeHandler(const QByteArray &scheme, QWebEngineUrlSchemeHandler *handler) { Q_D(QWebEngineProfile); Q_ASSERT(handler); - QByteArray scheme = handler->scheme(); if (checkInternalScheme(scheme)) { - qWarning("Can not install a URL scheme handler overriding internal scheme: %s", scheme.constData()); + qWarning("Cannot install a URL scheme handler overriding internal scheme: %s", scheme.constData()); return; } if (d->browserContext()->customUrlSchemeHandlers().contains(scheme)) { - qWarning("URL scheme handler already installed for the scheme: %s", scheme.constData()); + if (d->browserContext()->customUrlSchemeHandlers().value(scheme) != handler) + qWarning("URL scheme handler already installed for the scheme: %s", scheme.constData()); return; } - d->browserContext()->customUrlSchemeHandlers().insert(scheme, handler); - d->browserContext()->updateCustomUrlSchemeHandlers(); + d->browserContext()->addCustomUrlSchemeHandler(scheme, handler); connect(handler, SIGNAL(destroyed(QWebEngineUrlSchemeHandler*)), this, SLOT(destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler*))); } /*! \since 5.6 - Removes the custom URL scheme handler \a handler from the profile + Removes the custom URL scheme handler \a handler from the profile. + + \sa removeUrlScheme() */ void QWebEngineProfile::removeUrlSchemeHandler(QWebEngineUrlSchemeHandler *handler) { Q_D(QWebEngineProfile); Q_ASSERT(handler); - if (!handler) + if (!d->browserContext()->removeCustomUrlSchemeHandler(handler)) return; - int count = d->browserContext()->customUrlSchemeHandlers().remove(handler->scheme()); - if (!count) + disconnect(handler, SIGNAL(destroyed(QWebEngineUrlSchemeHandler*)), this, SLOT(destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler*))); +} + +/*! + \since 5.6 + + Removes the custom URL scheme \a scheme from the profile. + + \sa removeUrlSchemeHandler() +*/ +void QWebEngineProfile::removeUrlScheme(const QByteArray &scheme) +{ + Q_D(QWebEngineProfile); + QWebEngineUrlSchemeHandler *handler = d->browserContext()->takeCustomUrlSchemeHandler(scheme); + if (!handler) return; disconnect(handler, SIGNAL(destroyed(QWebEngineUrlSchemeHandler*)), this, SLOT(destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler*))); - d->browserContext()->updateCustomUrlSchemeHandlers(); } /*! @@ -606,7 +606,7 @@ void QWebEngineProfile::removeUrlSchemeHandler(QWebEngineUrlSchemeHandler *handl Removes all custom URL scheme handlers installed in the profile. */ -void QWebEngineProfile::clearUrlSchemeHandlers() +void QWebEngineProfile::removeAllUrlSchemeHandlers() { Q_D(QWebEngineProfile); d->browserContext()->customUrlSchemeHandlers().clear(); diff --git a/src/webenginewidgets/api/qwebengineprofile.h b/src/webenginewidgets/api/qwebengineprofile.h index 82946a223..7e03c065c 100644 --- a/src/webenginewidgets/api/qwebengineprofile.h +++ b/src/webenginewidgets/api/qwebengineprofile.h @@ -100,7 +100,6 @@ public: void setHttpCacheMaximumSize(int maxSize); QWebEngineCookieStoreClient* cookieStoreClient(); - void setCookieStoreClient(QWebEngineCookieStoreClient *client); void setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor); void clearAllVisitedLinks(); @@ -111,9 +110,10 @@ public: QWebEngineScriptCollection *scripts() const; const QWebEngineUrlSchemeHandler *urlSchemeHandler(const QByteArray &) const; - void installUrlSchemeHandler(QWebEngineUrlSchemeHandler *); + void installUrlSchemeHandler(const QByteArray &scheme, QWebEngineUrlSchemeHandler *); + void removeUrlScheme(const QByteArray &scheme); void removeUrlSchemeHandler(QWebEngineUrlSchemeHandler *); - void clearUrlSchemeHandlers(); + void removeAllUrlSchemeHandlers(); static QWebEngineProfile *defaultProfile(); |