From f341988f451c6ba1fc3b8da765c00d1d64eaff30 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 23 Jun 2020 13:11:58 +0200 Subject: Return valid path in Profile::GetPath() for incognito profiles Parts of Chromium depends on it for temporary directories it creates. This also changes the logic of depending on it being empty as indicating an in memory profile, so it required a bit of cleaning up. Note this does subtly change the return value of off-the-record profiles. Task-number: QTBUG-62957 Change-Id: Iec6e24556128c515fce27803171a766b8a9d92e3 Reviewed-by: Michal Klocek --- src/core/devtools_frontend_qt.cpp | 3 ++- src/core/pref_service_adapter.cpp | 2 +- src/core/profile_adapter.cpp | 30 ++++++++++++++++-------------- src/core/profile_io_data_qt.cpp | 8 +++++--- src/core/profile_io_data_qt.h | 2 ++ src/core/web_engine_context.cpp | 2 +- 6 files changed, 27 insertions(+), 20 deletions(-) (limited to 'src/core') diff --git a/src/core/devtools_frontend_qt.cpp b/src/core/devtools_frontend_qt.cpp index 52d7dc669..8070d1c98 100644 --- a/src/core/devtools_frontend_qt.cpp +++ b/src/core/devtools_frontend_qt.cpp @@ -339,7 +339,8 @@ void DevToolsFrontendQt::RemovePreference(const std::string &name) void DevToolsFrontendQt::ClearPreferences() { - if (web_contents()->GetBrowserContext()->IsOffTheRecord()) + ProfileQt *profile = static_cast(web_contents()->GetBrowserContext()); + if (profile->IsOffTheRecord() || profile->profileAdapter()->storageName().isEmpty()) m_prefStore = scoped_refptr(new InMemoryPrefStore()); else CreateJsonPreferences(true); diff --git a/src/core/pref_service_adapter.cpp b/src/core/pref_service_adapter.cpp index 4ded70d07..65dfb73ee 100644 --- a/src/core/pref_service_adapter.cpp +++ b/src/core/pref_service_adapter.cpp @@ -85,7 +85,7 @@ void PrefServiceAdapter::setup(const ProfileAdapter &profileAdapter) WebEngineContext::commandLine())); QString userPrefStorePath = profileAdapter.dataPath(); - if (userPrefStorePath.isEmpty() || profileAdapter.isOffTheRecord()) { + if (profileAdapter.isOffTheRecord() || profileAdapter.storageName().isEmpty()) { factory.set_user_prefs(new InMemoryPrefStore); } else { userPrefStorePath += QDir::separator(); diff --git a/src/core/profile_adapter.cpp b/src/core/profile_adapter.cpp index 4557ad7a4..c436c8277 100644 --- a/src/core/profile_adapter.cpp +++ b/src/core/profile_adapter.cpp @@ -245,13 +245,17 @@ QObject* ProfileAdapter::globalQObjectRoot() QString ProfileAdapter::dataPath() const { - if (m_offTheRecord) - return QString(); if (!m_dataPath.isEmpty()) return m_dataPath; - if (!m_name.isNull()) - return buildLocationFromStandardPath(QStandardPaths::writableLocation(QStandardPaths::DataLocation), m_name); - return QString(); + // And off-the-record or memory-only profile should not write to disk + // but Chromium often creates temporary directories anyway, so given them + // a location to do so. + QString name = m_name; + if (m_offTheRecord) + name = QStringLiteral("OffTheRecord"); + else if (m_name.isEmpty()) + name = QStringLiteral("UnknownProfile"); + return buildLocationFromStandardPath(QStandardPaths::writableLocation(QStandardPaths::DataLocation), name); } void ProfileAdapter::setDataPath(const QString &path) @@ -259,13 +263,11 @@ void ProfileAdapter::setDataPath(const QString &path) if (m_dataPath == path) return; m_dataPath = path; - if (!m_offTheRecord) { - m_profile->setupPrefService(); - if (!m_profile->m_profileIOData->isClearHttpCacheInProgress()) - m_profile->m_profileIOData->resetNetworkContext(); - if (m_visitedLinksManager) - resetVisitedLinksManager(); - } + m_profile->setupPrefService(); + if (!m_profile->m_profileIOData->isClearHttpCacheInProgress()) + m_profile->m_profileIOData->resetNetworkContext(); + if (!m_offTheRecord && m_visitedLinksManager) + resetVisitedLinksManager(); } void ProfileAdapter::setDownloadPath(const QString &path) @@ -353,7 +355,7 @@ void ProfileAdapter::setHttpCacheType(ProfileAdapter::HttpCacheType newhttpCache ProfileAdapter::PersistentCookiesPolicy ProfileAdapter::persistentCookiesPolicy() const { - if (isOffTheRecord() || dataPath().isEmpty()) + if (isOffTheRecord() || m_name.isEmpty()) return NoPersistentCookies; return m_persistentCookiesPolicy; } @@ -372,7 +374,7 @@ ProfileAdapter::VisitedLinksPolicy ProfileAdapter::visitedLinksPolicy() const { if (isOffTheRecord() || m_visitedLinksPolicy == DoNotTrackVisitedLinks) return DoNotTrackVisitedLinks; - if (dataPath().isEmpty()) + if (m_name.isEmpty()) return TrackVisitedLinksInMemory; return m_visitedLinksPolicy; } diff --git a/src/core/profile_io_data_qt.cpp b/src/core/profile_io_data_qt.cpp index ecebbdaa7..02912e35e 100644 --- a/src/core/profile_io_data_qt.cpp +++ b/src/core/profile_io_data_qt.cpp @@ -179,6 +179,8 @@ void ProfileIODataQt::setFullConfiguration() m_httpCacheMaxSize = m_profileAdapter->httpCacheMaxSize(); m_useForGlobalCertificateVerification = m_profileAdapter->isUsedForGlobalCertificateVerification(); m_dataPath = m_profileAdapter->dataPath(); + m_storageName = m_profileAdapter->storageName(); + m_inMemoryOnly = m_profileAdapter->isOffTheRecord() || m_storageName.isEmpty(); } void ProfileIODataQt::resetNetworkContext() @@ -221,7 +223,7 @@ network::mojom::NetworkContextParamsPtr ProfileIODataQt::CreateNetworkContextPar network::mojom::NetworkContextParamsPtr network_context_params = SystemNetworkContextManager::GetInstance()->CreateDefaultNetworkContextParams(); - network_context_params->context_name = m_profile->profileAdapter()->storageName().toStdString(); + network_context_params->context_name = m_storageName.toStdString(); network_context_params->user_agent = m_httpUserAgent.toStdString(); network_context_params->accept_language = m_httpAcceptLanguage.toStdString(); @@ -234,7 +236,7 @@ network::mojom::NetworkContextParamsPtr ProfileIODataQt::CreateNetworkContextPar if (m_httpCacheType == ProfileAdapter::DiskHttpCache && !m_httpCachePath.isEmpty()) network_context_params->http_cache_path = toFilePath(m_httpCachePath); - if (m_persistentCookiesPolicy != ProfileAdapter::NoPersistentCookies && !m_dataPath.isEmpty()) { + if (m_persistentCookiesPolicy != ProfileAdapter::NoPersistentCookies && !m_inMemoryOnly) { base::FilePath cookie_path = toFilePath(m_dataPath); cookie_path = cookie_path.AppendASCII("Cookies"); network_context_params->cookie_path = cookie_path; @@ -242,7 +244,7 @@ network::mojom::NetworkContextParamsPtr ProfileIODataQt::CreateNetworkContextPar network_context_params->restore_old_session_cookies = m_persistentCookiesPolicy == ProfileAdapter::ForcePersistentCookies; network_context_params->persist_session_cookies = m_persistentCookiesPolicy != ProfileAdapter::NoPersistentCookies; } - if (!m_dataPath.isEmpty()) { + if (!m_inMemoryOnly) { network_context_params->http_server_properties_path = toFilePath(m_dataPath).AppendASCII("Network Persistent State"); network_context_params->transport_security_persister_path = toFilePath(m_dataPath); } diff --git a/src/core/profile_io_data_qt.h b/src/core/profile_io_data_qt.h index b0567dead..00d2c392c 100644 --- a/src/core/profile_io_data_qt.h +++ b/src/core/profile_io_data_qt.h @@ -133,6 +133,8 @@ private: QString m_httpUserAgent; ProfileAdapter::HttpCacheType m_httpCacheType; QString m_httpCachePath; + QString m_storageName; + bool m_inMemoryOnly; #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) QMutex m_mutex{QMutex::Recursive}; using QRecursiveMutex = QMutex; diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index a28e469a3..b36e76417 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -324,7 +324,7 @@ void WebEngineContext::addProfileAdapter(ProfileAdapter *profileAdapter) { Q_ASSERT(!m_profileAdapters.contains(profileAdapter)); const QString path = profileAdapter->dataPath(); - if (!path.isEmpty()) { + if (!profileAdapter->isOffTheRecord() && !profileAdapter->storageName().isEmpty()) { for (auto profileAdapter : m_profileAdapters) { if (profileAdapter->dataPath() == path) { // QTBUG-66068 -- cgit v1.2.3 From 3cf8b25bd2c597e3fbdb70729b474db1e1051522 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 26 Jun 2020 09:56:54 +0200 Subject: Allow force enabling QUIC Still disabled by default though Fixes: QTBUG-72497 Change-Id: I81f270f08f9e4941a0afd34a4cb7ac7cb5320a33 Reviewed-by: Michal Klocek --- src/core/net/system_network_context_manager.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/net/system_network_context_manager.cpp b/src/core/net/system_network_context_manager.cpp index 29cc82abf..ed1171d1f 100644 --- a/src/core/net/system_network_context_manager.cpp +++ b/src/core/net/system_network_context_manager.cpp @@ -61,6 +61,7 @@ #include "chrome/common/chrome_switches.h" #include "components/certificate_transparency/ct_known_logs.h" #include "components/network_session_configurator/common/network_features.h" +#include "components/network_session_configurator/common/network_switches.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/cors_exempt_headers.h" @@ -245,8 +246,10 @@ SystemNetworkContextManager::~SystemNetworkContextManager() void SystemNetworkContextManager::OnNetworkServiceCreated(network::mojom::NetworkService *network_service) { + bool is_quic_force_enabled = base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableQuic); // Disable QUIC globally - network_service->DisableQuic(); + if (!is_quic_force_enabled) + network_service->DisableQuic(); network_service->SetUpHttpAuth(CreateHttpAuthStaticParams()); network_service->ConfigureHttpAuthPrefs(CreateHttpAuthDynamicParams()); -- cgit v1.2.3 From 7c966f59a8f8f8a51ffe4325f0809e0d3363a9fc Mon Sep 17 00:00:00 2001 From: Tamas Zakor Date: Wed, 17 Jun 2020 09:42:50 +0200 Subject: Fix double click event on flash content The blink::WebInputEvent::kMouseUp event sets the WebMouseEvent::click_count to zero before the blink::WebInputEvent::kMouseDown event handling is completed. We need to keep the click_count value during mouse-up event. Fixes: QTBUG-84660 Change-Id: I2494f56b51674413d7c8b324c138abcb7c0f9186 Reviewed-by: Allan Sandfeld Jensen --- src/core/render_widget_host_view_qt.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/core') diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index 2eeb09b2e..dd4965de5 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -1760,6 +1760,9 @@ void RenderWidgetHostViewQt::handlePointerEvent(T *event) m_clickHelper.lastPressPosition = QPointF(event->pos()).toPoint(); } + if (webEvent.GetType() == blink::WebInputEvent::kMouseUp) + webEvent.click_count = m_clickHelper.clickCounter; + webEvent.movement_x = event->globalX() - m_previousMousePosition.x(); webEvent.movement_y = event->globalY() - m_previousMousePosition.y(); -- cgit v1.2.3 From 3b93882e2b2397b7e259da30552ff1ee05e0036c Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 30 Jun 2020 08:56:25 +0200 Subject: Replace qgetenv with qEnvironmentVariable This preserves unicode characters in the environment variable on Windows. Fixes: QTBUG-85054 Change-Id: I3352cc3db4ce8d7b9b352c1634e3239954780618 Reviewed-by: Kirill Burtsev --- src/core/content_client_qt.cpp | 2 +- src/core/devtools_manager_delegate_qt.cpp | 2 +- src/core/web_engine_context.cpp | 6 +++--- src/core/web_engine_library_info.cpp | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src/core') diff --git a/src/core/content_client_qt.cpp b/src/core/content_client_qt.cpp index 083e10f2a..647d45819 100644 --- a/src/core/content_client_qt.cpp +++ b/src/core/content_client_qt.cpp @@ -199,7 +199,7 @@ void AddPepperFlashFromSystem(std::vector* plugins) { QStringList pluginPaths; #if defined(Q_OS_WIN) - QString winDir = QDir::fromNativeSeparators(qgetenv("WINDIR")); + QString winDir = QDir::fromNativeSeparators(qEnvironmentVariable("WINDIR")); if (winDir.isEmpty()) winDir = QString::fromLatin1("C:/Windows"); QDir pluginDir(winDir + "/System32/Macromed/Flash"); diff --git a/src/core/devtools_manager_delegate_qt.cpp b/src/core/devtools_manager_delegate_qt.cpp index ecd2a7d40..8c4037879 100644 --- a/src/core/devtools_manager_delegate_qt.cpp +++ b/src/core/devtools_manager_delegate_qt.cpp @@ -114,7 +114,7 @@ DevToolsServerQt::~DevToolsServerQt() void DevToolsServerQt::parseAddressAndPort() { - const QString inspectorEnv = QString::fromUtf8(qgetenv("QTWEBENGINE_REMOTE_DEBUGGING")); + const QString inspectorEnv = qEnvironmentVariable("QTWEBENGINE_REMOTE_DEBUGGING"); const base::CommandLine &commandLine = *base::CommandLine::ForCurrentProcess(); QString portStr; diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index b36e76417..1399c0fdc 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -173,9 +173,9 @@ bool usingDefaultSGBackend() } if (device.isEmpty()) - device = QString::fromLocal8Bit(qgetenv("QT_QUICK_BACKEND")); + device = qEnvironmentVariable("QT_QUICK_BACKEND"); if (device.isEmpty()) - device = QString::fromLocal8Bit(qgetenv("QMLSCENE_DEVICE")); + device = qEnvironmentVariable("QMLSCENE_DEVICE"); return device.isEmpty(); } @@ -878,7 +878,7 @@ base::CommandLine* WebEngineContext::commandLine() { QStringList appArgs = QCoreApplication::arguments(); if (qEnvironmentVariableIsSet(kChromiumFlagsEnv)) { appArgs = appArgs.mid(0, 1); // Take application name and drop the rest - appArgs.append(parseEnvCommandLine(QString::fromLocal8Bit(qgetenv(kChromiumFlagsEnv)))); + appArgs.append(parseEnvCommandLine(qEnvironmentVariable(kChromiumFlagsEnv))); } #ifdef Q_OS_WIN appArgs.removeAll(QStringLiteral("--enable-webgl-software-rendering")); diff --git a/src/core/web_engine_library_info.cpp b/src/core/web_engine_library_info.cpp index 1c8316430..9c99e7e22 100644 --- a/src/core/web_engine_library_info.cpp +++ b/src/core/web_engine_library_info.cpp @@ -153,10 +153,10 @@ QString subProcessPath() #endif QStringList candidatePaths; - const QByteArray fromEnv = qgetenv("QTWEBENGINEPROCESS_PATH"); + const QString fromEnv = qEnvironmentVariable("QTWEBENGINEPROCESS_PATH"); if (!fromEnv.isEmpty()) { // Only search in QTWEBENGINEPROCESS_PATH if set - candidatePaths << QString::fromLocal8Bit(fromEnv); + candidatePaths << fromEnv; } else { #if defined(OS_MACOSX) && defined(QT_MAC_FRAMEWORK_BUILD) candidatePaths << getPath(frameworkBundle()) @@ -218,10 +218,10 @@ QString dictionariesPath() if (!initialized) { initialized = true; - const QByteArray fromEnv = qgetenv("QTWEBENGINE_DICTIONARIES_PATH"); + const QString fromEnv = qEnvironmentVariable("QTWEBENGINE_DICTIONARIES_PATH"); if (!fromEnv.isEmpty()) { // Only search in QTWEBENGINE_DICTIONARIES_PATH if set - candidatePaths << QString::fromLocal8Bit(fromEnv); + candidatePaths << fromEnv; } else { // First try to find dictionaries near the application. #ifdef OS_MACOSX -- cgit v1.2.3 From 2dfc9e98a98979fc6d0d99a2ae0d805fd50ebb25 Mon Sep 17 00:00:00 2001 From: Szabolcs David Date: Wed, 1 Jul 2020 14:42:24 +0200 Subject: Avoid empty context menu in PDF viewer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Simply add some page navigation items. Change-Id: I6da3ff1c1e56f0c3fbbd6eb5cd3b77f32e850862 Reviewed-by: Jüri Valdmann --- src/core/render_view_context_menu_qt.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/core') diff --git a/src/core/render_view_context_menu_qt.cpp b/src/core/render_view_context_menu_qt.cpp index 4e182973c..8fdae498c 100644 --- a/src/core/render_view_context_menu_qt.cpp +++ b/src/core/render_view_context_menu_qt.cpp @@ -98,6 +98,8 @@ namespace QtWebEngineCore { appendCopyItem(); else appendPageItems(); + } else { + appendPageItems(); } if (m_contextData.linkUrl().isValid() || !m_contextData.unfilteredLinkUrl().isEmpty() || !m_contextData.linkUrl().isEmpty()) -- cgit v1.2.3 From d9a062a876b9309bde6005695504147dcb174c87 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 2 Jul 2020 11:41:47 +0200 Subject: Set application name based on source application name This makes it possible to tell the difference between multiple applications using QtWebEngine. Submodule src/3rdparty 15a42873..87e5a52b: > Pass through a new application name argument to utility processes > Fix libjpeg_turbo for ARM32 > Add missing include in certificate net log Fixes: QTBUG-85363 Change-Id: Ib5426d2e431eb3032f76270885c9cf2d83a75ac8 Reviewed-by: Kirill Burtsev --- src/core/content_main_delegate_qt.cpp | 9 +++++++++ src/core/web_engine_context.cpp | 2 ++ 2 files changed, 11 insertions(+) (limited to 'src/core') diff --git a/src/core/content_main_delegate_qt.cpp b/src/core/content_main_delegate_qt.cpp index f93a3c0ea..30bac71af 100644 --- a/src/core/content_main_delegate_qt.cpp +++ b/src/core/content_main_delegate_qt.cpp @@ -69,6 +69,7 @@ #endif #if defined(OS_LINUX) +#include "media/audio/audio_manager.h" #include "ui/base/ui_base_switches.h" #endif @@ -220,6 +221,14 @@ void ContentMainDelegateQt::PreSandboxStartup() media::InitializeVideoToolbox(); } #endif + + if (parsedCommandLine->HasSwitch(service_manager::switches::kApplicationName)) { + const std::string appName = parsedCommandLine->GetSwitchValueASCII(service_manager::switches::kApplicationName); + QCoreApplication::setApplicationName(QString::fromStdString(appName)); +#if defined(OS_LINUX) + media::AudioManager::SetGlobalAppName(appName); +#endif + } } content::ContentBrowserClient *ContentMainDelegateQt::CreateContentBrowserClient() diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 1399c0fdc..01d55a5a1 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -568,6 +568,8 @@ WebEngineContext::WebEngineContext() setupProxyPac(parsedCommandLine); parsedCommandLine->AppendSwitchPath(switches::kBrowserSubprocessPath, WebEngineLibraryInfo::getPath(content::CHILD_PROCESS_EXE)); + parsedCommandLine->AppendSwitchASCII(service_manager::switches::kApplicationName, QCoreApplication::applicationName().toStdString()); + // Enable sandboxing on OS X and Linux (Desktop / Embedded) by default. bool disable_sandbox = qEnvironmentVariableIsSet(kDisableSandboxEnv); if (!disable_sandbox) { -- cgit v1.2.3 From 7b5cb517da57f76437872a891c07fffd1779b6a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Br=C3=BCning?= Date: Fri, 3 Jul 2020 01:16:07 +0200 Subject: [macOS] Add utf-8 character set meta tag for HTML clipboard content MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This prevents unicode characters from becoming garbled when pasting the clipboard content into an application that uses the HTML content instead of the text data. This mirrors the behavior of Chromium's clipboard adaptation for macOS Fixes: QTBUG-75391 Change-Id: I033819a2caf3410509e90c9bc38c9830d184149d Reviewed-by: Jüri Valdmann --- src/core/clipboard_qt.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/clipboard_qt.cpp b/src/core/clipboard_qt.cpp index ef7a05299..c3b25ff63 100644 --- a/src/core/clipboard_qt.cpp +++ b/src/core/clipboard_qt.cpp @@ -143,7 +143,14 @@ void ClipboardQt::WriteText(const char *text_data, size_t text_len) void ClipboardQt::WriteHTML(const char *markup_data, size_t markup_len, const char *url_data, size_t url_len) { - getUncommittedData()->setHtml(QString::fromUtf8(markup_data, markup_len)); + QString markup_string = QString::fromUtf8(markup_data, markup_len); +#if defined (Q_OS_MACOS) + // We need to prepend the charset on macOS to prevent garbled Unicode characters + // when pasting to certain applications (e.g. Notes, TextEdit) + // Mirrors the behavior in ui/base/clipboard/clipboard_mac.mm in Chromium. + markup_string.prepend(QLatin1String("")); +#endif + getUncommittedData()->setHtml(markup_string); } void ClipboardQt::WriteRTF(const char *rtf_data, size_t data_len) -- cgit v1.2.3 From f41dbaad0f0b554b3168df5456e57c3016bd5e43 Mon Sep 17 00:00:00 2001 From: Kirill Burtsev Date: Fri, 3 Jul 2020 13:40:28 +0200 Subject: Reject permission request with invalid origin At least Push API is supposed to be disabled in incognito mode, which results in permission request with empty origin. Fixes: QTBUG-85116 Change-Id: Ie587013d135bf92a84779e6da87e12374f99bfdd Reviewed-by: Allan Sandfeld Jensen --- src/core/permission_manager_qt.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/core') diff --git a/src/core/permission_manager_qt.cpp b/src/core/permission_manager_qt.cpp index 862a1c262..ece74b123 100644 --- a/src/core/permission_manager_qt.cpp +++ b/src/core/permission_manager_qt.cpp @@ -200,6 +200,11 @@ int PermissionManagerQt::RequestPermission(content::PermissionType permission, bool /*user_gesture*/, base::OnceCallback callback) { + if (requesting_origin.is_empty()) { + std::move(callback).Run(blink::mojom::PermissionStatus::DENIED); + return content::PermissionController::kNoPendingOperation; + } + WebContentsDelegateQt *contentsDelegate = static_cast( content::WebContents::FromRenderFrameHost(frameHost)->GetDelegate()); Q_ASSERT(contentsDelegate); @@ -231,6 +236,11 @@ int PermissionManagerQt::RequestPermissions(const std::vector&)> callback) { + if (requesting_origin.is_empty()) { + std::move(callback).Run(std::vector(permissions.size(), blink::mojom::PermissionStatus::DENIED)); + return content::PermissionController::kNoPendingOperation; + } + WebContentsDelegateQt *contentsDelegate = static_cast( content::WebContents::FromRenderFrameHost(frameHost)->GetDelegate()); Q_ASSERT(contentsDelegate); -- cgit v1.2.3 From daf822dc41ce7c8acb7225cf17bbb269d6cc77ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Br=C3=BCning?= Date: Tue, 11 Feb 2020 18:26:58 +0100 Subject: Create an OpenGL 4.1 CoreProfile on macOS unless requested otherwise MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Chromium has blacklisted OpenGL version prior to 4.1 on macOS. To re-enable hardware acceleration in WebEngine on macOS, set the default surface format to a 4.1 CoreProfile before creating the shared OpenGL context, unless the surface format has been set to a specific other version. According to https://support.apple.com/en-us/HT202823 , the newest Mac that only had support for OpenGL 3.3 was released in Mid 2011, so this should be okay on the majority of machines. If the user requests an OpenGL 3.2 profile, it will also work as the Cocoa QPA plugin enables sharing between 3.2 and 4.x contexts. If the surface format has been requested to be a version lower than OpenGL 3.2 or not a core profile, warn the user about the lack of hardware acceleration. To ensure that we have actually created native contexts for the requested profile and not a context backed by the Apple Software Renderer, we query the context native renderer ID using Cocoa methods. Task-number: QTBUG-81693 Task-number: QTBUG-75262 Change-Id: I94e2e9913c8481fa8db37eb8381a89769026c919 Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Tor Arne Vestbø --- src/core/api/qtwebenginecoreglobal.cpp | 48 +++++++++++++++++++++++++++++++++ src/core/core_chromium.pri | 4 +++ src/core/macos_context_type_helper.h | 42 +++++++++++++++++++++++++++++ src/core/macos_context_type_helper.mm | 49 ++++++++++++++++++++++++++++++++++ 4 files changed, 143 insertions(+) create mode 100644 src/core/macos_context_type_helper.h create mode 100644 src/core/macos_context_type_helper.mm (limited to 'src/core') diff --git a/src/core/api/qtwebenginecoreglobal.cpp b/src/core/api/qtwebenginecoreglobal.cpp index ce4362741..3c9387a10 100644 --- a/src/core/api/qtwebenginecoreglobal.cpp +++ b/src/core/api/qtwebenginecoreglobal.cpp @@ -45,6 +45,8 @@ #ifdef Q_OS_MACOS #include #include +#include +#include "macos_context_type_helper.h" #endif #endif #include @@ -127,6 +129,52 @@ Q_WEBENGINECORE_PRIVATE_EXPORT void initialize() shareContext = new QOpenGLContext; QSurfaceFormat format = QSurfaceFormat::defaultFormat(); // format.setOption(QSurfaceFormat::ResetNotification); + +#ifdef Q_OS_MACOS + if (format == QSurfaceFormat()) { + QOpenGLContext testContext; + + // Chromium turns off OpenGL for CoreProfiles with versions < 4.1 + // The newest Mac that only supports 3.3 was released in Mid 2011, + // so it should be safe to request 4.1, but we still double check it + // works in order not to set an invalid default surface format. + format.setVersion(4, 1); + format.setProfile(QSurfaceFormat::CoreProfile); + + testContext.setFormat(format); + if (testContext.create()) { + QOffscreenSurface surface; + surface.setFormat(format); + surface.create(); + + if (testContext.makeCurrent(&surface)) { + // The Cocoa QPA integration allows sharing between OpenGL 3.2 and 4.1 contexts, + // which means even though we requested a 4.1 context, if we only get a 3.2 context, + // it will still work an Chromium will not black list it. + if (testContext.format().version() >= qMakePair(3, 2) && + testContext.format().profile() == QSurfaceFormat::CoreProfile && + !isCurrentContextSoftware()) { + QSurfaceFormat::setDefaultFormat(format); + } else { + qWarning("The available OpenGL surface format was either not version 3.2 or higher or not a Core Profile.\n" + "Chromium on macOS will fall back to software rendering in this case.\n" + "Hardware acceleration and features such as WebGL will not be available."); + format = QSurfaceFormat::defaultFormat(); + } + testContext.doneCurrent(); + } + surface.destroy(); + } + } else { + // The user explicitly requested a specific surface format that does not fit Chromium's requirements. Warn them about this. + if (format.version() < qMakePair(3,2) || format.profile() != QSurfaceFormat::CoreProfile) { + qWarning("An OpenGL surfcace format was requested that is either not version 3.2 or higher or a not Core Profile.\n" + "Chromium on macOS will fall back to software rendering in this case.\n" + "Hardware acceleration and features such as WebGL will not be available."); + } + } +#endif + shareContext->setFormat(format); shareContext->create(); qAddPostRoutine(deleteShareContext); diff --git a/src/core/core_chromium.pri b/src/core/core_chromium.pri index e1f5cd7ac..4e4f529ab 100644 --- a/src/core/core_chromium.pri +++ b/src/core/core_chromium.pri @@ -310,6 +310,10 @@ contains(QT_CONFIG, opengl) { compositor/display_gl_output_surface.h \ compositor/stream_video_node.h \ compositor/yuv_video_node.h + macos { + HEADERS+=macos_context_type_helper.h + SOURCES+=macos_context_type_helper.mm + } } qtConfig(webengine-geolocation) { diff --git a/src/core/macos_context_type_helper.h b/src/core/macos_context_type_helper.h new file mode 100644 index 000000000..d234a2bff --- /dev/null +++ b/src/core/macos_context_type_helper.h @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef MACOS_CONTEXT_TYPE_HELPER_H_ +#define MACOS_CONTEXT_TYPE_HELPER_H_ +bool isCurrentContextSoftware(); +#endif // MACOS_CONTEXT_TYPE_HELPER_H_ diff --git a/src/core/macos_context_type_helper.mm b/src/core/macos_context_type_helper.mm new file mode 100644 index 000000000..c814d2849 --- /dev/null +++ b/src/core/macos_context_type_helper.mm @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#import +#import + +#include "macos_context_type_helper.h" + +bool isCurrentContextSoftware() +{ + int rendererID = 0; + [NSOpenGLContext.currentContext getValues:&rendererID forParameter:NSOpenGLContextParameterCurrentRendererID]; + return (rendererID & kCGLRendererIDMatchingMask) == kCGLRendererGenericFloatID; +} -- cgit v1.2.3 From aa3052f72a5b4980010e42939baf26f068d8a9e3 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 26 Jun 2020 09:57:43 +0200 Subject: Remove some dead code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Was not used Change-Id: Ic87e35c12c8d6454ed10ca83dfba9ea732919be4 Reviewed-by: Michael Brüning --- src/core/net/system_network_context_manager.cpp | 13 ------------- src/core/net/system_network_context_manager.h | 21 --------------------- 2 files changed, 34 deletions(-) (limited to 'src/core') diff --git a/src/core/net/system_network_context_manager.cpp b/src/core/net/system_network_context_manager.cpp index ed1171d1f..611b5eafa 100644 --- a/src/core/net/system_network_context_manager.cpp +++ b/src/core/net/system_network_context_manager.cpp @@ -200,19 +200,6 @@ scoped_refptr SystemNetworkContextManager::GetS return shared_url_loader_factory_; } -void SystemNetworkContextManager::SetUp( - network::mojom::NetworkContextRequest *network_context_request, - network::mojom::NetworkContextParamsPtr *network_context_params, bool *stub_resolver_enabled, - base::Optional> *dns_over_https_servers, - network::mojom::HttpAuthStaticParamsPtr *http_auth_static_params, - network::mojom::HttpAuthDynamicParamsPtr *http_auth_dynamic_params, bool *is_quic_allowed) -{ - *is_quic_allowed = false; - *http_auth_static_params = CreateHttpAuthStaticParams(); - *http_auth_dynamic_params = CreateHttpAuthDynamicParams(); - // GetStubResolverConfig(local_state_, stub_resolver_enabled, dns_over_https_servers); -} - // static SystemNetworkContextManager *SystemNetworkContextManager::CreateInstance() { diff --git a/src/core/net/system_network_context_manager.h b/src/core/net/system_network_context_manager.h index 5094008f2..0dd503ce1 100644 --- a/src/core/net/system_network_context_manager.h +++ b/src/core/net/system_network_context_manager.h @@ -105,27 +105,6 @@ public: // Destroys the global SystemNetworkContextManager instance. static void DeleteInstance(); - // If the network service is disabled, |network_context_request| will be for - // the NetworkContext used by the SystemNetworkContextManager and - // |network_context_params| as needed to set up a system NetworkContext. - // Otherwise, this method can still be used to help set up the IOThread's - // in-process URLRequestContext. - // - // Must be called before the system NetworkContext is first used. - // - // |stub_resolver_enabled|, |dns_over_https_servers|, - // |http_auth_static_params|, |http_auth_dynamic_params|, and - // |is_quic_allowed| are used to pass initial NetworkService state to the - // caller, so the NetworkService can be configured appropriately. Using - // NetworkService's Mojo interface to set those options would lead to races - // with other UI->IO thread network-related tasks, since Mojo doesn't preserve - // execution order relative to PostTasks. - void SetUp(network::mojom::NetworkContextRequest *network_context_request, - network::mojom::NetworkContextParamsPtr *network_context_params, bool *stub_resolver_enabled, - base::Optional> *dns_over_https_servers, - network::mojom::HttpAuthStaticParamsPtr *http_auth_static_params, - network::mojom::HttpAuthDynamicParamsPtr *http_auth_dynamic_params, bool *is_quic_allowed); - // Returns the System NetworkContext. May only be called after SetUp(). Does // any initialization of the NetworkService that may be needed when first // called. -- cgit v1.2.3 From e5b5fcb1a2c186f14ae35f4c48f593e6fa75dd87 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 29 Jun 2020 17:04:53 +0200 Subject: Add pipewire detection and support Used for screensharing on wayland Fixes: QTBUG-85309 Change-Id: I7ec61611bb9e3f318a6a5bd3a43212f391766628 Reviewed-by: Kirill Burtsev --- src/core/config/linux.pri | 2 ++ src/core/configure.json | 15 +++++++++++++++ 2 files changed, 17 insertions(+) (limited to 'src/core') diff --git a/src/core/config/linux.pri b/src/core/config/linux.pri index e98524002..26d0dcf7d 100644 --- a/src/core/config/linux.pri +++ b/src/core/config/linux.pri @@ -29,6 +29,8 @@ qtConfig(webengine-embedded-build) { qtConfig(webengine-webrtc): gn_args += rtc_use_x11=true } + qtConfig(webengine-webrtc): qtConfig(webengine-webrtc-pipewire): gn_args += rtc_use_pipewire=true + qtConfig(webengine-system-libevent): gn_args += use_system_libevent=true qtConfig(webengine-system-libwebp): gn_args += use_system_libwebp=true qtConfig(webengine-system-libxml2): gn_args += use_system_libxml=true use_system_libxslt=true diff --git a/src/core/configure.json b/src/core/configure.json index 1a2162723..7ba4a94c7 100644 --- a/src/core/configure.json +++ b/src/core/configure.json @@ -25,6 +25,7 @@ "webengine-native-spellchecker": "boolean", "webengine-extensions": "boolean", "webengine-webrtc": "boolean", + "webengine-webrtc-pipewire": "boolean", "webengine-geolocation": "boolean", "webengine-webchannel": "boolean", "webengine-kerberos": "boolean", @@ -67,6 +68,12 @@ "sources": [ { "type": "pkgConfig", "args": "libpulse >= 0.9.10 libpulse-mainloop-glib" } ] + }, + "webengine-gio": { + "label": "gio", + "sources": [ + { "type": "pkgConfig", "args": "gio-2.0" } + ] } }, "tests" : { @@ -183,6 +190,13 @@ "autoDetect": "!features.webengine-embedded-build", "output": [ "privateFeature" ] }, + "webengine-webrtc-pipewire": { + "label": "PipeWire over GIO", + "purpose": "Provides PipeWire support in WebRTC using GIO.", + "condition": "features.webengine-webrtc && libs.webengine-gio", + "autoDetect": "false", + "output": [ "privateFeature" ] + }, "webengine-ozone" : { "label": "Support qpa-xcb", "condition": "features.webengine-ozone-x11", @@ -252,6 +266,7 @@ "webengine-spellchecker", "webengine-native-spellchecker", "webengine-webrtc", + "webengine-webrtc-pipewire", "webengine-geolocation", "webengine-webchannel", "webengine-kerberos", -- cgit v1.2.3 From adb616477f33d59c825d6b875bf4d8d975c009d9 Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Tue, 7 Jul 2020 14:44:42 +0200 Subject: Fix not working egl sync in compositor resource fence It seems this does not work already for a while. Add missing headers. Change-Id: I158519f69e2ce87fe6c84c03a6ac2ce178c20206 Reviewed-by: Allan Sandfeld Jensen --- src/core/compositor/compositor_resource_fence.cpp | 9 ++++++++- src/core/compositor/delegated_frame_node.cpp | 5 ----- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'src/core') diff --git a/src/core/compositor/compositor_resource_fence.cpp b/src/core/compositor/compositor_resource_fence.cpp index 4179395d6..e7bf2fea7 100644 --- a/src/core/compositor/compositor_resource_fence.cpp +++ b/src/core/compositor/compositor_resource_fence.cpp @@ -38,15 +38,22 @@ ****************************************************************************/ #include "compositor_resource_fence.h" - +#include "ozone/gl_surface_qt.h" #include "ui/gl/gl_context.h" +#include #include #ifndef GL_TIMEOUT_IGNORED #define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull #endif + +#if QT_CONFIG(egl) +#include +#include +#endif + namespace QtWebEngineCore { void CompositorResourceFence::wait() diff --git a/src/core/compositor/delegated_frame_node.cpp b/src/core/compositor/delegated_frame_node.cpp index 06ca49f4f..f182a2c9e 100644 --- a/src/core/compositor/delegated_frame_node.cpp +++ b/src/core/compositor/delegated_frame_node.cpp @@ -79,11 +79,6 @@ #include #include -#if QT_CONFIG(egl) -#include -#include -#endif - #ifndef GL_TEXTURE_RECTANGLE #define GL_TEXTURE_RECTANGLE 0x84F5 #endif -- cgit v1.2.3 From a34b3a4e804e44133d8b3d9ab27952cfb6a84b50 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 10 Jul 2020 13:10:02 +0200 Subject: Remove the lie MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This line of code just hided illegal cookie store changes from being observed by our API. Task-number: QTBUG-85526 Change-Id: I044221f70b7628bd727879f11f46bfefe75ca2ca Reviewed-by: Jüri Valdmann --- src/core/net/proxying_restricted_cookie_manager_qt.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/core') diff --git a/src/core/net/proxying_restricted_cookie_manager_qt.cpp b/src/core/net/proxying_restricted_cookie_manager_qt.cpp index 7ee6c2a15..500cb9deb 100644 --- a/src/core/net/proxying_restricted_cookie_manager_qt.cpp +++ b/src/core/net/proxying_restricted_cookie_manager_qt.cpp @@ -74,8 +74,7 @@ public: void OnCookieChange(const net::CookieChangeInfo &change) override { - if (restricted_cookie_manager_ && restricted_cookie_manager_->allowCookies(url_, site_for_cookies_)) - client_listener_->OnCookieChange(change); + client_listener_->OnCookieChange(change); } private: -- cgit v1.2.3 From 98ecea4b23c2e3122fda6e5b1df0e23a56d93ffe Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 2 Jul 2020 11:49:20 +0200 Subject: Parse forward and back mouse buttons It appears we have support for it on all levels. Fixes: QTBUG-85360 Change-Id: I68d03931197a3b883a1909e96096000fb84925bf Reviewed-by: Peter Varga --- src/core/render_widget_host_view_qt.cpp | 2 +- src/core/web_event_factory.cpp | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index dd4965de5..ef56e451d 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -1742,7 +1742,7 @@ void RenderWidgetHostViewQt::handlePointerEvent(T *event) blink::WebMouseEvent webEvent = WebEventFactory::toWebMouseEvent(event); if ((webEvent.GetType() == blink::WebInputEvent::kMouseDown || webEvent.GetType() == blink::WebInputEvent::kMouseUp) && webEvent.button == blink::WebMouseEvent::Button::kNoButton) { - // Blink can only handle the 3 main mouse-buttons and may assert when processing mouse-down for no button. + // Blink can only handle the 5 main mouse-buttons and may assert when processing mouse-down for no button. LOG(INFO) << "Unhandled mouse button"; return; } diff --git a/src/core/web_event_factory.cpp b/src/core/web_event_factory.cpp index e1db69b16..32d79049d 100644 --- a/src/core/web_event_factory.cpp +++ b/src/core/web_event_factory.cpp @@ -1229,6 +1229,10 @@ static WebMouseEvent::Button mouseButtonForEvent(T *event) return WebMouseEvent::Button::kRight; else if (event->button() == Qt::MidButton) return WebMouseEvent::Button::kMiddle; + else if (event->button() == Qt::BackButton) + return WebMouseEvent::Button::kBack; + else if (event->button() == Qt::ForwardButton) + return WebMouseEvent::Button::kForward; if (event->type() != QEvent::MouseMove && event->type() != QEvent::TabletMove) return WebMouseEvent::Button::kNoButton; @@ -1241,6 +1245,10 @@ static WebMouseEvent::Button mouseButtonForEvent(T *event) return WebMouseEvent::Button::kRight; else if (event->buttons() & Qt::MidButton) return WebMouseEvent::Button::kMiddle; + else if (event->buttons() & Qt::BackButton) + return WebMouseEvent::Button::kBack; + else if (event->buttons() & Qt::ForwardButton) + return WebMouseEvent::Button::kForward; return WebMouseEvent::Button::kNoButton; } @@ -1255,6 +1263,10 @@ static unsigned mouseButtonsModifiersForEvent(const T* event) ret |= WebInputEvent::kRightButtonDown; if (event->buttons() & Qt::MidButton) ret |= WebInputEvent::kMiddleButtonDown; + if (event->buttons() & Qt::BackButton) + ret |= WebInputEvent::kBackButtonDown; + if (event->buttons() & Qt::ForwardButton) + ret |= WebInputEvent::kForwardButtonDown; return ret; } @@ -1348,6 +1360,10 @@ static inline Qt::MouseButtons mouseButtonsForModifier(unsigned int modifier) buttons |= Qt::RightButton; if (modifier & WebInputEvent::kMiddleButtonDown) buttons |= Qt::MiddleButton; + if (modifier & WebInputEvent::kBackButtonDown) + buttons |= Qt::BackButton; + if (modifier & WebInputEvent::kForwardButtonDown) + buttons |= Qt::ForwardButton; return buttons; } -- cgit v1.2.3 From 44267635f32be01ae0be1434583f2a2f3cca583b Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 14 Jul 2020 11:27:47 +0200 Subject: Make loading PDF view less racy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There was some kind of race between loading as a plugin and this redirect. Task-number: QTBUG-84340 Change-Id: I57ac8fcae0c1de98b1fd3013d2b5299c85547cc0 Reviewed-by: Michael Brüning --- src/core/net/plugin_response_interceptor_url_loader_throttle.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/core') diff --git a/src/core/net/plugin_response_interceptor_url_loader_throttle.cpp b/src/core/net/plugin_response_interceptor_url_loader_throttle.cpp index d854a556c..4fdb8c3d0 100644 --- a/src/core/net/plugin_response_interceptor_url_loader_throttle.cpp +++ b/src/core/net/plugin_response_interceptor_url_loader_throttle.cpp @@ -125,6 +125,8 @@ void PluginResponseInterceptorURLLoaderThrottle::WillProcessResponse(const GURL if (extension_id.empty()) return; + *defer = true; + base::PostTask(FROM_HERE, {content::BrowserThread::UI}, base::BindOnce(&onPdfStreamIntercepted, response_url, -- cgit v1.2.3 From 11a27178e42df66906dd12dcb5773ac6cb4426b8 Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Mon, 13 Jul 2020 14:56:38 +0200 Subject: Remove ProxyingRestrictedCookieManagerListenerQt Cleanup after a34b3a4e Task-number: QTBUG-85526 Change-Id: I23fd5f504937efa44964546a1f4b095efd9ad65f Reviewed-by: Allan Sandfeld Jensen --- .../net/proxying_restricted_cookie_manager_qt.cpp | 40 +--------------------- 1 file changed, 1 insertion(+), 39 deletions(-) (limited to 'src/core') diff --git a/src/core/net/proxying_restricted_cookie_manager_qt.cpp b/src/core/net/proxying_restricted_cookie_manager_qt.cpp index 500cb9deb..331b55e62 100644 --- a/src/core/net/proxying_restricted_cookie_manager_qt.cpp +++ b/src/core/net/proxying_restricted_cookie_manager_qt.cpp @@ -58,33 +58,6 @@ namespace QtWebEngineCore { -class ProxyingRestrictedCookieManagerListenerQt : public network::mojom::CookieChangeListener { -public: - ProxyingRestrictedCookieManagerListenerQt(const GURL &url, - const GURL &site_for_cookies, - const url::Origin &top_frame_origin, - base::WeakPtr restricted_cookie_manager, - mojo::PendingRemote client_listener) - : url_(url) - , site_for_cookies_(site_for_cookies) - , top_frame_origin_(top_frame_origin) - , restricted_cookie_manager_(restricted_cookie_manager) - , client_listener_(std::move(client_listener)) - {} - - void OnCookieChange(const net::CookieChangeInfo &change) override - { - client_listener_->OnCookieChange(change); - } - -private: - const GURL url_; - const GURL site_for_cookies_; - const url::Origin top_frame_origin_; - base::WeakPtr restricted_cookie_manager_; - mojo::Remote client_listener_; -}; - // static void ProxyingRestrictedCookieManagerQt::CreateAndBind(ProfileIODataQt *profileIoData, mojo::PendingRemote underlying_rcm, @@ -178,18 +151,7 @@ void ProxyingRestrictedCookieManagerQt::AddChangeListener(const GURL &url, AddChangeListenerCallback callback) { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); - - mojo::PendingRemote proxy_listener_remote; - auto proxy_listener = - std::make_unique( - url, site_for_cookies, top_frame_origin, - weak_factory_.GetWeakPtr(), - std::move(listener)); - - mojo::MakeSelfOwnedReceiver(std::move(proxy_listener), - proxy_listener_remote.InitWithNewPipeAndPassReceiver()); - - underlying_restricted_cookie_manager_->AddChangeListener(url, site_for_cookies, top_frame_origin, std::move(proxy_listener_remote), std::move(callback)); + underlying_restricted_cookie_manager_->AddChangeListener(url, site_for_cookies, top_frame_origin, std::move(listener), std::move(callback)); } void ProxyingRestrictedCookieManagerQt::SetCookieFromString(const GURL &url, -- cgit v1.2.3 From 9a90cd56c432f2ad3e811449cb199b11c6ed9de8 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 10 Jul 2020 16:29:54 +0200 Subject: Add the cookie filter to URL requests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Submodule src/3rdparty c91f4d20..809e16e4: > Add cookie filter to URL requests cookie headers > Use audio-manager app-name for MPRIS Fixes: QTBUG-85526 Change-Id: Icab26cad3cea8e2ee021a3e589f41bf0543d64fa Reviewed-by: Michael Brüning --- src/core/api/qwebenginecookiestore.cpp | 9 +++++++ src/core/net/cookie_monster_delegate_qt.cpp | 39 +++++++++++++++++++++++++++++ src/core/net/cookie_monster_delegate_qt.h | 4 +++ 3 files changed, 52 insertions(+) (limited to 'src/core') diff --git a/src/core/api/qwebenginecookiestore.cpp b/src/core/api/qwebenginecookiestore.cpp index 40594b9c0..a09a74bf6 100644 --- a/src/core/api/qwebenginecookiestore.cpp +++ b/src/core/api/qwebenginecookiestore.cpp @@ -89,6 +89,9 @@ void QWebEngineCookieStorePrivate::processPendingUserCookies() delegate->deleteSessionCookies(CallbackDirectory::DeleteSessionCookiesCallbackId); } + if (bool(filterCallback)) + delegate->setHasFilter(true); + if (m_pendingUserCookies.isEmpty()) return; @@ -362,7 +365,10 @@ void QWebEngineCookieStore::deleteAllCookies() */ void QWebEngineCookieStore::setCookieFilter(const std::function &filterCallback) { + bool changed = bool(d_ptr->filterCallback) != bool(filterCallback); d_ptr->filterCallback = filterCallback; + if (changed && d_ptr->delegate) + d_ptr->delegate->setHasFilter(bool(d_ptr->filterCallback)); } /*! @@ -371,7 +377,10 @@ void QWebEngineCookieStore::setCookieFilter(const std::function &&filterCallback) { + bool changed = bool(d_ptr->filterCallback) != bool(filterCallback); d_ptr->filterCallback = std::move(filterCallback); + if (changed && d_ptr->delegate) + d_ptr->delegate->setHasFilter(bool(d_ptr->filterCallback)); } /*! diff --git a/src/core/net/cookie_monster_delegate_qt.cpp b/src/core/net/cookie_monster_delegate_qt.cpp index d3157f760..d2e0b38e2 100644 --- a/src/core/net/cookie_monster_delegate_qt.cpp +++ b/src/core/net/cookie_monster_delegate_qt.cpp @@ -72,6 +72,25 @@ private: DISALLOW_COPY_AND_ASSIGN(CookieChangeListener); }; +class CookieAccessFilter : public network::mojom::CookieRemoteAccessFilter +{ +public: + CookieAccessFilter(CookieMonsterDelegateQt *delegate) : m_delegate(delegate) { } + ~CookieAccessFilter() override = default; + + void AllowedAccess(const GURL& url, const GURL& site_for_cookies, AllowedAccessCallback callback) override + { + bool allow = m_delegate->canGetCookies(toQt(site_for_cookies), toQt(url)); + std::move(callback).Run(allow); + } + +private: + CookieMonsterDelegateQt *m_delegate; + + DISALLOW_COPY_AND_ASSIGN(CookieAccessFilter); +}; + + static GURL sourceUrlForCookie(const QNetworkCookie &cookie) { QString urlFragment = QStringLiteral("%1%2").arg(cookie.domain()).arg(cookie.path()); @@ -81,7 +100,10 @@ static GURL sourceUrlForCookie(const QNetworkCookie &cookie) CookieMonsterDelegateQt::CookieMonsterDelegateQt() : m_client(nullptr) , m_listener(new CookieChangeListener(this)) + , m_filter(new CookieAccessFilter(this)) , m_receiver(m_listener.get()) + , m_filterReceiver(m_filter.get()) + , m_hasFilter(false) { } @@ -176,14 +198,31 @@ void CookieMonsterDelegateQt::setMojoCookieManager(network::mojom::CookieManager m_mojoCookieManager.Bind(std::move(cookie_manager_info)); m_mojoCookieManager->AddGlobalChangeListener(m_receiver.BindNewPipeAndPassRemote()); + if (m_hasFilter) + m_mojoCookieManager->SetRemoteFilter(m_filterReceiver.BindNewPipeAndPassRemote()); if (m_client) m_client->d_func()->processPendingUserCookies(); } +void CookieMonsterDelegateQt::setHasFilter(bool hasFilter) +{ + m_hasFilter = hasFilter; + if (!m_mojoCookieManager.is_bound()) + return; + if (m_hasFilter) { + if (!m_filterReceiver.is_bound()) + m_mojoCookieManager->SetRemoteFilter(m_filterReceiver.BindNewPipeAndPassRemote()); + } else { + if (m_filterReceiver.is_bound()) + m_filterReceiver.reset(); + } +} + void CookieMonsterDelegateQt::unsetMojoCookieManager() { m_receiver.reset(); + m_filterReceiver.reset(); m_mojoCookieManager.reset(); } diff --git a/src/core/net/cookie_monster_delegate_qt.h b/src/core/net/cookie_monster_delegate_qt.h index bcbbe4c52..748e92da9 100644 --- a/src/core/net/cookie_monster_delegate_qt.h +++ b/src/core/net/cookie_monster_delegate_qt.h @@ -91,7 +91,10 @@ class Q_WEBENGINECORE_PRIVATE_EXPORT CookieMonsterDelegateQt : public base::RefC network::mojom::CookieManagerPtr m_mojoCookieManager; std::unique_ptr m_listener; + std::unique_ptr m_filter; mojo::Receiver m_receiver; + mojo::Receiver m_filterReceiver; + bool m_hasFilter; public: CookieMonsterDelegateQt(); ~CookieMonsterDelegateQt(); @@ -107,6 +110,7 @@ public: void setClient(QWebEngineCookieStore *client); void setMojoCookieManager(network::mojom::CookieManagerPtrInfo cookie_manager_info); void unsetMojoCookieManager(); + void setHasFilter(bool b); bool canSetCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &url) const; bool canGetCookies(const QUrl &firstPartyUrl, const QUrl &url) const; -- cgit v1.2.3 From 060c09b23b9ec0376fa7fd687d1f853660410f2a Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 15 Jul 2020 11:57:44 +0200 Subject: Disable navigation on back/forward mouse buttons in Qt 5 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Submodule src/3rdparty 809e16e4..840c8e5f: > Make navigation on back/forward mouse buttons optional Change-Id: I191f7781cf9b824b743b80a05a3e819a414ee546 Reviewed-by: Michael Brüning --- src/core/web_contents_delegate_qt.cpp | 9 +++++++++ src/core/web_contents_delegate_qt.h | 1 + 2 files changed, 10 insertions(+) (limited to 'src/core') diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index 54ae4937a..f13621b99 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -807,6 +807,15 @@ void WebContentsDelegateQt::ContentsZoomChange(bool zoom_in) adapter->setZoomFactor(adapter->currentZoomFactor() - 0.1f); } +bool WebContentsDelegateQt::ShouldNavigateOnBackForwardMouseButtons() +{ +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + return false; +#else + return true; +#endif +} + FaviconManager *WebContentsDelegateQt::faviconManager() { return m_faviconManager.data(); diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h index bfef9a1df..8a9d8be1b 100644 --- a/src/core/web_contents_delegate_qt.h +++ b/src/core/web_contents_delegate_qt.h @@ -168,6 +168,7 @@ public: void OnVisibilityChanged(content::Visibility visibility) override; void DidFirstVisuallyNonEmptyPaint() override; void ActivateContents(content::WebContents* contents) override; + bool ShouldNavigateOnBackForwardMouseButtons() override; void didFailLoad(const QUrl &url, int errorCode, const QString &errorDescription); void overrideWebPreferences(content::WebContents *, content::WebPreferences*); -- cgit v1.2.3 From 9c5608e4e4b600581ed17c0a6b2dc316bb1544d0 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 13 Jul 2020 12:59:26 +0200 Subject: Fix mistake from 78-based adaptations The options only need to allow httponly, it doesn't set it, and we shouldn't even forward canonical cookies that were excluded on creation. Change-Id: Ieec45734938c07a50ac03aa113a02a907bce689f Reviewed-by: Michal Klocek --- src/core/net/cookie_monster_delegate_qt.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/core') diff --git a/src/core/net/cookie_monster_delegate_qt.cpp b/src/core/net/cookie_monster_delegate_qt.cpp index d2e0b38e2..263973684 100644 --- a/src/core/net/cookie_monster_delegate_qt.cpp +++ b/src/core/net/cookie_monster_delegate_qt.cpp @@ -145,9 +145,12 @@ void CookieMonsterDelegateQt::setCookie(quint64 callbackId, const QNetworkCookie callback = base::BindOnce(&CookieMonsterDelegateQt::SetCookieCallbackOnUIThread, this, callbackId); net::CanonicalCookie::CookieInclusionStatus inclusion; auto canonCookie = net::CanonicalCookie::Create(gurl, cookie_line, base::Time::Now(), base::nullopt, &inclusion); + if (!inclusion.IsInclude()) { + LOG(WARNING) << "QWebEngineCookieStore::setCookie() - Tried to set invalid cookie"; + return; + } net::CookieOptions options; - if (!inclusion.HasExclusionReason(net::CanonicalCookie::CookieInclusionStatus::EXCLUDE_HTTP_ONLY)) - options.set_include_httponly(); + options.set_include_httponly(); m_mojoCookieManager->SetCanonicalCookie(*canonCookie.get(), gurl.scheme(), options, std::move(callback)); } -- cgit v1.2.3 From b610697828e2dc4ce19b6504454938b2dc84419c Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 21 Jul 2020 12:04:25 +0200 Subject: Replace Qt::MidButton with Qt::MiddleButton The latter has been the preferred name since Qt 4.7.0. (Pick back to 5.15 shall need to drop the test change, as the test was added to dev after it diverged from 5.15.) Change-Id: I3154ea1203e741cb337782d3374e02e15c5f209e Reviewed-by: Allan Sandfeld Jensen (cherry picked from commit 005a338f169b485077c248358e1cde96d22ae506) Reviewed-by: Edward Welbourne --- src/core/web_event_factory.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/core') diff --git a/src/core/web_event_factory.cpp b/src/core/web_event_factory.cpp index 32d79049d..dd7ed90c7 100644 --- a/src/core/web_event_factory.cpp +++ b/src/core/web_event_factory.cpp @@ -1227,7 +1227,7 @@ static WebMouseEvent::Button mouseButtonForEvent(T *event) return WebMouseEvent::Button::kLeft; else if (event->button() == Qt::RightButton) return WebMouseEvent::Button::kRight; - else if (event->button() == Qt::MidButton) + else if (event->button() == Qt::MiddleButton) return WebMouseEvent::Button::kMiddle; else if (event->button() == Qt::BackButton) return WebMouseEvent::Button::kBack; @@ -1243,7 +1243,7 @@ static WebMouseEvent::Button mouseButtonForEvent(T *event) return WebMouseEvent::Button::kLeft; else if (event->buttons() & Qt::RightButton) return WebMouseEvent::Button::kRight; - else if (event->buttons() & Qt::MidButton) + else if (event->buttons() & Qt::MiddleButton) return WebMouseEvent::Button::kMiddle; else if (event->buttons() & Qt::BackButton) return WebMouseEvent::Button::kBack; @@ -1261,7 +1261,7 @@ static unsigned mouseButtonsModifiersForEvent(const T* event) ret |= WebInputEvent::kLeftButtonDown; if (event->buttons() & Qt::RightButton) ret |= WebInputEvent::kRightButtonDown; - if (event->buttons() & Qt::MidButton) + if (event->buttons() & Qt::MiddleButton) ret |= WebInputEvent::kMiddleButtonDown; if (event->buttons() & Qt::BackButton) ret |= WebInputEvent::kBackButtonDown; -- cgit v1.2.3 From 6178015dff6f2f83c16a1dddb199c7f6c3e9c694 Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Mon, 20 Jul 2020 15:55:27 +0200 Subject: Move webengine-noexecstack to buildtools Change-Id: I854034fd63c8847867fd7ec01d5c25781e7de5ef Reviewed-by: Allan Sandfeld Jensen --- src/core/configure.json | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'src/core') diff --git a/src/core/configure.json b/src/core/configure.json index 7ba4a94c7..4cd6174fc 100644 --- a/src/core/configure.json +++ b/src/core/configure.json @@ -92,11 +92,6 @@ "label": "embedded build", "type": "detectEmbedded" }, - "webengine-noexecstack" : { - "label": "linker supports -z noexecstack", - "type": "linkerSupportsFlag", - "flag": "-z,noexecstack" - }, "webengine-nodejs": { "label": "node.js", "type": "detectNodeJS" @@ -218,11 +213,6 @@ { "type": "privateConfig", "name": "webcore_debug" } ] }, - "webengine-noexecstack": { - "label": "linker supports -z noexecstack", - "condition": "config.unix && tests.webengine-noexecstack", - "output": [ "privateFeature" ] - }, "webengine-nodejs": { "label": "Node.js", "condition": "tests.webengine-nodejs", -- cgit v1.2.3 From 74fe796039e85c97ffac3f7b014ca718e7284dea Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Mon, 20 Jul 2020 15:56:14 +0200 Subject: Share linking config between webenginecore and pdf Change-Id: Ib06a0a1ec3372d483008cc0ac0ec211ec8316e0e Reviewed-by: Allan Sandfeld Jensen --- src/core/core_module.pro | 57 ++++-------------------------------------------- 1 file changed, 4 insertions(+), 53 deletions(-) (limited to 'src/core') diff --git a/src/core/core_module.pro b/src/core/core_module.pro index 5007012ac..3b439e818 100644 --- a/src/core/core_module.pro +++ b/src/core/core_module.pro @@ -1,62 +1,10 @@ MODULE = webenginecore include(core_common.pri) -# Needed to set a CFBundleIdentifier -QMAKE_INFO_PLIST = Info_mac.plist - -linking_pri = $$OUT_PWD/$$getConfigDir()/$${TARGET}.pri - -!include($$linking_pri) { - error("Could not find the linking information that gn should have generated.") -} +include($${QTWEBENGINE_ROOT}/src/buildtools/config/linking.pri) api_library_name = qtwebenginecoreapi$$qtPlatformTargetSuffix() api_library_path = $$OUT_PWD/api/$$getConfigDir() - -# Do not precompile any headers. We are only interested in the linker step. -PRECOMPILED_HEADER = - -isEmpty(NINJA_OBJECTS): error("Missing object files from QtWebEngineCore linking pri.") -isEmpty(NINJA_LFLAGS): error("Missing linker flags from QtWebEngineCore linking pri") -isEmpty(NINJA_ARCHIVES): error("Missing archive files from QtWebEngineCore linking pri") -isEmpty(NINJA_LIBS): error("Missing library files from QtWebEngineCore linking pri") -NINJA_OBJECTS = $$eval($$list($$NINJA_OBJECTS)) -# Do manual response file linking for macOS and Linux - -RSP_OBJECT_FILE = $$OUT_PWD/$$getConfigDir()/$${TARGET}_o.rsp -for(object, NINJA_OBJECTS): RSP_O_CONTENT += $$object -write_file($$RSP_OBJECT_FILE, RSP_O_CONTENT) -RSP_ARCHIVE_FILE = $$OUT_PWD/$$getConfigDir()/$${TARGET}_a.rsp -for(archive, NINJA_ARCHIVES): RSP_A_CONTENT += $$archive -write_file($$RSP_ARCHIVE_FILE, RSP_A_CONTENT) - -macos:LIBS_PRIVATE += -Wl,-filelist,$$shell_quote($${RSP_OBJECT_FILE}) @$${RSP_ARCHIVE_FILE} -linux:QMAKE_LFLAGS += @$${RSP_OBJECT_FILE} -Wl,--start-group @$${RSP_ARCHIVE_FILE} -Wl,--end-group -win32:QMAKE_LFLAGS += @$${RSP_OBJECT_FILE} @$${RSP_ARCHIVE_FILE} - -LIBS_PRIVATE += $$NINJA_LIB_DIRS $$NINJA_LIBS -# GN's LFLAGS doesn't always work across all the Linux configurations we support. -# The Windows and macOS ones from GN does provide a few useful flags however - -unix:qtConfig(webengine-noexecstack): \ - QMAKE_LFLAGS += -Wl,-z,noexecstack -linux { - # add chromium flags - for(flag, NINJA_LFLAGS) { - # filter out some flags - !contains(flag, .*noexecstack$): \ - !contains(flag, .*as-needed$): \ - !contains(flag, ^-B.*): \ - !contains(flag, ^-fuse-ld.*): \ - QMAKE_LFLAGS += $$flag - } -} else { - QMAKE_LFLAGS += $$NINJA_LFLAGS -} - -POST_TARGETDEPS += $$NINJA_TARGETDEPS - - LIBS_PRIVATE += -L$$api_library_path CONFIG *= no_smart_library_merge osx { @@ -86,6 +34,9 @@ win32 { POST_TARGETDEPS += $${api_library_path}$${QMAKE_DIR_SEP}lib$${api_library_name}.a } +# Needed to set a CFBundleIdentifier +QMAKE_INFO_PLIST = Info_mac.plist + # Using -Wl,-Bsymbolic-functions seems to confuse the dynamic linker # and doesn't let Chromium get access to libc symbols through dlsym. CONFIG -= bsymbolic_functions -- cgit v1.2.3 From a2a19a6965601ced75e3e48b2bf618ba2bdbd29e Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 22 Jul 2020 15:41:07 +0200 Subject: Convert native scancode on Windows to what Chromium expects Fixes: QTBUG-85661 Change-Id: I7cd8ed534d94d6be06f77b9b2d1779905655e772 Reviewed-by: Kirill Burtsev --- src/core/web_event_factory.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/web_event_factory.cpp b/src/core/web_event_factory.cpp index dd7ed90c7..5b6c6bd0e 100644 --- a/src/core/web_event_factory.cpp +++ b/src/core/web_event_factory.cpp @@ -205,7 +205,14 @@ static quint32 nativeKeyCodeForKeyEvent(const QKeyEvent *ev) // Cygwin/X, etc). Also evdev key codes are *not* supported for the same // reason. #if defined(Q_OS_WINDOWS) - return keyboardDriver() == KeyboardDriver::Windows ? ev->nativeScanCode() : 0; + if (keyboardDriver() == KeyboardDriver::Windows) { + // see GetScanCodeFromLParam in events_win_utils.cc: + quint32 scancode = ev->nativeScanCode() & 0xff; + if (ev->nativeScanCode() & 0x100) + scancode |= 0xe000; + return scancode; + } + return 0; #elif defined(Q_OS_MACOS) return keyboardDriver() == KeyboardDriver::Cocoa ? ev->nativeVirtualKey() : 0; #elif defined(Q_OS_LINUX) -- cgit v1.2.3