From 229621361562d0e89aeb5f2d2f0ace0115bf164c Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 2 Oct 2019 16:23:09 +0200 Subject: Merge remote-tracking branch 'origin/5.13' into 5.14 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Conflicts: examples/webengine/minimal/main.cpp src/3rdparty src/core/net/url_request_custom_job.cpp tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp Change-Id: I33994024a4be5ed787800c5718a0a443b970c36d Reviewed-by: Jüri Valdmann --- src/core/api/qtwebenginecoreglobal.cpp | 2 +- src/core/content_browser_client_qt.cpp | 2 +- src/core/net/url_request_custom_job.cpp | 20 +++++++++++++------- src/webengine/api/qtwebengineglobal.cpp | 15 ++++++++++++--- src/webenginewidgets/api/qwebenginepage.cpp | 9 +++------ 5 files changed, 30 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/core/api/qtwebenginecoreglobal.cpp b/src/core/api/qtwebenginecoreglobal.cpp index 0fddacb15..b27de4c23 100644 --- a/src/core/api/qtwebenginecoreglobal.cpp +++ b/src/core/api/qtwebenginecoreglobal.cpp @@ -108,7 +108,7 @@ Q_WEBENGINECORE_PRIVATE_EXPORT void initialize() QCoreApplication *app = QCoreApplication::instance(); if (!app) { - qFatal("QtWebEngine::initialize() must be called after the construction of the application object."); + qFatal("QtWebEngine::initialize() but no core application instance."); return; } diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index 6fcd9ad5b..29b6e09ed 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -252,7 +252,7 @@ void ShareGroupQtQuick::AboutToAddFirstContext() // This currently has to be setup by ::main in all applications using QQuickWebEngineView with delegated rendering. QOpenGLContext *shareContext = qt_gl_global_share_context(); if (!shareContext) { - qFatal("QWebEngine: OpenGL resource sharing is not set up in QtQuick. Please make sure to call QtWebEngine::initialize() in your main() function."); + qFatal("QWebEngine: OpenGL resource sharing is not set up in QtQuick. Please make sure to call QtWebEngine::initialize() in your main() function before QCoreApplication is created."); } m_shareContextQtQuick = new QtShareGLContext(shareContext); #endif diff --git a/src/core/net/url_request_custom_job.cpp b/src/core/net/url_request_custom_job.cpp index 56ba79f35..0e640766f 100644 --- a/src/core/net/url_request_custom_job.cpp +++ b/src/core/net/url_request_custom_job.cpp @@ -41,6 +41,7 @@ #include "url_request_custom_job_proxy.h" #include "api/qwebengineurlscheme.h" + #include "base/strings/stringprintf.h" #include "base/task/post_task.h" #include "content/public/browser/browser_task_traits.h" @@ -146,17 +147,22 @@ void URLRequestCustomJob::GetResponseInfo(HttpResponseInfo* info) { // Based on net::URLRequestRedirectJob::StartAsync() - if (!m_corsEnabled) + if (m_error) return; std::string headers; - headers += base::StringPrintf("HTTP/1.1 %i OK\n", m_httpStatusCode); - if (m_redirect.is_valid()) + if (m_redirect.is_valid()) { + headers += "HTTP/1.1 303 See Other\n"; headers += base::StringPrintf("Location: %s\n", m_redirect.spec().c_str()); - std::string origin; - if (request_->extra_request_headers().GetHeader("Origin", &origin)) { - headers += base::StringPrintf("Access-Control-Allow-Origin: %s\n", origin.c_str()); - headers += "Access-Control-Allow-Credentials: true\n"; + } else { + headers += base::StringPrintf("HTTP/1.1 %i OK\n", m_httpStatusCode); + } + if (m_corsEnabled) { + std::string origin; + if (request_->extra_request_headers().GetHeader("Origin", &origin)) { + headers += base::StringPrintf("Access-Control-Allow-Origin: %s\n", origin.c_str()); + headers += "Access-Control-Allow-Credentials: true\n"; + } } info->headers = new HttpResponseHeaders(HttpUtil::AssembleRawHeaders(headers)); diff --git a/src/webengine/api/qtwebengineglobal.cpp b/src/webengine/api/qtwebengineglobal.cpp index a11618dba..4346832c9 100644 --- a/src/webengine/api/qtwebengineglobal.cpp +++ b/src/webengine/api/qtwebengineglobal.cpp @@ -38,6 +38,7 @@ ****************************************************************************/ #include "qtwebengineglobal.h" +#include namespace QtWebEngineCore { @@ -62,8 +63,8 @@ namespace QtWebEngine { /*! \fn QtWebEngine::initialize() - Sets up an OpenGL Context that can be shared between threads. This has to be done after - QGuiApplication is created, but before a Qt Quick window is created. + Sets up an OpenGL Context that can be shared between threads. This has to be done before + QGuiApplication is created and before window's QPlatformOpenGLContext is created. This has the same effect as setting the Qt::AA_ShareOpenGLContexts attribute with QCoreApplication::setAttribute before constructing @@ -71,7 +72,15 @@ namespace QtWebEngine { */ void initialize() { - QtWebEngineCore::initialize(); + QCoreApplication *app = QCoreApplication::instance(); + if (app) { + qWarning("QtWebEngine::initialize() called with QCoreApplication object already created and should be call before. "\ + "This is depreciated and may fail in the future."); + QtWebEngineCore::initialize(); + return; + } + // call initialize the same way as widgets do + qAddPreRoutine(QtWebEngineCore::initialize); } } // namespace QtWebEngine diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index db3efa521..524df0425 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -2671,16 +2671,13 @@ void QContextMenuBuilder::addMenuItem(ContextMenuItem menuItem) switch (menuItem) { case ContextMenuItem::Back: - action = new QAction(QIcon::fromTheme(QStringLiteral("go-previous")), QWebEnginePage::tr("&Back"), m_menu); - QObject::connect(action, &QAction::triggered, thisRef->d_ptr->view, &QWebEngineView::back); + action = thisRef->action(QWebEnginePage::Back); break; case ContextMenuItem::Forward: - action = new QAction(QIcon::fromTheme(QStringLiteral("go-next")), QWebEnginePage::tr("&Forward"), m_menu); - QObject::connect(action, &QAction::triggered, thisRef->d_ptr->view, &QWebEngineView::forward); + action = thisRef->action(QWebEnginePage::Forward); break; case ContextMenuItem::Reload: - action = new QAction(QIcon::fromTheme(QStringLiteral("view-refresh")), QWebEnginePage::tr("&Reload"), m_menu); - QObject::connect(action, &QAction::triggered, thisRef->d_ptr->view, &QWebEngineView::reload); + action = thisRef->action(QWebEnginePage::Reload); break; case ContextMenuItem::Cut: action = thisRef->action(QWebEnginePage::Cut); -- cgit v1.2.3