summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/api/qwebenginecookiestore.cpp12
-rw-r--r--src/core/api/qwebenginecookiestore.h4
-rw-r--r--src/core/content_browser_client_qt.cpp30
-rw-r--r--src/core/content_browser_client_qt.h2
-rw-r--r--src/core/content_client_qt.cpp1
-rw-r--r--src/core/gl_surface_qt.cpp24
-rw-r--r--src/core/printing/pdfium_document_wrapper_qt.cpp7
-rw-r--r--src/core/printing/pdfium_document_wrapper_qt.h4
-rw-r--r--src/core/quota_request_controller_impl.cpp5
-rw-r--r--src/core/quota_request_controller_impl.h2
-rw-r--r--src/core/register_protocol_handler_request_controller_impl.cpp5
-rw-r--r--src/core/register_protocol_handler_request_controller_impl.h2
-rw-r--r--src/core/render_widget_host_view_qt.cpp98
-rw-r--r--src/core/render_widget_host_view_qt.h2
-rw-r--r--src/core/renderer/user_resource_controller.cpp9
-rw-r--r--src/core/renderer/web_channel_ipc_transport.cpp38
-rw-r--r--src/core/renderer_host/web_channel_ipc_transport_host.cpp17
-rw-r--r--src/core/request_controller.h5
-rw-r--r--src/core/user_script.cpp11
-rw-r--r--src/core/user_script.h2
-rw-r--r--src/core/web_contents_adapter_client.h1
-rw-r--r--src/core/web_contents_delegate_qt.cpp24
-rw-r--r--src/core/web_contents_delegate_qt.h1
-rw-r--r--src/core/web_contents_view_qt.cpp6
-rw-r--r--src/webengine/api/qquickwebengineview.cpp7
-rw-r--r--src/webengine/api/qquickwebengineview_p_p.h1
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp10
-rw-r--r--src/webenginewidgets/api/qwebenginepage_p.h1
-rw-r--r--src/webenginewidgets/api/qwebengineview.cpp3
-rw-r--r--src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp4
30 files changed, 232 insertions, 106 deletions
diff --git a/src/core/api/qwebenginecookiestore.cpp b/src/core/api/qwebenginecookiestore.cpp
index ee82093a5..5fcd46064 100644
--- a/src/core/api/qwebenginecookiestore.cpp
+++ b/src/core/api/qwebenginecookiestore.cpp
@@ -200,7 +200,7 @@ bool QWebEngineCookieStorePrivate::canAccessCookies(const QUrl &firstPartyUrl, c
toGurl(firstPartyUrl),
net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
- QWebEngineCookieStore::FilterRequest request = { thirdParty, firstPartyUrl, url };
+ QWebEngineCookieStore::FilterRequest request = { firstPartyUrl, url, thirdParty, false, 0};
return filterCallback(request);
}
@@ -400,6 +400,16 @@ void QWebEngineCookieStore::setCookieFilter(std::function<bool(const FilterReque
*/
/*!
+ \variable QWebEngineCookieStore::FilterRequest::_reservedFlag
+ \internal
+*/
+
+/*!
+ \variable QWebEngineCookieStore::FilterRequest::_reservedType
+ \internal
+*/
+
+/*!
\variable QWebEngineCookieStore::FilterRequest::origin
\brief The URL of the script or content accessing a cookie.
diff --git a/src/core/api/qwebenginecookiestore.h b/src/core/api/qwebenginecookiestore.h
index a62765f77..87d7390a3 100644
--- a/src/core/api/qwebenginecookiestore.h
+++ b/src/core/api/qwebenginecookiestore.h
@@ -62,9 +62,11 @@ class QWEBENGINE_EXPORT QWebEngineCookieStore : public QObject {
public:
struct FilterRequest {
- bool thirdParty;
QUrl firstPartyUrl;
QUrl origin;
+ bool thirdParty;
+ bool _reservedFlag;
+ ushort _reservedType;
};
virtual ~QWebEngineCookieStore();
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp
index 6748fb956..aa13cce3a 100644
--- a/src/core/content_browser_client_qt.cpp
+++ b/src/core/content_browser_client_qt.cpp
@@ -53,6 +53,7 @@
#include "content/browser/renderer_host/render_view_host_delegate.h"
#include "content/common/url_schemes.h"
#include "content/public/browser/browser_main_parts.h"
+#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/client_certificate_delegate.h"
#include "content/public/browser/media_observer.h"
@@ -67,6 +68,7 @@
#include "content/public/common/main_function_params.h"
#include "content/public/common/service_names.mojom.h"
#include "content/public/common/url_constants.h"
+#include "device/geolocation/public/cpp/location_provider.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "printing/features/features.h"
@@ -121,6 +123,10 @@
#include "renderer_host/pepper/pepper_host_factory_qt.h"
#endif
+#if defined(QT_USE_POSITIONING)
+#include "location_provider_qt.h"
+#endif
+
#include <QGuiApplication>
#include <QLocale>
#ifndef QT_NO_OPENGL
@@ -723,6 +729,30 @@ bool ContentBrowserClientQt::CanCreateWindow(
return (settings && settings->getJavaScriptCanOpenWindowsAutomatically()) || user_gesture;
}
+std::unique_ptr<device::LocationProvider> ContentBrowserClientQt::OverrideSystemLocationProvider()
+{
+#if defined(QT_USE_POSITIONING)
+ return base::WrapUnique(new LocationProviderQt());
+#else
+ return nullptr;
+#endif
+}
+
+scoped_refptr<net::URLRequestContextGetter> GetSystemRequestContextOnUIThread()
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ return scoped_refptr<net::URLRequestContextGetter>(
+ BrowserContextAdapter::defaultContext()->browserContext()->GetRequestContext());
+}
+
+void ContentBrowserClientQt::GetGeolocationRequestContext(
+ base::OnceCallback<void(scoped_refptr<net::URLRequestContextGetter>)> callback)
+{
+ content::BrowserThread::PostTaskAndReplyWithResult(
+ content::BrowserThread::UI, FROM_HERE,
+ base::BindOnce(&GetSystemRequestContextOnUIThread), std::move(callback));
+}
+
bool ContentBrowserClientQt::AllowGetCookie(const GURL &url,
const GURL &first_party,
const net::CookieList & /*cookie_list*/,
diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h
index 042de5c8c..515574147 100644
--- a/src/core/content_browser_client_qt.h
+++ b/src/core/content_browser_client_qt.h
@@ -168,6 +168,8 @@ public:
content::ResourceContext *context,
const std::vector<std::pair<int, int> > &render_frames) override;
+ std::unique_ptr<device::LocationProvider> OverrideSystemLocationProvider() override;
+ void GetGeolocationRequestContext(base::OnceCallback<void(scoped_refptr<net::URLRequestContextGetter>)> callback) override;
#if defined(Q_OS_LINUX)
void GetAdditionalMappedFilesForChildProcess(const base::CommandLine& command_line, int child_process_id, content::PosixFileDescriptorInfo* mappings) override;
#endif
diff --git a/src/core/content_client_qt.cpp b/src/core/content_client_qt.cpp
index c1683bfa0..37b601bf8 100644
--- a/src/core/content_client_qt.cpp
+++ b/src/core/content_client_qt.cpp
@@ -276,6 +276,7 @@ void AddPepperWidevine(std::vector<content::PepperPluginInfo>* plugins)
widevine_cdm.mime_types.push_back(widevine_cdm_mime_type);
widevine_cdm.permissions = kWidevineCdmPluginPermissions;
plugins->push_back(widevine_cdm);
+ break;
}
}
#endif // defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS) &&
diff --git a/src/core/gl_surface_qt.cpp b/src/core/gl_surface_qt.cpp
index 8bfbd865c..0d143ee18 100644
--- a/src/core/gl_surface_qt.cpp
+++ b/src/core/gl_surface_qt.cpp
@@ -72,6 +72,14 @@
#include "ozone/gl_surface_glx_qt.h"
#include "ui/gl/gl_glx_api_implementation.h"
#include <dlfcn.h>
+
+#ifndef QT_NO_OPENGL
+#include <QOpenGLContext>
+QT_BEGIN_NAMESPACE
+Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context();
+QT_END_NAMESPACE
+#endif
+
#endif
#include "ozone/gl_surface_egl_qt.h"
@@ -195,10 +203,20 @@ bool InitializeStaticGLBindings(GLImplementation implementation) {
reinterpret_cast<GLGetProcAddressProc>(
base::GetFunctionPointerFromNativeLibrary(library,
"glXGetProcAddress"));
+
+#ifndef QT_NO_OPENGL
if (!get_proc_address) {
- LOG(ERROR) << "glxGetProcAddress not found.";
- base::UnloadNativeLibrary(library);
- return false;
+ // glx handle not loaded , fallback to qpa
+ if (QOpenGLContext *context = qt_gl_global_share_context()) {
+ get_proc_address = reinterpret_cast<gl::GLGetProcAddressProc>(
+ context->getProcAddress("glXGetProcAddress"));
+ }
+ }
+#endif
+ if (!get_proc_address) {
+ LOG(ERROR) << "glxGetProcAddress not found.";
+ base::UnloadNativeLibrary(library);
+ return false;
}
SetGLGetProcAddressProc(get_proc_address);
diff --git a/src/core/printing/pdfium_document_wrapper_qt.cpp b/src/core/printing/pdfium_document_wrapper_qt.cpp
index ca1e8cd07..a7433b2cc 100644
--- a/src/core/printing/pdfium_document_wrapper_qt.cpp
+++ b/src/core/printing/pdfium_document_wrapper_qt.cpp
@@ -37,11 +37,8 @@
**
****************************************************************************/
#include "pdf/features.h"
-#if BUILDFLAG(ENABLE_PDF)
-#define ENABLE_PDF
-#endif
-#if defined(ENABLE_PDF)
+#if BUILDFLAG(ENABLE_PDF)
#include "pdfium_document_wrapper_qt.h"
#include <QtCore/qhash.h>
@@ -168,4 +165,4 @@ PdfiumDocumentWrapperQt::~PdfiumDocumentWrapperQt()
}
}
-#endif // defined (ENABLE_PDF)
+#endif // BUILDFLAG(ENABLE_PDF)
diff --git a/src/core/printing/pdfium_document_wrapper_qt.h b/src/core/printing/pdfium_document_wrapper_qt.h
index 28c490ae5..7886c51c0 100644
--- a/src/core/printing/pdfium_document_wrapper_qt.h
+++ b/src/core/printing/pdfium_document_wrapper_qt.h
@@ -40,11 +40,8 @@
#ifndef PDFIUM_DOCUMENT_WRAPPER_QT_H
#define PDFIUM_DOCUMENT_WRAPPER_QT_H
-#if defined(ENABLE_PDF)
#include "qtwebenginecoreglobal.h"
-#include <QtCore/qglobal.h>
-#include <QtCore/qhash.h>
#include <QtGui/qimage.h>
namespace QtWebEngineCore {
@@ -67,5 +64,4 @@ private:
};
} // namespace QtWebEngineCore
-#endif // defined (ENABLE_PDF)
#endif // PDFIUM_DOCUMENT_WRAPPER_QT_H
diff --git a/src/core/quota_request_controller_impl.cpp b/src/core/quota_request_controller_impl.cpp
index ee94e1cdd..a18ad761d 100644
--- a/src/core/quota_request_controller_impl.cpp
+++ b/src/core/quota_request_controller_impl.cpp
@@ -54,6 +54,11 @@ QuotaRequestControllerImpl::QuotaRequestControllerImpl(
, m_callback(callback)
{}
+QuotaRequestControllerImpl::~QuotaRequestControllerImpl()
+{
+ reject();
+}
+
void QuotaRequestControllerImpl::accepted()
{
m_context->dispatchCallbackOnIOThread(m_callback, QuotaPermissionContextQt::QUOTA_PERMISSION_RESPONSE_ALLOW);
diff --git a/src/core/quota_request_controller_impl.h b/src/core/quota_request_controller_impl.h
index dacdce72f..5814895f3 100644
--- a/src/core/quota_request_controller_impl.h
+++ b/src/core/quota_request_controller_impl.h
@@ -52,6 +52,8 @@ public:
const content::StorageQuotaParams &params,
const content::QuotaPermissionContext::PermissionCallback &callback);
+ ~QuotaRequestControllerImpl();
+
protected:
void accepted() override;
void rejected() override;
diff --git a/src/core/register_protocol_handler_request_controller_impl.cpp b/src/core/register_protocol_handler_request_controller_impl.cpp
index 1e3a15c93..0f24d8812 100644
--- a/src/core/register_protocol_handler_request_controller_impl.cpp
+++ b/src/core/register_protocol_handler_request_controller_impl.cpp
@@ -54,6 +54,11 @@ RegisterProtocolHandlerRequestControllerImpl::RegisterProtocolHandlerRequestCont
, m_handler(handler)
{}
+RegisterProtocolHandlerRequestControllerImpl::~RegisterProtocolHandlerRequestControllerImpl()
+{
+ reject();
+}
+
ProtocolHandlerRegistry *RegisterProtocolHandlerRequestControllerImpl::protocolHandlerRegistry()
{
content::WebContents *webContents = web_contents();
diff --git a/src/core/register_protocol_handler_request_controller_impl.h b/src/core/register_protocol_handler_request_controller_impl.h
index 5ad64210c..64f229ac4 100644
--- a/src/core/register_protocol_handler_request_controller_impl.h
+++ b/src/core/register_protocol_handler_request_controller_impl.h
@@ -57,6 +57,8 @@ public:
content::WebContents *webContents,
ProtocolHandler handler);
+ ~RegisterProtocolHandlerRequestControllerImpl();
+
protected:
void accepted() override;
void rejected() override;
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index 66d9b819e..ec3add2f6 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -327,7 +327,7 @@ RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost *widget
, m_adapterClient(0)
, m_rendererCompositorFrameSink(0)
, m_imeInProgress(false)
- , m_receivedEmptyImeText(false)
+ , m_receivedEmptyImeEvent(false)
, m_initPending(false)
, m_beginFrameSource(nullptr)
, m_needsBeginFrames(false)
@@ -1219,22 +1219,20 @@ void RenderWidgetHostViewQt::handleKeyEvent(QKeyEvent *ev)
if (IsMouseLocked() && ev->key() == Qt::Key_Escape && ev->type() == QEvent::KeyRelease)
UnlockMouse();
- if (m_receivedEmptyImeText) {
+ if (m_receivedEmptyImeEvent) {
// IME composition was not finished with a valid commit string.
// We're getting the composition result in a key event.
if (ev->key() != 0) {
// The key event is not a result of an IME composition. Cancel IME.
m_host->ImeCancelComposition();
- m_receivedEmptyImeText = false;
+ m_receivedEmptyImeEvent = false;
} else {
if (ev->type() == QEvent::KeyRelease) {
- m_receivedEmptyImeText = false;
- m_host->ImeSetComposition(toString16(ev->text()),
- std::vector<ui::ImeTextSpan>(),
- gfx::Range::InvalidRange(),
- gfx::Range::InvalidRange().start(),
- gfx::Range::InvalidRange().end());
- m_host->ImeFinishComposingText(false);
+ m_host->ImeCommitText(toString16(ev->text()),
+ std::vector<ui::ImeTextSpan>(),
+ gfx::Range::InvalidRange(),
+ 0);
+ m_receivedEmptyImeEvent = false;
m_imeInProgress = false;
}
return;
@@ -1365,54 +1363,54 @@ void RenderWidgetHostViewQt::handleInputMethodEvent(QInputMethodEvent *ev)
}
}
- auto setCompositionString = [&](const QString &compositionString){
- m_host->ImeSetComposition(toString16(compositionString),
- underlines,
- replacementRange,
- selectionRange.start(),
- selectionRange.end());
- };
-
- if (!commitString.isEmpty() || replacementLength > 0) {
- setCompositionString(commitString);
- m_host->ImeFinishComposingText(false);
-
- // We might get a commit string and a pre-edit string in a single event, which means
- // we need to confirm the怀last composition, and start a new composition.
- if (!preeditString.isEmpty()) {
- setCompositionString(preeditString);
- m_imeInProgress = true;
- } else {
- m_imeInProgress = false;
- }
- m_receivedEmptyImeText = commitString.isEmpty();
- } else if (!preeditString.isEmpty()) {
- setCompositionString(preeditString);
- m_imeInProgress = true;
- m_receivedEmptyImeText = false;
- } else {
- // There are so-far two known cases, when an empty QInputMethodEvent is received.
- // First one happens when backspace is used to remove the last character in the pre-edit
- // string, thus signaling the end of the composition.
- // The second one happens (on Windows) when a Korean char gets composed, but instead of
- // the event having a commit string, both strings are empty, and the actual char is received
- // as a QKeyEvent after the QInputMethodEvent is processed.
- // In lieu of the second case, we can't simply cancel the composition on an empty event,
- // and then add the Korean char when QKeyEvent is received, because that leads to text
- // flickering in the textarea (or any other element).
- // Instead we postpone the processing of the empty QInputMethodEvent by posting it
- // to the same focused object, and cancelling the composition on the next event loop tick.
- if (!m_receivedEmptyImeText && m_imeInProgress && !hasSelection) {
- m_receivedEmptyImeText = true;
+ // There are so-far two known cases, when an empty QInputMethodEvent is received.
+ // First one happens when backspace is used to remove the last character in the pre-edit
+ // string, thus signaling the end of the composition.
+ // The second one happens (on Windows) when a Korean char gets composed, but instead of
+ // the event having a commit string, both strings are empty, and the actual char is received
+ // as a QKeyEvent after the QInputMethodEvent is processed.
+ // In lieu of the second case, we can't simply cancel the composition on an empty event,
+ // and then add the Korean char when QKeyEvent is received, because that leads to text
+ // flickering in the textarea (or any other element).
+ // Instead we postpone the processing of the empty QInputMethodEvent by posting it
+ // to the same focused object, and cancelling the composition on the next event loop tick.
+ if (commitString.isEmpty() && preeditString.isEmpty() && replacementLength == 0) {
+ if (!m_receivedEmptyImeEvent && m_imeInProgress && !hasSelection) {
+ m_receivedEmptyImeEvent = true;
QInputMethodEvent *eventCopy = new QInputMethodEvent(*ev);
QGuiApplication::postEvent(qApp->focusObject(), eventCopy);
} else {
- m_receivedEmptyImeText = false;
+ m_receivedEmptyImeEvent = false;
if (m_imeInProgress) {
m_imeInProgress = false;
m_host->ImeCancelComposition();
}
}
+
+ return;
+ }
+
+ m_receivedEmptyImeEvent = false;
+
+ // Finish compostion: insert or erase text.
+ if (!commitString.isEmpty() || replacementLength > 0) {
+ m_host->ImeCommitText(toString16(commitString),
+ underlines,
+ replacementRange,
+ 0);
+ m_imeInProgress = false;
+ }
+
+ // Update or start new composition.
+ // Be aware of that, we might get a commit string and a pre-edit string in a single event and
+ // this means a new composition.
+ if (!preeditString.isEmpty()) {
+ m_host->ImeSetComposition(toString16(preeditString),
+ underlines,
+ replacementRange,
+ selectionRange.start(),
+ selectionRange.end());
+ m_imeInProgress = true;
}
}
diff --git a/src/core/render_widget_host_view_qt.h b/src/core/render_widget_host_view_qt.h
index db68e5232..2a1485510 100644
--- a/src/core/render_widget_host_view_qt.h
+++ b/src/core/render_widget_host_view_qt.h
@@ -253,7 +253,7 @@ private:
viz::mojom::CompositorFrameSinkClient *m_rendererCompositorFrameSink;
bool m_imeInProgress;
- bool m_receivedEmptyImeText;
+ bool m_receivedEmptyImeEvent;
QPoint m_previousMousePosition;
bool m_initPending;
diff --git a/src/core/renderer/user_resource_controller.cpp b/src/core/renderer/user_resource_controller.cpp
index ebc88c403..50a3924c6 100644
--- a/src/core/renderer/user_resource_controller.cpp
+++ b/src/core/renderer/user_resource_controller.cpp
@@ -69,6 +69,11 @@ static content::RenderView * const globalScriptsIndex = 0;
// Scripts meant to run after the load event will be run 500ms after DOMContentLoaded if the load event doesn't come within that delay.
static const int afterLoadTimeout = 500;
+static int validUserScriptSchemes()
+{
+ return URLPattern::SCHEME_HTTP | URLPattern::SCHEME_HTTPS | URLPattern::SCHEME_FILE;
+}
+
static bool regexMatchesURL(const std::string &pat, const GURL &url) {
QRegularExpression qre(QtWebEngineCore::toQt(pat));
qre.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
@@ -97,8 +102,8 @@ static bool scriptMatchesURL(const UserScriptData &scriptData, const GURL &url)
if (!scriptData.urlPatterns.empty()) {
matchFound = false;
for (auto it = scriptData.urlPatterns.begin(), end = scriptData.urlPatterns.end(); it != end; ++it) {
- URLPattern urlPattern(QtWebEngineCore::UserScript::validUserScriptSchemes(), *it);
- if (urlPattern.MatchesURL(url))
+ URLPattern urlPattern(validUserScriptSchemes());
+ if (urlPattern.Parse(*it) == URLPattern::PARSE_SUCCESS && urlPattern.MatchesURL(url))
matchFound = true;
}
if (!matchFound)
diff --git a/src/core/renderer/web_channel_ipc_transport.cpp b/src/core/renderer/web_channel_ipc_transport.cpp
index bb544168f..ef00bcef3 100644
--- a/src/core/renderer/web_channel_ipc_transport.cpp
+++ b/src/core/renderer/web_channel_ipc_transport.cpp
@@ -64,7 +64,7 @@ public:
static void Uninstall(blink::WebLocalFrame *frame, uint worldId);
private:
WebChannelTransport() {}
- bool NativeQtSendMessage(gin::Arguments *args);
+ void NativeQtSendMessage(gin::Arguments *args);
// gin::WrappableBase
gin::ObjectTemplateBuilder GetObjectTemplateBuilder(v8::Isolate *isolate) override;
@@ -118,37 +118,45 @@ void WebChannelTransport::Uninstall(blink::WebLocalFrame *frame, uint worldId)
qtObject->Delete(gin::StringToV8(isolate, "webChannelTransport"));
}
-bool WebChannelTransport::NativeQtSendMessage(gin::Arguments *args)
+void WebChannelTransport::NativeQtSendMessage(gin::Arguments *args)
{
blink::WebLocalFrame *frame = blink::WebLocalFrame::FrameForCurrentContext();
if (!frame || !frame->View())
- return false;
+ return;
content::RenderFrame *renderFrame = content::RenderFrame::FromWebFrame(frame);
if (!renderFrame)
- return false;
+ return;
+
+ v8::Local<v8::Value> jsonValue;
+ if (!args->GetNext(&jsonValue)) {
+ args->ThrowTypeError("Missing argument");
+ return;
+ }
- std::string message;
- if (!args->GetNext(&message))
- return false;
+ if (!jsonValue->IsString()) {
+ args->ThrowTypeError("Expected string");
+ return;
+ }
+ v8::Local<v8::String> jsonString = v8::Local<v8::String>::Cast(jsonValue);
+
+ QByteArray json(jsonString->Utf8Length(), 0);
+ jsonString->WriteUtf8(json.data(), json.size(),
+ nullptr,
+ v8::String::REPLACE_INVALID_UTF8);
- QByteArray valueData(message.data(), message.size());
QJsonParseError error;
- QJsonDocument doc = QJsonDocument::fromJson(valueData, &error);
+ QJsonDocument doc = QJsonDocument::fromJson(json, &error);
if (error.error != QJsonParseError::NoError) {
- LOG(WARNING) << "Parsing error: " << qPrintable(error.errorString());
- return false;
+ args->ThrowTypeError("Invalid JSON");
+ return;
}
int size = 0;
const char *rawData = doc.rawData(&size);
- if (size == 0)
- return false;
-
renderFrame->Send(new WebChannelIPCTransportHost_SendMessage(
renderFrame->GetRoutingID(),
std::vector<char>(rawData, rawData + size)));
- return true;
}
gin::ObjectTemplateBuilder WebChannelTransport::GetObjectTemplateBuilder(v8::Isolate *isolate)
diff --git a/src/core/renderer_host/web_channel_ipc_transport_host.cpp b/src/core/renderer_host/web_channel_ipc_transport_host.cpp
index 6b32093a6..d99dfde97 100644
--- a/src/core/renderer_host/web_channel_ipc_transport_host.cpp
+++ b/src/core/renderer_host/web_channel_ipc_transport_host.cpp
@@ -49,6 +49,8 @@
#include <QJsonObject>
#include <QLoggingCategory>
+#include <QtCore/private/qjson_p.h>
+
namespace QtWebEngineCore {
Q_LOGGING_CATEGORY(log, "qt.webengine.webchanneltransport");
@@ -108,10 +110,19 @@ void WebChannelIPCTransportHost::setWorldId(content::RenderFrameHost *frame, bas
void WebChannelIPCTransportHost::onWebChannelMessage(const std::vector<char> &message)
{
- Q_ASSERT(!message.empty());
- QJsonDocument doc = QJsonDocument::fromRawData(message.data(), message.size(), QJsonDocument::BypassValidation);
- Q_ASSERT(doc.isObject());
content::RenderFrameHost *frame = web_contents()->GetMainFrame();
+
+ QJsonDocument doc;
+ // QJsonDocument::fromRawData does not check the length before it starts
+ // parsing the QJsonPrivate::Header and QJsonPrivate::Base structures.
+ if (message.size() >= sizeof(QJsonPrivate::Header) + sizeof(QJsonPrivate::Base))
+ doc = QJsonDocument::fromRawData(message.data(), message.size());
+
+ if (!doc.isObject()) {
+ qCCritical(log).nospace() << "received invalid webchannel message from " << frame;
+ return;
+ }
+
qCDebug(log).nospace() << "received webchannel message from " << frame << ": " << doc;
Q_EMIT messageReceived(doc.object(), this);
}
diff --git a/src/core/request_controller.h b/src/core/request_controller.h
index a15c601d7..ffcf9edac 100644
--- a/src/core/request_controller.h
+++ b/src/core/request_controller.h
@@ -70,10 +70,7 @@ public:
}
}
- virtual ~RequestController()
- {
- reject();
- }
+ virtual ~RequestController() {}
protected:
virtual void accepted() = 0;
diff --git a/src/core/user_script.cpp b/src/core/user_script.cpp
index 9b9d66d55..bdd6524ca 100644
--- a/src/core/user_script.cpp
+++ b/src/core/user_script.cpp
@@ -38,7 +38,6 @@
****************************************************************************/
#include "common/user_script_data.h"
-#include "extensions/common/url_pattern.h"
#include "user_script.h"
#include "type_conversion.h"
@@ -66,11 +65,6 @@ bool GetDeclarationValue(const base::StringPiece& line,
namespace QtWebEngineCore {
-int UserScript::validUserScriptSchemes()
-{
- return URLPattern::SCHEME_HTTP | URLPattern::SCHEME_HTTPS | URLPattern::SCHEME_FILE;
-}
-
ASSERT_ENUMS_MATCH(UserScript::AfterLoad, UserScriptData::AfterLoad)
ASSERT_ENUMS_MATCH(UserScript::DocumentLoadFinished, UserScriptData::DocumentLoadFinished)
ASSERT_ENUMS_MATCH(UserScript::DocumentElementCreation, UserScriptData::DocumentElementCreation)
@@ -222,8 +216,6 @@ void UserScript::parseMetadataHeader()
// support @noframes rule, we have to change the current default behavior.
// static const base::StringPiece kNoFramesDeclaration("// @noframes");
- static URLPattern urlPatternParser(validUserScriptSchemes());
-
while (line_start < script_text.length()) {
line_end = script_text.find('\n', line_start);
@@ -260,8 +252,7 @@ void UserScript::parseMetadataHeader()
}
scriptData->excludeGlobs.push_back(value);
} else if (GetDeclarationValue(line, kMatchDeclaration, &value)) {
- if (URLPattern::PARSE_SUCCESS == urlPatternParser.Parse(value))
- scriptData->urlPatterns.push_back(value);
+ scriptData->urlPatterns.push_back(value);
} else if (GetDeclarationValue(line, kRunAtDeclaration, &value)) {
if (value == kRunAtDocumentStartValue)
scriptData->injectionPoint = DocumentElementCreation;
diff --git a/src/core/user_script.h b/src/core/user_script.h
index e44efd3e9..93cde9aa6 100644
--- a/src/core/user_script.h
+++ b/src/core/user_script.h
@@ -85,8 +85,6 @@ public:
bool operator==(const UserScript &) const;
- static int validUserScriptSchemes();
-
private:
void initData();
UserScriptData &data() const;
diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h
index 2d057160d..1e3f4981b 100644
--- a/src/core/web_contents_adapter_client.h
+++ b/src/core/web_contents_adapter_client.h
@@ -449,6 +449,7 @@ public:
virtual void updateContentsSize(const QSizeF &size) = 0;
virtual void startDragging(const content::DropData &dropData, Qt::DropActions allowedActions,
const QPixmap &pixmap, const QPoint &offset) = 0;
+ virtual bool supportsDragging() const = 0;
virtual bool isEnabled() const = 0;
virtual const QObject *holdingQObject() const = 0;
virtual void setToolTip(const QString& toolTipText) = 0;
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index b98c822b0..48eee41c0 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -44,6 +44,7 @@
#include "web_contents_delegate_qt.h"
#include "browser_context_adapter.h"
+#include "browser_context_qt.h"
#include "color_chooser_qt.h"
#include "color_chooser_controller.h"
#include "favicon_manager.h"
@@ -115,19 +116,25 @@ WebContentsDelegateQt::~WebContentsDelegateQt()
content::WebContents *WebContentsDelegateQt::OpenURLFromTab(content::WebContents *source, const content::OpenURLParams &params)
{
content::WebContents *target = source;
+ content::SiteInstance *target_site_instance = params.source_site_instance.get();
+ content::Referrer referrer = params.referrer;
if (params.disposition != WindowOpenDisposition::CURRENT_TAB) {
QSharedPointer<WebContentsAdapter> targetAdapter = createWindow(0, params.disposition, gfx::Rect(), params.user_gesture);
if (targetAdapter) {
+ if (targetAdapter->browserContext() != source->GetBrowserContext()) {
+ target_site_instance = nullptr;
+ referrer = content::Referrer();
+ }
if (!targetAdapter->isInitialized())
- targetAdapter->initialize(params.source_site_instance.get());
+ targetAdapter->initialize(target_site_instance);
target = targetAdapter->webContents();
}
}
Q_ASSERT(target);
content::NavigationController::LoadURLParams load_url_params(params.url);
- load_url_params.source_site_instance = params.source_site_instance;
- load_url_params.referrer = params.referrer;
+ load_url_params.source_site_instance = target_site_instance;
+ load_url_params.referrer = referrer;
load_url_params.frame_tree_node_id = params.frame_tree_node_id;
load_url_params.redirect_chain = params.redirect_chain;
load_url_params.transition_type = params.transition;
@@ -519,6 +526,17 @@ void WebContentsDelegateQt::ActivateContents(content::WebContents* contents)
contents->Focus();
}
+void WebContentsDelegateQt::RenderViewHostChanged(content::RenderViewHost *old_host, content::RenderViewHost *new_host)
+{
+ Q_ASSERT(new_host);
+
+ // The old RVH can be nullptr if it was shut down.
+ if (!old_host)
+ return;
+
+ new_host->UpdateWebkitPreferences(old_host->GetWebkitPreferences());
+}
+
void WebContentsDelegateQt::RequestToLockMouse(content::WebContents *web_contents, bool user_gesture, bool last_unlocked_by_target)
{
Q_UNUSED(user_gesture);
diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h
index 2ef87ccd8..43badf60e 100644
--- a/src/core/web_contents_delegate_qt.h
+++ b/src/core/web_contents_delegate_qt.h
@@ -139,6 +139,7 @@ public:
void WasShown() override;
void DidFirstVisuallyNonEmptyPaint() override;
void ActivateContents(content::WebContents* contents) override;
+ void RenderViewHostChanged(content::RenderViewHost *old_host, content::RenderViewHost *new_host) override;
void didFailLoad(const QUrl &url, int errorCode, const QString &errorDescription);
void overrideWebPreferences(content::WebContents *, content::WebPreferences*);
diff --git a/src/core/web_contents_view_qt.cpp b/src/core/web_contents_view_qt.cpp
index a7895d61c..6b68a9569 100644
--- a/src/core/web_contents_view_qt.cpp
+++ b/src/core/web_contents_view_qt.cpp
@@ -232,6 +232,12 @@ void WebContentsViewQt::StartDragging(const content::DropData &drop_data,
#if QT_CONFIG(draganddrop)
Q_UNUSED(event_info);
+ if (!m_client->supportsDragging()) {
+ if (source_rwh)
+ source_rwh->DragSourceSystemDragEnded();
+ return;
+ }
+
QPixmap pixmap;
QPoint hotspot;
pixmap = QPixmap::fromImage(toQImage(image.GetRepresentation(m_client->dpiScale())));
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index 97a0adef3..32df81538 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -1023,6 +1023,13 @@ void QQuickWebEngineViewPrivate::startDragging(const content::DropData &dropData
#endif // QT_CONFIG(draganddrop)
}
+bool QQuickWebEngineViewPrivate::supportsDragging() const
+{
+ // QTBUG-57516
+ // Fixme: This is just a band-aid workaround.
+ return QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::MultipleWindows);
+}
+
bool QQuickWebEngineViewPrivate::isEnabled() const
{
const Q_Q(QQuickWebEngineView);
diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h
index 8c8c57cf6..5b52919b6 100644
--- a/src/webengine/api/qquickwebengineview_p_p.h
+++ b/src/webengine/api/qquickwebengineview_p_p.h
@@ -146,6 +146,7 @@ public:
void updateContentsSize(const QSizeF &size) override;
void startDragging(const content::DropData &dropData, Qt::DropActions allowedActions,
const QPixmap &pixmap, const QPoint &offset) override;
+ bool supportsDragging() const override;
bool isEnabled() const override;
void setToolTip(const QString &toolTipText) override;
const QObject *holdingQObject() const override;
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index eeca450c9..99fbf523f 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -47,7 +47,6 @@
#include "favicon_manager.h"
#include "file_picker_controller.h"
#include "javascript_dialog_controller.h"
-#include "printing/pdfium_document_wrapper_qt.h"
#include "qwebenginefullscreenrequest.h"
#include "qwebenginehistory.h"
#include "qwebenginehistory_p.h"
@@ -87,6 +86,10 @@
#include <QTimer>
#include <QUrl>
+#if defined(ENABLE_PRINTING) && defined(ENABLE_PDF)
+#include "printing/pdfium_document_wrapper_qt.h"
+#endif
+
QT_BEGIN_NAMESPACE
using namespace QtWebEngineCore;
@@ -1673,6 +1676,11 @@ void QWebEnginePagePrivate::startDragging(const content::DropData &dropData,
#endif // QT_CONFIG(draganddrop)
}
+bool QWebEnginePagePrivate::supportsDragging() const
+{
+ return true;
+}
+
bool QWebEnginePagePrivate::isEnabled() const
{
const Q_Q(QWebEnginePage);
diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h
index 39fbf1506..9c87cbfe7 100644
--- a/src/webenginewidgets/api/qwebenginepage_p.h
+++ b/src/webenginewidgets/api/qwebenginepage_p.h
@@ -142,6 +142,7 @@ public:
void updateContentsSize(const QSizeF &size) override;
void startDragging(const content::DropData &dropData, Qt::DropActions allowedActions,
const QPixmap &pixmap, const QPoint &offset) override;
+ bool supportsDragging() const override;
bool isEnabled() const override;
void setToolTip(const QString &toolTipText) override;
const QObject *holdingQObject() const override;
diff --git a/src/webenginewidgets/api/qwebengineview.cpp b/src/webenginewidgets/api/qwebengineview.cpp
index 80c60e1a8..f03679d17 100644
--- a/src/webenginewidgets/api/qwebengineview.cpp
+++ b/src/webenginewidgets/api/qwebengineview.cpp
@@ -259,7 +259,8 @@ void QWebEngineView::findText(const QString &subString, QWebEnginePage::FindFlag
*/
QSize QWebEngineView::sizeHint() const
{
- return QSize(800, 600);
+ // TODO: Remove this override for Qt 6
+ return QWidget::sizeHint();
}
QWebEngineSettings *QWebEngineView::settings() const
diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
index 16ea216f2..98482ae78 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
@@ -198,6 +198,9 @@ void RenderWidgetHostViewQtDelegateWidget::initAsChild(WebContentsAdapterClient*
disconnect(parentWidget(), &QObject::destroyed,
this, &RenderWidgetHostViewQtDelegateWidget::removeParentBeforeParentDelete);
pagePrivate->view->layout()->addWidget(this);
+ if (QWidget *focusProxy = pagePrivate->view->focusProxy())
+ if (focusProxy != this)
+ pagePrivate->view->layout()->removeWidget(focusProxy);
pagePrivate->view->setFocusProxy(this);
show();
} else
@@ -250,6 +253,7 @@ void RenderWidgetHostViewQtDelegateWidget::setKeyboardFocus()
QGuiApplication::sync();
m_rootItem->forceActiveFocus();
+ setFocus();
}
bool RenderWidgetHostViewQtDelegateWidget::hasKeyboardFocus()