diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/config/linux.pri | 4 | ||||
-rw-r--r-- | src/core/gl_surface_qt.cpp | 6 | ||||
-rw-r--r-- | src/core/renderer_host/user_resource_controller_host.cpp | 5 | ||||
-rw-r--r-- | src/core/renderer_host/web_channel_ipc_transport_host.cpp | 14 | ||||
-rw-r--r-- | src/core/renderer_host/web_channel_ipc_transport_host.h | 1 | ||||
-rw-r--r-- | src/core/web_contents_adapter.cpp | 25 | ||||
-rw-r--r-- | src/core/web_contents_adapter.h | 4 | ||||
-rw-r--r-- | src/core/web_contents_adapter_client.h | 42 | ||||
-rw-r--r-- | src/core/web_contents_view_qt.cpp | 3 | ||||
-rw-r--r-- | src/core/web_engine_context.cpp | 48 | ||||
-rw-r--r-- | src/core/web_engine_context.h | 2 | ||||
-rw-r--r-- | src/core/web_event_factory.cpp | 5 |
12 files changed, 126 insertions, 33 deletions
diff --git a/src/core/config/linux.pri b/src/core/config/linux.pri index c2d41b4d0..c0f2f6289 100644 --- a/src/core/config/linux.pri +++ b/src/core/config/linux.pri @@ -41,7 +41,7 @@ cross_compile:!host_build { !isEmpty(TOOLCHAIN_SYSROOT): gn_args += target_sysroot=\"$${TOOLCHAIN_SYSROOT}\" } -contains(QT_ARCH, "arm"):!host_build { +contains(QT_ARCH, "arm") { # Extract ARM specific compiler options that we have to pass to gn, # but let gn figure out a default if an option is not present. MTUNE = $$extractCFlag("-mtune=.*") @@ -78,7 +78,7 @@ contains(QT_ARCH, "arm"):!host_build { else: contains(QMAKE_CFLAGS, "-mthumb"): gn_args += arm_use_thumb=true } -contains(QT_ARCH, "mips"):!host_build { +contains(QT_ARCH, "mips") { MARCH = $$extractCFlag("-march=.*") !isEmpty(MARCH) { equals(MARCH, "mips32r6"): gn_args += mips_arch_variant=\"r6\" diff --git a/src/core/gl_surface_qt.cpp b/src/core/gl_surface_qt.cpp index 69609f4d4..93c1c5293 100644 --- a/src/core/gl_surface_qt.cpp +++ b/src/core/gl_surface_qt.cpp @@ -48,6 +48,7 @@ #include <QGuiApplication> #include "gl_context_qt.h" #include "qtwebenginecoreglobal_p.h" +#include "web_engine_context.h" #include "base/logging.h" #include "gpu/ipc/service/image_transport_surface.h" @@ -652,6 +653,11 @@ bool InitializeGLOneOffPlatform() return false; } +bool usingSoftwareDynamicGL() +{ + return QtWebEngineCore::usingSoftwareDynamicGL(); +} + scoped_refptr<GLSurface> CreateOffscreenGLSurfaceWithFormat(const gfx::Size& size, GLSurfaceFormat format) { diff --git a/src/core/renderer_host/user_resource_controller_host.cpp b/src/core/renderer_host/user_resource_controller_host.cpp index f90aebda6..2799d5d85 100644 --- a/src/core/renderer_host/user_resource_controller_host.cpp +++ b/src/core/renderer_host/user_resource_controller_host.cpp @@ -88,11 +88,6 @@ void UserResourceControllerHost::WebContentsObserverHelper::RenderFrameHostChang { if (oldHost) oldHost->Send(new RenderFrameObserverHelper_ClearScripts(oldHost->GetRoutingID())); - - content::WebContents *contents = web_contents(); - Q_FOREACH (const UserScript &script, m_controllerHost->m_perContentsScripts.value(contents)) - newHost->Send(new RenderFrameObserverHelper_AddScript(newHost->GetRoutingID(), - script.data())); } void UserResourceControllerHost::WebContentsObserverHelper::WebContentsDestroyed() 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 1cd4e4063..c47b255b7 100644 --- a/src/core/renderer_host/web_channel_ipc_transport_host.cpp +++ b/src/core/renderer_host/web_channel_ipc_transport_host.cpp @@ -40,6 +40,7 @@ #include "web_channel_ipc_transport_host.h" #include "base/strings/string16.h" +#include "content/public/browser/render_view_host.h" #include "common/qt_messages.h" #include "type_conversion.h" @@ -61,11 +62,16 @@ WebChannelIPCTransportHost::~WebChannelIPCTransportHost() { } -void WebChannelIPCTransportHost::RenderViewHostChanged(content::RenderViewHost *, content::RenderViewHost *) +void WebChannelIPCTransportHost::RenderViewHostChanged(content::RenderViewHost *oldHost, content::RenderViewHost *) { - // This means that we were moved into a different RenderView, possibly in a different - // render process and that we lost our WebChannelIPCTransport object and its state. - Send(new WebChannelIPCTransport_Install(routing_id(), m_worldId)); + if (oldHost) + oldHost->Send(new WebChannelIPCTransport_Uninstall(oldHost->GetRoutingID(), m_worldId)); +} + +void WebChannelIPCTransportHost::RenderViewCreated(content::RenderViewHost *view_host) +{ + // Make sure the new view knows a webchannel is installed and in which world. + view_host->Send(new WebChannelIPCTransport_Install(view_host->GetRoutingID(), m_worldId)); } void WebChannelIPCTransportHost::setWorldId(uint worldId) diff --git a/src/core/renderer_host/web_channel_ipc_transport_host.h b/src/core/renderer_host/web_channel_ipc_transport_host.h index aa406471c..a1e697a91 100644 --- a/src/core/renderer_host/web_channel_ipc_transport_host.h +++ b/src/core/renderer_host/web_channel_ipc_transport_host.h @@ -60,6 +60,7 @@ public: // WebContentsObserver void RenderViewHostChanged(content::RenderViewHost* old_host, content::RenderViewHost* new_host) override; + void RenderViewCreated(content::RenderViewHost* render_view_host) override; // QWebChannelAbstractTransport void sendMessage(const QJsonObject &message) override; diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 6181c0b72..827349115 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -926,7 +926,9 @@ void WebContentsAdapter::updateWebPreferences(const content::WebPreferences & we d->webContents->GetRenderViewHost()->UpdateWebkitPreferences(webPreferences); } -void WebContentsAdapter::download(const QUrl &url, const QString &suggestedFileName) +void WebContentsAdapter::download(const QUrl &url, const QString &suggestedFileName, + const QUrl &referrerUrl, + ReferrerPolicy referrerPolicy) { Q_D(WebContentsAdapter); content::BrowserContext *bctx = webContents()->GetBrowserContext(); @@ -939,9 +941,19 @@ void WebContentsAdapter::download(const QUrl &url, const QString &suggestedFileN dlmd->setDownloadType(BrowserContextAdapterClient::UserRequested); dlm->SetDelegate(dlmd); + GURL gurl = toGurl(url); std::unique_ptr<content::DownloadUrlParameters> params( - content::DownloadUrlParameters::CreateForWebContentsMainFrame(webContents(), toGurl(url))); + content::DownloadUrlParameters::CreateForWebContentsMainFrame(webContents(), gurl)); + params->set_suggested_name(toString16(suggestedFileName)); + + // referrer logic based on chrome/browser/renderer_context_menu/render_view_context_menu.cc: + params->set_referrer( + content::Referrer::SanitizeForRequest( + gurl, + content::Referrer(toGurl(referrerUrl).GetAsReferrer(), + static_cast<blink::WebReferrerPolicy>(referrerPolicy)))); + dlm->DownloadUrl(std::move(params)); } @@ -1473,4 +1485,13 @@ ASSERT_ENUMS_MATCH(WebContentsAdapterClient::SaveToDiskDisposition, WindowOpenDi ASSERT_ENUMS_MATCH(WebContentsAdapterClient::OffTheRecordDisposition, WindowOpenDisposition::OFF_THE_RECORD) ASSERT_ENUMS_MATCH(WebContentsAdapterClient::IgnoreActionDisposition, WindowOpenDisposition::IGNORE_ACTION) +ASSERT_ENUMS_MATCH(ReferrerPolicy::Always, blink::kWebReferrerPolicyAlways) +ASSERT_ENUMS_MATCH(ReferrerPolicy::Default, blink::kWebReferrerPolicyDefault) +ASSERT_ENUMS_MATCH(ReferrerPolicy::NoReferrerWhenDowngrade, blink::kWebReferrerPolicyNoReferrerWhenDowngrade) +ASSERT_ENUMS_MATCH(ReferrerPolicy::Never, blink::kWebReferrerPolicyNever) +ASSERT_ENUMS_MATCH(ReferrerPolicy::Origin, blink::kWebReferrerPolicyOrigin) +ASSERT_ENUMS_MATCH(ReferrerPolicy::OriginWhenCrossOrigin, blink::kWebReferrerPolicyOriginWhenCrossOrigin) +ASSERT_ENUMS_MATCH(ReferrerPolicy::NoReferrerWhenDowngradeOriginWhenCrossOrigin, blink::kWebReferrerPolicyNoReferrerWhenDowngradeOriginWhenCrossOrigin) +ASSERT_ENUMS_MATCH(ReferrerPolicy::Last, blink::kWebReferrerPolicyLast) + } // namespace QtWebEngineCore diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h index 46c8d2604..67fcbe7af 100644 --- a/src/core/web_contents_adapter.h +++ b/src/core/web_contents_adapter.h @@ -124,7 +124,9 @@ public: quint64 findText(const QString &subString, bool caseSensitively, bool findBackward); void stopFinding(); void updateWebPreferences(const content::WebPreferences &webPreferences); - void download(const QUrl &url, const QString &suggestedFileName); + void download(const QUrl &url, const QString &suggestedFileName, + const QUrl &referrerUrl = QUrl(), + ReferrerPolicy referrerPolicy = ReferrerPolicy::Default); bool isAudioMuted() const; void setAudioMuted(bool mute); bool recentlyAudible(); diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h index 8b7365342..4280dbfe1 100644 --- a/src/core/web_contents_adapter_client.h +++ b/src/core/web_contents_adapter_client.h @@ -71,6 +71,17 @@ class WebContentsAdapter; class WebContentsDelegateQt; class WebEngineSettings; +// Must match blink::WebReferrerPolicy +enum class ReferrerPolicy { + Always, + Default, + NoReferrerWhenDowngrade, + Never, + Origin, + OriginWhenCrossOrigin, + NoReferrerWhenDowngradeOriginWhenCrossOrigin, + Last = NoReferrerWhenDowngradeOriginWhenCrossOrigin, +}; class WebEngineContextMenuSharedData : public QSharedData { @@ -97,6 +108,9 @@ public: QString suggestedFileName; QString misspelledWord; QStringList spellCheckerSuggestions; + QUrl pageUrl; + QUrl frameUrl; + ReferrerPolicy referrerPolicy = ReferrerPolicy::Default; // Some likely candidates for future additions as we add support for the related actions: // bool isImageBlocked; // <enum tbd> mediaType; @@ -253,6 +267,34 @@ public: return d->spellCheckerSuggestions; } + void setFrameUrl(const QUrl &url) { + d->frameUrl = url; + } + + QUrl frameUrl() const { + return d->frameUrl; + } + + void setPageUrl(const QUrl &url) { + d->pageUrl = url; + } + + QUrl pageUrl() const { + return d->pageUrl; + } + + QUrl referrerUrl() const { + return !d->frameUrl.isEmpty() ? d->frameUrl : d->pageUrl; + } + + void setReferrerPolicy(ReferrerPolicy referrerPolicy) { + d->referrerPolicy = referrerPolicy; + } + + ReferrerPolicy referrerPolicy() const { + return d->referrerPolicy; + } + private: QSharedDataPointer<WebEngineContextMenuSharedData> d; }; diff --git a/src/core/web_contents_view_qt.cpp b/src/core/web_contents_view_qt.cpp index f9435ac34..28f202e24 100644 --- a/src/core/web_contents_view_qt.cpp +++ b/src/core/web_contents_view_qt.cpp @@ -176,6 +176,9 @@ static inline WebEngineContextMenuData fromParams(const content::ContextMenuPara ret.setMisspelledWord(toQt(params.misspelled_word)); ret.setSpellCheckerSuggestions(fromVector(params.dictionary_suggestions)); #endif + ret.setFrameUrl(toQt(params.frame_url)); + ret.setPageUrl(toQt(params.page_url)); + ret.setReferrerPolicy((ReferrerPolicy)params.referrer_policy); return ret; } diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 4df4dbfae..83b7c2d36 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -135,21 +135,6 @@ bool usingANGLE() #endif } -bool usingSoftwareDynamicGL() -{ - if (QCoreApplication::testAttribute(Qt::AA_UseSoftwareOpenGL)) - return true; -#if defined(Q_OS_WIN) - HMODULE handle = static_cast<HMODULE>(QOpenGLContext::openGLModuleHandle()); - wchar_t path[MAX_PATH]; - DWORD size = GetModuleFileName(handle, path, MAX_PATH); - QFileInfo openGLModule(QString::fromWCharArray(path, size)); - return openGLModule.fileName() == QLatin1String("opengl32sw.dll"); -#else - return false; -#endif -} - bool usingQtQuick2DRenderer() { const QStringList args = QGuiApplication::arguments(); @@ -186,6 +171,21 @@ void dummyGetPluginCallback(const std::vector<content::WebPluginInfo>&) namespace QtWebEngineCore { +bool usingSoftwareDynamicGL() +{ + if (QCoreApplication::testAttribute(Qt::AA_UseSoftwareOpenGL)) + return true; +#if defined(Q_OS_WIN) + HMODULE handle = static_cast<HMODULE>(QOpenGLContext::openGLModuleHandle()); + wchar_t path[MAX_PATH]; + DWORD size = GetModuleFileName(handle, path, MAX_PATH); + QFileInfo openGLModule(QString::fromWCharArray(path, size)); + return openGLModule.fileName() == QLatin1String("opengl32sw.dll"); +#else + return false; +#endif +} + void WebEngineContext::destroyBrowserContext() { m_defaultBrowserContext.reset(); @@ -287,6 +287,9 @@ WebEngineContext::WebEngineContext() appArgs.append(QString::fromLocal8Bit(qgetenv(kChromiumFlagsEnv)).split(' ')); } + bool enableWebGLSoftwareRendering = + appArgs.removeAll(QStringLiteral("--enable-webgl-software-rendering")); + bool useEmbeddedSwitches = false; #if defined(QTWEBENGINE_EMBEDDED_SWITCHES) useEmbeddedSwitches = !appArgs.removeAll(QStringLiteral("--disable-embedded-switches")); @@ -371,7 +374,20 @@ WebEngineContext::WebEngineContext() const char *glType = 0; #ifndef QT_NO_OPENGL - if (!usingANGLE() && !usingSoftwareDynamicGL() && !usingQtQuick2DRenderer()) { + + bool tryGL = + !usingANGLE() + && (!usingSoftwareDynamicGL() +#ifdef Q_OS_WIN + // If user requested WebGL support on Windows, instead of using Skia rendering to + // bitmaps, use software rendering via opengl32sw.dll. This might be less + // performant, but at least provides WebGL support. + || enableWebGLSoftwareRendering +#endif + ) + && !usingQtQuick2DRenderer(); + + if (tryGL) { if (qt_gl_global_share_context() && qt_gl_global_share_context()->isValid()) { // If the native handle is QEGLNativeContext try to use GL ES/2, if there is no native handle // assume we are using wayland and try GL ES/2, and finally Ozone demands GL ES/2 too. diff --git a/src/core/web_engine_context.h b/src/core/web_engine_context.h index 386f43035..92c45e260 100644 --- a/src/core/web_engine_context.h +++ b/src/core/web_engine_context.h @@ -74,6 +74,8 @@ class ContentMainDelegateQt; class DevToolsServerQt; class SurfaceFactoryQt; +bool usingSoftwareDynamicGL(); + class WebEngineContext : public base::RefCounted<WebEngineContext> { public: static scoped_refptr<WebEngineContext> current(); diff --git a/src/core/web_event_factory.cpp b/src/core/web_event_factory.cpp index e6ac63c0d..18f8d393f 100644 --- a/src/core/web_event_factory.cpp +++ b/src/core/web_event_factory.cpp @@ -144,7 +144,6 @@ static int windowsKeyCodeForKeyEvent(unsigned int keycode, bool isKeypad) return VK_SHIFT; // (10) SHIFT key case Qt::Key_Control: return VK_CONTROL; // (11) CTRL key - case Qt::Key_Menu: case Qt::Key_Alt: return VK_MENU; // (12) ALT key default: @@ -167,7 +166,6 @@ static int windowsKeyCodeForKeyEvent(unsigned int keycode, bool isKeypad) return VK_SHIFT; // (10) SHIFT key case Qt::Key_Control: return VK_CONTROL; // (11) CTRL key - case Qt::Key_Menu: case Qt::Key_Alt: return VK_MENU; // (12) ALT key @@ -357,7 +355,8 @@ static int windowsKeyCodeForKeyEvent(unsigned int keycode, bool isKeypad) return VK_LWIN; // (5B) Left Windows key (Microsoft Natural keyboard) // case Qt::Key_Meta_R: FIXME: What to do here? // return VK_RWIN; // (5C) Right Windows key (Natural keyboard) - // VK_APPS (5D) Applications key (Natural keyboard) + case Qt::Key_Menu: // (5D) Applications key (Natural keyboard) + return VK_APPS; // VK_SLEEP (5F) Computer Sleep key // VK_SEPARATOR (6C) Separator key // VK_SUBTRACT (6D) Subtract key |