From 9cdd03b44a09b6b40656d4a494f58384007d8aac Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Tue, 1 Mar 2016 14:16:05 +0100 Subject: Fix crash when link opens a modal QDialog, using the trackpad. When a QWebEngine link is clicked on, and as a result a modal dialog is opened, a QEvent::TouchCancel without any touch points is forwarded to Chromium, which tries to access the first touch point position, and causes a QList assertion. Fix consists of two parts: 1) Make sure that no TouchCancel is forwarded, in case if no TouchBegin or TouchUpdate was issued beforehand. 2) Because QEvent::TouchCancel events might contain an empty touch point list, and Chromium expects at least one point, make sure to forward the last saved touch points (saved in previous TouchUpdate) together with the TouchCancel. Task-number: QTBUG-48661 Change-Id: I1eeb2980417b1b04e8387dc9f82f935ef2bd8f00 Reviewed-by: Joerg Bornemann --- src/core/render_widget_host_view_qt.cpp | 53 ++++++++++++++++++++++++++++----- src/core/render_widget_host_view_qt.h | 3 ++ 2 files changed, 48 insertions(+), 8 deletions(-) (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 b15aa94ef..500a94659 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -249,6 +249,7 @@ RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost* widget : m_host(content::RenderWidgetHostImpl::From(widget)) , m_gestureProvider(QtGestureProviderConfig(), this) , m_sendMotionActionDown(false) + , m_touchMotionStarted(false) , m_chromiumCompositorData(new ChromiumCompositorData) , m_needsDelegatedFrameAck(false) , m_didFirstVisuallyNonEmptyLayout(false) @@ -1009,6 +1010,12 @@ void RenderWidgetHostViewQt::handleWheelEvent(QWheelEvent *ev) m_host->ForwardWheelEvent(WebEventFactory::toWebWheelEvent(ev, dpiScale())); } +void RenderWidgetHostViewQt::clearPreviousTouchMotionState() +{ + m_previousTouchPoints.clear(); + m_touchMotionStarted = false; +} + void RenderWidgetHostViewQt::handleTouchEvent(QTouchEvent *ev) { // Chromium expects the touch event timestamps to be comparable to base::TimeTicks::Now(). @@ -1023,19 +1030,46 @@ void RenderWidgetHostViewQt::handleTouchEvent(QTouchEvent *ev) QList touchPoints = mapTouchPointIds(ev->touchPoints()); - if (ev->type() == QEvent::TouchCancel) { - MotionEventQt cancelEvent(touchPoints, eventTimestamp, ui::MotionEvent::ACTION_CANCEL, ev->modifiers(), dpiScale()); + switch (ev->type()) { + case QEvent::TouchBegin: + m_sendMotionActionDown = true; + m_touchMotionStarted = true; + break; + case QEvent::TouchUpdate: + m_touchMotionStarted = true; + break; + case QEvent::TouchCancel: + { + // Don't process a TouchCancel event if no motion was started beforehand, or if there are + // no touch points in the current event or in the previously processed event. + if (!m_touchMotionStarted || (touchPoints.isEmpty() && m_previousTouchPoints.isEmpty())) { + clearPreviousTouchMotionState(); + return; + } + + // Use last saved touch points for the cancel event, to get rid of a QList assert, + // because Chromium expects a MotionEvent::ACTION_CANCEL instance to contain at least + // one touch point, whereas a QTouchCancel may not contain any touch points at all. + if (touchPoints.isEmpty()) + touchPoints = m_previousTouchPoints; + clearPreviousTouchMotionState(); + MotionEventQt cancelEvent(touchPoints, eventTimestamp, ui::MotionEvent::ACTION_CANCEL, + ev->modifiers(), dpiScale()); processMotionEvent(cancelEvent); return; } - - if (ev->type() == QEvent::TouchBegin) - m_sendMotionActionDown = true; + case QEvent::TouchEnd: + clearPreviousTouchMotionState(); + break; + default: + break; + } // Make sure that ACTION_POINTER_DOWN is delivered before ACTION_MOVE, // and ACTION_MOVE before ACTION_POINTER_UP. std::sort(touchPoints.begin(), touchPoints.end(), compareTouchPoints); + m_previousTouchPoints = touchPoints; for (int i = 0; i < touchPoints.size(); ++i) { ui::MotionEvent::Action action; switch (touchPoints[i].state()) { @@ -1043,21 +1077,24 @@ void RenderWidgetHostViewQt::handleTouchEvent(QTouchEvent *ev) if (m_sendMotionActionDown) { action = ui::MotionEvent::ACTION_DOWN; m_sendMotionActionDown = false; - } else + } else { action = ui::MotionEvent::ACTION_POINTER_DOWN; + } break; case Qt::TouchPointMoved: action = ui::MotionEvent::ACTION_MOVE; break; case Qt::TouchPointReleased: - action = touchPoints.size() > 1 ? ui::MotionEvent::ACTION_POINTER_UP : ui::MotionEvent::ACTION_UP; + action = touchPoints.size() > 1 ? ui::MotionEvent::ACTION_POINTER_UP : + ui::MotionEvent::ACTION_UP; break; default: // Ignore Qt::TouchPointStationary continue; } - MotionEventQt motionEvent(touchPoints, eventTimestamp, action, ev->modifiers(), dpiScale(), i); + MotionEventQt motionEvent(touchPoints, eventTimestamp, action, ev->modifiers(), dpiScale(), + i); processMotionEvent(motionEvent); } } diff --git a/src/core/render_widget_host_view_qt.h b/src/core/render_widget_host_view_qt.h index 7c4723f0e..2a56f61a4 100644 --- a/src/core/render_widget_host_view_qt.h +++ b/src/core/render_widget_host_view_qt.h @@ -205,6 +205,7 @@ public: private: void sendDelegatedFrameAck(); void processMotionEvent(const ui::MotionEvent &motionEvent); + void clearPreviousTouchMotionState(); QList mapTouchPointIds(const QList &inputPoints); float dpiScale() const; @@ -214,7 +215,9 @@ private: ui::FilteredGestureProvider m_gestureProvider; base::TimeDelta m_eventsToNowDelta; bool m_sendMotionActionDown; + bool m_touchMotionStarted; QMap m_touchIdMapping; + QList m_previousTouchPoints; scoped_ptr m_delegate; QExplicitlySharedDataPointer m_chromiumCompositorData; -- cgit v1.2.3 From f66c8894268e25d58f7a405914f81595ce6ac8c1 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 29 Mar 2016 14:16:09 +0200 Subject: Doc: Fix documentation about cookie stores Remove misleading "singleton, if one has been set" from the accessor's documentation. Also link to the accessor's from the class documentation, and remove mentioning of cookie store as something that can be accessed for an individual page. Finally, mark QWebEngineProfile::cookieStore as new in Qt 5.6. Change-Id: Ia20ca0ef45a9a15de0052f7ceb7f59d454c70fdc Reviewed-by: Florian Bruhin Reviewed-by: Leena Miettinen --- src/core/api/qwebenginecookiestore.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/core') diff --git a/src/core/api/qwebenginecookiestore.cpp b/src/core/api/qwebenginecookiestore.cpp index 5220073f3..df537a787 100644 --- a/src/core/api/qwebenginecookiestore.cpp +++ b/src/core/api/qwebenginecookiestore.cpp @@ -188,6 +188,9 @@ void QWebEngineCookieStorePrivate::onCookieChanged(const QNetworkCookie &cookie, to get notified about the success of the operation. The signal handlers for removal and addition should not be used to execute heavy tasks, because they might block the IO thread in case of a blocking connection. + + Use QWebEngineProfile::cookieStore() and QQuickWebEngineProfile::cookieStore() + to access the cookie store object for a specific profile. */ /*! -- cgit v1.2.3 From 173c421596beae6984fc7cb3c719670249f322bc Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Fri, 18 Mar 2016 15:45:47 +0100 Subject: Fix QtWebEngineProcess not being found after macdeployqt is used. Currently on OSX, two Info.plist files are generated and copied to the QtWebEngineCore framework, one into Contents/Info.plist and another into Resources/Info.plist. The first one is generated by core_headers.pro and the second by core_module.pro. OS X frameworks only use the plist found in the Resources directory, and the Contents one was generated by qmake erroneously, assuming that core_headers is an application, rather than a framework. When macdeployqt is used with -always-overwrite option, it copies Contents/Info.plist (which contained an incorrect bundle id) over to Resources/Info.plist, and afterwards when an application is executed, it cannot find the plist file because it contains the the wrong CFBundleIdentifier, thus not being able to find the QtWebEngineProcess. Fix consists in making sure code_headers.pro does not generate an Info.plist, and just use the one generated by core_module.pro. Change-Id: I6295bde3b1d1771ed45f3a2fdff9fc60577f2ab6 Task-number: QTBUG-51939 Reviewed-by: Kai Koehne --- src/core/core_headers.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/core_headers.pro b/src/core/core_headers.pro index ebafe58ec..52c6ca57d 100644 --- a/src/core/core_headers.pro +++ b/src/core/core_headers.pro @@ -1,5 +1,5 @@ TARGET = QtWebEngineCore -CONFIG += no_private_module header_module internal_module +CONFIG += no_private_module header_module internal_module no_plist MODULE = webenginecoreheaders load(qt_module) -- cgit v1.2.3 From 665c422803e9d6767f9fa2fd69964c03a254167b Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 21 Mar 2016 13:56:20 +0100 Subject: Fix CommandLine initialization on Windows Chromium insists on getting the command line via the system call GetCommandLineW. QCoreApplication already did that, and we want to pass the already split argument vector to init CommandLine. This way, the user can pass custom arguments to QGuiApplication, and Chromium will pick those up correctly. Task-number: QTBUG-51971 Change-Id: I85b2071fcd8e5781b13ec8d22dc00b1a0c71601b Reviewed-by: Kai Koehne --- src/core/web_engine_context.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'src/core') diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index a8cab45c5..8845cedbe 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -203,21 +203,34 @@ WebEngineContext::WebEngineContext() , m_browserRunner(content::BrowserMainRunner::Create()) , m_globalQObject(new QObject()) { - QVector args; - Q_FOREACH (const QString& arg, QCoreApplication::arguments()) - args << arg.toUtf8(); - - bool useEmbeddedSwitches = args.removeAll("--enable-embedded-switches"); + QStringList appArgs = QCoreApplication::arguments(); + bool useEmbeddedSwitches = appArgs.removeAll(QStringLiteral("--enable-embedded-switches")); #if defined(QTWEBENGINE_EMBEDDED_SWITCHES) - useEmbeddedSwitches = !args.removeAll("--disable-embedded-switches"); + useEmbeddedSwitches = !appArgs.removeAll(QStringLiteral("--disable-embedded-switches")); #endif +#if defined(Q_OS_WIN) + // We must initialize the command line with the UTF-16 arguments vector we got from + // QCoreApplication. CommandLine::Init ignores its arguments on Windows and calls + // GetCommandLineW() instead. + base::CommandLine::CreateEmpty(); + base::CommandLine* parsedCommandLine = base::CommandLine::ForCurrentProcess(); + base::CommandLine::StringVector argv; + argv.resize(appArgs.size()); + std::transform(appArgs.constBegin(), appArgs.constEnd(), argv.begin(), &toString16); + parsedCommandLine->InitFromArgv(argv); +#else + QVector args; + Q_FOREACH (const QString& arg, appArgs) + args << arg.toUtf8(); + QVector argv(args.size()); for (int i = 0; i < args.size(); ++i) argv[i] = args[i].constData(); base::CommandLine::Init(argv.size(), argv.constData()); - base::CommandLine* parsedCommandLine = base::CommandLine::ForCurrentProcess(); +#endif + parsedCommandLine->AppendSwitchPath(switches::kBrowserSubprocessPath, WebEngineLibraryInfo::getPath(content::CHILD_PROCESS_EXE)); parsedCommandLine->AppendSwitch(switches::kNoSandbox); parsedCommandLine->AppendSwitch(switches::kEnableDelegatedRenderer); -- cgit v1.2.3 From 204de3973d7063f9ec65c0cd1ac15a13cde228c6 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 30 Mar 2016 17:50:23 +0200 Subject: Fix Windows build when response files for moc are generated moc.prf contains magic (translation: weird heuristics) to determine if the moc command line would exceed the command line length limit on Windows. If such an excess is detected a response file is created in MOC_DIR. As our build directory is not qmake's default one, moc calls will not find the response file. Set MOC_DIR accordingly to generate the reponse file in the right location. Task-number: QTBUG-51847 Change-Id: Id0695451a986cd9514a7c965c6d33c5c3ef800cd Reviewed-by: Kai Koehne --- src/core/core_gyp_generator.pro | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/core') diff --git a/src/core/core_gyp_generator.pro b/src/core/core_gyp_generator.pro index e018c010f..58e83f954 100644 --- a/src/core/core_gyp_generator.pro +++ b/src/core/core_gyp_generator.pro @@ -17,6 +17,9 @@ DEFINES += QT_NO_KEYWORDS \ QTWEBENGINECORE_VERSION_STR=\\\"$$MODULE_VERSION\\\" \ BUILDING_CHROMIUM +# Ensure that response files, generated by qtbase/mkspecs/features/moc.prf, are found by moc. +MOC_DIR = $$OUT_PWD/$$getConfigDir()/.moc + # Assume that we want mobile touch and low-end hardware behaviors # whenever we are cross compiling. cross_compile: DEFINES += QTWEBENGINE_EMBEDDED_SWITCHES -- cgit v1.2.3 From f22435da983a9e0070ef9c969bb9aa8c1191c0a6 Mon Sep 17 00:00:00 2001 From: Adam Kallai Date: Tue, 17 Nov 2015 17:47:43 +0100 Subject: Avoid triggering extra urlChanged signal Chromium usually clears the pending entry when it fails, so that an arbitrary URL is not left visible above a committed page. However, it does preserve the pending entry in some cases, such as on the initial navigation of an unmodified blank tab. So in other cases Chromium clears the pending entry (if the navigation is not in progress), and it does force the UI (URL bar) to refresh. In our case we allow failed URLs to stick around in the URL bar but only when alternate error pages are used. Change-Id: I26e81e7a99415aa184880dcb647a06d977584119 Task-number: QTBUG-48995 Reviewed-by: Kai Koehne --- src/core/web_contents_delegate_qt.cpp | 14 ++++++++++++++ src/core/web_contents_delegate_qt.h | 1 + 2 files changed, 15 insertions(+) (limited to 'src/core') diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index baf61b5fc..e3903c902 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -122,6 +122,20 @@ void WebContentsDelegateQt::NavigationStateChanged(content::WebContents* source, m_viewClient->titleChanged(toQt(source->GetTitle())); } +bool WebContentsDelegateQt::ShouldPreserveAbortedURLs(content::WebContents *source) +{ + Q_UNUSED(source) + + // Allow failed URLs to stick around in the URL bar, but only when the error-page is enabled. + WebEngineSettings *settings = m_viewClient->webEngineSettings(); + bool isErrorPageEnabled = settings->testAttribute(settings->Attribute::ErrorPageEnabled); + + if (isErrorPageEnabled) + return true; + + return false; +} + void WebContentsDelegateQt::AddNewContents(content::WebContents* source, content::WebContents* new_contents, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, bool user_gesture, bool* was_blocked) { Q_UNUSED(source) diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h index 356b2df88..c971c75e8 100644 --- a/src/core/web_contents_delegate_qt.h +++ b/src/core/web_contents_delegate_qt.h @@ -91,6 +91,7 @@ public: virtual bool IsPopupOrPanel(const content::WebContents *source) const Q_DECL_OVERRIDE; virtual void UpdateTargetURL(content::WebContents* source, const GURL& url) Q_DECL_OVERRIDE; virtual void RequestToLockMouse(content::WebContents *web_contents, bool user_gesture, bool last_unlocked_by_target) Q_DECL_OVERRIDE; + virtual bool ShouldPreserveAbortedURLs(content::WebContents *source) Q_DECL_OVERRIDE; virtual void ShowValidationMessage(content::WebContents *web_contents, const gfx::Rect &anchor_in_root_view, const base::string16 &main_text, const base::string16 &sub_text) Q_DECL_OVERRIDE; virtual void HideValidationMessage(content::WebContents *web_contents) Q_DECL_OVERRIDE; virtual void MoveValidationMessage(content::WebContents *web_contents, const gfx::Rect &anchor_in_root_view) Q_DECL_OVERRIDE; -- cgit v1.2.3 From 82900c7b96b2a6fb42fe3841df7685b820edd588 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 24 Mar 2016 13:55:28 +0100 Subject: Use system NSS only for certificate handling Compiling against NSS 3.23 fails with current Chromium. Also, with NSS 3.21 there are failures connecting to e.g. google.com. Fix this by adapting the setup endorsed by upstream Chromium: BoringSSL is always used for cryptography, and NSS only for certificate handlng. Patches included in 3rdparty update: 0a385bb [backport] Call EnsureNSSHttpIOInit in the chimera build. 0472123 Fix build against newer NSS 90c62c4 [Backport] update to libpng 1.2.56 34857b8 [Backport] Stop large iCCP chunks causing delays and "Aw Snap!" Task-number: QTBUG-52193 Task-number: QTBUG-51890 Task-number: QTBUG-52068 Change-Id: If8aaed9b9a09475c5ed0dfec64d31f45ce9670f5 Reviewed-by: Allan Sandfeld Jensen --- src/core/config/linux.pri | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/core') diff --git a/src/core/config/linux.pri b/src/core/config/linux.pri index 88c1a41aa..39eeb2a90 100644 --- a/src/core/config/linux.pri +++ b/src/core/config/linux.pri @@ -18,11 +18,14 @@ GYP_CONFIG += \ use_gio=0 \ use_gnome_keyring=0 \ use_kerberos=0 \ - use_pango=0 + use_pango=0 \ + use_openssl=1 -!use?(nss) { +use?(nss) { + GYP_CONFIG += use_nss_certs=1 \ + use_openssl_certs=0 +} else { GYP_CONFIG += use_nss_certs=0 \ - use_openssl=1 \ use_openssl_certs=1 } -- cgit v1.2.3 From b98d79b561791459dd6bfb0fed5dc7462a1a09a7 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Wed, 30 Mar 2016 18:22:21 +0200 Subject: Fix crashes due to qputenv being called after Chromium initialization. The qputenv() call inside gl_surface_qt.cpp, which is executed on a GpuChildThread, can reallocate the process environment structure, and it is possible that at the same time the main thread calls getenv, which will dereference a pointer to the freed environment structure, essentially causing a use-after-free crash. Make sure the qputenv() call happens before Chromium initialization starts, so no thread-race can occur. Change-Id: I4ecbdc8bf2abbe45f7d6c5d2633dc9fe27f51e66 Task-number: QTBUG-52124 Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Kai Koehne (cherry picked from commit 76c61aa1400ef2def204c3732e30e08e40631e8d) --- src/core/gl_surface_qt.cpp | 3 --- src/core/web_engine_context.cpp | 6 ++++++ 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src/core') diff --git a/src/core/gl_surface_qt.cpp b/src/core/gl_surface_qt.cpp index 86bb4fda9..7596fcaff 100644 --- a/src/core/gl_surface_qt.cpp +++ b/src/core/gl_surface_qt.cpp @@ -171,9 +171,6 @@ bool GLSurfaceQtGLX::InitializeOneOff() if (initialized) return true; - // http://crbug.com/245466 - qputenv("force_s3tc_enable", "true"); - XInitThreads(); g_display = GLContextHelper::getXDisplay(); diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 8845cedbe..9a96f695e 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -209,6 +209,12 @@ WebEngineContext::WebEngineContext() useEmbeddedSwitches = !appArgs.removeAll(QStringLiteral("--disable-embedded-switches")); #endif +#ifdef Q_OS_LINUX + // Call qputenv before BrowserMainRunnerImpl::Initialize is called. + // http://crbug.com/245466 + qputenv("force_s3tc_enable", "true"); +#endif + #if defined(Q_OS_WIN) // We must initialize the command line with the UTF-16 arguments vector we got from // QCoreApplication. CommandLine::Init ignores its arguments on Windows and calls -- cgit v1.2.3 From 4ed08bb0a8195746c333dabbdb9da3400d174296 Mon Sep 17 00:00:00 2001 From: Szabolcs David Date: Wed, 16 Dec 2015 08:13:05 -0800 Subject: Fix typo in the folder name of the cookies Change-Id: I9e1acaa0dbd31978730dae33ebb517f467f8df49 Reviewed-by: Allan Sandfeld Jensen --- src/core/browser_context_adapter.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/core') diff --git a/src/core/browser_context_adapter.cpp b/src/core/browser_context_adapter.cpp index 52674e8bd..d394cd302 100644 --- a/src/core/browser_context_adapter.cpp +++ b/src/core/browser_context_adapter.cpp @@ -221,8 +221,13 @@ QString BrowserContextAdapter::cookiesPath() const if (m_offTheRecord) return QString(); QString basePath = dataPath(); - if (!basePath.isEmpty()) - return basePath % QLatin1String("/Coookies"); + if (!basePath.isEmpty()) { + // This is a typo fix. We still need the old path in order to avoid breaking migration. + QDir coookiesFolder(basePath % QLatin1String("/Coookies")); + if (coookiesFolder.exists()) + return coookiesFolder.path(); + return basePath % QLatin1String("/Cookies"); + } return QString(); } -- cgit v1.2.3 From 3e9a6407bbbc5f83eb8bd56c5c1d899dba9bc56f Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 4 Apr 2016 15:13:31 +0200 Subject: Implement CheckMediaAccessPermission Fixes access of label of MediaStream tracks Also fixes the logged error: WebContentsDelegate::CheckMediaAccessPermission: Not supported. Change-Id: I3fee9ccd9e8b2e5cbd6b707336cc61425a44ba31 Task-number: QTBUG-52216 Reviewed-by: Kai Koehne --- src/core/browser_context_adapter.cpp | 5 +++++ src/core/browser_context_adapter.h | 3 +++ src/core/permission_manager_qt.cpp | 6 ++++++ src/core/permission_manager_qt.h | 1 + src/core/web_contents_adapter.cpp | 5 +++++ src/core/web_contents_delegate_qt.cpp | 14 ++++++++++++++ src/core/web_contents_delegate_qt.h | 1 + 7 files changed, 35 insertions(+) (limited to 'src/core') diff --git a/src/core/browser_context_adapter.cpp b/src/core/browser_context_adapter.cpp index d394cd302..7f9363c06 100644 --- a/src/core/browser_context_adapter.cpp +++ b/src/core/browser_context_adapter.cpp @@ -405,6 +405,11 @@ void BrowserContextAdapter::permissionRequestReply(const QUrl &origin, Permissio static_cast(browserContext()->GetPermissionManager())->permissionRequestReply(origin, type, reply); } +bool BrowserContextAdapter::checkPermission(const QUrl &origin, PermissionType type) +{ + return static_cast(browserContext()->GetPermissionManager())->checkPermission(origin, type); +} + QString BrowserContextAdapter::httpAcceptLanguageWithoutQualities() const { const QStringList list = m_httpAcceptLanguage.split(QLatin1Char(',')); diff --git a/src/core/browser_context_adapter.h b/src/core/browser_context_adapter.h index 97a4dca4a..a388e9a0c 100644 --- a/src/core/browser_context_adapter.h +++ b/src/core/browser_context_adapter.h @@ -127,6 +127,8 @@ public: GeolocationPermission = 1, // Reserved: // NotificationPermission = 2, + AudioCapturePermission = 3, + VideoCapturePermission = 4, }; HttpCacheType httpCacheType() const; @@ -152,6 +154,7 @@ public: UserScriptControllerHost *userScriptController(); void permissionRequestReply(const QUrl &origin, PermissionType type, bool reply); + bool checkPermission(const QUrl &origin, PermissionType type); QString httpAcceptLanguageWithoutQualities() const; QString httpAcceptLanguage() const; diff --git a/src/core/permission_manager_qt.cpp b/src/core/permission_manager_qt.cpp index b322e507e..a4b763464 100644 --- a/src/core/permission_manager_qt.cpp +++ b/src/core/permission_manager_qt.cpp @@ -91,6 +91,12 @@ void PermissionManagerQt::permissionRequestReply(const QUrl &origin, BrowserCont } } +bool PermissionManagerQt::checkPermission(const QUrl &origin, BrowserContextAdapter::PermissionType type) +{ + QPair key(origin, type); + return m_permissions.contains(key) && m_permissions[key]; +} + void PermissionManagerQt::RequestPermission(content::PermissionType permission, content::RenderFrameHost *frameHost, int request_id, diff --git a/src/core/permission_manager_qt.h b/src/core/permission_manager_qt.h index 6dfc60c39..8d03f275e 100644 --- a/src/core/permission_manager_qt.h +++ b/src/core/permission_manager_qt.h @@ -54,6 +54,7 @@ public: typedef BrowserContextAdapter::PermissionType PermissionType; void permissionRequestReply(const QUrl &origin, PermissionType type, bool reply); + bool checkPermission(const QUrl &origin, PermissionType type); // content::PermissionManager implementation: void RequestPermission( diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 608dbf7e7..cd6505df5 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -844,6 +844,11 @@ void WebContentsAdapter::wasHidden() void WebContentsAdapter::grantMediaAccessPermission(const QUrl &securityOrigin, WebContentsAdapterClient::MediaRequestFlags flags) { Q_D(WebContentsAdapter); + // Let the permission manager remember the reply. + if (flags & WebContentsAdapterClient::MediaAudioCapture) + d->browserContextAdapter->permissionRequestReply(securityOrigin, BrowserContextAdapter::AudioCapturePermission, true); + if (flags & WebContentsAdapterClient::MediaVideoCapture) + d->browserContextAdapter->permissionRequestReply(securityOrigin, BrowserContextAdapter::VideoCapturePermission, true); MediaCaptureDevicesDispatcher::GetInstance()->handleMediaAccessPermissionResponse(d->webContents.get(), securityOrigin, flags); } diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index e3903c902..bf12537d1 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -438,4 +438,18 @@ void WebContentsDelegateQt::BeforeUnloadFired(content::WebContents *tab, bool pr m_viewClient->windowCloseRejected(); } +bool WebContentsDelegateQt::CheckMediaAccessPermission(content::WebContents *web_contents, const GURL& security_origin, content::MediaStreamType type) +{ + switch (type) { + case content::MEDIA_DEVICE_AUDIO_CAPTURE: + return m_viewClient->browserContextAdapter()->checkPermission(toQt(security_origin), BrowserContextAdapter::AudioCapturePermission); + case content::MEDIA_DEVICE_VIDEO_CAPTURE: + return m_viewClient->browserContextAdapter()->checkPermission(toQt(security_origin), BrowserContextAdapter::VideoCapturePermission); + default: + LOG(INFO) << "WebContentsDelegateQt::CheckMediaAccessPermission: " + << "Unsupported media stream type checked" << type; + return false; + } +} + } // namespace QtWebEngineCore diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h index c971c75e8..7ead8dc7c 100644 --- a/src/core/web_contents_delegate_qt.h +++ b/src/core/web_contents_delegate_qt.h @@ -96,6 +96,7 @@ public: virtual void HideValidationMessage(content::WebContents *web_contents) Q_DECL_OVERRIDE; virtual void MoveValidationMessage(content::WebContents *web_contents, const gfx::Rect &anchor_in_root_view) Q_DECL_OVERRIDE; void BeforeUnloadFired(content::WebContents* tab, bool proceed, bool* proceed_to_fire_unload) Q_DECL_OVERRIDE; + bool CheckMediaAccessPermission(content::WebContents *web_contents, const GURL& security_origin, content::MediaStreamType type) Q_DECL_OVERRIDE; // WebContentsObserver overrides virtual void RenderFrameDeleted(content::RenderFrameHost *render_frame_host) Q_DECL_OVERRIDE; -- cgit v1.2.3 From 29f9a2fb68568208a70ba9efef0e455b50a4d3e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Br=C3=BCning?= Date: Tue, 1 Mar 2016 10:55:34 +0100 Subject: Register qrc as local after blink initialization. It is needed to let local content access the qrc resources by making them part of the same security origin. This is stated in the docs as the default behavior. This also backports change f7d343000d77c80f34a115fe9c78f101929292b1 from 5.7, which fixed some race condition with the qrc registration. Task-number: QTBUG-52085 Change-Id: Ia704fa6dbce8529f82695ab543244020cb9f8b8a Reviewed-by: Allan Sandfeld Jensen --- src/core/renderer/content_renderer_client_qt.cpp | 18 +++++++++++++++--- src/core/renderer/content_renderer_client_qt.h | 5 +++++ 2 files changed, 20 insertions(+), 3 deletions(-) (limited to 'src/core') diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp index 261b9c581..e53076525 100644 --- a/src/core/renderer/content_renderer_client_qt.cpp +++ b/src/core/renderer/content_renderer_client_qt.cpp @@ -65,6 +65,19 @@ namespace QtWebEngineCore { static const char kHttpErrorDomain[] = "http"; static const char kQrcSchemeQt[] = "qrc"; +class RenderProcessObserverQt : public content::RenderProcessObserver { +public: + void WebKitInitialized() override + { + // Can only be done after blink is initialized. + blink::WebString qrcScheme(base::ASCIIToUTF16(kQrcSchemeQt)); + // mark qrc as a secure scheme (avoids deprecation warnings) + blink::WebSecurityPolicy::registerURLSchemeAsSecure(qrcScheme); + // mark qrc as a local scheme (allows local access to qrc) + blink::WebSecurityPolicy::registerURLSchemeAsLocal(qrcScheme); + } +}; + ContentRendererClientQt::ContentRendererClientQt() { } @@ -79,12 +92,11 @@ void ContentRendererClientQt::RenderThreadStarted() renderThread->RegisterExtension(WebChannelIPCTransport::getV8Extension()); m_visitedLinkSlave.reset(new visitedlink::VisitedLinkSlave); m_webCacheObserver.reset(new web_cache::WebCacheRenderProcessObserver()); + m_renderProcessObserver.reset(new RenderProcessObserverQt()); renderThread->AddObserver(m_visitedLinkSlave.data()); renderThread->AddObserver(m_webCacheObserver.data()); renderThread->AddObserver(UserScriptController::instance()); - - // mark qrc as a secure scheme (avoids deprecation warnings) - blink::WebSecurityPolicy::registerURLSchemeAsSecure(blink::WebString::fromLatin1(kQrcSchemeQt)); + renderThread->AddObserver(m_renderProcessObserver.data()); } void ContentRendererClientQt::RenderViewCreated(content::RenderView* render_view) diff --git a/src/core/renderer/content_renderer_client_qt.h b/src/core/renderer/content_renderer_client_qt.h index eb55156ad..7df824e3e 100644 --- a/src/core/renderer/content_renderer_client_qt.h +++ b/src/core/renderer/content_renderer_client_qt.h @@ -41,6 +41,10 @@ #include #include +namespace content { +class RenderProcessObserver; +} + namespace visitedlink { class VisitedLinkSlave; } @@ -69,6 +73,7 @@ public: private: QScopedPointer m_visitedLinkSlave; QScopedPointer m_webCacheObserver; + QScopedPointer m_renderProcessObserver; }; } // namespace -- cgit v1.2.3