summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-10-23 14:20:07 +0200
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-10-23 14:20:07 +0200
commitdffe673c3044a6351aa72b69a5bf60429259c08c (patch)
treee0feba0056896b981a287704b2ef7383f9b95266
parent9be23eb946580519b2b0600cc854ec8050b90659 (diff)
parent8f32ce028a48ddc6a7333b7af635424c78437ed7 (diff)
Merge remote-tracking branch 'origin/5.6' into dev
-rw-r--r--examples/webenginewidgets/demobrowser/tabwidget.cpp19
-rw-r--r--examples/webenginewidgets/demobrowser/tabwidget.h2
m---------src/3rdparty0
-rw-r--r--src/core/api/core_api.pro3
-rw-r--r--src/core/api/qwebenginecallback_p.h6
-rw-r--r--src/core/api/qwebenginecookiestoreclient.cpp59
-rw-r--r--src/core/api/qwebenginecookiestoreclient.h16
-rw-r--r--src/core/api/qwebenginecookiestoreclient_p.h1
-rw-r--r--src/core/api/qwebengineurlschemehandler.cpp19
-rw-r--r--src/core/api/qwebengineurlschemehandler.h5
-rw-r--r--src/core/browser_context_adapter.cpp39
-rw-r--r--src/core/browser_context_adapter.h7
-rw-r--r--src/core/resource_dispatcher_host_delegate_qt.cpp5
-rw-r--r--src/core/url_request_context_getter_qt.cpp19
-rw-r--r--src/core/web_contents_adapter.cpp6
-rw-r--r--src/core/web_contents_adapter.h1
-rw-r--r--src/core/web_contents_adapter_client.h4
-rw-r--r--src/core/web_contents_delegate_qt.cpp17
-rw-r--r--src/webengine/api/qquickwebengineprofile.cpp10
-rw-r--r--src/webengine/api/qquickwebengineprofile_p.h8
-rw-r--r--src/webengine/api/qquickwebengineview.cpp19
-rw-r--r--src/webengine/api/qquickwebengineview_p.h10
-rw-r--r--src/webengine/api/qquickwebengineview_p_p.h4
-rw-r--r--src/webengine/api/qtwebengineglobal.cpp28
-rw-r--r--src/webengine/doc/qtwebengine.qdocconf4
-rw-r--r--src/webengine/doc/src/qtwebengine-modules.qdoc3
-rw-r--r--src/webengine/doc/src/qtwebengine-overview.qdoc15
-rw-r--r--src/webengine/doc/src/qtwebengine-platform-notes.qdoc2
-rw-r--r--src/webengine/ui_delegates_manager.cpp2
-rw-r--r--src/webenginewidgets/api/qwebenginefullscreenrequest.cpp (renamed from src/core/api/qwebengineurlschemehandler_p.h)40
-rw-r--r--src/webenginewidgets/api/qwebenginefullscreenrequest.h68
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp47
-rw-r--r--src/webenginewidgets/api/qwebenginepage.h11
-rw-r--r--src/webenginewidgets/api/qwebenginepage_p.h8
-rw-r--r--src/webenginewidgets/api/qwebengineprofile.cpp52
-rw-r--r--src/webenginewidgets/api/qwebengineprofile.h6
-rw-r--r--src/webenginewidgets/webenginewidgets.pro2
-rw-r--r--tests/auto/core/qwebenginecookiestoreclient/tst_qwebenginecookiestoreclient.cpp48
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp31
-rw-r--r--tests/quicktestbrowser/main.cpp29
-rw-r--r--tools/qmake/mkspecs/features/functions.prf20
41 files changed, 431 insertions, 264 deletions
diff --git a/examples/webenginewidgets/demobrowser/tabwidget.cpp b/examples/webenginewidgets/demobrowser/tabwidget.cpp
index 9e08426f1..4e2073b11 100644
--- a/examples/webenginewidgets/demobrowser/tabwidget.cpp
+++ b/examples/webenginewidgets/demobrowser/tabwidget.cpp
@@ -48,10 +48,11 @@
#include "urllineedit.h"
#include "webview.h"
+#include <QWebEngineDownloadItem>
+#include <QWebEngineProfile>
+#include <QWebEngineFullScreenRequest>
#include <QtCore/QMimeData>
#include <QtGui/QClipboard>
-#include <QtWebEngineWidgets/QWebEngineDownloadItem>
-#include <QtWebEngineWidgets/QWebEngineProfile>
#include <QtWidgets/QCompleter>
#include <QtWidgets/QListView>
#include <QtWidgets/QMenu>
@@ -321,8 +322,8 @@ void TabWidget::currentChanged(int index)
this, SIGNAL(loadProgress(int)));
disconnect(oldWebView->page()->profile(), SIGNAL(downloadRequested(QWebEngineDownloadItem*)),
this, SLOT(downloadRequested(QWebEngineDownloadItem*)));
- disconnect(oldWebView->page(), SIGNAL(fullScreenRequested(bool)),
- this, SLOT(fullScreenRequested(bool)));
+ disconnect(oldWebView->page(), SIGNAL(fullScreenRequested(const QWebEngineFullScreenRequest&)),
+ this, SLOT(fullScreenRequested(const QWebEngineFullScreenRequest&)));
}
#if defined(QWEBENGINEVIEW_STATUSBARMESSAGE)
@@ -335,8 +336,8 @@ void TabWidget::currentChanged(int index)
this, SIGNAL(loadProgress(int)));
connect(webView->page()->profile(), SIGNAL(downloadRequested(QWebEngineDownloadItem*)),
this, SLOT(downloadRequested(QWebEngineDownloadItem*)));
- connect(webView->page(), SIGNAL(fullScreenRequested(bool)),
- this, SLOT(fullScreenRequested(bool)));
+ connect(webView->page(), SIGNAL(fullScreenRequested(const QWebEngineFullScreenRequest&)),
+ this, SLOT(fullScreenRequested(const QWebEngineFullScreenRequest&)));
for (int i = 0; i < m_actions.count(); ++i) {
WebActionMapper *mapper = m_actions[i];
@@ -352,13 +353,14 @@ void TabWidget::currentChanged(int index)
webView->setFocus();
}
-void TabWidget::fullScreenRequested(bool fullscreen)
+void TabWidget::fullScreenRequested(const QWebEngineFullScreenRequest &request)
{
- if (fullscreen) {
+ if (request.toggleOn()) {
if (!m_fullScreenView)
m_fullScreenView = new QWebEngineView();
WebPage *webPage = qobject_cast<WebPage*>(sender());
webPage->setView(m_fullScreenView);
+ request.accept();
m_fullScreenView->showFullScreen();
m_fullScreenView->raise();
} else {
@@ -367,6 +369,7 @@ void TabWidget::fullScreenRequested(bool fullscreen)
WebPage *webPage = qobject_cast<WebPage*>(sender());
WebView *oldWebView = this->webView(m_lineEdits->currentIndex());
webPage->setView(oldWebView);
+ request.accept();
raise();
m_fullScreenView->hide();
}
diff --git a/examples/webenginewidgets/demobrowser/tabwidget.h b/examples/webenginewidgets/demobrowser/tabwidget.h
index 0f2a20c34..3a1fe7171 100644
--- a/examples/webenginewidgets/demobrowser/tabwidget.h
+++ b/examples/webenginewidgets/demobrowser/tabwidget.h
@@ -216,7 +216,7 @@ private slots:
void lineEditReturnPressed();
void windowCloseRequested();
void moveTab(int fromIndex, int toIndex);
- void fullScreenRequested(bool);
+ void fullScreenRequested(const QWebEngineFullScreenRequest& request);
private:
QAction *m_recentlyClosedTabsAction;
diff --git a/src/3rdparty b/src/3rdparty
-Subproject 6c28e9497f45870d1d6db37f54a67fb597f9592
+Subproject 9409dd36053110043e048ebdc5ded4c72f26f47
diff --git a/src/core/api/core_api.pro b/src/core/api/core_api.pro
index 6a37b2ac3..e4cdf43cb 100644
--- a/src/core/api/core_api.pro
+++ b/src/core/api/core_api.pro
@@ -39,8 +39,7 @@ HEADERS = \
qwebengineurlrequestinfo.h \
qwebengineurlrequestinfo_p.h \
qwebengineurlrequestjob.h \
- qwebengineurlschemehandler.h \
- qwebengineurlschemehandler_p.h
+ qwebengineurlschemehandler.h
SOURCES = \
qwebenginecookiestoreclient.cpp \
diff --git a/src/core/api/qwebenginecallback_p.h b/src/core/api/qwebenginecallback_p.h
index 44d9ceb14..f0c25fe9e 100644
--- a/src/core/api/qwebenginecallback_p.h
+++ b/src/core/api/qwebenginecallback_p.h
@@ -98,6 +98,12 @@ public:
FOR_EACH_TYPE(DEFINE_INVOKE_FOR_TYPE)
#undef DEFINE_INVOKE_FOR_TYPE
+ template <typename A>
+ void invokeDirectly(const QWebEngineCallback<A> &callback, const A &argument)
+ {
+ return callback.d.data()->operator()(std::forward<const A&>(argument));
+ }
+
private:
struct CallbackSharedDataPointerBase {
virtual ~CallbackSharedDataPointerBase() { }
diff --git a/src/core/api/qwebenginecookiestoreclient.cpp b/src/core/api/qwebenginecookiestoreclient.cpp
index 3a003ff3e..167b3f68c 100644
--- a/src/core/api/qwebenginecookiestoreclient.cpp
+++ b/src/core/api/qwebenginecookiestoreclient.cpp
@@ -175,8 +175,16 @@ void QWebEngineCookieStoreClientPrivate::onCookieChanged(const QNetworkCookie &c
bool QWebEngineCookieStoreClientPrivate::canSetCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &url)
{
- Q_Q(QWebEngineCookieStoreClient);
- return q->acceptCookie(firstPartyUrl, cookieLine, url);
+ if (filterCallback) {
+ QWebEngineCookieStoreClient::FilterRequest request;
+ request.accepted = true;
+ request.firstPartyUrl = firstPartyUrl;
+ request.cookieLine = cookieLine;
+ request.cookieSource = url;
+ callbackDirectory.invokeDirectly<const QWebEngineCookieStoreClient::FilterRequest&>(filterCallback, request);
+ return request.accepted;
+ }
+ return true;
}
/*!
@@ -185,8 +193,7 @@ bool QWebEngineCookieStoreClientPrivate::canSetCookie(const QUrl &firstPartyUrl,
\since 5.6
\brief The QWebEngineCookieStoreClient class provides access to Chromium's cookies.
- By subclassing the QWebEngineCookieStoreClient and installing it on the profile, the user can
- access HTTP cookies of Chromium.
+ The class allows to access HTTP cookies of Chromium for a specific profile.
It can be used to synchronize cookies of Chromium and the QNetworkAccessManager, as well as
to set, delete, and intercept cookies during navigation.
Because cookie operations are asynchronous, the user can choose to provide a callback function
@@ -196,6 +203,27 @@ bool QWebEngineCookieStoreClientPrivate::canSetCookie(const QUrl &firstPartyUrl,
*/
/*!
+ \class QWebEngineCookieStoreClient::FilterRequest
+ \inmodule QtWebEngineCore
+ \since 5.6
+
+ The structure specifies properties of a cookie, and whether it should accepted or not. It is
+ used as an argument to a filter installed via setCookieFilter().
+*/
+
+/*!
+ \variable QWebEngineCookieStoreClient::FilterRequest::accepted
+ Whether the cookie shall be accepted. The default is \c true.
+ \variable QWebEngineCookieStoreClient::FilterRequest::firstPartyUrl
+ URL of page that triggered the setting of the cookie.
+ \variable QWebEngineCookieStoreClient::FilterRequest::cookieLine
+ Content of the cookie.
+ \variable QWebEngineCookieStoreClient::FilterRequest::cookieSource
+ URL of site that sets the cookie.
+*/
+
+
+/*!
\fn void QWebEngineCookieStoreClient::cookieAdded(const QNetworkCookie &cookie)
This signal is emitted whenever a new \a cookie is added to the cookie store.
@@ -355,20 +383,21 @@ void QWebEngineCookieStoreClient::deleteAllCookies()
}
/*!
- This virtual function is called before a new cookie is added to the cookie store.
- By overriding this function and returning \c false the user can decide to deny
- from \a firstPartyUrl the cookie \a cookieLine with the source \a cookieSource.
- The request's \a firstPartyUrl can be used to identify a third-party cookie.
- This function should not be used to execute heavy tasks since it is running on the
+ \fn void QWebEngineCookieStoreClient::setCookieFilter(FunctorOrLambda filterCallback)
+
+ Installs a cookie filter that can reject cookies before they are added to the cookie store.
+ The \a filterCallback must be a lambda or functor taking FilterRequest structure. If the
+ cookie is to be rejected, the filter can set FilterRequest::accepted to \c false.
+
+ The callback should not be used to execute heavy tasks since it is running on the
IO thread and therefore blocks the Chromium networking.
-*/
-bool QWebEngineCookieStoreClient::acceptCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &cookieSource)
+ \sa deleteAllCookiesWithCallback(), getAllCookies()
+*/
+void QWebEngineCookieStoreClient::setCookieFilter(const QWebEngineCallback<const QWebEngineCookieStoreClient::FilterRequest&> &filter)
{
- Q_UNUSED(firstPartyUrl);
- Q_UNUSED(cookieLine);
- Q_UNUSED(cookieSource);
- return true;
+ Q_D(QWebEngineCookieStoreClient);
+ d->filterCallback = filter;
}
QT_END_NAMESPACE
diff --git a/src/core/api/qwebenginecookiestoreclient.h b/src/core/api/qwebenginecookiestoreclient.h
index 3a6f54ea7..8bdb988e2 100644
--- a/src/core/api/qwebenginecookiestoreclient.h
+++ b/src/core/api/qwebenginecookiestoreclient.h
@@ -46,6 +46,7 @@
#include <QtNetwork/qnetworkcookie.h>
namespace QtWebEngineCore {
+class BrowserContextAdapter;
class CookieMonsterDelegateQt;
}
@@ -54,8 +55,15 @@ QT_BEGIN_NAMESPACE
class QWebEngineCookieStoreClientPrivate;
class QWEBENGINE_EXPORT QWebEngineCookieStoreClient : public QObject {
Q_OBJECT
+
public:
- explicit QWebEngineCookieStoreClient(QObject *parent = 0);
+ struct FilterRequest {
+ bool accepted;
+
+ QUrl firstPartyUrl;
+ QByteArray cookieLine;
+ QUrl cookieSource;
+ };
virtual ~QWebEngineCookieStoreClient();
#ifdef Q_QDOC
@@ -63,24 +71,26 @@ public:
void deleteSessionCookiesWithCallback(FunctorOrLambda resultCallback);
void deleteAllCookiesWithCallback(FunctorOrLambda resultCallback);
void getAllCookies(FunctorOrLambda resultCallback);
+ void setCookieFilter(FunctorOrLambda filterCallback);
#else
void setCookieWithCallback(const QNetworkCookie &cookie, const QWebEngineCallback<bool> &resultCallback, const QUrl &origin = QUrl());
void deleteSessionCookiesWithCallback(const QWebEngineCallback<int> &resultCallback);
void deleteAllCookiesWithCallback(const QWebEngineCallback<int> &resultCallback);
void getAllCookies(const QWebEngineCallback<const QByteArray&> &resultCallback);
+ void setCookieFilter(const QWebEngineCallback<const FilterRequest&> &filterCallback);
#endif
void setCookie(const QNetworkCookie &cookie, const QUrl &origin = QUrl());
void deleteCookie(const QNetworkCookie &cookie, const QUrl &origin = QUrl());
void deleteSessionCookies();
void deleteAllCookies();
- virtual bool acceptCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &cookieSource);
-
Q_SIGNALS:
void cookieAdded(const QNetworkCookie &cookie);
void cookieRemoved(const QNetworkCookie &cookie);
private:
+ explicit QWebEngineCookieStoreClient(QObject *parent = 0);
+ friend class QtWebEngineCore::BrowserContextAdapter;
friend class QtWebEngineCore::CookieMonsterDelegateQt;
Q_DISABLE_COPY(QWebEngineCookieStoreClient)
Q_DECLARE_PRIVATE(QWebEngineCookieStoreClient)
diff --git a/src/core/api/qwebenginecookiestoreclient_p.h b/src/core/api/qwebenginecookiestoreclient_p.h
index a5b0a7068..43652fba6 100644
--- a/src/core/api/qwebenginecookiestoreclient_p.h
+++ b/src/core/api/qwebenginecookiestoreclient_p.h
@@ -74,6 +74,7 @@ class QWEBENGINE_PRIVATE_EXPORT QWebEngineCookieStoreClientPrivate {
public:
Q_DECLARE_PUBLIC(QWebEngineCookieStoreClient)
QtWebEngineCore::CallbackDirectory callbackDirectory;
+ QWebEngineCallback<const QWebEngineCookieStoreClient::FilterRequest&> filterCallback;
QList<CookieData> m_pendingUserCookies;
quint64 m_nextCallbackId;
bool m_deleteSessionCookiesPending;
diff --git a/src/core/api/qwebengineurlschemehandler.cpp b/src/core/api/qwebengineurlschemehandler.cpp
index e6c20dbca..f887e4e98 100644
--- a/src/core/api/qwebengineurlschemehandler.cpp
+++ b/src/core/api/qwebengineurlschemehandler.cpp
@@ -35,7 +35,6 @@
****************************************************************************/
#include "qwebengineurlschemehandler.h"
-#include "qwebengineurlschemehandler_p.h"
#include "qwebengineurlrequestjob.h"
@@ -59,20 +58,14 @@ QT_BEGIN_NAMESPACE
This signal is emitted when the custom URL scheme handler \a handler is deleted.
*/
-QWebEngineUrlSchemeHandlerPrivate::QWebEngineUrlSchemeHandlerPrivate(const QByteArray &scheme)
- : m_scheme(scheme)
-{
-}
-
/*!
Constructs a new URL scheme handler.
- The handler is created for \a scheme with the parent \a parent.
+ The handler is created with the parent \a parent.
*/
-QWebEngineUrlSchemeHandler::QWebEngineUrlSchemeHandler(const QByteArray &scheme, QObject *parent)
+QWebEngineUrlSchemeHandler::QWebEngineUrlSchemeHandler(QObject *parent)
: QObject(parent)
- , d_ptr(new QWebEngineUrlSchemeHandlerPrivate(scheme))
{
}
@@ -86,14 +79,6 @@ QWebEngineUrlSchemeHandler::~QWebEngineUrlSchemeHandler()
}
/*!
- Returns the custom URL scheme handled.
-*/
-QByteArray QWebEngineUrlSchemeHandler::scheme() const
-{
- return d_ptr->scheme();
-}
-
-/*!
\fn void QWebEngineUrlSchemeHandler::requestStarted(QWebEngineUrlRequestJob *request)
This method is called whenever a request \a request for the registered scheme is started.
diff --git a/src/core/api/qwebengineurlschemehandler.h b/src/core/api/qwebengineurlschemehandler.h
index 1b6a66706..8c1e52646 100644
--- a/src/core/api/qwebengineurlschemehandler.h
+++ b/src/core/api/qwebengineurlschemehandler.h
@@ -39,7 +39,6 @@
#include "qtwebenginecoreglobal.h"
-#include <QtCore/qbytearray.h>
#include <QtCore/qobject.h>
namespace QtWebEngineCore {
@@ -54,11 +53,9 @@ class QWebEngineUrlSchemeHandlerPrivate;
class QWEBENGINE_EXPORT QWebEngineUrlSchemeHandler : public QObject {
Q_OBJECT
public:
- QWebEngineUrlSchemeHandler(const QByteArray &scheme, QObject *parent = 0);
+ QWebEngineUrlSchemeHandler(QObject *parent = 0);
~QWebEngineUrlSchemeHandler();
- QByteArray scheme() const;
-
virtual void requestStarted(QWebEngineUrlRequestJob*) = 0;
Q_SIGNALS:
diff --git a/src/core/browser_context_adapter.cpp b/src/core/browser_context_adapter.cpp
index 345741847..b5fdf2ce0 100644
--- a/src/core/browser_context_adapter.cpp
+++ b/src/core/browser_context_adapter.cpp
@@ -138,16 +138,11 @@ DownloadManagerDelegateQt *BrowserContextAdapter::downloadManagerDelegate()
QWebEngineCookieStoreClient *BrowserContextAdapter::cookieStoreClient()
{
+ if (!m_cookieStoreClient)
+ m_cookieStoreClient.reset(new QWebEngineCookieStoreClient);
return m_cookieStoreClient.data();
}
-void BrowserContextAdapter::setCookieStoreClient(QWebEngineCookieStoreClient *client)
-{
- m_cookieStoreClient = client;
- if (m_browserContext->url_request_getter_.get())
- m_browserContext->url_request_getter_->updateStorageSettings();
-}
-
QWebEngineUrlRequestInterceptor *BrowserContextAdapter::requestInterceptor()
{
return m_requestInterceptor.data();
@@ -365,9 +360,35 @@ void BrowserContextAdapter::updateCustomUrlSchemeHandlers()
m_browserContext->url_request_getter_->updateStorageSettings();
}
-void BrowserContextAdapter::removeCustomUrlSchemeHandler(QWebEngineUrlSchemeHandler *handler)
+bool BrowserContextAdapter::removeCustomUrlSchemeHandler(QWebEngineUrlSchemeHandler *handler)
+{
+ bool removedOneOrMore = false;
+ auto it = m_customUrlSchemeHandlers.begin();
+ auto end = m_customUrlSchemeHandlers.end();
+ for (; it != end; ++it) {
+ if (it.value() == handler) {
+ it = m_customUrlSchemeHandlers.erase(it);
+ removedOneOrMore = true;
+ continue;
+ }
+ }
+ if (removedOneOrMore)
+ updateCustomUrlSchemeHandlers();
+ return removedOneOrMore;
+}
+
+QWebEngineUrlSchemeHandler *BrowserContextAdapter::takeCustomUrlSchemeHandler(const QByteArray &scheme)
+{
+ QWebEngineUrlSchemeHandler *handler = m_customUrlSchemeHandlers.take(scheme);
+ if (handler)
+ updateCustomUrlSchemeHandlers();
+ return handler;
+}
+
+void BrowserContextAdapter::addCustomUrlSchemeHandler(const QByteArray &scheme, QWebEngineUrlSchemeHandler *handler)
{
- m_customUrlSchemeHandlers.remove(handler->scheme());
+ m_customUrlSchemeHandlers.insert(scheme, handler);
+ updateCustomUrlSchemeHandlers();
}
UserScriptControllerHost *BrowserContextAdapter::userScriptController()
diff --git a/src/core/browser_context_adapter.h b/src/core/browser_context_adapter.h
index 5272268f7..818dfda3d 100644
--- a/src/core/browser_context_adapter.h
+++ b/src/core/browser_context_adapter.h
@@ -74,7 +74,6 @@ public:
DownloadManagerDelegateQt *downloadManagerDelegate();
QWebEngineCookieStoreClient *cookieStoreClient();
- void setCookieStoreClient(QWebEngineCookieStoreClient *client);
QWebEngineUrlRequestInterceptor* requestInterceptor();
void setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor);
@@ -147,7 +146,9 @@ public:
QHash<QByteArray, QWebEngineUrlSchemeHandler *> &customUrlSchemeHandlers();
void updateCustomUrlSchemeHandlers();
- void removeCustomUrlSchemeHandler(QWebEngineUrlSchemeHandler *);
+ void addCustomUrlSchemeHandler(const QByteArray &, QWebEngineUrlSchemeHandler *);
+ bool removeCustomUrlSchemeHandler(QWebEngineUrlSchemeHandler *);
+ QWebEngineUrlSchemeHandler *takeCustomUrlSchemeHandler(const QByteArray &);
UserScriptControllerHost *userScriptController();
void permissionRequestReply(const QUrl &origin, PermissionType type, bool reply);
@@ -163,7 +164,7 @@ private:
QScopedPointer<WebEngineVisitedLinksManager> m_visitedLinksManager;
QScopedPointer<DownloadManagerDelegateQt> m_downloadManagerDelegate;
QScopedPointer<UserScriptControllerHost> m_userScriptController;
- QPointer<QWebEngineCookieStoreClient> m_cookieStoreClient;
+ QScopedPointer<QWebEngineCookieStoreClient> m_cookieStoreClient;
QPointer<QWebEngineUrlRequestInterceptor> m_requestInterceptor;
QString m_dataPath;
diff --git a/src/core/resource_dispatcher_host_delegate_qt.cpp b/src/core/resource_dispatcher_host_delegate_qt.cpp
index e6c513bf6..0213daa3a 100644
--- a/src/core/resource_dispatcher_host_delegate_qt.cpp
+++ b/src/core/resource_dispatcher_host_delegate_qt.cpp
@@ -100,7 +100,10 @@ bool ResourceDispatcherHostLoginDelegateQt::isProxy() const
void ResourceDispatcherHostLoginDelegateQt::triggerDialog()
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- content::RenderViewHost* renderViewHost = content::RenderFrameHost::FromID(m_renderProcessId, m_renderFrameId)->GetRenderViewHost();
+ content::RenderFrameHost *renderFrameHost = content::RenderFrameHost::FromID(m_renderProcessId, m_renderFrameId);
+ if (!renderFrameHost)
+ return;
+ content::RenderViewHost *renderViewHost = renderFrameHost->GetRenderViewHost();
content::WebContentsImpl *webContents = static_cast<content::WebContentsImpl *>(content::WebContents::FromRenderViewHost(renderViewHost));
WebContentsAdapterClient *client = WebContentsViewQt::from(webContents->GetView())->client();
diff --git a/src/core/url_request_context_getter_qt.cpp b/src/core/url_request_context_getter_qt.cpp
index 771a662b9..26e1dbea8 100644
--- a/src/core/url_request_context_getter_qt.cpp
+++ b/src/core/url_request_context_getter_qt.cpp
@@ -336,11 +336,13 @@ void URLRequestContextGetterQt::generateJobFactory()
Q_ASSERT(!m_jobFactory);
m_jobFactory.reset(new net::URLRequestJobFactoryImpl());
- // Chromium has a few protocol handlers ready for us, only pick blob: and throw away the rest.
- content::ProtocolHandlerMap::iterator it = m_protocolHandlers.find(url::kBlobScheme);
- Q_ASSERT(it != m_protocolHandlers.end());
- m_jobFactory->SetProtocolHandler(it->first, it->second.release());
- m_protocolHandlers.clear();
+ {
+ // Chromium has a few protocol handlers ready for us, only pick blob: and throw away the rest.
+ content::ProtocolHandlerMap::iterator it = m_protocolHandlers.find(url::kBlobScheme);
+ Q_ASSERT(it != m_protocolHandlers.end());
+ m_jobFactory->SetProtocolHandler(it->first, it->second.release());
+ m_protocolHandlers.clear();
+ }
m_jobFactory->SetProtocolHandler(url::kDataScheme, new net::DataProtocolHandler());
m_jobFactory->SetProtocolHandler(url::kFileScheme, new net::FileProtocolHandler(
@@ -350,9 +352,10 @@ void URLRequestContextGetterQt::generateJobFactory()
m_jobFactory->SetProtocolHandler(url::kFtpScheme,
new net::FtpProtocolHandler(new net::FtpNetworkLayer(m_urlRequestContext->host_resolver())));
- Q_FOREACH (QWebEngineUrlSchemeHandler *handler, m_browserContext->customUrlSchemeHandlers()) {
- m_jobFactory->SetProtocolHandler(handler->scheme().toStdString(), new CustomProtocolHandler(handler));
- }
+ QHash<QByteArray, QWebEngineUrlSchemeHandler*>::const_iterator it = m_browserContext->customUrlSchemeHandlers().constBegin();
+ const QHash<QByteArray, QWebEngineUrlSchemeHandler*>::const_iterator end = m_browserContext->customUrlSchemeHandlers().constEnd();
+ for (; it != end; ++it)
+ m_jobFactory->SetProtocolHandler(it.key().toStdString(), new CustomProtocolHandler(it.value()));
m_urlRequestContext->set_job_factory(m_jobFactory.get());
}
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 2ab2e9471..c38b8ee02 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -829,6 +829,12 @@ void WebContentsAdapter::exitFullScreen()
d->webContents->ExitFullscreen();
}
+void WebContentsAdapter::changedFullScreen()
+{
+ Q_D(WebContentsAdapter);
+ d->webContents->NotifyFullscreenChanged();
+}
+
void WebContentsAdapter::wasShown()
{
Q_D(WebContentsAdapter);
diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h
index 6e356befd..b6a90d3f1 100644
--- a/src/core/web_contents_adapter.h
+++ b/src/core/web_contents_adapter.h
@@ -130,6 +130,7 @@ public:
bool hasInspector() const;
void exitFullScreen();
void requestClose();
+ void changedFullScreen();
void wasShown();
void wasHidden();
diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h
index 4a857b320..d9a2876f9 100644
--- a/src/core/web_contents_adapter_client.h
+++ b/src/core/web_contents_adapter_client.h
@@ -211,8 +211,8 @@ public:
virtual void windowCloseRejected() = 0;
virtual bool contextMenuRequested(const WebEngineContextMenuData&) = 0;
virtual void navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame) = 0;
- virtual void requestFullScreen(bool) = 0;
- virtual bool isFullScreen() const = 0;
+ virtual void requestFullScreenMode(const QUrl &origin, bool fullscreen) = 0;
+ virtual bool isFullScreenMode() const = 0;
virtual void javascriptDialog(QSharedPointer<JavaScriptDialogController>) = 0;
virtual void runFileChooser(FilePickerController *controller) = 0;
virtual void didRunJavaScript(quint64 requestId, const QVariant& result) = 0;
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index 497910a9c..1f789161a 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -245,24 +245,21 @@ content::JavaScriptDialogManager *WebContentsDelegateQt::GetJavaScriptDialogMana
void WebContentsDelegateQt::EnterFullscreenModeForTab(content::WebContents *web_contents, const GURL& origin)
{
- Q_UNUSED(origin); // FIXME
- if (!m_viewClient->isFullScreen()) {
- m_viewClient->requestFullScreen(true);
- web_contents->GetRenderViewHost()->WasResized();
- }
+ Q_UNUSED(web_contents);
+ if (!m_viewClient->isFullScreenMode())
+ m_viewClient->requestFullScreenMode(toQt(origin), true);
}
void WebContentsDelegateQt::ExitFullscreenModeForTab(content::WebContents *web_contents)
{
- if (m_viewClient->isFullScreen()) {
- m_viewClient->requestFullScreen(false);
- web_contents->GetRenderViewHost()->WasResized();
- }
+ if (m_viewClient->isFullScreenMode())
+ m_viewClient->requestFullScreenMode(toQt(web_contents->GetLastCommittedURL().GetOrigin()), false);
}
bool WebContentsDelegateQt::IsFullscreenForTabOrPending(const content::WebContents* web_contents) const
{
- return m_viewClient->isFullScreen();
+ Q_UNUSED(web_contents);
+ return m_viewClient->isFullScreenMode();
}
ASSERT_ENUMS_MATCH(FilePickerController::Open, content::FileChooserParams::Open)
diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp
index b06345b83..a678fe5fa 100644
--- a/src/webengine/api/qquickwebengineprofile.cpp
+++ b/src/webengine/api/qquickwebengineprofile.cpp
@@ -419,16 +419,16 @@ QQuickWebEngineProfile *QQuickWebEngineProfile::defaultProfile()
return profile;
}
-QQuickWebEngineSettings *QQuickWebEngineProfile::settings() const
+QWebEngineCookieStoreClient *QQuickWebEngineProfile::cookieStoreClient() const
{
const Q_D(QQuickWebEngineProfile);
- return d->settings();
+ return d->browserContext()->cookieStoreClient();
}
-void QQuickWebEngineProfile::setCookieStoreClient(QWebEngineCookieStoreClient* client)
+QQuickWebEngineSettings *QQuickWebEngineProfile::settings() const
{
- Q_D(QQuickWebEngineProfile);
- d->browserContext()->setCookieStoreClient(client);
+ const Q_D(QQuickWebEngineProfile);
+ return d->settings();
}
QT_END_NAMESPACE
diff --git a/src/webengine/api/qquickwebengineprofile_p.h b/src/webengine/api/qquickwebengineprofile_p.h
index af5762032..b4e0d173c 100644
--- a/src/webengine/api/qquickwebengineprofile_p.h
+++ b/src/webengine/api/qquickwebengineprofile_p.h
@@ -75,7 +75,7 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineProfile : public QObject {
Q_PROPERTY(QString cachePath READ cachePath WRITE setCachePath NOTIFY cachePathChanged FINAL)
Q_PROPERTY(QString httpUserAgent READ httpUserAgent WRITE setHttpUserAgent NOTIFY httpUserAgentChanged FINAL)
Q_PROPERTY(HttpCacheType httpCacheType READ httpCacheType WRITE setHttpCacheType NOTIFY httpCacheTypeChanged FINAL)
- Q_PROPERTY(QString httpAcceptLanguage READ httpAcceptLanguage WRITE setHttpAcceptLanguage NOTIFY httpAcceptLanguageChanged FINAL)
+ Q_PROPERTY(QString httpAcceptLanguage READ httpAcceptLanguage WRITE setHttpAcceptLanguage NOTIFY httpAcceptLanguageChanged FINAL REVISION 1)
Q_PROPERTY(PersistentCookiesPolicy persistentCookiesPolicy READ persistentCookiesPolicy WRITE setPersistentCookiesPolicy NOTIFY persistentCookiesPolicyChanged FINAL)
Q_PROPERTY(int httpCacheMaximumSize READ httpCacheMaximumSize WRITE setHttpCacheMaximumSize NOTIFY httpCacheMaximumSizeChanged FINAL)
public:
@@ -117,12 +117,12 @@ public:
int httpCacheMaximumSize() const;
void setHttpCacheMaximumSize(int maxSize);
- Q_REVISION(1) QString httpAcceptLanguage() const;
- Q_REVISION(1) void setHttpAcceptLanguage(const QString &httpAcceptLanguage);
+ QString httpAcceptLanguage() const;
+ void setHttpAcceptLanguage(const QString &httpAcceptLanguage);
static QQuickWebEngineProfile *defaultProfile();
- Q_REVISION(1) Q_INVOKABLE void setCookieStoreClient(QWebEngineCookieStoreClient* client);
+ Q_REVISION(1) Q_INVOKABLE QWebEngineCookieStoreClient *cookieStoreClient() const;
signals:
void storageNameChanged();
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index d2fb7f19a..aa450003c 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -275,7 +275,7 @@ bool QQuickWebEngineViewPrivate::contextMenuRequested(const WebEngineContextMenu
QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::InspectElement); });
ui()->addMenuItem(item, QQuickWebEngineView::tr("Inspect Element"));
}
- if (isFullScreen()) {
+ if (isFullScreenMode()) {
item = new MenuItemHandler(menu);
QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::ExitFullScreen); });
ui()->addMenuItem(item, QQuickWebEngineView::tr("Exit Full Screen Mode"));
@@ -519,14 +519,14 @@ void QQuickWebEngineViewPrivate::windowCloseRejected()
#endif
}
-void QQuickWebEngineViewPrivate::requestFullScreen(bool fullScreen)
+void QQuickWebEngineViewPrivate::requestFullScreenMode(const QUrl &origin, bool fullscreen)
{
Q_Q(QQuickWebEngineView);
- QQuickWebEngineFullScreenRequest request(this, fullScreen);
+ QQuickWebEngineFullScreenRequest request(this, origin, fullscreen);
Q_EMIT q->fullScreenRequested(request);
}
-bool QQuickWebEngineViewPrivate::isFullScreen() const
+bool QQuickWebEngineViewPrivate::isFullScreenMode() const
{
return m_isFullScreen;
}
@@ -1392,8 +1392,9 @@ QQuickWebEngineFullScreenRequest::QQuickWebEngineFullScreenRequest()
{
}
-QQuickWebEngineFullScreenRequest::QQuickWebEngineFullScreenRequest(QQuickWebEngineViewPrivate *viewPrivate, bool toggleOn)
+QQuickWebEngineFullScreenRequest::QQuickWebEngineFullScreenRequest(QQuickWebEngineViewPrivate *viewPrivate, const QUrl &origin, bool toggleOn)
: viewPrivate(viewPrivate)
+ , m_origin(origin)
, m_toggleOn(toggleOn)
{
}
@@ -1402,10 +1403,18 @@ void QQuickWebEngineFullScreenRequest::accept()
{
if (viewPrivate && viewPrivate->m_isFullScreen != m_toggleOn) {
viewPrivate->m_isFullScreen = m_toggleOn;
+ viewPrivate->adapter->changedFullScreen();
Q_EMIT viewPrivate->q_ptr->isFullScreenChanged();
}
}
+void QQuickWebEngineFullScreenRequest::reject()
+{
+ if (viewPrivate) {
+ viewPrivate->adapter->changedFullScreen();
+ }
+}
+
QQuickWebEngineViewExperimental::QQuickWebEngineViewExperimental(QQuickWebEngineViewPrivate *viewPrivate)
: q_ptr(0)
, d_ptr(viewPrivate)
diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h
index b0fd5cff6..d1c2e7abb 100644
--- a/src/webengine/api/qquickwebengineview_p.h
+++ b/src/webengine/api/qquickwebengineview_p.h
@@ -71,17 +71,21 @@ class QQuickWebEngineTestSupport;
class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineFullScreenRequest {
Q_GADGET
+ Q_PROPERTY(QUrl origin READ origin)
Q_PROPERTY(bool toggleOn READ toggleOn)
public:
QQuickWebEngineFullScreenRequest();
- QQuickWebEngineFullScreenRequest(QQuickWebEngineViewPrivate *viewPrivate, bool toggleOn);
+ QQuickWebEngineFullScreenRequest(QQuickWebEngineViewPrivate *viewPrivate, const QUrl &origin, bool toggleOn);
Q_INVOKABLE void accept();
- bool toggleOn() { return m_toggleOn; }
+ Q_INVOKABLE void reject();
+ QUrl origin() const { return m_origin; }
+ bool toggleOn() const { return m_toggleOn; }
private:
QQuickWebEngineViewPrivate *viewPrivate;
- bool m_toggleOn;
+ const QUrl m_origin;
+ const bool m_toggleOn;
};
#define LATEST_WEBENGINEVIEW_REVISION 2
diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h
index f2924fafb..748944a69 100644
--- a/src/webengine/api/qquickwebengineview_p_p.h
+++ b/src/webengine/api/qquickwebengineview_p_p.h
@@ -144,8 +144,8 @@ public:
virtual void adoptNewWindow(QtWebEngineCore::WebContentsAdapter *newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &) Q_DECL_OVERRIDE;
virtual void close() Q_DECL_OVERRIDE;
virtual void windowCloseRejected() 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 bool contextMenuRequested(const QtWebEngineCore::WebEngineContextMenuData &) Q_DECL_OVERRIDE;
virtual void navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame) Q_DECL_OVERRIDE;
virtual void javascriptDialog(QSharedPointer<QtWebEngineCore::JavaScriptDialogController>) Q_DECL_OVERRIDE;
diff --git a/src/webengine/api/qtwebengineglobal.cpp b/src/webengine/api/qtwebengineglobal.cpp
index 1c67e710e..07561be6e 100644
--- a/src/webengine/api/qtwebengineglobal.cpp
+++ b/src/webengine/api/qtwebengineglobal.cpp
@@ -47,6 +47,17 @@ Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context();
namespace QtWebEngine {
+/*!
+ \namespace QtWebEngine
+ \inmodule QtWebEngine
+ \ingroup qtwebengine-namespaces
+ \keyword QtWebEngine Namespace
+
+ \brief Helper functions for the Qt WebEngine (Qt Quick) module
+
+ The \l[CPP]{QtWebEngine} namespace is part of the Qt WebEngine module.
+*/
+
static QOpenGLContext *shareContext;
static void deleteShareContext()
@@ -59,6 +70,16 @@ static void deleteShareContext()
// QtWebEngine::initialize was introduced first and meant to be called
// after the QGuiApplication creation, when AA_ShareOpenGLContexts fills
// the same need but the flag has to be set earlier.
+
+/*!
+ \fn QtWebEngine::initialize()
+
+ Sets up an OpenGL Context that can be shared between processes. This has to be done after
+ QGuiApplication is created, but before a Qt Quick window is created.
+
+ This has the same effect as passing Qt::AA_ShareOpenGLContexts to the QGuiApplication
+ constructor.
+*/
void initialize()
{
#ifdef Q_OS_WIN32
@@ -71,11 +92,11 @@ void initialize()
QCoreApplication *app = QCoreApplication::instance();
if (!app) {
- qFatal("QWebEngine(Widgets)::initialize() must be called after the construction of the application object.");
+ qFatal("QtWebEngine::initialize() must be called after the construction of the application object.");
return;
}
if (app->thread() != QThread::currentThread()) {
- qFatal("QWebEngine(Widgets)::initialize() must be called from the Qt gui thread.");
+ qFatal("QtWebEngine::initialize() must be called from the Qt gui thread.");
return;
}
@@ -86,6 +107,9 @@ void initialize()
shareContext->create();
qAddPostRoutine(deleteShareContext);
qt_gl_set_global_share_context(shareContext);
+
+ // Classes like QOpenGLWidget check for the attribute
+ app->setAttribute(Qt::AA_ShareOpenGLContexts);
}
} // namespace QtWebEngine
diff --git a/src/webengine/doc/qtwebengine.qdocconf b/src/webengine/doc/qtwebengine.qdocconf
index e277f4190..01485dc56 100644
--- a/src/webengine/doc/qtwebengine.qdocconf
+++ b/src/webengine/doc/qtwebengine.qdocconf
@@ -4,7 +4,7 @@ project = QtWebEngine
description = Qt WebEngine Reference Documentation
version = $QT_VERSION
-examplesinstallpath =
+examplesinstallpath = qtwebengine
qhp.projects = QtWebEngine
@@ -67,4 +67,4 @@ navigation.landingpage = "Qt WebEngine"
navigation.cppclassespage = "Qt WebEngine C++ Classes"
navigation.qmltypespage = "Qt WebEngine QML Types"
-Cpp.ignoretokens += QWEBENGINEWIDGETS_EXPORT
+Cpp.ignoretokens += Q_WEBENGINE_EXPORT QWEBENGINEWIDGETS_EXPORT
diff --git a/src/webengine/doc/src/qtwebengine-modules.qdoc b/src/webengine/doc/src/qtwebengine-modules.qdoc
index 2e1b4c947..8530f5d01 100644
--- a/src/webengine/doc/src/qtwebengine-modules.qdoc
+++ b/src/webengine/doc/src/qtwebengine-modules.qdoc
@@ -32,6 +32,9 @@
\e {Qt WebEngine} provides functionality for rendering regions of dynamic web content.
+ \section1 Namespaces
+ \annotatedlist qtwebengine-namespaces
+
\section1 Classes
\section2 Qt WebEngineCore Module
diff --git a/src/webengine/doc/src/qtwebengine-overview.qdoc b/src/webengine/doc/src/qtwebengine-overview.qdoc
index 15052f6e8..fa30892d3 100644
--- a/src/webengine/doc/src/qtwebengine-overview.qdoc
+++ b/src/webengine/doc/src/qtwebengine-overview.qdoc
@@ -123,7 +123,20 @@
\section1 Using WebEngine Core
- Qt WebEngine Core provides an API shared by Qt WebEngine and Qt WebEngine Widgets.
+ Qt WebEngine Core provides an API shared by Qt WebEngine and Qt WebEngine Widgets for handling
+ URL requests issued for the networking stack of Chromium and for accessing its HTTP cookies.
+
+ Implementing the QWebEngineUrlRequestInterceptor interface and installing the interceptor on a
+ profile enables intercepting, blocking, and modifying URL requests (QWebEngineUrlRequestInfo)
+ before they reach the networking stack of Chromium.
+
+ A QWebEngineUrlSchemeHandler can be registered for a profile to add support for custom URL
+ schemes. Requests for the scheme are then issued to QWebEngineUrlSchemeHandler::requestStarted()
+ as QWebEngineUrlRequestJob objects.
+
+ The QWebEngineCookieStoreClient class provides functions for accessing HTTP cookies of Chromium.
+ The functions can be used to synchronize cookies with QNetworkAccessManager, as well as to set,
+ delete, and intercept cookies during navigation.
\section1 License Information
diff --git a/src/webengine/doc/src/qtwebengine-platform-notes.qdoc b/src/webengine/doc/src/qtwebengine-platform-notes.qdoc
index 86cccfa3c..fdaa4f861 100644
--- a/src/webengine/doc/src/qtwebengine-platform-notes.qdoc
+++ b/src/webengine/doc/src/qtwebengine-platform-notes.qdoc
@@ -45,7 +45,7 @@
In addition, the following tools are required for building the \l {Qt WebEngine} module:
\list
- \li Windows: Visual Studio 2013 or Visual Studio 2013 Express
+ \li Windows: Visual Studio 2013 or Visual Studio 2015
\li Linux: Clang or GCC version 4.7 or later
\li OS X: Xcode version 5.1 or later
\endlist
diff --git a/src/webengine/ui_delegates_manager.cpp b/src/webengine/ui_delegates_manager.cpp
index 4cc64c8c7..6c4282eb3 100644
--- a/src/webengine/ui_delegates_manager.cpp
+++ b/src/webengine/ui_delegates_manager.cpp
@@ -60,7 +60,7 @@ namespace QtWebEngineCore {
#if defined(Q_OS_WIN)
#define FILE_NAME_CASE_STATEMENT(TYPE, COMPONENT) \
case UIDelegatesManager::TYPE:\
- return QStringLiteral(#TYPE L ##".qml");
+ return QString::fromLatin1(#TYPE ##".qml");
#else
#define FILE_NAME_CASE_STATEMENT(TYPE, COMPONENT) \
case UIDelegatesManager::TYPE:\
diff --git a/src/core/api/qwebengineurlschemehandler_p.h b/src/webenginewidgets/api/qwebenginefullscreenrequest.cpp
index d63666326..6223c070d 100644
--- a/src/core/api/qwebengineurlschemehandler_p.h
+++ b/src/webenginewidgets/api/qwebenginefullscreenrequest.cpp
@@ -34,34 +34,26 @@
**
****************************************************************************/
-#ifndef QWEBENGINEURLSCHEMEHANDLER_P_H
-#define QWEBENGINEURLSCHEMEHANDLER_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qbytearray.h>
+#include "qwebenginefullscreenrequest.h"
+#include "qwebenginepage_p.h"
QT_BEGIN_NAMESPACE
-class QWEBENGINE_EXPORT QWebEngineUrlSchemeHandlerPrivate {
-public:
- QWebEngineUrlSchemeHandlerPrivate(const QByteArray &);
+QWebEngineFullScreenRequest::QWebEngineFullScreenRequest(QWebEnginePagePrivate *pagePrivate, const QUrl &origin, bool fullscreen)
+ : m_pagePrivate(pagePrivate)
+ , m_origin(origin)
+ , m_toggleOn(fullscreen)
+{
+}
- const QByteArray &scheme() const { return m_scheme; }
+void QWebEngineFullScreenRequest::reject() const
+{
+ m_pagePrivate->setFullScreenMode(!m_toggleOn);
+}
-private:
- QByteArray m_scheme;
-};
+void QWebEngineFullScreenRequest::accept() const
+{
+ m_pagePrivate->setFullScreenMode(m_toggleOn);
+}
QT_END_NAMESPACE
-
-#endif // QWEBENGINEURLSCHEMEHANDLER_P_H
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();
diff --git a/src/webenginewidgets/webenginewidgets.pro b/src/webenginewidgets/webenginewidgets.pro
index 17a0a3dbb..4622d0028 100644
--- a/src/webenginewidgets/webenginewidgets.pro
+++ b/src/webenginewidgets/webenginewidgets.pro
@@ -12,6 +12,7 @@ SOURCES = \
api/qtwebenginewidgetsglobal.cpp \
api/qwebenginecertificateerror.cpp \
api/qwebenginedownloaditem.cpp \
+ api/qwebenginefullscreenrequest.cpp \
api/qwebenginehistory.cpp \
api/qwebenginepage.cpp \
api/qwebengineprofile.cpp \
@@ -26,6 +27,7 @@ HEADERS = \
api/qwebenginedownloaditem.h \
api/qwebenginedownloaditem_p.h \
api/qwebenginecertificateerror.h \
+ api/qwebenginefullscreenrequest.h \
api/qwebenginehistory.h \
api/qwebenginepage.h \
api/qwebenginepage_p.h \
diff --git a/tests/auto/core/qwebenginecookiestoreclient/tst_qwebenginecookiestoreclient.cpp b/tests/auto/core/qwebenginecookiestoreclient/tst_qwebenginecookiestoreclient.cpp
index 0f007d643..d78a81c21 100644
--- a/tests/auto/core/qwebenginecookiestoreclient/tst_qwebenginecookiestoreclient.cpp
+++ b/tests/auto/core/qwebenginecookiestoreclient/tst_qwebenginecookiestoreclient.cpp
@@ -94,13 +94,11 @@ void tst_QWebEngineCookieStoreClient::cleanupTestCase()
void tst_QWebEngineCookieStoreClient::cookieSignals()
{
QWebEngineView view;
- QWebEngineCookieStoreClient client;
+ QWebEngineCookieStoreClient *client = view.page()->profile()->cookieStoreClient();
QSignalSpy loadSpy(&view, SIGNAL(loadFinished(bool)));
- QSignalSpy cookieAddedSpy(&client, SIGNAL(cookieAdded(const QNetworkCookie &)));
- QSignalSpy cookieRemovedSpy(&client, SIGNAL(cookieRemoved(const QNetworkCookie &)));
-
- view.page()->profile()->setCookieStoreClient(&client);
+ QSignalSpy cookieAddedSpy(client, SIGNAL(cookieAdded(const QNetworkCookie &)));
+ QSignalSpy cookieRemovedSpy(client, SIGNAL(cookieRemoved(const QNetworkCookie &)));
view.load(QUrl("qrc:///resources/index.html"));
@@ -111,24 +109,24 @@ void tst_QWebEngineCookieStoreClient::cookieSignals()
// try whether updating a cookie to be expired results in that cookie being removed.
QNetworkCookie expiredCookie(QNetworkCookie::parseCookies(QByteArrayLiteral("SessionCookie=delete; expires=Thu, 01-Jan-1970 00:00:00 GMT; path=///resources")).first());
- client.setCookie(expiredCookie, QUrl("qrc:///resources/index.html"));
+ client->setCookie(expiredCookie, QUrl("qrc:///resources/index.html"));
QTRY_COMPARE(cookieRemovedSpy.count(), 1);
cookieRemovedSpy.clear();
// try removing the other cookie.
QNetworkCookie nonSessionCookie(QNetworkCookie::parseCookies(QByteArrayLiteral("CookieWithExpiresField=QtWebEngineCookieTest; path=///resources")).first());
- client.deleteCookie(nonSessionCookie, QUrl("qrc:///resources/index.html"));
+ client->deleteCookie(nonSessionCookie, QUrl("qrc:///resources/index.html"));
QTRY_COMPARE(cookieRemovedSpy.count(), 1);
}
void tst_QWebEngineCookieStoreClient::setAndDeleteCookie()
{
QWebEngineView view;
- QWebEngineCookieStoreClient client;
+ QWebEngineCookieStoreClient *client = view.page()->profile()->cookieStoreClient();
QSignalSpy loadSpy(&view, SIGNAL(loadFinished(bool)));
- QSignalSpy cookieAddedSpy(&client, SIGNAL(cookieAdded(const QNetworkCookie &)));
- QSignalSpy cookieRemovedSpy(&client, SIGNAL(cookieRemoved(const QNetworkCookie &)));
+ QSignalSpy cookieAddedSpy(client, SIGNAL(cookieAdded(const QNetworkCookie &)));
+ QSignalSpy cookieRemovedSpy(client, SIGNAL(cookieRemoved(const QNetworkCookie &)));
QNetworkCookie cookie1(QNetworkCookie::parseCookies(QByteArrayLiteral("khaos=I9GX8CWI; Domain=.example.com; Path=/docs")).first());
QNetworkCookie cookie2(QNetworkCookie::parseCookies(QByteArrayLiteral("Test%20Cookie=foobar; domain=example.com; Path=/")).first());
@@ -136,11 +134,10 @@ void tst_QWebEngineCookieStoreClient::setAndDeleteCookie()
QNetworkCookie expiredCookie3(QNetworkCookie::parseCookies(QByteArrayLiteral("SessionCookie=delete; expires=Thu, 01-Jan-1970 00:00:00 GMT; path=///resources")).first());
// check if pending cookies are set and removed
- client.setCookieWithCallback(cookie1, [](bool success) { QVERIFY(success); });
- client.setCookieWithCallback(cookie2, [](bool success) { QVERIFY(success); });
- client.deleteCookie(cookie1);
+ client->setCookieWithCallback(cookie1, [](bool success) { QVERIFY(success); });
+ client->setCookieWithCallback(cookie2, [](bool success) { QVERIFY(success); });
+ client->deleteCookie(cookie1);
- view.page()->profile()->setCookieStoreClient(&client);
view.load(QUrl("qrc:///resources/content.html"));
QTRY_COMPARE(loadSpy.count(), 1);
@@ -151,10 +148,10 @@ void tst_QWebEngineCookieStoreClient::setAndDeleteCookie()
cookieAddedSpy.clear();
cookieRemovedSpy.clear();
- client.setCookieWithCallback(cookie3, [](bool success) { QVERIFY(success); });
+ client->setCookieWithCallback(cookie3, [](bool success) { QVERIFY(success); });
// updating a cookie with an expired 'expires' field should remove the cookie with the same name
- client.setCookieWithCallback(expiredCookie3, [](bool success) { QVERIFY(success); });
- client.deleteCookie(cookie2);
+ client->setCookieWithCallback(expiredCookie3, [](bool success) { QVERIFY(success); });
+ client->deleteCookie(cookie2);
QTRY_COMPARE(cookieAddedSpy.count(), 1);
QTRY_COMPARE(cookieRemovedSpy.count(), 2);
}
@@ -162,21 +159,20 @@ void tst_QWebEngineCookieStoreClient::setAndDeleteCookie()
void tst_QWebEngineCookieStoreClient::batchCookieTasks()
{
QWebEngineView view;
- QWebEngineCookieStoreClient client;
+ QWebEngineCookieStoreClient *client = view.page()->profile()->cookieStoreClient();
QSignalSpy loadSpy(&view, SIGNAL(loadFinished(bool)));
- QSignalSpy cookieAddedSpy(&client, SIGNAL(cookieAdded(const QNetworkCookie &)));
- QSignalSpy cookieRemovedSpy(&client, SIGNAL(cookieRemoved(const QNetworkCookie &)));
+ QSignalSpy cookieAddedSpy(client, SIGNAL(cookieAdded(const QNetworkCookie &)));
+ QSignalSpy cookieRemovedSpy(client, SIGNAL(cookieRemoved(const QNetworkCookie &)));
QNetworkCookie cookie1(QNetworkCookie::parseCookies(QByteArrayLiteral("khaos=I9GX8CWI; Domain=.example.com; Path=/docs")).first());
QNetworkCookie cookie2(QNetworkCookie::parseCookies(QByteArrayLiteral("Test%20Cookie=foobar; domain=example.com; Path=/")).first());
int capture = 0;
- client.setCookieWithCallback(cookie1, [&capture](bool success) { QVERIFY(success); ++capture; });
- client.setCookieWithCallback(cookie2, [&capture](bool success) { QVERIFY(success); ++capture; });
+ client->setCookieWithCallback(cookie1, [&capture](bool success) { QVERIFY(success); ++capture; });
+ client->setCookieWithCallback(cookie2, [&capture](bool success) { QVERIFY(success); ++capture; });
- view.page()->profile()->setCookieStoreClient(&client);
view.load(QUrl("qrc:///resources/index.html"));
QTRY_COMPARE(loadSpy.count(), 1);
@@ -190,17 +186,17 @@ void tst_QWebEngineCookieStoreClient::batchCookieTasks()
cookieAddedSpy.clear();
cookieRemovedSpy.clear();
- client.getAllCookies([&capture](const QByteArray& cookieLine) {
+ client->getAllCookies([&capture](const QByteArray& cookieLine) {
++capture;
QCOMPARE(QNetworkCookie::parseCookies(cookieLine).count(), 4);
});
- client.deleteSessionCookiesWithCallback([&capture](int numDeleted) {
+ client->deleteSessionCookiesWithCallback([&capture](int numDeleted) {
++capture;
QCOMPARE(numDeleted, 3);
});
- client.deleteAllCookiesWithCallback([&capture](int numDeleted) {
+ client->deleteAllCookiesWithCallback([&capture](int numDeleted) {
++capture;
QCOMPARE(numDeleted, 1);
});
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index 9559f3cf5..da19acbf6 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -38,6 +38,7 @@
#include <qnetworkreply.h>
#include <qnetworkrequest.h>
#include <qpa/qplatforminputcontext.h>
+#include <qwebenginefullscreenrequest.h>
#include <qwebenginehistory.h>
#include <qwebenginepage.h>
#include <qwebengineprofile.h>
@@ -3736,28 +3737,10 @@ void tst_QWebEnginePage::runJavaScript()
QVERIFY(watcher.wait());
}
-class FullScreenPage : public QWebEnginePage {
- Q_OBJECT
-public:
- FullScreenPage(QObject* parent = 0)
- : QWebEnginePage(parent)
- , m_isFullScreen(true)
- { }
-
- void setIsFullScreen(bool b) { m_isFullScreen = b; }
-
-protected:
- bool isFullScreen() override
- {
- return m_isFullScreen;
- }
- bool m_isFullScreen;
-};
-
void tst_QWebEnginePage::fullScreenRequested()
{
JavaScriptCallbackWatcher watcher;
- FullScreenPage* page = new FullScreenPage;
+ QWebEnginePage* page = new QWebEnginePage;
QWebEngineView* view = new QWebEngineView;
view->setPage(page);
view->show();
@@ -3773,12 +3756,20 @@ void tst_QWebEnginePage::fullScreenRequested()
QVERIFY(watcher.wait());
// FullscreenRequest must be a user gesture
+ bool acceptRequest = true;
+ connect(page, &QWebEnginePage::fullScreenRequested,
+ [&acceptRequest](const QWebEngineFullScreenRequest &request) {
+ if (acceptRequest) request.accept(); else request.reject();
+ });
+
QTest::keyPress(qApp->focusWindow(), Qt::Key_Space);
QTest::qWait(100);
page->runJavaScript("document.webkitIsFullScreen", JavaScriptCallback(true));
page->runJavaScript("document.webkitExitFullscreen()", JavaScriptCallbackUndefined());
QVERIFY(watcher.wait());
- page->setIsFullScreen(false);
+
+ acceptRequest = false;
+
page->runJavaScript("document.webkitFullscreenEnabled", JavaScriptCallback(true));
QTest::keyPress(qApp->focusWindow(), Qt::Key_Space);
QVERIFY(watcher.wait());
diff --git a/tests/quicktestbrowser/main.cpp b/tests/quicktestbrowser/main.cpp
index 166da4d5b..167f67dc3 100644
--- a/tests/quicktestbrowser/main.cpp
+++ b/tests/quicktestbrowser/main.cpp
@@ -69,24 +69,6 @@ static QUrl startupUrl()
return QUrl(QStringLiteral("http://qt.io/"));
}
-class CookieClient: public QWebEngineCookieStoreClient
-{
- QMetaProperty m_settingProperty;
- const QObject *m_object;
-public:
- CookieClient(const QObject *object)
- : m_object(object)
- {
- const QMetaObject *rootMeta = object->metaObject();
- int index = rootMeta->indexOfProperty("thirdPartyCookiesEnabled");
- Q_ASSERT(index != -1);
- m_settingProperty = rootMeta->property(index);
- }
- virtual bool acceptCookieFromUrl(const QByteArray &, const QUrl &) {
- return m_settingProperty.read(m_object).toBool();
- }
-};
-
int main(int argc, char **argv)
{
Application app(argc, argv);
@@ -110,10 +92,15 @@ int main(int argc, char **argv)
"}")
, QUrl());
QObject *profile = component.create();
- CookieClient client(rootObject);
- QMetaObject::invokeMethod(profile, "setCookieStoreClient", Q_ARG(QWebEngineCookieStoreClient*, &client));
const QMetaObject *rootMeta = rootObject->metaObject();
- int index = rootMeta->indexOfProperty("testProfile");
+ QWebEngineCookieStoreClient *client = 0;
+ QMetaObject::invokeMethod(profile, "cookieStoreClient", Q_RETURN_ARG(QWebEngineCookieStoreClient*, client));
+ int index = rootMeta->indexOfProperty("thirdPartyCookiesEnabled");
+ Q_ASSERT(index != -1);
+ QMetaProperty thirdPartyCookiesProperty = rootMeta->property(index);
+ client->setCookieFilter([rootObject,&thirdPartyCookiesProperty](const QWebEngineCookieStoreClient::FilterRequest&){ return thirdPartyCookiesProperty.read(rootObject).toBool(); });
+
+ index = rootMeta->indexOfProperty("testProfile");
Q_ASSERT(index != -1);
QMetaProperty profileProperty = rootMeta->property(index);
profileProperty.write(rootObject, qVariantFromValue(profile));
diff --git a/tools/qmake/mkspecs/features/functions.prf b/tools/qmake/mkspecs/features/functions.prf
index 99f60d0e5..9f54f4f3c 100644
--- a/tools/qmake/mkspecs/features/functions.prf
+++ b/tools/qmake/mkspecs/features/functions.prf
@@ -1,5 +1,5 @@
defineTest(isPlatformSupported) {
- !win32-msvc2013: !contains(QT_CONFIG, c++11) {
+ !contains(QT_CONFIG, c++11) {
skipBuild("C++11 support is required in order to build chromium.")
return(false)
}
@@ -7,17 +7,25 @@ defineTest(isPlatformSupported) {
skipBuild("Static builds of QtWebEngine aren't supported.")
return(false)
}
- osx:lessThan(QMAKE_XCODE_VERSION, 5.1) {
- skipBuild("Using xcode version $$QMAKE_XCODE_VERSION, but at least version 5.1 is required to build Qt WebEngine.")
- return(false)
+ osx {
+ lessThan(QMAKE_XCODE_VERSION, 5.1) {
+ skipBuild("Using xcode version $$QMAKE_XCODE_VERSION, but at least version 5.1 is required to build Qt WebEngine.")
+ return(false)
+ }
+ # We require OS X 10.9 (darwin version 13.0.0) or newer
+ darwin_major_version = $$section(QMAKE_HOST.version, ., 0, 0)
+ lessThan(darwin_major_version, 13) {
+ skipBuild("OS X version 10.9 or newer is required to build Qt WebEngine.")
+ return(false)
+ }
}
linux-g++*:!isGCCVersionSupported(): return(false)
!isPythonVersionSupported(): return(false)
- linux-g++*|linux-clang|win32-msvc2013|macx-clang*: return(true)
+ linux-g++*|linux-clang|win32-msvc2013*|win32-msvc2015*|macx-clang*: return(true)
boot2qt: return(true)
- skipBuild("Qt WebEngine can currently only be built for Linux (GCC/clang), Windows (MSVC 2013), OS X (XCode 5.1+) or Qt for Device Creation.")
+ skipBuild("Qt WebEngine can currently only be built for Linux (GCC/clang), Windows (MSVC 2013 or 2015), OS X (10.9/XCode 5.1+) or Qt for Device Creation.")
return(false)
}