From 29cb44ee471908ac7c4cac70e3defb8bd72a80cd Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 21 Feb 2020 23:17:43 +0100 Subject: PdfScrollablePageView: retain position after pinch zoom If you do the pinch on a trackpad, the mouse cursor doesn't move, and the same visible part of the page will remain under the cursor after the page is re-rendered. Likewise when doing the pinch on a touchscreen, the centroid (midpoint between the two fingers) is held in place. This is achieved by moving the scrollbars afterwards, subject to their constraints. Change-Id: I34caca4ebbb5c11007dd2462416a42c1a2d8e104 Reviewed-by: Shawn Rutledge --- src/pdf/quick/qml/PdfScrollablePageView.qml | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/pdf/quick/qml/PdfScrollablePageView.qml b/src/pdf/quick/qml/PdfScrollablePageView.qml index 55aa44bbf..ae7bdb6f4 100644 --- a/src/pdf/quick/qml/PdfScrollablePageView.qml +++ b/src/pdf/quick/qml/PdfScrollablePageView.qml @@ -243,15 +243,29 @@ Flickable { enabled: image.sourceSize.width < 5000 onActiveChanged: if (!active) { + var centroidInPoints = Qt.point(pinch.centroid.position.x / root.renderScale, + pinch.centroid.position.y / root.renderScale) + var centroidInFlickable = root.mapFromItem(paper, pinch.centroid.position.x, pinch.centroid.position.y) var newSourceWidth = image.sourceSize.width * paper.scale var ratio = newSourceWidth / image.sourceSize.width + if (root.debug) + console.log("pinch ended with centroid", pinch.centroid.position, centroidInPoints, "wrt flickable", centroidInFlickable, + "page at", paper.x.toFixed(2), paper.y.toFixed(2), + "contentX/Y were", root.contentX.toFixed(2), root.contentY.toFixed(2)) if (ratio > 1.1 || ratio < 0.9) { + var centroidOnPage = Qt.point(centroidInPoints.x * root.renderScale * ratio, centroidInPoints.y * root.renderScale * ratio) paper.scale = 1 - root.renderScale *= ratio + paper.x = 0 + paper.y = 0 + root.contentX = centroidOnPage.x - centroidInFlickable.x + root.contentY = centroidOnPage.y - centroidInFlickable.y + root.renderScale *= ratio // onRenderScaleChanged calls navigationStack.update() so we don't need to here + if (root.debug) + console.log("contentX/Y adjusted to", root.contentX.toFixed(2), root.contentY.toFixed(2)) + } else { + paper.x = 0 + paper.y = 0 } - // TODO adjust contentX/Y to position the page so the same region is visible - paper.x = 0 - paper.y = 0 } grabPermissions: PointerHandler.CanTakeOverFromAnything } -- cgit v1.2.3 From 0d7c2b4a84feec5f65f440dd4a537c8946179314 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 21 Feb 2020 23:51:11 +0100 Subject: PdfScrollablePageView: move selections and links inside the image Now that the Image is being rotated and the "paper" rectangle is not, we need to work in the right coordinate system for rendering of Shapes on top, and for handling drags to select text. Change-Id: I6bc1e2fe7997ffc4673720abdcd3b7e4d9bc9012 Reviewed-by: Shawn Rutledge --- src/pdf/quick/qml/PdfScrollablePageView.qml | 120 +++++++++++++--------------- 1 file changed, 57 insertions(+), 63 deletions(-) (limited to 'src') diff --git a/src/pdf/quick/qml/PdfScrollablePageView.qml b/src/pdf/quick/qml/PdfScrollablePageView.qml index ae7bdb6f4..e27b21d14 100644 --- a/src/pdf/quick/qml/PdfScrollablePageView.qml +++ b/src/pdf/quick/qml/PdfScrollablePageView.qml @@ -175,63 +175,72 @@ Flickable { rotation: root.pageRotation anchors.centerIn: parent property real pageScale: image.paintedWidth / document.pagePointSize(navigationStack.currentPage).width - } - Shape { - anchors.fill: parent - opacity: 0.25 - visible: image.status === Image.Ready - ShapePath { - strokeWidth: 1 - strokeColor: "cyan" - fillColor: "steelblue" - scale: Qt.size(image.pageScale, image.pageScale) - PathMultiline { - paths: searchModel.currentPageBoundingPolygons + Shape { + anchors.fill: parent + opacity: 0.25 + visible: image.status === Image.Ready + ShapePath { + strokeWidth: 1 + strokeColor: "cyan" + fillColor: "steelblue" + scale: Qt.size(image.pageScale, image.pageScale) + PathMultiline { + paths: searchModel.currentPageBoundingPolygons + } } - } - ShapePath { - strokeWidth: 1 - strokeColor: "orange" - fillColor: "cyan" - scale: Qt.size(image.pageScale, image.pageScale) - PathMultiline { - paths: searchModel.currentResultBoundingPolygons + ShapePath { + strokeWidth: 1 + strokeColor: "orange" + fillColor: "cyan" + scale: Qt.size(image.pageScale, image.pageScale) + PathMultiline { + paths: searchModel.currentResultBoundingPolygons + } } - } - ShapePath { - fillColor: "orange" - scale: Qt.size(image.pageScale, image.pageScale) - PathMultiline { - paths: selection.geometry + ShapePath { + fillColor: "orange" + scale: Qt.size(image.pageScale, image.pageScale) + PathMultiline { + paths: selection.geometry + } } } - } - Repeater { - model: PdfLinkModel { - id: linkModel - document: root.document - page: navigationStack.currentPage - } - delegate: Rectangle { - color: "transparent" - border.color: "lightgrey" - x: rect.x * image.pageScale - y: rect.y * image.pageScale - width: rect.width * image.pageScale - height: rect.height * image.pageScale - MouseArea { // TODO switch to TapHandler / HoverHandler in 5.15 - anchors.fill: parent - cursorShape: Qt.PointingHandCursor - onClicked: { - if (page >= 0) - navigationStack.push(page, Qt.point(0, 0), root.renderScale) - else - Qt.openUrlExternally(url) + Repeater { + model: PdfLinkModel { + id: linkModel + document: root.document + page: navigationStack.currentPage + } + delegate: Rectangle { + color: "transparent" + border.color: "lightgrey" + x: rect.x * image.pageScale + y: rect.y * image.pageScale + width: rect.width * image.pageScale + height: rect.height * image.pageScale + MouseArea { // TODO switch to TapHandler / HoverHandler in 5.15 + anchors.fill: parent + cursorShape: Qt.PointingHandCursor + onClicked: { + if (page >= 0) + navigationStack.push(page, Qt.point(0, 0), root.renderScale) + else + Qt.openUrlExternally(url) + } } } } + DragHandler { + id: textSelectionDrag + acceptedDevices: PointerDevice.Mouse | PointerDevice.Stylus + target: null + } + TapHandler { + id: tapHandler + acceptedDevices: PointerDevice.Mouse | PointerDevice.Stylus + } } PinchHandler { @@ -269,20 +278,5 @@ Flickable { } grabPermissions: PointerHandler.CanTakeOverFromAnything } - DragHandler { - id: pageMovingMiddleMouseDrag - acceptedDevices: PointerDevice.Mouse | PointerDevice.Stylus - acceptedButtons: Qt.MiddleButton - snapMode: DragHandler.NoSnap - } - DragHandler { - id: textSelectionDrag - acceptedDevices: PointerDevice.Mouse | PointerDevice.Stylus - target: null - } - TapHandler { - id: tapHandler - acceptedDevices: PointerDevice.Mouse | PointerDevice.Stylus - } } } -- cgit v1.2.3 From dbf1be9c98337701b18dae66892f645c51b8bd22 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 24 Feb 2020 21:19:14 +0100 Subject: PdfMultiPageView: retain position after pinch zoom If you do the pinch on a trackpad, the mouse cursor doesn't move, and the same visible part of the page will remain under the cursor after the page is re-rendered. Likewise when doing the pinch on a touchscreen, the centroid (midpoint between the two fingers) is held in place, subject to the constraints that Flickable.returnToBounds() imposes. Similar to 29cb44ee471908ac7c4cac70e3defb8bd72a80cd. Also corrected the horizontal scrolling range according to rotation; added left and right margins so that the page edges are more visible when the page is wider than the view, and thus the horizontal scrolling range feels more accurate while the scrollbars are still shown. Change-Id: Ia2a15eee5bcd5c9e7f025634f02a5a546e6aab68 Reviewed-by: Shawn Rutledge --- src/pdf/quick/qml/PdfMultiPageView.qml | 43 ++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/pdf/quick/qml/PdfMultiPageView.qml b/src/pdf/quick/qml/PdfMultiPageView.qml index e8eccaf3b..cb4419b4d 100644 --- a/src/pdf/quick/qml/PdfMultiPageView.qml +++ b/src/pdf/quick/qml/PdfMultiPageView.qml @@ -121,13 +121,14 @@ Item { TableView { id: tableView anchors.fill: parent + anchors.leftMargin: 2 model: root.document === undefined ? 0 : root.document.pageCount rowSpacing: 6 - property real rotationModulus: Math.abs(root.pageRotation % 180) - property bool rot90: rotationModulus > 45 && rotationModulus < 135 + property real rotationNorm: Math.round((360 + (root.pageRotation % 360)) % 360) + property bool rot90: rotationNorm == 90 || rotationNorm == 270 onRot90Changed: forceLayout() property size firstPagePointSize: document === undefined ? Qt.size(0, 0) : document.pagePointSize(0) - contentWidth: document === undefined ? 0 : document.maxPageWidth * root.renderScale + contentWidth: document === undefined ? 0 : (rot90 ? document.maxPageHeight : document.maxPageWidth) * root.renderScale + vscroll.width + 2 // workaround for missing function (see https://codereview.qt-project.org/c/qt/qtdeclarative/+/248464) function itemAtPos(x, y, includeSpacing) { // we don't care about x (assume col 0), and assume includeSpacing is true @@ -139,7 +140,7 @@ Item { if (child.y < y && (!ret || child.y > ret.y)) ret = child } - if (root.debug) + if (root.debug && ret !== null) console.log("given y", y, "found", ret, "@", ret.y) return ret // the delegate with the largest y that is less than the given y } @@ -164,7 +165,7 @@ Item { width: image.width height: image.height rotation: root.pageRotation - anchors.centerIn: parent + anchors.centerIn: pinch.active ? undefined : parent property size pagePointSize: document.pagePointSize(index) property real pageScale: image.paintedWidth / pagePointSize.width Image { @@ -223,19 +224,46 @@ Item { id: pinch minimumScale: 0.1 maximumScale: root.renderScale < 4 ? 2 : 1 - minimumRotation: 0 - maximumRotation: 0 + minimumRotation: root.pageRotation + maximumRotation: root.pageRotation enabled: image.sourceSize.width < 5000 onActiveChanged: if (active) { paper.z = 10 } else { paper.z = 0 + var centroidInPoints = Qt.point(pinch.centroid.position.x / root.renderScale, + pinch.centroid.position.y / root.renderScale) + var centroidInFlickable = tableView.mapFromItem(paper, pinch.centroid.position.x, pinch.centroid.position.y) var newSourceWidth = image.sourceSize.width * paper.scale var ratio = newSourceWidth / image.sourceSize.width + if (root.debug) + console.log("pinch ended on page", index, "with centroid", pinch.centroid.position, centroidInPoints, "wrt flickable", centroidInFlickable, + "page at", pageHolder.x.toFixed(2), pageHolder.y.toFixed(2), + "contentX/Y were", tableView.contentX.toFixed(2), tableView.contentY.toFixed(2)) if (ratio > 1.1 || ratio < 0.9) { + var centroidOnPage = Qt.point(centroidInPoints.x * root.renderScale * ratio, centroidInPoints.y * root.renderScale * ratio) paper.scale = 1 + paper.x = 0 + paper.y = 0 root.renderScale *= ratio + tableView.forceLayout() + if (tableView.rotationNorm == 0) { + tableView.contentX = pageHolder.x + tableView.originX + centroidOnPage.x - centroidInFlickable.x + tableView.contentY = pageHolder.y + tableView.originY + centroidOnPage.y - centroidInFlickable.y + } else if (tableView.rotationNorm == 90) { + tableView.contentX = pageHolder.x + tableView.originX + image.height - centroidOnPage.y - centroidInFlickable.x + tableView.contentY = pageHolder.y + tableView.originY + centroidOnPage.x - centroidInFlickable.y + } else if (tableView.rotationNorm == 180) { + tableView.contentX = pageHolder.x + tableView.originX + image.width - centroidOnPage.x - centroidInFlickable.x + tableView.contentY = pageHolder.y + tableView.originY + image.height - centroidOnPage.y - centroidInFlickable.y + } else if (tableView.rotationNorm == 270) { + tableView.contentX = pageHolder.x + tableView.originX + centroidOnPage.y - centroidInFlickable.x + tableView.contentY = pageHolder.y + tableView.originY + image.width - centroidOnPage.x - centroidInFlickable.y + } + if (root.debug) + console.log("contentX/Y adjusted to", tableView.contentX.toFixed(2), tableView.contentY.toFixed(2), "y @top", pageHolder.y) + tableView.returnToBounds() } } grabPermissions: PointerHandler.CanTakeOverFromAnything @@ -298,6 +326,7 @@ Item { } } ScrollBar.vertical: ScrollBar { + id: vscroll property bool moved: false onPositionChanged: moved = true onActiveChanged: { -- cgit v1.2.3 From 8091944ae8ccfb4e0b3e7518912802c9c75704d0 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 25 Feb 2020 22:37:09 +0100 Subject: PdfMultiPageView: highlight current search result when tapped in list Change-Id: Ib0a1aeac28350c8705899ab799ce776e6764b306 Reviewed-by: Shawn Rutledge --- src/pdf/quick/qml/PdfMultiPageView.qml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/pdf/quick/qml/PdfMultiPageView.qml b/src/pdf/quick/qml/PdfMultiPageView.qml index cb4419b4d..d50763a64 100644 --- a/src/pdf/quick/qml/PdfMultiPageView.qml +++ b/src/pdf/quick/qml/PdfMultiPageView.qml @@ -84,6 +84,7 @@ Item { if (zoom > 0) root.renderScale = zoom navigationStack.push(page, location, zoom) + searchModel.currentPage = page } // page scaling @@ -366,6 +367,6 @@ Item { PdfSearchModel { id: searchModel document: root.document === undefined ? null : root.document - onCurrentPageChanged: root.goToPage(currentPage) + onCurrentPageChanged: if (currentPage != navigationStack.currentPage) root.goToPage(currentPage) } } -- cgit v1.2.3 From 926afcaa6f3ce02b51cd535d82454f4b25e0b7f6 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 25 Feb 2020 17:49:56 +0100 Subject: PdfSearchModel: provide ContextBefore and ContextAfter ...as separate roles, to make alignment easier, and to avoid hard-coding HTML tags in the Context role as it was before. But the strings in these context roles are not always adjacent to the search results in geometric coordinates sometimes, in some PDF files, despite having adjacent character indices. I.e. the "next" character after the search string, or the "previous" character before it, could be anywhere on the page. Change-Id: Ief0a490b64fdb3c3ca98506926650648b609ece1 Reviewed-by: Shawn Rutledge --- src/pdf/api/qpdfsearchmodel.h | 3 ++- src/pdf/api/qpdfsearchresult.h | 8 +++++--- src/pdf/api/qpdfsearchresult_p.h | 8 +++++--- src/pdf/qpdfsearchmodel.cpp | 42 ++++++++++++++++++++++++++-------------- src/pdf/qpdfsearchresult.cpp | 16 ++++++++++----- 5 files changed, 51 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/pdf/api/qpdfsearchmodel.h b/src/pdf/api/qpdfsearchmodel.h index cc91e214a..f1593b64b 100644 --- a/src/pdf/api/qpdfsearchmodel.h +++ b/src/pdf/api/qpdfsearchmodel.h @@ -58,7 +58,8 @@ public: Page = Qt::UserRole, IndexOnPage, Location, - Context, + ContextBefore, + ContextAfter, _Count }; Q_ENUM(Role) diff --git a/src/pdf/api/qpdfsearchresult.h b/src/pdf/api/qpdfsearchresult.h index db7af3dd9..84a2f2343 100644 --- a/src/pdf/api/qpdfsearchresult.h +++ b/src/pdf/api/qpdfsearchresult.h @@ -50,18 +50,20 @@ class QPdfSearchResultPrivate; class Q_PDF_EXPORT QPdfSearchResult : public QPdfDestination { Q_GADGET - Q_PROPERTY(QString context READ context) + Q_PROPERTY(QString contextBefore READ contextBefore) + Q_PROPERTY(QString contextAfter READ contextAfter) Q_PROPERTY(QVector rectangles READ rectangles) public: QPdfSearchResult(); ~QPdfSearchResult() {} - QString context() const; + QString contextBefore() const; + QString contextAfter() const; QVector rectangles() const; private: - QPdfSearchResult(int page, QVector rects, QString context); + QPdfSearchResult(int page, QVector rects, QString contextBefore, QString contextAfter); QPdfSearchResult(QPdfSearchResultPrivate *d); friend class QPdfDocument; friend class QPdfSearchModelPrivate; diff --git a/src/pdf/api/qpdfsearchresult_p.h b/src/pdf/api/qpdfsearchresult_p.h index a0f8e4457..615dce4e0 100644 --- a/src/pdf/api/qpdfsearchresult_p.h +++ b/src/pdf/api/qpdfsearchresult_p.h @@ -56,12 +56,14 @@ class QPdfSearchResultPrivate : public QPdfDestinationPrivate { public: QPdfSearchResultPrivate() = default; - QPdfSearchResultPrivate(int page, QVector rects, QString context) : + QPdfSearchResultPrivate(int page, QVector rects, QString contextBefore, QString contextAfter) : QPdfDestinationPrivate(page, rects.first().topLeft(), 0), - context(context), + contextBefore(contextBefore), + contextAfter(contextAfter), rects(rects) {} - QString context; + QString contextBefore; + QString contextAfter; QVector rects; }; diff --git a/src/pdf/qpdfsearchmodel.cpp b/src/pdf/qpdfsearchmodel.cpp index 4129c7cb7..27b7833fc 100644 --- a/src/pdf/qpdfsearchmodel.cpp +++ b/src/pdf/qpdfsearchmodel.cpp @@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY(qLcS, "qt.pdf.search") static const int UpdateTimerInterval = 100; -static const int ContextChars = 20; +static const int ContextChars = 64; static const double CharacterHitTolerance = 6.0; QPdfSearchModel::QPdfSearchModel(QObject *parent) @@ -95,13 +95,19 @@ QVariant QPdfSearchModel::data(const QModelIndex &index, int role) const return pi.index; case Role::Location: return d->searchResults[pi.page][pi.index].location(); - case Role::Context: - return d->searchResults[pi.page][pi.index].context(); + case Role::ContextBefore: + return d->searchResults[pi.page][pi.index].contextBefore(); + case Role::ContextAfter: + return d->searchResults[pi.page][pi.index].contextAfter(); case Role::_Count: break; } - if (role == Qt::DisplayRole) - return d->searchResults[pi.page][pi.index].context(); + if (role == Qt::DisplayRole) { + const QString ret = d->searchResults[pi.page][pi.index].contextBefore() + + QLatin1String("") + d->searchString + QLatin1String("") + + d->searchResults[pi.page][pi.index].contextAfter(); + return ret; + } return QVariant(); } @@ -124,9 +130,9 @@ void QPdfSearchModel::setSearchString(QString searchString) return; d->searchString = searchString; - emit searchStringChanged(); beginResetModel(); d->clearResults(); + emit searchStringChanged(); endResetModel(); } @@ -161,8 +167,8 @@ void QPdfSearchModel::setDocument(QPdfDocument *document) return; d->document = document; - emit documentChanged(); d->clearResults(); + emit documentChanged(); } void QPdfSearchModel::timerEvent(QTimerEvent *event) @@ -179,7 +185,7 @@ void QPdfSearchModel::timerEvent(QTimerEvent *event) d->doSearch(d->nextPageToUpdate++); } -QPdfSearchModelPrivate::QPdfSearchModelPrivate() +QPdfSearchModelPrivate::QPdfSearchModelPrivate() : QAbstractItemModelPrivate() { } @@ -246,7 +252,7 @@ bool QPdfSearchModelPrivate::doSearch(int page) } qCDebug(qLcS) << rects.last() << "char idx" << startIndex << "->" << endIndex; } - QString context; + QString contextBefore, contextAfter; if (startIndex >= 0 || endIndex >= 0) { startIndex = qMax(0, startIndex - ContextChars); endIndex += ContextChars; @@ -255,13 +261,21 @@ bool QPdfSearchModelPrivate::doSearch(int page) QVector buf(count + 1); int len = FPDFText_GetText(textPage, startIndex, count, buf.data()); Q_ASSERT(len - 1 <= count); // len is number of characters written, including the terminator - context = QString::fromUtf16(buf.constData(), len - 1); - context = context.replace(QLatin1Char('\n'), QLatin1Char(' ')); - context = context.replace(searchString, - QLatin1String("") + searchString + QLatin1String("")); + QString context = QString::fromUtf16(buf.constData(), len - 1); + context = context.replace(QLatin1Char('\n'), QStringLiteral("\u23CE")); + context = context.remove(QLatin1Char('\r')); + // try to find the search string near the middle of the context if possible + int si = context.indexOf(searchString, ContextChars - 5, Qt::CaseInsensitive); + if (si < 0) + si = context.indexOf(searchString, Qt::CaseInsensitive); + if (si < 0) + qWarning() << "search string" << searchString << "not found in context" << context; + contextBefore = context.mid(0, si); + contextAfter = context.mid(si + searchString.length()); } } - newSearchResults << QPdfSearchResult(page, rects, context); + if (!rects.isEmpty()) + newSearchResults << QPdfSearchResult(page, rects, contextBefore, contextAfter); } FPDFText_FindClose(sh); FPDFText_ClosePage(textPage); diff --git a/src/pdf/qpdfsearchresult.cpp b/src/pdf/qpdfsearchresult.cpp index 1164a1d43..53da1c165 100644 --- a/src/pdf/qpdfsearchresult.cpp +++ b/src/pdf/qpdfsearchresult.cpp @@ -42,15 +42,20 @@ QT_BEGIN_NAMESPACE QPdfSearchResult::QPdfSearchResult() : QPdfSearchResult(new QPdfSearchResultPrivate()) { } -QPdfSearchResult::QPdfSearchResult(int page, QVector rects, QString context) : - QPdfSearchResult(new QPdfSearchResultPrivate(page, rects, context)) { } +QPdfSearchResult::QPdfSearchResult(int page, QVector rects, QString contextBefore, QString contextAfter) : + QPdfSearchResult(new QPdfSearchResultPrivate(page, rects, contextBefore, contextAfter)) { } QPdfSearchResult::QPdfSearchResult(QPdfSearchResultPrivate *d) : QPdfDestination(static_cast(d)) { } -QString QPdfSearchResult::context() const +QString QPdfSearchResult::contextBefore() const { - return static_cast(d.data())->context; + return static_cast(d.data())->contextBefore; +} + +QString QPdfSearchResult::contextAfter() const +{ + return static_cast(d.data())->contextAfter; } QVector QPdfSearchResult::rectangles() const @@ -63,7 +68,8 @@ QDebug operator<<(QDebug dbg, const QPdfSearchResult &searchResult) QDebugStateSaver saver(dbg); dbg.nospace(); dbg << "QPdfSearchResult(page=" << searchResult.page() - << " context=" << searchResult.context() + << " contextBefore=" << searchResult.contextBefore() + << " contextAfter=" << searchResult.contextAfter() << " rects=" << searchResult.rectangles(); dbg << ')'; return dbg; -- cgit v1.2.3 From 7e75e9b80249f553fcfbdb2716c93707b40f8c48 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 26 Feb 2020 11:09:09 +0100 Subject: PdfMultiPageView: update search highlights when results change In the single-page view, we bind to the PdfSearchModel.currentPageBoundingPolygons property, which is convenient because it has a changed signal, so it stays updated in all cases: when the user changes the search string, when a different document is loaded, or when changing the current page. In the multi-page view, we need to invoke a function to get the search results on each page, because results are different on each page, and we often need to show multiple pages at the same time. The challenge then is how to ensure that it gets re-evaluated often enough. It requires connecting to more than one signal; but there isn't any way to "kick" a binding when some signal occurs, so the solution isn't very declarative, unfortunately. Change-Id: I72e7dad01b8cb6c43abcccf4fa46e443409b39e0 Reviewed-by: Shawn Rutledge --- src/pdf/quick/qml/PdfMultiPageView.qml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/pdf/quick/qml/PdfMultiPageView.qml b/src/pdf/quick/qml/PdfMultiPageView.qml index d50763a64..5efad39f0 100644 --- a/src/pdf/quick/qml/PdfMultiPageView.qml +++ b/src/pdf/quick/qml/PdfMultiPageView.qml @@ -183,21 +183,33 @@ Item { image.sourceSize.width = paper.pagePointSize.width * renderScale image.sourceSize.height = 0 paper.scale = 1 + searchHighlights.update() } } Shape { anchors.fill: parent opacity: 0.25 visible: image.status === Image.Ready + onVisibleChanged: searchHighlights.update() ShapePath { strokeWidth: 1 strokeColor: "cyan" fillColor: "steelblue" scale: Qt.size(paper.pageScale, paper.pageScale) PathMultiline { - paths: searchModel.boundingPolygonsOnPage(index) + id: searchHighlights + function update() { + // paths could be a binding, but we need to be able to "kick" it sometimes + paths = searchModel.boundingPolygonsOnPage(index) + } } } + Connections { + target: searchModel + // whenever the highlights on the _current_ page change, they actually need to change on _all_ pages + // (usually because the search string has changed) + function onCurrentPageBoundingPolygonsChanged() { searchHighlights.update() } + } ShapePath { fillColor: "orange" scale: Qt.size(paper.pageScale, paper.pageScale) -- cgit v1.2.3 From 25e76f19fb3e92aca05e108f823e0e8e822ee2dc Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 4 Mar 2020 17:45:25 +0100 Subject: PdfMultiPageView: correct the license header Standard header for module code rather than for an example. Change-Id: I39fad99f9c018530ccc12036eb502a78a521a0c0 Reviewed-by: Allan Sandfeld Jensen --- src/pdf/quick/qml/PdfMultiPageView.qml | 52 +++++++++++++--------------------- 1 file changed, 19 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/pdf/quick/qml/PdfMultiPageView.qml b/src/pdf/quick/qml/PdfMultiPageView.qml index 5efad39f0..de61f1782 100644 --- a/src/pdf/quick/qml/PdfMultiPageView.qml +++ b/src/pdf/quick/qml/PdfMultiPageView.qml @@ -1,48 +1,34 @@ /**************************************************************************** ** ** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ +** Contact: http://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the QtPDF module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ +** $QT_BEGIN_LICENSE:LGPL3$ ** 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. +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: +** 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.LGPLv3 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.html. ** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. ** ** $QT_END_LICENSE$ ** -- cgit v1.2.3 From eb4a66480356356b19969f13553e4179b24c4041 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Sat, 29 Feb 2020 23:29:43 +0100 Subject: Render PDF link decorations as dashed underlines rather than boxes So they look more like (old-school) web links. The underlines are always horizontal and underneath the area of occurrence though; rotated link text has not been tested. Change-Id: I4fc01d88367b0cc9bbc23e9f85a3b42efb271fb8 Reviewed-by: Shawn Rutledge --- src/pdf/quick/qml/PdfMultiPageView.qml | 12 +++++++++--- src/pdf/quick/qml/PdfScrollablePageView.qml | 12 +++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/pdf/quick/qml/PdfMultiPageView.qml b/src/pdf/quick/qml/PdfMultiPageView.qml index de61f1782..9d9e2800a 100644 --- a/src/pdf/quick/qml/PdfMultiPageView.qml +++ b/src/pdf/quick/qml/PdfMultiPageView.qml @@ -282,13 +282,19 @@ Item { document: root.document page: image.currentFrame } - delegate: Rectangle { - color: "transparent" - border.color: "lightgrey" + delegate: Shape { x: rect.x * paper.pageScale y: rect.y * paper.pageScale width: rect.width * paper.pageScale height: rect.height * paper.pageScale + ShapePath { + strokeWidth: 1 + strokeColor: "steelblue" + strokeStyle: ShapePath.DashLine + dashPattern: [ 1, 4 ] + startX: 0; startY: height + PathLine { x: width; y: height } + } MouseArea { // TODO switch to TapHandler / HoverHandler in 5.15 id: linkMA anchors.fill: parent diff --git a/src/pdf/quick/qml/PdfScrollablePageView.qml b/src/pdf/quick/qml/PdfScrollablePageView.qml index e27b21d14..2d335849d 100644 --- a/src/pdf/quick/qml/PdfScrollablePageView.qml +++ b/src/pdf/quick/qml/PdfScrollablePageView.qml @@ -213,13 +213,19 @@ Flickable { document: root.document page: navigationStack.currentPage } - delegate: Rectangle { - color: "transparent" - border.color: "lightgrey" + delegate: Shape { x: rect.x * image.pageScale y: rect.y * image.pageScale width: rect.width * image.pageScale height: rect.height * image.pageScale + ShapePath { + strokeWidth: 1 + strokeColor: "steelblue" + strokeStyle: ShapePath.DashLine + dashPattern: [ 1, 4 ] + startX: 0; startY: height + PathLine { x: width; y: height } + } MouseArea { // TODO switch to TapHandler / HoverHandler in 5.15 anchors.fill: parent cursorShape: Qt.PointingHandCursor -- cgit v1.2.3 From 60663c79a1f7c0642c71f64c2415deca18d8207e Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 26 Feb 2020 22:35:35 +0100 Subject: Add PdfStyle; use Control palette colors PdfStyle.qml can be overridden via file selectors, and contains extra styling beyond what Control.palette provides. Search results are highlighted with a lightened, translucent version of the Controls style's accent color, and the current search result is highlighted with a solid border with the accent color. The text selection color comes from the Controls theme highlight color, which tends to be the same as QPalette::Highlight. The link underscore is also configurable in PdfStyle, but its color comes from the Controls theme link color, which tends to be the same as QPalette::link. Task-number: QTBUG-82540 Change-Id: I7c7e80323cf5d7c94dde775a38cdec239a6351a9 Reviewed-by: Mitch Curtis --- src/pdf/quick/qml/+material/PdfStyle.qml | 54 ++++++++++++++++++++++++++++ src/pdf/quick/qml/+universal/PdfStyle.qml | 55 +++++++++++++++++++++++++++++ src/pdf/quick/qml/PdfMultiPageView.qml | 26 +++++++------- src/pdf/quick/qml/PdfScrollablePageView.qml | 23 ++++++------ src/pdf/quick/qml/PdfStyle.qml | 54 ++++++++++++++++++++++++++++ src/pdf/quick/resources.qrc | 3 ++ 6 files changed, 189 insertions(+), 26 deletions(-) create mode 100644 src/pdf/quick/qml/+material/PdfStyle.qml create mode 100644 src/pdf/quick/qml/+universal/PdfStyle.qml create mode 100644 src/pdf/quick/qml/PdfStyle.qml (limited to 'src') diff --git a/src/pdf/quick/qml/+material/PdfStyle.qml b/src/pdf/quick/qml/+material/PdfStyle.qml new file mode 100644 index 000000000..12df30466 --- /dev/null +++ b/src/pdf/quick/qml/+material/PdfStyle.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtPDF module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQml 2.14 +import QtQuick.Controls 2.14 +import QtQuick.Controls.Material 2.14 +import QtQuick.Shapes 1.14 + +QtObject { + property Control prototypeControl: Control { } + function withAlpha(color, alpha) { + return Qt.hsla(color.hslHue, color.hslSaturation, color.hslLightness, alpha) + } + property color selectionColor: withAlpha(prototypeControl.palette.highlight, 0.5) + property color pageSearchResultsColor: withAlpha(Qt.lighter(Material.accentColor, 1.5), 0.5) + property color currentSearchResultStrokeColor: Material.accentColor + property real currentSearchResultStrokeWidth: 2 + property color linkUnderscoreColor: prototypeControl.palette.link + property real linkUnderscoreStrokeWidth: 1 + property var linkUnderscoreStrokeStyle: ShapePath.DashLine + property var linkUnderscoreDashPattern: [ 1, 4 ] +} diff --git a/src/pdf/quick/qml/+universal/PdfStyle.qml b/src/pdf/quick/qml/+universal/PdfStyle.qml new file mode 100644 index 000000000..e92f2a080 --- /dev/null +++ b/src/pdf/quick/qml/+universal/PdfStyle.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtPDF module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQml 2.14 +import QtQuick 2.14 +import QtQuick.Controls 2.14 +import QtQuick.Controls.Universal 2.14 +import QtQuick.Shapes 1.14 + +QtObject { + property Control prototypeControl: Control { } + function withAlpha(color, alpha) { + return Qt.hsla(color.hslHue, color.hslSaturation, color.hslLightness, alpha) + } + property color selectionColor: withAlpha(prototypeControl.palette.highlight, 0.5) + property color pageSearchResultsColor: withAlpha(Qt.lighter(Universal.accent, 1.5), 0.5) + property color currentSearchResultStrokeColor: Universal.accent + property real currentSearchResultStrokeWidth: 2 + property color linkUnderscoreColor: prototypeControl.palette.link + property real linkUnderscoreStrokeWidth: 1 + property var linkUnderscoreStrokeStyle: ShapePath.DashLine + property var linkUnderscoreDashPattern: [ 1, 4 ] +} diff --git a/src/pdf/quick/qml/PdfMultiPageView.qml b/src/pdf/quick/qml/PdfMultiPageView.qml index 9d9e2800a..579c9a1ce 100644 --- a/src/pdf/quick/qml/PdfMultiPageView.qml +++ b/src/pdf/quick/qml/PdfMultiPageView.qml @@ -105,6 +105,7 @@ Item { function searchForward() { ++searchModel.currentResult } id: root + PdfStyle { id: style } TableView { id: tableView anchors.fill: parent @@ -174,13 +175,11 @@ Item { } Shape { anchors.fill: parent - opacity: 0.25 visible: image.status === Image.Ready onVisibleChanged: searchHighlights.update() ShapePath { - strokeWidth: 1 - strokeColor: "cyan" - fillColor: "steelblue" + strokeWidth: -1 + fillColor: style.pageSearchResultsColor scale: Qt.size(paper.pageScale, paper.pageScale) PathMultiline { id: searchHighlights @@ -197,22 +196,21 @@ Item { function onCurrentPageBoundingPolygonsChanged() { searchHighlights.update() } } ShapePath { - fillColor: "orange" + strokeWidth: -1 + fillColor: style.selectionColor scale: Qt.size(paper.pageScale, paper.pageScale) PathMultiline { - id: selectionBoundaries paths: selection.geometry } } } Shape { anchors.fill: parent - opacity: 0.5 visible: image.status === Image.Ready && searchModel.currentPage === index ShapePath { - strokeWidth: 1 - strokeColor: "blue" - fillColor: "cyan" + strokeWidth: style.currentSearchResultStrokeWidth + strokeColor: style.currentSearchResultStrokeColor + fillColor: "transparent" scale: Qt.size(paper.pageScale, paper.pageScale) PathMultiline { paths: searchModel.currentResultBoundingPolygons @@ -288,10 +286,10 @@ Item { width: rect.width * paper.pageScale height: rect.height * paper.pageScale ShapePath { - strokeWidth: 1 - strokeColor: "steelblue" - strokeStyle: ShapePath.DashLine - dashPattern: [ 1, 4 ] + strokeWidth: style.linkUnderscoreStrokeWidth + strokeColor: style.linkUnderscoreColor + strokeStyle: style.linkUnderscoreStrokeStyle + dashPattern: style.linkUnderscoreDashPattern startX: 0; startY: height PathLine { x: width; y: height } } diff --git a/src/pdf/quick/qml/PdfScrollablePageView.qml b/src/pdf/quick/qml/PdfScrollablePageView.qml index 2d335849d..4c43972c9 100644 --- a/src/pdf/quick/qml/PdfScrollablePageView.qml +++ b/src/pdf/quick/qml/PdfScrollablePageView.qml @@ -101,6 +101,7 @@ Flickable { // implementation id: root + PdfStyle { id: style } contentWidth: paper.width contentHeight: paper.height ScrollBar.vertical: ScrollBar { @@ -178,28 +179,26 @@ Flickable { Shape { anchors.fill: parent - opacity: 0.25 visible: image.status === Image.Ready ShapePath { - strokeWidth: 1 - strokeColor: "cyan" - fillColor: "steelblue" + strokeWidth: -1 + fillColor: style.pageSearchResultsColor scale: Qt.size(image.pageScale, image.pageScale) PathMultiline { paths: searchModel.currentPageBoundingPolygons } } ShapePath { - strokeWidth: 1 - strokeColor: "orange" - fillColor: "cyan" + strokeWidth: style.currentSearchResultStrokeWidth + strokeColor: style.currentSearchResultStrokeColor + fillColor: "transparent" scale: Qt.size(image.pageScale, image.pageScale) PathMultiline { paths: searchModel.currentResultBoundingPolygons } } ShapePath { - fillColor: "orange" + fillColor: style.selectionColor scale: Qt.size(image.pageScale, image.pageScale) PathMultiline { paths: selection.geometry @@ -219,10 +218,10 @@ Flickable { width: rect.width * image.pageScale height: rect.height * image.pageScale ShapePath { - strokeWidth: 1 - strokeColor: "steelblue" - strokeStyle: ShapePath.DashLine - dashPattern: [ 1, 4 ] + strokeWidth: style.linkUnderscoreStrokeWidth + strokeColor: style.linkUnderscoreColor + strokeStyle: style.linkUnderscoreStrokeStyle + dashPattern: style.linkUnderscoreDashPattern startX: 0; startY: height PathLine { x: width; y: height } } diff --git a/src/pdf/quick/qml/PdfStyle.qml b/src/pdf/quick/qml/PdfStyle.qml new file mode 100644 index 000000000..090465ce6 --- /dev/null +++ b/src/pdf/quick/qml/PdfStyle.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtPDF module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQml 2.14 +import QtQuick 2.14 +import QtQuick.Controls 2.14 +import QtQuick.Shapes 1.14 + +QtObject { + property Control prototypeControl: Control { } + function withAlpha(color, alpha) { + return Qt.hsla(color.hslHue, color.hslSaturation, color.hslLightness, alpha) + } + property color selectionColor: withAlpha(prototypeControl.palette.highlight, 0.5) + property color pageSearchResultsColor: "#80B0C4DE" + property color currentSearchResultStrokeColor: "cyan" + property real currentSearchResultStrokeWidth: 2 + property color linkUnderscoreColor: prototypeControl.palette.link + property real linkUnderscoreStrokeWidth: 1 + property var linkUnderscoreStrokeStyle: ShapePath.DashLine + property var linkUnderscoreDashPattern: [ 1, 4 ] +} diff --git a/src/pdf/quick/resources.qrc b/src/pdf/quick/resources.qrc index 20cac4827..8270a2028 100644 --- a/src/pdf/quick/resources.qrc +++ b/src/pdf/quick/resources.qrc @@ -1,5 +1,8 @@ + qml/+material/PdfStyle.qml + qml/+universal/PdfStyle.qml + qml/PdfStyle.qml qml/PdfMultiPageView.qml qml/PdfPageView.qml qml/PdfScrollablePageView.qml -- cgit v1.2.3 From 3b355d2be812e11d32d884056e29ff97f7da0342 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Br=C3=BCning?= Date: Thu, 5 Mar 2020 16:06:41 +0100 Subject: Update Chromium Pulls in the following changes: a7d90c1eadc Fix undefined range-based for loops in torque 24581ca7dde [Backport] Security bug 1040700 e4659a4c8a8 [Backport] CVE-2020-6418 - Type confusion in V8 5707cc4f757 [Backport] CVE-2020-6383 - Type confusion in V8 642c7bea74e [Backport] CVE-2020-6407: Out of bounds memory access in streams d8724284f47 [Backport] CVE-2020-6384: Use after free in WebAudio e87caa4598d [Backport] Security bug 1029865 da60616b969 [Backport] Security bug 1044570 51012dcb3e6 [Backport] CVE-2020-6387 - Out of bounds write in WebRTC 6c4b486ce60 [Backport] CVE-2020-6389 - Out of bounds write in WebRTC 1c3145818e4 [Backport] CVE-2020-6420: Insufficient policy enforcement in media 4a01d3a4103 [Backport] Security bug 1031909 Change-Id: Ic6d76f64a82d3f5738c31a53cf7e0f3f37183767 Reviewed-by: Allan Sandfeld Jensen --- src/3rdparty | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/3rdparty b/src/3rdparty index dcfdd7e5c..4a01d3a41 160000 --- a/src/3rdparty +++ b/src/3rdparty @@ -1 +1 @@ -Subproject commit dcfdd7e5cacd2cf01df7a9a467a7eeeee3348d1d +Subproject commit 4a01d3a410354bc8fe2e6ef03d32cbe39a770204 -- cgit v1.2.3 From 9377855eb7c2310951d67e0fe5454be35fefd72c Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 5 Mar 2020 17:12:30 +0100 Subject: Doc: Fix highlighting of QML import Change-Id: I1420b0c6293fbd3caf5dce3ada3b6fec90c74bfc Reviewed-by: Leena Miettinen --- src/webengine/doc/src/qtwebengine-qmlmodule.qdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/webengine/doc/src/qtwebengine-qmlmodule.qdoc b/src/webengine/doc/src/qtwebengine-qmlmodule.qdoc index 44e6c7e27..4fd7e3a3b 100644 --- a/src/webengine/doc/src/qtwebengine-qmlmodule.qdoc +++ b/src/webengine/doc/src/qtwebengine-qmlmodule.qdoc @@ -35,9 +35,9 @@ The QML types can be imported into your application using the following import statements in your .qml file: - \badcode + \qml import QtWebEngine 1.10 - \endcode + \endqml To link against the module, add the following QT variable to your qmake .pro file: -- cgit v1.2.3 From 04da0b14840f12ebd98e85c4ef4d42063610e375 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Br=C3=BCning?= Date: Fri, 6 Mar 2020 17:07:25 +0100 Subject: Update Chromium Pulls in the following changes: b6fde543e11 FIXUP: Fix build with gcc 5 feeaf8ecd52 [Backport] CVE-2020-6406 - Use after free in audio ada63371baf [Backport] CVE-2020-6392 - Insufficient policy enforcement in extensions 80029e44737 [Backport] CVE-2020-6393 - Insufficient policy enforcement in Blink cfd1a2eb98c [Backport] CVE-2020-6394 - Insufficient policy enforcement in Blink 8b524801b75 [Backport] CVE-2020-6396 - Inappropriate implementation in Skia 7b2e898f2b4 [Backport] CVE-2020-6398 - Uninitialized use in PDFium d8c1659ae97 [Backport] CVE-2020-6400 - Inappropriate implementation in CORS 4d5dbe41ae3 [Backport] CVE-2020-6401 (1/3) and CVE-2020-6411 b88a10e7a66 [Backport] CVE-2020-6401 (2/3) 25b6ec913a1 [Backport] CVE-2020-6401 (3/3) 31bf030226a [Backport] CVE-2020-6404 - Inappropriate implementation in Blink 42e3d739230 [Backport] CVE-2020-6399 - Insufficient policy enforcement in AppCache 02f1da71840 [Backport] Security bug 1035723 3e757b536e5 [Backport] Dependency for CVE-2020-6391 f720be4aac5 [Backport] CVE-2020-6391 - Insufficient validation of untrusted input in Blink (1/3) e7980ade9ab [Backport] CVE-2020-6391 - Insufficient validation of untrusted input in Blink (2/3) 3f6e9bf1fb0 [Backport] CVE-2020-6391 - Insufficient validation of untrusted input in Blink (3/3) 6b0d12aa31a [Backport] Security bug 1018629 Change-Id: I929158db502b6e3705e50cd3c0da6601d3a17c04 Reviewed-by: Allan Sandfeld Jensen --- src/3rdparty | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/3rdparty b/src/3rdparty index 4a01d3a41..6b0d12aa3 160000 --- a/src/3rdparty +++ b/src/3rdparty @@ -1 +1 @@ -Subproject commit 4a01d3a410354bc8fe2e6ef03d32cbe39a770204 +Subproject commit 6b0d12aa31ae3553db04277d46ce14f57a6e20b3 -- cgit v1.2.3 From 62e55be6b8a23003ca877d917e5ef0cd3ff4110f Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Wed, 4 Mar 2020 14:56:36 +0100 Subject: Fix applying background color on RenderView MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The RenderViewObserverQt_SetBackgroundColor message was sent with wrong Routing ID. This fix also cleans up RenderWidgetHostViewQt::UpdateBackgroundColor() method. Fixes: QTBUG-81781 Change-Id: Ida198fb061715d389859ace17e1f773db491c51d Reviewed-by: Jüri Valdmann --- src/core/common/qt_messages.h | 6 +++--- src/core/render_widget_host_view_qt.cpp | 18 ++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/core/common/qt_messages.h b/src/core/common/qt_messages.h index b99204b74..43f07c9a6 100644 --- a/src/core/common/qt_messages.h +++ b/src/core/common/qt_messages.h @@ -36,6 +36,9 @@ IPC_MESSAGE_ROUTED1(RenderViewObserverQt_FetchDocumentMarkup, IPC_MESSAGE_ROUTED1(RenderViewObserverQt_FetchDocumentInnerText, uint64_t /* requestId */) +IPC_MESSAGE_ROUTED1(RenderViewObserverQt_SetBackgroundColor, + uint32_t /* color */) + // User scripts messages IPC_MESSAGE_ROUTED1(RenderFrameObserverHelper_AddScript, UserScriptData /* script */) @@ -65,9 +68,6 @@ IPC_MESSAGE_ROUTED2(RenderViewObserverHostQt_DidFetchDocumentInnerText, uint64_t /* requestId */, base::string16 /* innerText */) -IPC_MESSAGE_ROUTED1(RenderViewObserverQt_SetBackgroundColor, - uint32_t /* color */) - IPC_MESSAGE_ROUTED0(RenderViewObserverHostQt_DidFirstVisuallyNonEmptyLayout) //----------------------------------------------------------------------------- diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index e9be587cf..7a5118837 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -48,6 +48,7 @@ #include "touch_selection_controller_client_qt.h" #include "touch_selection_menu_controller.h" #include "type_conversion.h" +#include "web_contents_adapter.h" #include "web_contents_adapter_client.h" #include "web_event_factory.h" @@ -488,23 +489,20 @@ gfx::Rect RenderWidgetHostViewQt::GetViewBounds() void RenderWidgetHostViewQt::UpdateBackgroundColor() { + DCHECK(GetBackgroundColor()); + SkColor color = *GetBackgroundColor(); + + m_delegate->setClearColor(toQt(color)); + if (m_enableViz) { - DCHECK(GetBackgroundColor()); - SkColor color = *GetBackgroundColor(); bool opaque = SkColorGetA(color) == SK_AlphaOPAQUE; m_rootLayer->SetFillsBoundsOpaquely(opaque); m_rootLayer->SetColor(color); m_uiCompositor->SetBackgroundColor(color); - m_delegate->setClearColor(toQt(color)); - host()->Send(new RenderViewObserverQt_SetBackgroundColor(host()->GetRoutingID(), color)); - return; } - auto color = GetBackgroundColor(); - if (color) { - m_delegate->setClearColor(toQt(*color)); - host()->Send(new RenderViewObserverQt_SetBackgroundColor(host()->GetRoutingID(), *color)); - } + content::RenderViewHost *rvh = content::RenderViewHost::From(host()); + host()->Send(new RenderViewObserverQt_SetBackgroundColor(rvh->GetRoutingID(), color)); } // Return value indicates whether the mouse is locked successfully or not. -- cgit v1.2.3 From f253884934cbdbc16fd9b783a2b115960d11af10 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 10 Mar 2020 12:59:13 +0100 Subject: PDF quick plugin: fix warning about unused engine arg on static builds The build for iOS is static. Change-Id: I3e6c13c920861a2a6bf0079e53e76322bb93935f Reviewed-by: Shawn Rutledge --- src/pdf/quick/plugin.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/pdf/quick/plugin.cpp b/src/pdf/quick/plugin.cpp index bb68a817e..670fe0bf9 100644 --- a/src/pdf/quick/plugin.cpp +++ b/src/pdf/quick/plugin.cpp @@ -71,7 +71,9 @@ public: void initializeEngine(QQmlEngine *engine, const char *uri) override { Q_UNUSED(uri); -#ifndef QT_STATIC +#ifdef QT_STATIC + Q_UNUSED(engine); +#else engine->addImportPath(QStringLiteral("qrc:/")); #endif } -- cgit v1.2.3 From 5dc78ed4e2891205a7162b696b3439a87253140f Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 10 Mar 2020 12:57:32 +0100 Subject: PdfSelection: add selectAll() function; use in examples The usual shortcut (control-A) now selects all text on the current page, it is highlighted, and it can be copied to the clipboard. Change-Id: I5e6d9cae675862808f8b9027cb47024ca65cf2fd Reviewed-by: Shawn Rutledge --- src/pdf/api/qpdfdocument.h | 1 + src/pdf/api/qpdfdocument_p.h | 1 + src/pdf/qpdfdocument.cpp | 43 +++++++++++++++++++++++++---- src/pdf/quick/qml/PdfMultiPageView.qml | 5 ++++ src/pdf/quick/qml/PdfPageView.qml | 3 ++ src/pdf/quick/qml/PdfScrollablePageView.qml | 3 ++ src/pdf/quick/qquickpdfselection.cpp | 16 +++++++++++ src/pdf/quick/qquickpdfselection_p.h | 1 + 8 files changed, 67 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/pdf/api/qpdfdocument.h b/src/pdf/api/qpdfdocument.h index 40df181f4..027cdeb47 100644 --- a/src/pdf/api/qpdfdocument.h +++ b/src/pdf/api/qpdfdocument.h @@ -113,6 +113,7 @@ public: QImage render(int page, QSize imageSize, QPdfDocumentRenderOptions options = QPdfDocumentRenderOptions()); Q_INVOKABLE QPdfSelection getSelection(int page, QPointF start, QPointF end); + Q_INVOKABLE QPdfSelection getAllText(int page); Q_SIGNALS: void passwordChanged(); diff --git a/src/pdf/api/qpdfdocument_p.h b/src/pdf/api/qpdfdocument_p.h index 15d8b8259..2dcb70407 100644 --- a/src/pdf/api/qpdfdocument_p.h +++ b/src/pdf/api/qpdfdocument_p.h @@ -105,6 +105,7 @@ public: static int fpdf_GetBlock(void* param, unsigned long position, unsigned char* pBuf, unsigned long size); static void fpdf_AddSegment(struct _FX_DOWNLOADHINTS* pThis, size_t offset, size_t size); void updateLastError(); + QString getText(FPDF_TEXTPAGE textPage, int startIndex, int count); }; QT_END_NAMESPACE diff --git a/src/pdf/qpdfdocument.cpp b/src/pdf/qpdfdocument.cpp index 1e8a0f527..d56edf4e9 100644 --- a/src/pdf/qpdfdocument.cpp +++ b/src/pdf/qpdfdocument.cpp @@ -393,6 +393,15 @@ void QPdfDocumentPrivate::fpdf_AddSegment(_FX_DOWNLOADHINTS *pThis, size_t offse Q_UNUSED(size); } +QString QPdfDocumentPrivate::getText(FPDF_TEXTPAGE textPage, int startIndex, int count) +{ + QVector buf(count + 1); + // TODO is that enough space in case one unicode character is more than one in utf-16? + int len = FPDFText_GetText(textPage, startIndex, count, buf.data()); + Q_ASSERT(len - 1 <= count); // len is number of characters written, including the terminator + return QString::fromUtf16(buf.constData(), len - 1); +} + /*! \class QPdfDocument \since 5.10 @@ -737,15 +746,10 @@ QPdfSelection QPdfDocument::getSelection(int page, QPointF start, QPointF end) int endIndex = FPDFText_GetCharIndexAtPos(textPage, end.x(), pageHeight - end.y(), CharacterHitTolerance, CharacterHitTolerance); if (startIndex >= 0 && endIndex != startIndex) { - QString text; if (startIndex > endIndex) qSwap(startIndex, endIndex); int count = endIndex - startIndex + 1; - QVector buf(count + 1); - // TODO is that enough space in case one unicode character is more than one in utf-16? - int len = FPDFText_GetText(textPage, startIndex, count, buf.data()); - Q_ASSERT(len - 1 <= count); // len is number of characters written, including the terminator - text = QString::fromUtf16(buf.constData(), len - 1); + QString text = d->getText(textPage, startIndex, count); QVector bounds; int rectCount = FPDFText_CountRects(textPage, startIndex, endIndex - startIndex); for (int i = 0; i < rectCount; ++i) { @@ -767,6 +771,33 @@ QPdfSelection QPdfDocument::getSelection(int page, QPointF start, QPointF end) return QPdfSelection(); } +QPdfSelection QPdfDocument::getAllText(int page) +{ + const QPdfMutexLocker lock; + FPDF_PAGE pdfPage = FPDF_LoadPage(d->doc, page); + double pageHeight = FPDF_GetPageHeight(pdfPage); + FPDF_TEXTPAGE textPage = FPDFText_LoadPage(pdfPage); + int count = FPDFText_CountChars(textPage); + if (count < 1) + return QPdfSelection(); + QString text = d->getText(textPage, 0, count); + QVector bounds; + int rectCount = FPDFText_CountRects(textPage, 0, count); + for (int i = 0; i < rectCount; ++i) { + double l, r, b, t; + FPDFText_GetRect(textPage, i, &l, &t, &r, &b); + QPolygonF poly; + poly << QPointF(l, pageHeight - t); + poly << QPointF(r, pageHeight - t); + poly << QPointF(r, pageHeight - b); + poly << QPointF(l, pageHeight - b); + poly << QPointF(l, pageHeight - t); + bounds << poly; + } + qCDebug(qLcDoc) << "on page" << page << "got" << count << "chars" << rectCount << "rects"; + return QPdfSelection(text, bounds); +} + QT_END_NAMESPACE #include "moc_qpdfdocument.cpp" diff --git a/src/pdf/quick/qml/PdfMultiPageView.qml b/src/pdf/quick/qml/PdfMultiPageView.qml index 579c9a1ce..70bb5454f 100644 --- a/src/pdf/quick/qml/PdfMultiPageView.qml +++ b/src/pdf/quick/qml/PdfMultiPageView.qml @@ -47,6 +47,11 @@ Item { property bool debug: false property string selectedText + function selectAll() { + var currentItem = tableView.itemAtPos(0, tableView.contentY + root.height / 2) + if (currentItem !== null) + currentItem.selection.selectAll() + } function copySelectionToClipboard() { var currentItem = tableView.itemAtPos(0, tableView.contentY + root.height / 2) if (debug) diff --git a/src/pdf/quick/qml/PdfPageView.qml b/src/pdf/quick/qml/PdfPageView.qml index dfd00a1a8..b90ad2d7f 100644 --- a/src/pdf/quick/qml/PdfPageView.qml +++ b/src/pdf/quick/qml/PdfPageView.qml @@ -46,6 +46,9 @@ Rectangle { property alias status: image.status property alias selectedText: selection.text + function selectAll() { + selection.selectAll() + } function copySelectionToClipboard() { selection.copyToClipboard() } diff --git a/src/pdf/quick/qml/PdfScrollablePageView.qml b/src/pdf/quick/qml/PdfScrollablePageView.qml index 4c43972c9..6076e57df 100644 --- a/src/pdf/quick/qml/PdfScrollablePageView.qml +++ b/src/pdf/quick/qml/PdfScrollablePageView.qml @@ -47,6 +47,9 @@ Flickable { property alias status: image.status property alias selectedText: selection.text + function selectAll() { + selection.selectAll() + } function copySelectionToClipboard() { selection.copyToClipboard() } diff --git a/src/pdf/quick/qquickpdfselection.cpp b/src/pdf/quick/qquickpdfselection.cpp index d313820ba..5371e85e5 100644 --- a/src/pdf/quick/qquickpdfselection.cpp +++ b/src/pdf/quick/qquickpdfselection.cpp @@ -124,6 +124,22 @@ QVector QQuickPdfSelection::geometry() const return m_geometry; } +void QQuickPdfSelection::selectAll() +{ + QPdfSelection sel = m_document->m_doc.getAllText(m_page); + if (sel.text() != m_text) { + m_text = sel.text(); + if (QGuiApplication::clipboard()->supportsSelection()) + sel.copyToClipboard(QClipboard::Selection); + emit textChanged(); + } + + if (sel.bounds() != m_geometry) { + m_geometry = sel.bounds(); + emit geometryChanged(); + } +} + void QQuickPdfSelection::resetPoints() { bool wasHolding = m_hold; diff --git a/src/pdf/quick/qquickpdfselection_p.h b/src/pdf/quick/qquickpdfselection_p.h index a0e6d1a8d..bb4a50fed 100644 --- a/src/pdf/quick/qquickpdfselection_p.h +++ b/src/pdf/quick/qquickpdfselection_p.h @@ -86,6 +86,7 @@ public: QString text() const; QVector geometry() const; + Q_INVOKABLE void selectAll(); #if QT_CONFIG(clipboard) Q_INVOKABLE void copyToClipboard() const; #endif -- cgit v1.2.3 From 5d9b86dff687621cad7cd1a9075d35fc49ed96e1 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 13 Feb 2020 14:53:03 +0100 Subject: Update chromium + simplify snapshot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Simplifies our snapshoting and includes among other files the chrome command-line preference store, which we can use with minor adaptations. Submodule src/3rdparty 07787da4..4ea22135: > Fix build for expanded sources > Merge "Merge remote-tracking branch 'origin/upstream-master' into 79-based" into 79-based > Don't trigger quad blending for opacity > FIXUP: Fix build with gcc 5 > [Backport] Allow restricted clock_nanosleep in Linux sandbox Change-Id: Ibdf7b24c0fbe920edd61f550913dca02ed67cd20 Reviewed-by: Jüri Valdmann --- src/3rdparty | 2 +- src/core/command_line_pref_store_qt.cpp | 90 --------------------------------- src/core/command_line_pref_store_qt.h | 56 -------------------- src/core/core_chromium.pri | 2 - src/core/pref_service_adapter.cpp | 11 ++-- src/core/profile_qt.cpp | 1 - src/core/qtwebengine_sources.gni | 3 ++ 7 files changed, 10 insertions(+), 155 deletions(-) delete mode 100644 src/core/command_line_pref_store_qt.cpp delete mode 100644 src/core/command_line_pref_store_qt.h (limited to 'src') diff --git a/src/3rdparty b/src/3rdparty index 07787da49..4ea221350 160000 --- a/src/3rdparty +++ b/src/3rdparty @@ -1 +1 @@ -Subproject commit 07787da493d9a71b994582904a188a53aae9e473 +Subproject commit 4ea2213507a2317fef895a1ab473f9a2729d74af diff --git a/src/core/command_line_pref_store_qt.cpp b/src/core/command_line_pref_store_qt.cpp deleted file mode 100644 index 5c5c82e1a..000000000 --- a/src/core/command_line_pref_store_qt.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 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$ -** -****************************************************************************/ - -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "command_line_pref_store_qt.h" - -#include "chrome/common/chrome_switches.h" -#include "components/proxy_config/proxy_config_dictionary.h" -#include "components/proxy_config/proxy_config_pref_names.h" -#include "content/public/common/content_switches.h" -#include - -CommandLinePrefStoreQt::CommandLinePrefStoreQt(const base::CommandLine *commandLine) - : CommandLinePrefStore(commandLine) -{ - - if (commandLine->HasSwitch(switches::kNoProxyServer)) { - SetValue(proxy_config::prefs::kProxy, - std::make_unique(ProxyConfigDictionary::CreateDirect()), - WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); - } else if (commandLine->HasSwitch(switches::kProxyPacUrl)) { - std::string pac_script_url = - commandLine->GetSwitchValueASCII(switches::kProxyPacUrl); - SetValue(proxy_config::prefs::kProxy, - std::make_unique(ProxyConfigDictionary::CreatePacScript( - pac_script_url, false)), - WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); - } else if (commandLine->HasSwitch(switches::kProxyAutoDetect)) { - SetValue(proxy_config::prefs::kProxy, - std::make_unique( - ProxyConfigDictionary::CreateAutoDetect()), - WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); - } else if (commandLine->HasSwitch(switches::kProxyServer)) { - std::string proxy_server = - commandLine->GetSwitchValueASCII(switches::kProxyServer); - std::string bypass_list = - commandLine->GetSwitchValueASCII(switches::kProxyBypassList); - SetValue( - proxy_config::prefs::kProxy, - std::make_unique(ProxyConfigDictionary::CreateFixedServers( - proxy_server, bypass_list)), - WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); - } - - if (commandLine->HasSwitch(switches::kNoProxyServer) && (commandLine->HasSwitch(switches::kProxyAutoDetect) || commandLine->HasSwitch(switches::kProxyServer) || commandLine->HasSwitch(switches::kProxyPacUrl) || commandLine->HasSwitch(switches::kProxyBypassList))) { - qWarning("Additional command-line proxy switches specified when --%s was also specified", - qPrintable(switches::kNoProxyServer)); - } -} - -CommandLinePrefStoreQt::~CommandLinePrefStoreQt() = default; diff --git a/src/core/command_line_pref_store_qt.h b/src/core/command_line_pref_store_qt.h deleted file mode 100644 index a509f8ca9..000000000 --- a/src/core/command_line_pref_store_qt.h +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 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 COMMAND_LINE_PREF_STORE_QT_H -#define COMMAND_LINE_PREF_STORE_QT_H - -#include "base/command_line.h" -#include "components/prefs/command_line_pref_store.h" - -class CommandLinePrefStoreQt : public CommandLinePrefStore -{ -public: - explicit CommandLinePrefStoreQt(const base::CommandLine *commandLine); - -protected: - ~CommandLinePrefStoreQt() override; - DISALLOW_COPY_AND_ASSIGN(CommandLinePrefStoreQt); -}; - -#endif // COMMAND_LINE_PREF_STORE_QT_H diff --git a/src/core/core_chromium.pri b/src/core/core_chromium.pri index b7180070b..ac118101a 100644 --- a/src/core/core_chromium.pri +++ b/src/core/core_chromium.pri @@ -50,7 +50,6 @@ SOURCES = \ clipboard_qt.cpp \ color_chooser_qt.cpp \ color_chooser_controller.cpp \ - command_line_pref_store_qt.cpp \ common/qt_ipc_logging.cpp \ common/qt_messages.cpp \ common/user_script_data.cpp \ @@ -157,7 +156,6 @@ HEADERS = \ client_cert_select_controller.h \ clipboard_change_observer.h \ clipboard_qt.h \ - command_line_pref_store_qt.h \ color_chooser_qt.h \ color_chooser_controller_p.h \ color_chooser_controller.h \ diff --git a/src/core/pref_service_adapter.cpp b/src/core/pref_service_adapter.cpp index a1ac5e912..4ded70d07 100644 --- a/src/core/pref_service_adapter.cpp +++ b/src/core/pref_service_adapter.cpp @@ -39,12 +39,13 @@ #include "pref_service_adapter.h" -#include "command_line_pref_store_qt.h" #include "profile_adapter.h" #include "type_conversion.h" #include "web_engine_context.h" +#include "chrome/browser/prefs/chrome_command_line_pref_store.h" #include "content/public/browser/browser_thread.h" +#include "components/language/core/browser/pref_names.h" #include "components/prefs/pref_member.h" #include "components/prefs/in_memory_pref_store.h" #include "components/prefs/json_pref_store.h" @@ -80,7 +81,7 @@ void PrefServiceAdapter::setup(const ProfileAdapter &profileAdapter) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); PrefServiceFactory factory; - factory.set_command_line_prefs(base::MakeRefCounted( + factory.set_command_line_prefs(base::MakeRefCounted( WebEngineContext::commandLine())); QString userPrefStorePath = profileAdapter.dataPath(); @@ -92,12 +93,12 @@ void PrefServiceAdapter::setup(const ProfileAdapter &profileAdapter) factory.set_user_prefs(base::MakeRefCounted(toFilePath(userPrefStorePath))); } - PrefRegistrySimple *registry = new PrefRegistrySimple(); - PrefProxyConfigTrackerImpl::RegisterPrefs(registry); + auto registry = base::MakeRefCounted(); + PrefProxyConfigTrackerImpl::RegisterPrefs(registry.get()); #if QT_CONFIG(webengine_spellchecker) // Initial spellcheck settings - registry->RegisterStringPref(prefs::kAcceptLanguages, std::string()); + registry->RegisterStringPref(language::prefs::kAcceptLanguages, std::string()); registry->RegisterListPref(spellcheck::prefs::kSpellCheckDictionaries); registry->RegisterListPref(spellcheck::prefs::kSpellCheckForcedDictionaries); registry->RegisterListPref(spellcheck::prefs::kSpellCheckBlacklistedDictionaries); diff --git a/src/core/profile_qt.cpp b/src/core/profile_qt.cpp index 3d3baa0d7..748104312 100644 --- a/src/core/profile_qt.cpp +++ b/src/core/profile_qt.cpp @@ -41,7 +41,6 @@ #include "profile_adapter.h" #include "browsing_data_remover_delegate_qt.h" -#include "command_line_pref_store_qt.h" #include "download_manager_delegate_qt.h" #include "net/ssl_host_state_delegate_qt.h" #include "permission_manager_qt.h" diff --git a/src/core/qtwebengine_sources.gni b/src/core/qtwebengine_sources.gni index 9facb98f0..9c65fa690 100644 --- a/src/core/qtwebengine_sources.gni +++ b/src/core/qtwebengine_sources.gni @@ -51,6 +51,7 @@ source_set("qtwebengine_sources") { "//components/nacl/common:buildflags", "//components/plugins/renderer/", "//extensions/buildflags:buildflags", + "//rlz/buildflags:buildflags", "//third_party/blink/public/mojom:mojom_platform", ] @@ -64,6 +65,8 @@ source_set("qtwebengine_sources") { "//chrome/browser/media/webrtc/desktop_media_list.h", "//chrome/browser/net/chrome_mojo_proxy_resolver_factory.cc", "//chrome/browser/net/chrome_mojo_proxy_resolver_factory.h", + "//chrome/browser/prefs/chrome_command_line_pref_store.cc", + "//chrome/browser/prefs/chrome_command_line_pref_store.h", "//chrome/browser/profiles/profile.cc", "//chrome/browser/profiles/profile.h", "//chrome/browser/ui/webui/devtools_ui.cc", -- cgit v1.2.3 From 8ab924b7f735ba25a2b8ea40d16e997464d87378 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Br=C3=BCning?= Date: Tue, 10 Mar 2020 16:51:43 +0100 Subject: Update Chromium Pulls in the following changes: 7622e2b8071 [Backport] CVE-2020-6395 - Out of bounds read in JavaScript 2643eee04e0 [Backport] CVE-2020-6410 - Insufficient policy enforcement in navigation f938fe1765e [Backport] CVE-2020-6412 - Insufficient validation of untrusted input in Omnibox 98f5d9e5b14 [Backport] CVE-2020-6413 - Inappropriate implementation in Blink e95d8df0220 [Backport] CVE-2020-6415 - Inappropriate implementation in JavaScript cac651b7205 [Backport] Security bug 1020031 20b67be01c3 [Backport] Security bug 1016506 5043a049628 [Backport] Security bug 1026293 edd82d1d7ce [Backport] Security bug 1047097 334bb80e4ce [Backport] Security bug 1025442 6f1a37c63ba [Backport] Security bug 1016038 Change-Id: I443677e4d832c7f7336eb95cd640f69be11dbe1e Reviewed-by: Allan Sandfeld Jensen --- src/3rdparty | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/3rdparty b/src/3rdparty index 6b0d12aa3..6f1a37c63 160000 --- a/src/3rdparty +++ b/src/3rdparty @@ -1 +1 @@ -Subproject commit 6b0d12aa31ae3553db04277d46ce14f57a6e20b3 +Subproject commit 6f1a37c63baf7cdbb919221258ad6fe294de9d82 -- cgit v1.2.3 From 22c3bfa462eb6e3785eeda1a6540b09a9ae9fd67 Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Thu, 20 Feb 2020 18:00:18 +0100 Subject: Add support for qrc proxy pac file Change-Id: Ic4b70d31c85a31a434644c311eb173cda6a82fbd Reviewed-by: Allan Sandfeld Jensen --- src/core/web_engine_context.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 708fdaa74..55a9cc4a6 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -221,8 +221,13 @@ bool usingSoftwareDynamicGL() void setupProxyPac(base::CommandLine *commandLine){ if (commandLine->HasSwitch(switches::kProxyPacUrl)) { QUrl pac_url(toQt(commandLine->GetSwitchValueASCII(switches::kProxyPacUrl))); - if (pac_url.isValid() && pac_url.isLocalFile()) { - QFile file(pac_url.toLocalFile()); + if (pac_url.isValid() && (pac_url.isLocalFile() || + !pac_url.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive))) { + QFile file; + if (pac_url.isLocalFile()) + file.setFileName(pac_url.toLocalFile()); + else + file.setFileName(pac_url.path().prepend(QChar(':'))); if (file.exists() && file.open(QIODevice::ReadOnly | QIODevice::Text)) { QByteArray ba = file.readAll(); commandLine->RemoveSwitch(switches::kProxyPacUrl); -- cgit v1.2.3 From 0b688fe2e3f049995d65f9814eb42465d21bfabb Mon Sep 17 00:00:00 2001 From: Kirill Burtsev Date: Fri, 13 Mar 2020 13:12:53 +0100 Subject: ProfileIODataQt: remove remains of non network service code Change-Id: Ia11429880d6a40561bccd2feaddcae584cd34dac Reviewed-by: Allan Sandfeld Jensen --- src/core/profile_io_data_qt.cpp | 47 ++++++----------------------------------- src/core/profile_io_data_qt.h | 12 ++++------- 2 files changed, 11 insertions(+), 48 deletions(-) (limited to 'src') diff --git a/src/core/profile_io_data_qt.cpp b/src/core/profile_io_data_qt.cpp index 5190924f9..91af8d544 100644 --- a/src/core/profile_io_data_qt.cpp +++ b/src/core/profile_io_data_qt.cpp @@ -46,27 +46,22 @@ #include "content/public/browser/browsing_data_remover.h" #include "content/public/browser/shared_cors_origin_access_list.h" #include "content/public/common/content_features.h" -#include "chrome/browser/net/chrome_mojo_proxy_resolver_factory.h" -#include "components/proxy_config/pref_proxy_config_tracker_impl.h" -#include "net/proxy_resolution/proxy_config_service.h" -#include "net/proxy_resolution/proxy_resolution_service.h" #include "net/ssl/ssl_config_service_defaults.h" -#include "services/network/proxy_service_mojo.h" -#include "services/network/public/cpp/features.h" #include "services/network/public/cpp/cors/origin_access_list.h" #include "net/client_cert_override.h" #include "net/client_cert_store_data.h" #include "net/cookie_monster_delegate_qt.h" -#include "net/proxy_config_service_qt.h" #include "net/system_network_context_manager.h" #include "profile_qt.h" #include "resource_context_qt.h" #include "type_conversion.h" -#include +#include #include +#include + namespace QtWebEngineCore { ProfileIODataQt::ProfileIODataQt(ProfileQt *profile) @@ -87,7 +82,6 @@ ProfileIODataQt::~ProfileIODataQt() DCHECK_CURRENTLY_ON(content::BrowserThread::IO); m_resourceContext.reset(); - delete m_proxyConfigService.fetchAndStoreAcquire(0); } QPointer ProfileIODataQt::profileAdapter() @@ -151,7 +145,6 @@ void ProfileIODataQt::initializeOnIOThread() m_weakPtr = m_weakPtrFactory.GetWeakPtr(); const std::lock_guard lock(m_mutex); generateAllStorage(); -// generateJobFactory(); setGlobalCertificateVerification(); m_initialized = true; } @@ -163,10 +156,7 @@ void ProfileIODataQt::initializeOnUIThread() m_resourceContext.reset(new ResourceContextQt(this)); m_cookieDelegate = new CookieMonsterDelegateQt(); m_cookieDelegate->setClient(m_profile->profileAdapter()->cookieStore()); - if (base::FeatureList::IsEnabled(network::features::kNetworkService)) - m_proxyConfigMonitor.reset(new ProxyConfigMonitor(m_profile->GetPrefs())); - else - createProxyConfig(); + m_proxyConfigMonitor.reset(new ProxyConfigMonitor(m_profile->GetPrefs())); } void ProfileIODataQt::generateAllStorage() @@ -236,31 +226,11 @@ void ProfileIODataQt::requestStorageGeneration() { const std::lock_guard lock(m_mutex); if (m_initialized && !m_updateAllStorage) { m_updateAllStorage = true; - if (!base::FeatureList::IsEnabled(network::features::kNetworkService)) - createProxyConfig(); base::PostTask(FROM_HERE, {content::BrowserThread::IO}, base::BindOnce(&ProfileIODataQt::generateAllStorage, m_weakPtr)); } } -// TODO(miklocek): mojofy ProxyConfigServiceQt -void ProfileIODataQt::createProxyConfig() -{ - Q_ASSERT(!base::FeatureList::IsEnabled(network::features::kNetworkService)); - Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); - const std::lock_guard lock(m_mutex); - // We must create the proxy config service on the UI loop on Linux because it - // must synchronously run on the glib message loop. This will be passed to - // the URLRequestContextStorage on the IO thread in GetURLRequestContext(). - Q_ASSERT(m_proxyConfigService == 0); - m_proxyConfigService = - new ProxyConfigServiceQt( - m_profileAdapter->profile()->GetPrefs(), - base::CreateSingleThreadTaskRunner({content::BrowserThread::IO})); - //pass interface to io thread - m_proxyResolverFactoryInterface = ChromeMojoProxyResolverFactory::CreateWithSelfOwnedReceiver(); -} - void ProfileIODataQt::updateStorageSettings() { Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); @@ -426,7 +396,6 @@ network::mojom::NetworkContextParamsPtr ProfileIODataQt::CreateNetworkContextPar network_context_params->enable_referrers = true; // Encrypted cookies requires os_crypt, which currently has issues for us on Linux. network_context_params->enable_encrypted_cookies = false; -// network_context_params->proxy_resolver_factory = std::move(m_proxyResolverFactoryInterface); network_context_params->http_cache_enabled = m_httpCacheType != ProfileAdapter::NoCache; network_context_params->http_cache_max_size = m_httpCacheMaxSize; @@ -455,11 +424,9 @@ network::mojom::NetworkContextParamsPtr ProfileIODataQt::CreateNetworkContextPar network_context_params->enforce_chrome_ct_policy = false; network_context_params->primary_network_context = m_useForGlobalCertificateVerification; - if (base::FeatureList::IsEnabled(network::features::kNetworkService)) { - // Should be initialized with existing per-profile CORS access lists. - network_context_params->cors_origin_access_list = - m_profile->GetSharedCorsOriginAccessList()->GetOriginAccessList().CreateCorsOriginAccessPatternsList(); - } + // Should be initialized with existing per-profile CORS access lists. + network_context_params->cors_origin_access_list = + m_profile->GetSharedCorsOriginAccessList()->GetOriginAccessList().CreateCorsOriginAccessPatternsList(); m_proxyConfigMonitor->AddToNetworkContextParams(network_context_params.get()); diff --git a/src/core/profile_io_data_qt.h b/src/core/profile_io_data_qt.h index cf94e70f6..fcd209bf8 100644 --- a/src/core/profile_io_data_qt.h +++ b/src/core/profile_io_data_qt.h @@ -40,14 +40,13 @@ #ifndef PROFILE_IO_DATA_QT_H #define PROFILE_IO_DATA_QT_H -#include "profile_adapter.h" #include "content/public/browser/browsing_data_remover.h" #include "chrome/browser/profiles/profile.h" #include "extensions/buildflags/buildflags.h" -#include "net/proxy_config_monitor.h" #include "services/network/cookie_settings.h" -#include "services/network/public/mojom/network_context.mojom.h" -#include "services/proxy_resolver/public/mojom/proxy_resolver.mojom.h" + +#include "net/proxy_config_monitor.h" +#include "profile_adapter.h" #include #include @@ -55,7 +54,7 @@ namespace net { class ClientCertStore; -class ProxyConfigService; +class URLRequestContext; } namespace extensions { @@ -125,7 +124,6 @@ public: void updateJobFactory(); // runs on ui thread void updateRequestInterceptor(); // runs on ui thread void requestStorageGeneration(); //runs on ui thread - void createProxyConfig(); //runs on ui thread void updateUsedForGlobalCertificateVerification(); // runs on ui thread bool hasPageInterceptors(); @@ -152,8 +150,6 @@ private: scoped_refptr m_cookieDelegate; content::URLRequestInterceptorScopedVector m_requestInterceptors; content::ProtocolHandlerMap m_protocolHandlers; - mojo::InterfacePtrInfo m_proxyResolverFactoryInterface; - QAtomicPointer m_proxyConfigService; QPointer m_profileAdapter; // never dereferenced in IO thread and it is passed by qpointer ProfileAdapter::PersistentCookiesPolicy m_persistentCookiesPolicy; std::unique_ptr m_proxyConfigMonitor; -- cgit v1.2.3 From 1c8498cbc6929465c5acc33edfcc505bc3664720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Br=C3=BCning?= Date: Fri, 13 Mar 2020 11:49:48 +0100 Subject: Update Chromium MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pulls in the following changes: 80bf361c042 [Backport] Dependency for security bug 925035 4af826b4d35 [Backport] Fix for security issue 925035 Change-Id: I1941c5c9b91028129e76b1f95186d2ec2140ab8b Reviewed-by: Jüri Valdmann Reviewed-by: Allan Sandfeld Jensen --- src/3rdparty | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/3rdparty b/src/3rdparty index 6f1a37c63..4af826b4d 160000 --- a/src/3rdparty +++ b/src/3rdparty @@ -1 +1 @@ -Subproject commit 6f1a37c63baf7cdbb919221258ad6fe294de9d82 +Subproject commit 4af826b4d3512f93c6aaf891c9e4434da0f8a7f6 -- cgit v1.2.3 From 3ddbe29629fc3ff397d84ee97abfa63551daeeaf Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Sat, 14 Mar 2020 22:47:05 +0100 Subject: Doc: Remove \contentspage commands The command is deprecated and has no effect apart from generating a documentation warning. Change-Id: I7f3b71274fb2c51da721f5e35ab1af775f5b2b60 Reviewed-by: Paul Wicking --- src/webengine/doc/src/qwebengine-licensing.qdoc | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/webengine/doc/src/qwebengine-licensing.qdoc b/src/webengine/doc/src/qwebengine-licensing.qdoc index 8795ca44c..f6a0a6c32 100644 --- a/src/webengine/doc/src/qwebengine-licensing.qdoc +++ b/src/webengine/doc/src/qwebengine-licensing.qdoc @@ -26,7 +26,6 @@ ****************************************************************************/ /*! -\contentspage qtwebengine-licensing.html \group qtwebengine-licensing \title Qt WebEngine Licensing @@ -43,7 +42,6 @@ Third party licenses included in the sources are: */ /*! -\contentspage qtwebengine-licensing.html \page qtwebengine-3rdparty-chromium-global.html attribution \ingroup qtwebengine-licensing \title Chromium License -- cgit v1.2.3 From 83adde7eeab94c2e6d6a756cf268a6c664cfb309 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 16 Mar 2020 11:44:48 +0100 Subject: Update Chromium Changes: 1e19109f2cd Fix skia crash on Windows after 77-merge ef0a09b990f Fix ozone builds of ANGLE 9424dc7ceec Fix build with spell-checking disabled Fixes: QTBUG-82894 Change-Id: Icf9ea86ad4cd3887a718f5d4d3be2e391264cb6b Reviewed-by: Michal Klocek --- src/3rdparty | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/3rdparty b/src/3rdparty index 4ea221350..9424dc7ce 160000 --- a/src/3rdparty +++ b/src/3rdparty @@ -1 +1 @@ -Subproject commit 4ea2213507a2317fef895a1ab473f9a2729d74af +Subproject commit 9424dc7ceeccf6e6d5edc7757edb39a7ae4983ab -- cgit v1.2.3 From 0f9e8f15e6ed95c225fe3b6f9aaa22288987c9a2 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 16 Mar 2020 11:26:24 +0100 Subject: Fixup copyright headers and includes From API review. Task-number: QTBUG-81853 Change-Id: Ib208a342edcaa9c48dde80ef02bc6f85e35d8029 Reviewed-by: Michal Klocek --- src/pdf/api/qpdfbookmarkmodel.h | 4 ++-- src/pdf/api/qpdfdocument.h | 11 ++++++----- src/pdf/api/qpdfdocument_p.h | 10 +++++----- src/pdf/api/qpdfnamespace.h | 3 ++- src/pdf/api/qpdfpagenavigation.h | 3 ++- src/pdf/api/qpdfpagerenderer.h | 8 +++++--- src/pdf/api/qpdfsearchmodel.h | 6 +++--- src/pdf/api/qpdfsearchresult.h | 3 +-- src/pdf/api/qpdfselection.h | 9 +++++---- src/pdf/api/qtpdfglobal.h | 2 +- src/pdf/jsbridge.cpp | 2 +- src/pdf/qpdfbookmarkmodel.cpp | 2 +- src/pdf/qpdfdocument.cpp | 2 +- 13 files changed, 35 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/pdf/api/qpdfbookmarkmodel.h b/src/pdf/api/qpdfbookmarkmodel.h index 503a29100..8e06a1547 100644 --- a/src/pdf/api/qpdfbookmarkmodel.h +++ b/src/pdf/api/qpdfbookmarkmodel.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtPDF module of the Qt Toolkit. @@ -38,7 +38,7 @@ #define QPDFBOOKMARKMODEL_H #include -#include +#include QT_BEGIN_NAMESPACE diff --git a/src/pdf/api/qpdfdocument.h b/src/pdf/api/qpdfdocument.h index 027cdeb47..f80a7832b 100644 --- a/src/pdf/api/qpdfdocument.h +++ b/src/pdf/api/qpdfdocument.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtPDF module of the Qt Toolkit. @@ -38,10 +38,11 @@ #define QPDFDOCUMENT_H #include -#include -#include -#include -#include "qpdfselection.h" + +#include +#include +#include +#include QT_BEGIN_NAMESPACE diff --git a/src/pdf/api/qpdfdocument_p.h b/src/pdf/api/qpdfdocument_p.h index 2dcb70407..b69b6f19e 100644 --- a/src/pdf/api/qpdfdocument_p.h +++ b/src/pdf/api/qpdfdocument_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtPDF module of the Qt Toolkit. @@ -53,10 +53,10 @@ #include "third_party/pdfium/public/fpdfview.h" #include "third_party/pdfium/public/fpdf_dataavail.h" -#include -#include -#include -#include +#include +#include +#include +#include QT_BEGIN_NAMESPACE diff --git a/src/pdf/api/qpdfnamespace.h b/src/pdf/api/qpdfnamespace.h index c8fd8a580..e76d0abd9 100644 --- a/src/pdf/api/qpdfnamespace.h +++ b/src/pdf/api/qpdfnamespace.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias König +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtPDF module of the Qt Toolkit. @@ -37,7 +38,7 @@ #ifndef QPDFNAMESPACE_H #define QPDFNAMESPACE_H -#include +#include QT_BEGIN_NAMESPACE diff --git a/src/pdf/api/qpdfpagenavigation.h b/src/pdf/api/qpdfpagenavigation.h index 8da809646..0f416bf77 100644 --- a/src/pdf/api/qpdfpagenavigation.h +++ b/src/pdf/api/qpdfpagenavigation.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias König +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtPDF module of the Qt Toolkit. @@ -38,7 +39,7 @@ #define QPDFPAGENAVIGATION_H #include -#include +#include QT_BEGIN_NAMESPACE diff --git a/src/pdf/api/qpdfpagerenderer.h b/src/pdf/api/qpdfpagerenderer.h index de6704480..21f270bd4 100644 --- a/src/pdf/api/qpdfpagerenderer.h +++ b/src/pdf/api/qpdfpagerenderer.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias König +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtPDF module of the Qt Toolkit. @@ -38,9 +39,10 @@ #define QPDFPAGERENDERER_H #include -#include -#include -#include + +#include +#include +#include QT_BEGIN_NAMESPACE diff --git a/src/pdf/api/qpdfsearchmodel.h b/src/pdf/api/qpdfsearchmodel.h index f1593b64b..eb0fb831f 100644 --- a/src/pdf/api/qpdfsearchmodel.h +++ b/src/pdf/api/qpdfsearchmodel.h @@ -37,11 +37,11 @@ #ifndef QPDFSEARCHMODEL_H #define QPDFSEARCHMODEL_H -#include "qtpdfglobal.h" -#include "qpdfdocument.h" -#include "qpdfsearchresult.h" +#include #include +#include +#include QT_BEGIN_NAMESPACE diff --git a/src/pdf/api/qpdfsearchresult.h b/src/pdf/api/qpdfsearchresult.h index 84a2f2343..2dfca2dc4 100644 --- a/src/pdf/api/qpdfsearchresult.h +++ b/src/pdf/api/qpdfsearchresult.h @@ -37,11 +37,10 @@ #ifndef QPDFSEARCHRESULT_H #define QPDFSEARCHRESULT_H -#include "qpdfdestination.h" - #include #include #include +#include QT_BEGIN_NAMESPACE diff --git a/src/pdf/api/qpdfselection.h b/src/pdf/api/qpdfselection.h index 900b203cf..a5e9280dc 100644 --- a/src/pdf/api/qpdfselection.h +++ b/src/pdf/api/qpdfselection.h @@ -38,10 +38,11 @@ #define QPDFSELECTION_H #include -#include -#include -#include -#include + +#include +#include +#include +#include QT_BEGIN_NAMESPACE diff --git a/src/pdf/api/qtpdfglobal.h b/src/pdf/api/qtpdfglobal.h index 34cfc46d9..223ec4bcb 100644 --- a/src/pdf/api/qtpdfglobal.h +++ b/src/pdf/api/qtpdfglobal.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtPDF module of the Qt Toolkit. diff --git a/src/pdf/jsbridge.cpp b/src/pdf/jsbridge.cpp index 95b813929..33d3b2465 100644 --- a/src/pdf/jsbridge.cpp +++ b/src/pdf/jsbridge.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtPDF module of the Qt Toolkit. diff --git a/src/pdf/qpdfbookmarkmodel.cpp b/src/pdf/qpdfbookmarkmodel.cpp index e648657ba..c9c365568 100644 --- a/src/pdf/qpdfbookmarkmodel.cpp +++ b/src/pdf/qpdfbookmarkmodel.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtPDF module of the Qt Toolkit. diff --git a/src/pdf/qpdfdocument.cpp b/src/pdf/qpdfdocument.cpp index d56edf4e9..89b27da8b 100644 --- a/src/pdf/qpdfdocument.cpp +++ b/src/pdf/qpdfdocument.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtPDF module of the Qt Toolkit. -- cgit v1.2.3 From 2e03a8135025e60dd6f9de5a0b4e115085a382f0 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 16 Mar 2020 12:59:26 +0100 Subject: Add move constructors To complete the set when we already have move assign operators Change-Id: I50ac1d76f1acc76faeac0db6078d72d275b77bb0 Reviewed-by: Shawn Rutledge --- src/pdf/api/qpdfdestination.h | 5 +++-- src/pdf/api/qpdfselection.h | 5 +++-- src/pdf/qpdfdestination.cpp | 5 +++++ src/pdf/qpdfselection.cpp | 11 +++++++++++ 4 files changed, 22 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/pdf/api/qpdfdestination.h b/src/pdf/api/qpdfdestination.h index 325863226..f9c186ff6 100644 --- a/src/pdf/api/qpdfdestination.h +++ b/src/pdf/api/qpdfdestination.h @@ -56,10 +56,11 @@ class Q_PDF_EXPORT QPdfDestination Q_PROPERTY(qreal zoom READ zoom) public: - QPdfDestination(const QPdfDestination &other); ~QPdfDestination(); + QPdfDestination(const QPdfDestination &other); QPdfDestination &operator=(const QPdfDestination &other); - inline QPdfDestination &operator=(QPdfDestination &&other) noexcept { swap(other); return *this; } + QPdfDestination(QPdfDestination &&other) noexcept; + QPdfDestination &operator=(QPdfDestination &&other) noexcept { swap(other); return *this; } void swap(QPdfDestination &other) noexcept { d.swap(other.d); } bool isValid() const; int page() const; diff --git a/src/pdf/api/qpdfselection.h b/src/pdf/api/qpdfselection.h index a5e9280dc..5a6a1cddc 100644 --- a/src/pdf/api/qpdfselection.h +++ b/src/pdf/api/qpdfselection.h @@ -56,10 +56,11 @@ class Q_PDF_EXPORT QPdfSelection Q_PROPERTY(QString text READ text) public: - QPdfSelection(const QPdfSelection &other); ~QPdfSelection(); + QPdfSelection(const QPdfSelection &other); QPdfSelection &operator=(const QPdfSelection &other); - inline QPdfSelection &operator=(QPdfSelection &&other) noexcept { swap(other); return *this; } + QPdfSelection(QPdfSelection &&other) noexcept; + QPdfSelection &operator=(QPdfSelection &&other) noexcept { swap(other); return *this; } void swap(QPdfSelection &other) noexcept { d.swap(other.d); } bool isValid() const; QVector bounds() const; diff --git a/src/pdf/qpdfdestination.cpp b/src/pdf/qpdfdestination.cpp index b347445e9..b70e031ca 100644 --- a/src/pdf/qpdfdestination.cpp +++ b/src/pdf/qpdfdestination.cpp @@ -73,6 +73,11 @@ QPdfDestination::QPdfDestination(const QPdfDestination &other) { } +QPdfDestination::QPdfDestination(QPdfDestination &&other) noexcept + : d(std::move(other.d)) +{ +} + QPdfDestination::~QPdfDestination() { } diff --git a/src/pdf/qpdfselection.cpp b/src/pdf/qpdfselection.cpp index 8c3d6fde0..e334f0fb6 100644 --- a/src/pdf/qpdfselection.cpp +++ b/src/pdf/qpdfselection.cpp @@ -82,10 +82,21 @@ QPdfSelection::QPdfSelection(const QPdfSelection &other) { } +QPdfSelection::QPdfSelection(QPdfSelection &&other) noexcept + : d(std::move(other.d)) +{ +} + QPdfSelection::~QPdfSelection() { } +QPdfSelection &QPdfSelection::operator=(const QPdfSelection &other) +{ + d = other.d; + return *this; +} + /*! \property QPdfSelection::valid -- cgit v1.2.3 From 0e59294a0f88ba167dad4279372021841f51c82e Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 16 Mar 2020 15:04:24 +0100 Subject: Enum class QPdfPageRenderer::RenderMode Avoid having the enum name in the enum values. Change-Id: Ida5b3405e6922eb1a2a37edc6fb650019254f4d4 Reviewed-by: Shawn Rutledge --- src/pdf/api/qpdfpagerenderer.h | 8 ++++---- src/pdf/qpdfpagerenderer.cpp | 18 ++++++++++-------- src/pdfwidgets/qpdfview.cpp | 2 +- 3 files changed, 15 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/pdf/api/qpdfpagerenderer.h b/src/pdf/api/qpdfpagerenderer.h index 21f270bd4..c7b8de0df 100644 --- a/src/pdf/api/qpdfpagerenderer.h +++ b/src/pdf/api/qpdfpagerenderer.h @@ -57,15 +57,15 @@ class Q_PDF_EXPORT QPdfPageRenderer : public QObject Q_PROPERTY(RenderMode renderMode READ renderMode WRITE setRenderMode NOTIFY renderModeChanged) public: - enum RenderMode + enum class RenderMode { - MultiThreadedRenderMode, - SingleThreadedRenderMode + MultiThreaded, + SingleThreaded }; Q_ENUM(RenderMode) explicit QPdfPageRenderer(QObject *parent = nullptr); - ~QPdfPageRenderer(); + ~QPdfPageRenderer() override; RenderMode renderMode() const; void setRenderMode(RenderMode mode); diff --git a/src/pdf/qpdfpagerenderer.cpp b/src/pdf/qpdfpagerenderer.cpp index e90f66700..31d9f4e1e 100644 --- a/src/pdf/qpdfpagerenderer.cpp +++ b/src/pdf/qpdfpagerenderer.cpp @@ -79,7 +79,7 @@ public: void requestFinished(int page, QSize imageSize, const QImage &image, QPdfDocumentRenderOptions options, quint64 requestId); - QPdfPageRenderer::RenderMode m_renderMode = QPdfPageRenderer::SingleThreadedRenderMode; + QPdfPageRenderer::RenderMode m_renderMode = QPdfPageRenderer::RenderMode::SingleThreaded; QPointer m_document; struct PageRequest @@ -164,6 +164,8 @@ void QPdfPageRendererPrivate::handleNextRequest() void QPdfPageRendererPrivate::requestFinished(int page, QSize imageSize, const QImage &image, QPdfDocumentRenderOptions options, quint64 requestId) { + Q_UNUSED(image); + Q_UNUSED(requestId); const auto it = std::find_if(m_pendingRequests.begin(), m_pendingRequests.end(), [page, imageSize, options](const PageRequest &request){ return request.pageNumber == page && request.imageSize == imageSize && request.options == options; }); @@ -180,8 +182,8 @@ void QPdfPageRendererPrivate::requestFinished(int page, QSize imageSize, const Q The QPdfPageRenderer contains a queue that collects all render requests that are invoked through requestPage(). Depending on the configured RenderMode the QPdfPageRenderer processes this queue - in the main UI thread on next event loop invocation (SingleThreadedRenderMode) or in a separate worker thread - (MultiThreadedRenderMode) and emits the result through the pageRendered() signal for each request once + in the main UI thread on next event loop invocation (\c RenderMode::SingleThreaded) or in a separate worker thread + (\c RenderMode::MultiThreaded) and emits the result through the pageRendered() signal for each request once the rendering is done. \sa QPdfDocument @@ -218,8 +220,8 @@ QPdfPageRenderer::~QPdfPageRenderer() This enum describes how the pages are rendered. - \value MultiThreadedRenderMode All pages are rendered in a separate worker thread. - \value SingleThreadedRenderMode All pages are rendered in the main UI thread (default). + \value MultiThreaded All pages are rendered in a separate worker thread. + \value SingleThreaded All pages are rendered in the main UI thread (default). \sa renderMode(), setRenderMode() */ @@ -228,7 +230,7 @@ QPdfPageRenderer::~QPdfPageRenderer() \property QPdfPageRenderer::renderMode \brief The mode the renderer uses to render the pages. - By default, this property is \c QPdfPageRenderer::SingleThreaded. + By default, this property is \c RenderMode::SingleThreaded. \sa setRenderMode(), RenderMode */ @@ -260,7 +262,7 @@ void QPdfPageRenderer::setRenderMode(RenderMode mode) d->m_renderMode = mode; emit renderModeChanged(d->m_renderMode); - if (d->m_renderMode == MultiThreadedRenderMode) { + if (d->m_renderMode == RenderMode::MultiThreaded) { d->m_renderThread = new QThread; d->m_renderWorker->moveToThread(d->m_renderThread); d->m_renderThread->start(); @@ -332,7 +334,7 @@ quint64 QPdfPageRenderer::requestPage(int pageNumber, QSize imageSize, if (!d->m_document || d->m_document->status() != QPdfDocument::Ready) return 0; - for (const auto request : qAsConst(d->m_pendingRequests)) { + for (const auto &request : qAsConst(d->m_pendingRequests)) { if (request.pageNumber == pageNumber && request.imageSize == imageSize && request.options == options) diff --git a/src/pdfwidgets/qpdfview.cpp b/src/pdfwidgets/qpdfview.cpp index 19e5b719a..35e368633 100644 --- a/src/pdfwidgets/qpdfview.cpp +++ b/src/pdfwidgets/qpdfview.cpp @@ -70,7 +70,7 @@ void QPdfViewPrivate::init() m_pageNavigation = new QPdfPageNavigation(q); m_pageRenderer = new QPdfPageRenderer(q); - m_pageRenderer->setRenderMode(QPdfPageRenderer::MultiThreadedRenderMode); + m_pageRenderer->setRenderMode(QPdfPageRenderer::RenderMode::MultiThreaded); } void QPdfViewPrivate::documentStatusChanged() -- cgit v1.2.3 From e06fe400389a1e29abee94455eecec591e05c3bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Br=C3=BCning?= Date: Mon, 16 Mar 2020 17:53:22 +0100 Subject: Update Chromium MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pulls in the following change f7ffd2f7dff Fixup for [Backport] CVE-2020-6401 (2/3) Fixes: QTBUG-81909 Change-Id: I735544d31dc97c0e85a0abf912ed3651b3adee1c Reviewed-by: Jüri Valdmann --- src/3rdparty | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/3rdparty b/src/3rdparty index 4af826b4d..f7ffd2f7d 160000 --- a/src/3rdparty +++ b/src/3rdparty @@ -1 +1 @@ -Subproject commit 4af826b4d3512f93c6aaf891c9e4434da0f8a7f6 +Subproject commit f7ffd2f7dffd911e37f6a638bb410bd71da23491 -- cgit v1.2.3 From 2ac4903962c9b7e25793d7bf3fdd084b0719d327 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 17 Mar 2020 14:34:01 +0100 Subject: Avoid type-punning in QPdfDocumentRenderOptions Technically undefined behavior. Change-Id: I7538f800b01473c7c2861137a47dc0424251b926 Reviewed-by: Allan Sandfeld Jensen --- src/pdf/api/qpdfdocumentrenderoptions.h | 51 +++++++++++++++------------------ 1 file changed, 23 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/pdf/api/qpdfdocumentrenderoptions.h b/src/pdf/api/qpdfdocumentrenderoptions.h index 873be0085..cafb4716f 100644 --- a/src/pdf/api/qpdfdocumentrenderoptions.h +++ b/src/pdf/api/qpdfdocumentrenderoptions.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias König +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtPDF module of the Qt Toolkit. @@ -38,56 +39,50 @@ #define QPDFDOCUMENTRENDEROPTIONS_H #include -#include -#include +#include +#include QT_BEGIN_NAMESPACE class QPdfDocumentRenderOptions { public: - Q_DECL_CONSTEXPR QPdfDocumentRenderOptions() Q_DECL_NOTHROW : data(0) {} + Q_DECL_CONSTEXPR QPdfDocumentRenderOptions() noexcept : m_renderFlags(0), m_rotation(0), m_reserved(0) {} - Q_DECL_CONSTEXPR QPdf::Rotation rotation() const Q_DECL_NOTHROW { return static_cast(bits.rotation); } - Q_DECL_RELAXED_CONSTEXPR void setRotation(QPdf::Rotation _rotation) Q_DECL_NOTHROW { bits.rotation = _rotation; } + Q_DECL_CONSTEXPR QPdf::Rotation rotation() const noexcept { return static_cast(m_rotation); } + Q_DECL_RELAXED_CONSTEXPR void setRotation(QPdf::Rotation r) noexcept { m_rotation = r; } - Q_DECL_CONSTEXPR QPdf::RenderFlags renderFlags() const Q_DECL_NOTHROW { return static_cast(bits.renderFlags); } - Q_DECL_RELAXED_CONSTEXPR void setRenderFlags(QPdf::RenderFlags _renderFlags) Q_DECL_NOTHROW { bits.renderFlags = _renderFlags; } + Q_DECL_CONSTEXPR QPdf::RenderFlags renderFlags() const noexcept { return static_cast(m_renderFlags); } + Q_DECL_RELAXED_CONSTEXPR void setRenderFlags(QPdf::RenderFlags r) noexcept { m_renderFlags = r; } - Q_DECL_CONSTEXPR QRect scaledClipRect() const Q_DECL_NOTHROW { return m_clipRect; } - Q_DECL_RELAXED_CONSTEXPR void setScaledClipRect(const QRect &r) Q_DECL_NOTHROW { m_clipRect = r; } + Q_DECL_CONSTEXPR QRect scaledClipRect() const noexcept { return m_clipRect; } + Q_DECL_RELAXED_CONSTEXPR void setScaledClipRect(const QRect &r) noexcept { m_clipRect = r; } - Q_DECL_CONSTEXPR QSize scaledSize() const Q_DECL_NOTHROW { return m_scaledSize; } - Q_DECL_RELAXED_CONSTEXPR void setScaledSize(const QSize &s) Q_DECL_NOTHROW { m_scaledSize = s; } + Q_DECL_CONSTEXPR QSize scaledSize() const noexcept { return m_scaledSize; } + Q_DECL_RELAXED_CONSTEXPR void setScaledSize(const QSize &s) noexcept { m_scaledSize = s; } private: - friend Q_DECL_CONSTEXPR inline bool operator==(QPdfDocumentRenderOptions lhs, QPdfDocumentRenderOptions rhs) Q_DECL_NOTHROW; - - - struct Bits { - quint32 renderFlags : 8; - quint32 rotation : 3; - quint32 reserved : 21; - quint32 reserved2 : 32; - }; - - union { - Bits bits; - quint64 data; - }; + friend Q_DECL_CONSTEXPR inline bool operator==(QPdfDocumentRenderOptions lhs, QPdfDocumentRenderOptions rhs) noexcept; QRect m_clipRect; QSize m_scaledSize; + + quint32 m_renderFlags : 8; + quint32 m_rotation : 3; + quint32 m_reserved : 21; + quint32 m_reserved2 = 0; }; Q_DECLARE_TYPEINFO(QPdfDocumentRenderOptions, Q_PRIMITIVE_TYPE); -Q_DECL_CONSTEXPR inline bool operator==(QPdfDocumentRenderOptions lhs, QPdfDocumentRenderOptions rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool operator==(QPdfDocumentRenderOptions lhs, QPdfDocumentRenderOptions rhs) noexcept { - return lhs.data == rhs.data && lhs.m_clipRect == rhs.m_clipRect && lhs.m_scaledSize == rhs.m_scaledSize; + return lhs.m_clipRect == rhs.m_clipRect && lhs.m_scaledSize == rhs.m_scaledSize && + lhs.m_renderFlags == rhs.m_renderFlags && lhs.m_rotation == rhs.m_rotation && + lhs.m_reserved == rhs.m_reserved && lhs.m_reserved2 == rhs.m_reserved2; // fix -Wunused-private-field } -Q_DECL_CONSTEXPR inline bool operator!=(QPdfDocumentRenderOptions lhs, QPdfDocumentRenderOptions rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool operator!=(QPdfDocumentRenderOptions lhs, QPdfDocumentRenderOptions rhs) noexcept { return !operator==(lhs, rhs); } -- cgit v1.2.3 From 540451ab9a7e8e9f85078b4cebcc7f619a8b6322 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 18 Mar 2020 17:41:27 +0100 Subject: Fix for macOS packaging problem Running build in parallel for debug and release on mac os was resulting in corrupted resource, due to possible simultaneous QMAKE_BUNDLE_DATA resources write from release and debug builds. Add missing qtConfig checks. Fixes: QTBUG-76549 Change-Id: Icc0dee7b06d442e9c15d7afa53c0372e8d82b4a2 Reviewed-by: Michal Klocek --- src/core/core_module.pro | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/core/core_module.pro b/src/core/core_module.pro index 4b9268e1a..d7e2ab8da 100644 --- a/src/core/core_module.pro +++ b/src/core/core_module.pro @@ -107,7 +107,7 @@ resources.files = $$REPACK_DIR/qtwebengine_resources.pak \ icu.files = $$OUT_PWD/$$getConfigDir()/icudtl.dat -!debug_and_release|!build_all|CONFIG(release, debug|release) { +!qtConfig(debug_and_release)|!qtConfig(build_all)|CONFIG(release, debug|release) { qtConfig(framework) { locales.version = Versions locales.path = Resources/qtwebengine_locales @@ -146,7 +146,7 @@ icu.files = $$OUT_PWD/$$getConfigDir()/icudtl.dat } } -!build_pass:debug_and_release { +!build_pass:qtConfig(debug_and_release) { # Special GNU make target that ensures linking isn't done for both debug and release builds # at the same time. notParallel.target = .NOTPARALLEL -- cgit v1.2.3 From df241d1585e2ef6be28e38182cdf7e562e9c1a8a Mon Sep 17 00:00:00 2001 From: Kirill Burtsev Date: Fri, 20 Mar 2020 14:06:01 +0100 Subject: Protect against null adapter client OnRenderFrameMetadataChangedAfterActivation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Notification for metadata change is asynchronous and may come after assigned adapter client was destroyed (that is at least what happens in linked test comboBoxPopupPositionAfterChildMove for popup). Fix is similar to 01ee897dc5. Fixes: QTBUG-82987 Change-Id: Ia22ee3c054ed5d5c26982cff579be9d48145f93b Reviewed-by: Jüri Valdmann --- src/core/render_widget_host_view_qt.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index 5366fba5f..26ddc807f 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -1882,9 +1882,9 @@ void RenderWidgetHostViewQt::OnRenderFrameMetadataChangedAfterActivation() gfx::SizeF contentsSize = metadata.root_layer_size; std::swap(m_lastScrollOffset, scrollOffset); std::swap(m_lastContentsSize, contentsSize); - if (scrollOffset != m_lastScrollOffset) + if (m_adapterClient && scrollOffset != m_lastScrollOffset) m_adapterClient->updateScrollPosition(toQt(m_lastScrollOffset)); - if (contentsSize != m_lastContentsSize) + if (m_adapterClient && contentsSize != m_lastContentsSize) m_adapterClient->updateContentsSize(toQt(m_lastContentsSize)); } -- cgit v1.2.3 From ed4a363f17158b8e6553d12ba55e43325ba43449 Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Thu, 13 Feb 2020 16:56:21 +0100 Subject: Make pdf core module aware of support from buildtools This adds support for messages like: Note: The following modules are not being compiled in this configuration: pdf pdfwidgets Change-Id: I89cd3ff4934197ce0dfee7a73d9f829c94f6606c Reviewed-by: Allan Sandfeld Jensen --- src/pdf/configure.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/pdf/configure.json b/src/pdf/configure.json index 1f21183a2..ddc0e99dc 100644 --- a/src/pdf/configure.json +++ b/src/pdf/configure.json @@ -2,7 +2,7 @@ "module": "pdf", "depends" : [ "buildtools-private" ], "testDir": "../../config.tests", - "condition": "features.build-qtpdf", + "condition": "features.build-qtpdf && features.webengine-qtpdf-support", "libraries": { }, "tests": { -- cgit v1.2.3 From 35aa6c30f0e766b8825519e04242b7a4c93b6e0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Br=C3=BCning?= Date: Tue, 24 Mar 2020 10:16:30 +0100 Subject: Update Chromium Pulls in the following changes: ab79f5394af [Backport] CVE-2020-6426: Inappropriate implementation in V8. c110d4f93df [Backport] CVE-2020-6422: Use after free in WebGL. 8f4cef2a9d9 [Backport] CVE-2020-6427: Use after free in audio. 72d0936150f [Backport] CVE-2020-6428: Use after free in audio. 2a9a1c057d8 [Backport] CVE-2020-6429: Use after free in audio. 9aabebeb69b [Backport] CVE-2020-6449: Use after free in audio. 6c9be50c2d9 [Backport] CVE-2019-20503: Out of bounds read in usersctplib Task-number: QTBUG-81909 Change-Id: I15d5a786db945202f8577e894e9f0e1fb6bf6086 Reviewed-by: Allan Sandfeld Jensen --- src/3rdparty | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/3rdparty b/src/3rdparty index f7ffd2f7d..6c9be50c2 160000 --- a/src/3rdparty +++ b/src/3rdparty @@ -1 +1 @@ -Subproject commit f7ffd2f7dffd911e37f6a638bb410bd71da23491 +Subproject commit 6c9be50c2d901e66119679155fb3c7c9200448d1 -- cgit v1.2.3 From 06523f14700ccb898625254cb0c939e807b14dbe Mon Sep 17 00:00:00 2001 From: Szabolcs David Date: Mon, 23 Mar 2020 18:15:55 +0100 Subject: Fix default file dialogs in QML QVariant::toStringList() never worked in that case where the variant stores QList. Bring back the old logic from 5.12 and unwrap URLs "manually". Task-number: QTWB-46 Change-Id: I8d690c092e1a9bd459ab55cd4d5934d633e907e1 Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Tamas Zakor --- src/core/file_picker_controller.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/core/file_picker_controller.cpp b/src/core/file_picker_controller.cpp index 62e02e126..3c81a977c 100644 --- a/src/core/file_picker_controller.cpp +++ b/src/core/file_picker_controller.cpp @@ -100,10 +100,19 @@ void FilePickerController::accepted(const QStringList &files) void FilePickerController::accepted(const QVariant &files) { - if (!files.canConvert(QVariant::StringList)) + QStringList stringList; + + if (files.canConvert(QVariant::StringList)) { + stringList = files.toStringList(); + } else if (files.canConvert >()) { + const QList urls = files.value>(); + for (const QUrl &url : urls) + stringList.append(url.toLocalFile()); + } else { qWarning("An unhandled type '%s' was provided in FilePickerController::accepted(QVariant)", files.typeName()); + } - accepted(files.toStringList()); + accepted(stringList); } void FilePickerController::rejected() -- cgit v1.2.3 From 1390979a6f0a8469642bc294e4647470575016c4 Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Tue, 24 Mar 2020 11:47:19 +0100 Subject: Keep HTML dropdown always on top It worked properly when RenderWidgetHostViewQtDelegateQuickWindow had Qt::ToolTip flag because tooltips are forced to be on top by QPA. Force RenderWidgethostViewQtDelegateQuickWindow to stay on top by the Qt::WindowStaysOnTopHint flag. Fixes: QTBUG-82993 Change-Id: Iccc48d6bf3570fee09af6d713f6f0bcd56e22b9b Reviewed-by: Allan Sandfeld Jensen --- src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp b/src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp index d3ebdbf27..1de4d8835 100644 --- a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp +++ b/src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp @@ -48,7 +48,7 @@ RenderWidgetHostViewQtDelegateQuickWindow::RenderWidgetHostViewQtDelegateQuickWi : m_realDelegate(realDelegate) , m_virtualParent(nullptr) { - setFlags(Qt::Tool | Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus); + setFlags(Qt::Tool | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus); } RenderWidgetHostViewQtDelegateQuickWindow::~RenderWidgetHostViewQtDelegateQuickWindow() -- cgit v1.2.3 From 8b62b52ffee3bb67e58a2bf2be56c50b79f00617 Mon Sep 17 00:00:00 2001 From: Szabolcs David Date: Wed, 25 Mar 2020 12:52:35 +0100 Subject: Disable picture-in-picture mode for videos Remove non-working PIP option of the video player until we figure out how to support it. Task-number: QTBUG-82390 Change-Id: Id8aee294f50137e98c00c76d94e8227a61fb89f8 Reviewed-by: Allan Sandfeld Jensen --- src/core/web_engine_context.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 55a9cc4a6..5937d3b21 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -599,6 +599,7 @@ WebEngineContext::WebEngineContext() appendToFeatureList(disableFeatures, features::kWebAuthCable.name); appendToFeatureList(disableFeatures, features::kWebPayments.name); appendToFeatureList(disableFeatures, features::kWebUsb.name); + appendToFeatureList(disableFeatures, media::kPictureInPicture.name); if (useEmbeddedSwitches) { // embedded switches are based on the switches for Android, see content/browser/android/content_startup_flags.cc -- cgit v1.2.3 From 1d5c00fde1d2263dd74f2bdc8590783057ec853e Mon Sep 17 00:00:00 2001 From: Kirill Burtsev Date: Thu, 19 Mar 2020 20:47:58 +0100 Subject: Detect newer msvc 2017 and 2019 cross compiler for full debug info Latest build tools installed with prefixes like: VC\Tools\MSVC\14.16.27023\bin\HostX64\x86\cl.exe VC\Tools\MSVC\14.24.28314\bin\Hostx86\x64\cl.exe where last part (x86 or x64) corresponds to target architecture and its parent directory (HostX86 or HostX64) to actual version of the compiler binary. Detect 64bit binary compiling for 32bit to allow activation of full set of debug symbols with force_debug_info. Change-Id: I1044203764ee0bec9dbc983448dcbf595217498d Reviewed-by: Allan Sandfeld Jensen --- src/buildtools/config/windows.pri | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/buildtools/config/windows.pri b/src/buildtools/config/windows.pri index 2e5ebb876..a910e3e31 100644 --- a/src/buildtools/config/windows.pri +++ b/src/buildtools/config/windows.pri @@ -56,12 +56,17 @@ defineTest(usingMSVC32BitCrossCompiler) { } CL_DIR = $$system_path($$CL_DIR) CL_DIR = $$split(CL_DIR, \\) - CL_PLATFORM = $$last(CL_DIR) + CL_PLATFORM = $$take_last(CL_DIR) equals(CL_PLATFORM, amd64_x86): return(true) + equals(CL_PLATFORM, x86)|equals(CL_PLATFORM, x64) { + CL_PLATFORM = $$take_last(CL_DIR) + equals(CL_PLATFORM, HostX64): return(true) + } return(false) } msvc:contains(QT_ARCH, "i386"):!usingMSVC32BitCrossCompiler() { + warning(Full debug info is disabled for chromium due to 32bit compiler) # The 32 bit MSVC linker runs out of memory if we do not remove all debug information. force_debug_info: gn_args -= symbol_level=1 gn_args *= symbol_level=0 -- cgit v1.2.3 From 2f471f1fc80952a715299b7faf2db738944f9bd0 Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Thu, 26 Mar 2020 14:05:09 +0100 Subject: Replace NULL in gl_surface_qt.cpp Fixes build error with MSVC: error C2440: 'return': cannot convert from 'int' to 'scoped_refptr' Change-Id: Ie24528cc98951de6863c12e1d25e3722bd20b046 Reviewed-by: Allan Sandfeld Jensen --- src/core/ozone/gl_surface_qt.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/core/ozone/gl_surface_qt.cpp b/src/core/ozone/gl_surface_qt.cpp index c54a8f12e..4be17f12b 100644 --- a/src/core/ozone/gl_surface_qt.cpp +++ b/src/core/ozone/gl_surface_qt.cpp @@ -76,9 +76,9 @@ namespace { bool g_initializedEGL = false; } -void* GLSurfaceQt::g_display = NULL; -void* GLSurfaceQt::g_config = NULL; -const char* GLSurfaceQt::g_extensions = NULL; +void* GLSurfaceQt::g_display = nullptr; +void* GLSurfaceQt::g_config = nullptr; +const char* GLSurfaceQt::g_extensions = nullptr; GLSurfaceQt::~GLSurfaceQt() { @@ -196,14 +196,14 @@ CreateOffscreenGLSurfaceWithFormat(const gfx::Size& size, GLSurfaceFormat format } LOG(ERROR) << "Requested OpenGL implementation is not supported. Implementation: " << GetGLImplementation(); Q_UNREACHABLE(); - return NULL; + return nullptr; } scoped_refptr CreateViewGLSurface(gfx::AcceleratedWidget window) { QT_NOT_USED - return NULL; + return nullptr; } } // namespace init -- cgit v1.2.3 From 4dfe65f6d4d27bde9d4dae51d262493bea70e619 Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Thu, 12 Mar 2020 16:26:07 +0100 Subject: Fix rare crash on exit in isCreateContextRobustnessSupported During shutdown we might need to flush the gpu buffer if root frame sink is being deleted, which needs current context, which calls isCreateContextRobustnessSupported and ends up in calling platformName() from gpu thread, which might be already destructed on ui thread. Keep context helper till gpu thread is gone. Task-number: QTBUG-79864 Change-Id: Idadc064694fe0584fb894a9405a0af80d9848626 Reviewed-by: Allan Sandfeld Jensen --- src/core/ozone/gl_context_qt.cpp | 19 +++++++++++-------- src/core/ozone/gl_context_qt.h | 1 + src/core/web_engine_context.cpp | 3 ++- 3 files changed, 14 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/core/ozone/gl_context_qt.cpp b/src/core/ozone/gl_context_qt.cpp index 9813a3256..e9337874a 100644 --- a/src/core/ozone/gl_context_qt.cpp +++ b/src/core/ozone/gl_context_qt.cpp @@ -81,6 +81,15 @@ void GLContextHelper::initialize() { if (!contextHelper) contextHelper = new GLContextHelper; +#if QT_CONFIG(opengl) + if (QGuiApplication::platformName() == QLatin1String("offscreen")){ + contextHelper->m_robustness = false; + return; + } + + if (QOpenGLContext *context = qt_gl_global_share_context()) + contextHelper->m_robustness = context->format().testOption(QSurfaceFormat::ResetNotification); +#endif } void GLContextHelper::destroy() @@ -165,15 +174,9 @@ QFunctionPointer GLContextHelper::getEglGetProcAddress() bool GLContextHelper::isCreateContextRobustnessSupported() { -#if QT_CONFIG(opengl) - if (QGuiApplication::platformName() == QLatin1String("offscreen")) - return false; - - if (QOpenGLContext *context = qt_gl_global_share_context()) - return context->format().testOption(QSurfaceFormat::ResetNotification); -#endif - return false; + return contextHelper->m_robustness; } + QT_END_NAMESPACE #if defined(OS_WIN) diff --git a/src/core/ozone/gl_context_qt.h b/src/core/ozone/gl_context_qt.h index 8559af313..cc4f6b0d1 100644 --- a/src/core/ozone/gl_context_qt.h +++ b/src/core/ozone/gl_context_qt.h @@ -70,6 +70,7 @@ private: Q_INVOKABLE bool initializeContextOnBrowserThread(gl::GLContext* context, gl::GLSurface* surface, gl::GLContextAttribs attribs); static GLContextHelper* contextHelper; + bool m_robustness = false; }; QT_END_NAMESPACE diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 5937d3b21..1fa12885f 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -344,12 +344,13 @@ void WebEngineContext::destroy() // This should deliver all nessesery calls of DeleteSoon from PostTask while (delegate->DoWork()) { } - GLContextHelper::destroy(); m_devtoolsServer.reset(); m_runLoop->AfterRun(); // Destroy the main runner, this stops main message loop m_browserRunner.reset(); + // gpu thread is no longer around, so no more cotnext is used, remove the helper + GLContextHelper::destroy(); // These would normally be in the content-runner, but we allocated them separately: m_startupData.reset(); -- cgit v1.2.3 From 0223d2911cea5a8a412e4b8a625c19b8c8b7848b Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 24 Mar 2020 09:13:45 +0100 Subject: Windows: Look for the WidevineCdm plugin in the new Chrome locations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With the later versions of Chrome it will place the WidevineCdm plugin inside the Program Files folder, so we need to check in there for the plugin on Windows as well as the older locations. Change-Id: I4ce10536dbd4779a2c3631827a9cb3a5eb8cb7d0 Reviewed-by: Michael Brüning --- src/core/content_client_qt.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src') diff --git a/src/core/content_client_qt.cpp b/src/core/content_client_qt.cpp index 22f3f548f..7274615ea 100644 --- a/src/core/content_client_qt.cpp +++ b/src/core/content_client_qt.cpp @@ -114,6 +114,15 @@ static QString getLocalAppDataDir() result = QDir::fromNativeSeparators(QString::fromWCharArray(path)); return result; } + +static QString getProgramFilesDir(bool x86Dir = false) +{ + QString result; + wchar_t path[MAX_PATH]; + if (SHGetSpecialFolderPath(0, path, x86Dir ? CSIDL_PROGRAM_FILESX86 : CSIDL_PROGRAM_FILES, FALSE)) + result = QDir::fromNativeSeparators(QString::fromWCharArray(path)); + return result; +} #endif #if QT_CONFIG(webengine_pepper_plugins) @@ -307,6 +316,28 @@ static bool IsWidevineAvailable(base::FilePath *cdm_path, } } #elif defined(Q_OS_WIN) + const QString googleChromeDir = QLatin1String("/Google/Chrome/Application"); + const QStringList programFileDirs{getProgramFilesDir() + googleChromeDir, + getProgramFilesDir(true) + googleChromeDir}; + for (const QString &dir : programFileDirs) { + QDir d(dir); + if (d.exists()) { + QFileInfoList widevineVersionDirs = d.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name | QDir::Reversed); + for (int i = 0; i < widevineVersionDirs.size(); ++i) { + QString versionDirPath(widevineVersionDirs.at(i).absoluteFilePath()); +#ifdef WIN64 + QString potentialWidevinePluginPath = versionDirPath + + "/WidevineCdm/_platform_specific/win_x64/" + + QString::fromLatin1(kWidevineCdmFileName); +#else + QString potentialWidevinePluginPath = versionDirPath + + "/WidevineCdm/_platform_specific/win_x86/" + + QString::fromLatin1(kWidevineCdmFileName); +#endif + pluginPaths << potentialWidevinePluginPath; + } + } + } QDir potentialWidevineDir(getLocalAppDataDir() + "/Google/Chrome/User Data/WidevineCDM"); if (potentialWidevineDir.exists()) { QFileInfoList widevineVersionDirs = potentialWidevineDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name | QDir::Reversed); -- cgit v1.2.3 From 887b236e54354c53cf2714197e017488fc788b7a Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 31 Mar 2020 13:27:41 +0200 Subject: Fixup build_all Don't build both release and debug, when build_all is not requested. Change-Id: I4e0458ba460a9c62b32161ea588955b2f539a37e Reviewed-by: Michal Klocek --- src/core/api/core_api.pro | 3 ++- src/core/gn_run.pro | 3 ++- src/pdf/gn_run.pro | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/core/api/core_api.pro b/src/core/api/core_api.pro index 6b4291cb7..d53fb6942 100644 --- a/src/core/api/core_api.pro +++ b/src/core/api/core_api.pro @@ -14,7 +14,8 @@ CONFIG -= create_prl # Copy this logic from qt_module.prf so that the intermediate library can be # created to the same rules as the final module linking in core_module.pro. !host_build:if(win32|mac):!macx-xcode { - qtConfig(debug_and_release): CONFIG += debug_and_release build_all + qtConfig(debug_and_release): CONFIG += debug_and_release + qtConfig(build_all): CONFIG += build_all } DEFINES += \ diff --git a/src/core/gn_run.pro b/src/core/gn_run.pro index 377d8363c..8b16d7c59 100644 --- a/src/core/gn_run.pro +++ b/src/core/gn_run.pro @@ -4,7 +4,8 @@ QT_FOR_CONFIG += buildtools-private webenginecore-private core-private gui-priva TEMPLATE = aux -qtConfig(debug_and_release): CONFIG += debug_and_release build_all +qtConfig(debug_and_release): CONFIG += debug_and_release +qtConfig(build_all): CONFIG += build_all qtConfig(webengine-system-ninja) { QT_TOOL.ninja.binary = ninja diff --git a/src/pdf/gn_run.pro b/src/pdf/gn_run.pro index 7fd4d4ffc..87070fd81 100644 --- a/src/pdf/gn_run.pro +++ b/src/pdf/gn_run.pro @@ -3,7 +3,8 @@ QT_FOR_CONFIG += buildtools-private TEMPLATE = aux -qtConfig(debug_and_release): CONFIG += debug_and_release build_all +qtConfig(debug_and_release): CONFIG += debug_and_release +qtConfig(build_all): CONFIG += build_all qtConfig(webengine-system-ninja) { QT_TOOL.ninja.binary = ninja -- cgit v1.2.3 From b688719130142e1bee4b7e1c010332dc65e89cb5 Mon Sep 17 00:00:00 2001 From: Leena Miettinen Date: Thu, 26 Mar 2020 17:16:52 +0100 Subject: Doc: Fix docs for playbackRequiresUserGesture WebEngine setting Fixes: QTBUG-83101 Change-Id: I7ca8271cc88c7e157c36c79e06fa378f4bce48e4 Reviewed-by: Allan Sandfeld Jensen --- src/webengine/api/qquickwebenginesettings.cpp | 8 ++++++-- src/webengine/doc/src/external-resources.qdoc | 5 +++++ src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc | 8 +++++--- 3 files changed, 16 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/webengine/api/qquickwebenginesettings.cpp b/src/webengine/api/qquickwebenginesettings.cpp index 9a102a504..78fbe16e8 100644 --- a/src/webengine/api/qquickwebenginesettings.cpp +++ b/src/webengine/api/qquickwebenginesettings.cpp @@ -404,10 +404,14 @@ bool QQuickWebEngineSettings::showScrollBars() const \qmlproperty bool WebEngineSettings::playbackRequiresUserGesture \since QtWebEngine 1.7 Inhibits playback of media content until the user interacts with - the page. Disabled by default. + the page. + + By default, Qt WebEngine uses Chromium settings, as described in + \l {Autoplay Policy Changes}. To overwrite the default behavior, + this property must be set to \c false. \note The behavior is similar to Chrome on Android when enabled, - and similar to Chrome on desktops when disabled (default). + and similar to Chrome on desktops when disabled. */ bool QQuickWebEngineSettings::playbackRequiresUserGesture() const { diff --git a/src/webengine/doc/src/external-resources.qdoc b/src/webengine/doc/src/external-resources.qdoc index 55f6a68a3..acf63fb04 100644 --- a/src/webengine/doc/src/external-resources.qdoc +++ b/src/webengine/doc/src/external-resources.qdoc @@ -139,3 +139,8 @@ \externalpage https://www.w3.org/TR/notifications \title Web Notifications API */ + +/*! + \externalpage https://developers.google.com/web/updates/2017/09/autoplay-policy-changes + \title Autoplay Policy Changes +*/ diff --git a/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc index 0706598ef..5cd0132aa 100644 --- a/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc +++ b/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc @@ -175,9 +175,11 @@ Enabled by default. (Added in Qt 5.10) \value PlaybackRequiresUserGesture Inhibits playback of media content until the user interacts with - the page. This is similar to how Chrome on Android behaves, while - the default behavior when it is disabled is similar to Chrome on desktops. - (Added in Qt 5.11) + the page. By default, WebEngine uses Chromium settings, as described + in \l {Autoplay Policy Changes}. This is similar to how Chrome on + Android behaves, while the default behavior when it is disabled is + similar to Chrome on desktops. To overwrite the default behavior, + disable this setting. (Added in Qt 5.11) \value JavascriptCanPaste Enables JavaScript \c{execCommand("paste")}. This also requires enabling JavascriptCanAccessClipboard. -- cgit v1.2.3 From ed5bd3c5638b237846234028381cab5d67669786 Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Tue, 31 Mar 2020 20:19:10 +0200 Subject: Speculative fix for titleUpdate test case After tedious investigation the issue boils down to error prone synchronization of web engine settings. WebEngineSettings are synchronized between the browser process and the render process. Moreover in the browser process the sync message is send to the render with QTimer::singleShot, which can cause race conditions if for example QWebPage::setUrl was used meanwhile. This makes current settings not being picked up by the render process and results in 'titleUpdate' test case flaky. This happens due to the fact that ShouldDisplayErrorPageForFailedLoad in the render process frame view could have invalid value. Try to sync web engine settings on every adapter load, setContent or reload. Mark some flaky settings in tests. Fixes: QTBUG-83078 Change-Id: I5289472f146e104d5cb6c3b9b20b26d3dc42f4b1 Reviewed-by: Allan Sandfeld Jensen --- src/core/web_contents_adapter.cpp | 10 ++++++++++ src/core/web_engine_settings.cpp | 2 ++ 2 files changed, 12 insertions(+) (limited to 'src') diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 138ea7039..9cecb9ecb 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -614,6 +614,8 @@ void WebContentsAdapter::reload() bool wasDiscarded = (m_lifecycleState == LifecycleState::Discarded); setLifecycleState(LifecycleState::Active); CHECK_VALID_RENDER_WIDGET_HOST_VIEW(m_webContents->GetRenderViewHost()); + WebEngineSettings *settings = m_adapterClient->webEngineSettings(); + settings->doApply(); if (!wasDiscarded) // undiscard() already triggers a reload m_webContents->GetController().Reload(content::ReloadType::NORMAL, /*checkRepost = */false); focusIfNecessary(); @@ -625,6 +627,8 @@ void WebContentsAdapter::reloadAndBypassCache() bool wasDiscarded = (m_lifecycleState == LifecycleState::Discarded); setLifecycleState(LifecycleState::Active); CHECK_VALID_RENDER_WIDGET_HOST_VIEW(m_webContents->GetRenderViewHost()); + WebEngineSettings *settings = m_adapterClient->webEngineSettings(); + settings->doApply(); if (!wasDiscarded) // undiscard() already triggers a reload m_webContents->GetController().Reload(content::ReloadType::BYPASSING_CACHE, /*checkRepost = */false); focusIfNecessary(); @@ -655,6 +659,9 @@ void WebContentsAdapter::load(const QWebEngineHttpRequest &request) CHECK_VALID_RENDER_WIDGET_HOST_VIEW(m_webContents->GetRenderViewHost()); + WebEngineSettings *settings = m_adapterClient->webEngineSettings(); + settings->doApply(); + // The situation can occur when relying on the editingFinished signal in QML to set the url // of the WebView. // When enter is pressed, onEditingFinished fires and the url of the webview is set, which @@ -740,6 +747,9 @@ void WebContentsAdapter::setContent(const QByteArray &data, const QString &mimeT CHECK_VALID_RENDER_WIDGET_HOST_VIEW(m_webContents->GetRenderViewHost()); + WebEngineSettings *settings = m_adapterClient->webEngineSettings(); + settings->doApply(); + QByteArray encodedData = data.toPercentEncoding(); std::string urlString; if (!mimeType.isEmpty()) diff --git a/src/core/web_engine_settings.cpp b/src/core/web_engine_settings.cpp index eb6db9793..c54570b33 100644 --- a/src/core/web_engine_settings.cpp +++ b/src/core/web_engine_settings.cpp @@ -333,6 +333,8 @@ void WebEngineSettings::doApply() { if (webPreferences.isNull()) return; + + m_batchTimer.stop(); // Override with our settings when applicable applySettingsToWebPreferences(webPreferences.data()); Q_ASSERT(m_adapter); -- cgit v1.2.3 From 6b62dfe7242ce0d3067aa98620664a4dc7a656d8 Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Fri, 20 Mar 2020 15:52:51 +0100 Subject: Fix CSS backdrop-filter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-82842 Change-Id: I79394cf726d9c5d16881fa8c07b43d28fa43e026 Reviewed-by: Jüri Valdmann --- src/core/compositor/display_gl_output_surface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/core/compositor/display_gl_output_surface.cpp b/src/core/compositor/display_gl_output_surface.cpp index 0077af112..ef12cc71b 100644 --- a/src/core/compositor/display_gl_output_surface.cpp +++ b/src/core/compositor/display_gl_output_surface.cpp @@ -273,7 +273,7 @@ void DisplayGLOutputSurface::ApplyExternalStencil() // glCopyTexSubImage2D on our framebuffer. uint32_t DisplayGLOutputSurface::GetFramebufferCopyTextureFormat() { - return GL_RGBA; + return m_currentShape.hasAlpha ? GL_RGBA : GL_RGB; } // Called from viz::DirectRenderer::DrawFrame, only used for overlays. -- cgit v1.2.3 From 98bbdd3330171332c8b73aa5329d24e7780c4661 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 12 Mar 2020 17:46:17 +0100 Subject: Fix crash in ProxyingURLLoaderFactoryQt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We need to be on the UI thread to walk the frame-node tree. Task-number: QTBUG-82999 Change-Id: I8011a29e91d6af92da341cbdd01fc9403c587e23 Reviewed-by: Tamas Zakor Reviewed-by: Jüri Valdmann --- src/core/content_browser_client_qt.cpp | 1 - src/core/net/proxying_url_loader_factory_qt.cpp | 48 ++++++++++++++++--------- src/core/net/proxying_url_loader_factory_qt.h | 4 --- 3 files changed, 32 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index a8d9e6ddc..d38a5916e 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -1200,7 +1200,6 @@ bool ContentBrowserClientQt::WillCreateURLLoaderFactory( base::PostTask(FROM_HERE, { content::BrowserThread::IO }, base::BindOnce(&ProxyingURLLoaderFactoryQt::CreateProxy, process_id, browser_context->GetResourceContext(), - static_cast(frame), std::move(proxied_receiver), std::move(target_factory_info))); return true; diff --git a/src/core/net/proxying_url_loader_factory_qt.cpp b/src/core/net/proxying_url_loader_factory_qt.cpp index a2cb268b0..4931bb3e3 100644 --- a/src/core/net/proxying_url_loader_factory_qt.cpp +++ b/src/core/net/proxying_url_loader_factory_qt.cpp @@ -94,13 +94,14 @@ class InterceptedRequest : public network::mojom::URLLoader { public: InterceptedRequest(int process_id, uint64_t request_id, int32_t routing_id, uint32_t options, - const network::ResourceRequest &request, const GURL &top_document_url, + const network::ResourceRequest &request, const net::MutableNetworkTrafficAnnotationTag &traffic_annotation, ProfileIODataQt *profileData, network::mojom::URLLoaderRequest loader_request, network::mojom::URLLoaderClientPtr client, network::mojom::URLLoaderFactoryPtr target_factory); ~InterceptedRequest() override; + void Start(); void Restart(); void InterceptOnUIThread(); @@ -170,7 +171,7 @@ private: }; InterceptedRequest::InterceptedRequest(int process_id, uint64_t request_id, int32_t routing_id, uint32_t options, - const network::ResourceRequest &request, const GURL &top_document_url, + const network::ResourceRequest &request, const net::MutableNetworkTrafficAnnotationTag &traffic_annotation, ProfileIODataQt *profileData, network::mojom::URLLoaderRequest loader_request, @@ -180,7 +181,6 @@ InterceptedRequest::InterceptedRequest(int process_id, uint64_t request_id, int3 , request_id_(request_id) , routing_id_(routing_id) , options_(options) - , m_topDocumentUrl(top_document_url) , request_(request) , traffic_annotation_(traffic_annotation) , m_profileData(profileData) @@ -203,6 +203,31 @@ InterceptedRequest::~InterceptedRequest() m_weakFactory.InvalidateWeakPtrs(); } +void InterceptedRequest::Start() +{ + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + + content::FrameTreeNode *frameTreeNode = nullptr; + if (process_id_) { + content::RenderFrameHostImpl *renderFrameHost = content::RenderFrameHostImpl::FromID(process_id_, + request_.render_frame_id); + if (renderFrameHost) + frameTreeNode = renderFrameHost->frame_tree_node(); + } else { + frameTreeNode = content::FrameTreeNode::GloballyFindByID(request_.render_frame_id); + } + // Follows a similar path to the root as RenderFrameHostImpl::CalculateSiteForCookies() + if (frameTreeNode && frameTreeNode->frame_tree() + && frameTreeNode->frame_tree()->root() + && frameTreeNode->frame_tree()->root()->current_frame_host()) + m_topDocumentUrl = frameTreeNode->frame_tree()->root()->current_frame_host()->GetLastCommittedURL(); + else + LOG(INFO) << "InterceptedRequest::Start() - null frameTreeNode or path to top frame"; + + base::PostTask(FROM_HERE, {content::BrowserThread::IO}, + base::BindOnce(&InterceptedRequest::Restart, m_weakPtr)); +} + void InterceptedRequest::Restart() { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); @@ -466,10 +491,9 @@ void InterceptedRequest::SendErrorAndCompleteImmediately(int error_code) ProxyingURLLoaderFactoryQt::ProxyingURLLoaderFactoryQt(int process_id, content::ResourceContext *resourceContext, - content::RenderFrameHostImpl *host, mojo::PendingReceiver loader_receiver, network::mojom::URLLoaderFactoryPtrInfo target_factory_info) - : m_processId(process_id), m_resourceContext(resourceContext), m_renderFrameHost(host), m_weakFactory(this) + : m_processId(process_id), m_resourceContext(resourceContext), m_weakFactory(this) { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); if (target_factory_info) { @@ -490,14 +514,13 @@ ProxyingURLLoaderFactoryQt::~ProxyingURLLoaderFactoryQt() // static void ProxyingURLLoaderFactoryQt::CreateProxy(int process_id, content::ResourceContext *resourceContext, - content::RenderFrameHostImpl *host, mojo::PendingReceiver loader_receiver, network::mojom::URLLoaderFactoryPtrInfo target_factory_info) { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); // Will manage its own lifetime - new ProxyingURLLoaderFactoryQt(process_id, resourceContext, host, std::move(loader_receiver), std::move(target_factory_info)); + new ProxyingURLLoaderFactoryQt(process_id, resourceContext, std::move(loader_receiver), std::move(target_factory_info)); } void ProxyingURLLoaderFactoryQt::CreateLoaderAndStart(network::mojom::URLLoaderRequest loader, int32_t routing_id, @@ -522,20 +545,13 @@ void ProxyingURLLoaderFactoryQt::CreateLoaderAndStart(network::mojom::URLLoaderR if (m_targetFactory) m_targetFactory->Clone(mojo::MakeRequest(&target_factory_clone)); - // Follows a similar path to the root as RenderFrameHostImpl::CalculateSiteForCookies() - GURL top_document_url; - if (m_renderFrameHost) - top_document_url = m_renderFrameHost->frame_tree_node()->frame_tree()->root()->current_frame_host()->GetLastCommittedURL(); - else - LOG(INFO) << "ProxyingURLLoaderFactoryQt::CreateLoaderAndStart() - null m_renderFrameHost, shouldn't happen"; - // Will manage its own lifetime InterceptedRequest *req = new InterceptedRequest(m_processId, request_id, routing_id, options, request, - top_document_url, traffic_annotation, profileIOData, std::move(loader), std::move(client), std::move(target_factory_clone)); - req->Restart(); + base::PostTask(FROM_HERE, {content::BrowserThread::UI}, + base::BindOnce(&InterceptedRequest::Start, base::Unretained(req))); } void ProxyingURLLoaderFactoryQt::OnTargetFactoryError() diff --git a/src/core/net/proxying_url_loader_factory_qt.h b/src/core/net/proxying_url_loader_factory_qt.h index 4d913f545..0a436fd81 100644 --- a/src/core/net/proxying_url_loader_factory_qt.h +++ b/src/core/net/proxying_url_loader_factory_qt.h @@ -60,7 +60,6 @@ // found in the LICENSE file. namespace content { -class RenderFrameHostImpl; class ResourceContext; } @@ -70,14 +69,12 @@ class ProxyingURLLoaderFactoryQt : public network::mojom::URLLoaderFactory { public: ProxyingURLLoaderFactoryQt(int process_id, content::ResourceContext *resourceContext, - content::RenderFrameHostImpl *host, mojo::PendingReceiver loader_receiver, network::mojom::URLLoaderFactoryPtrInfo target_factory_info); ~ProxyingURLLoaderFactoryQt() override; static void CreateProxy(int process_id, content::ResourceContext *resourceContext, - content::RenderFrameHostImpl *host, mojo::PendingReceiver loader_receiver, network::mojom::URLLoaderFactoryPtrInfo target_factory_info); @@ -97,7 +94,6 @@ private: network::mojom::URLLoaderFactoryPtr m_targetFactory; content::ResourceContext *m_resourceContext; - content::RenderFrameHostImpl *m_renderFrameHost; base::WeakPtrFactory m_weakFactory; -- cgit v1.2.3 From 2893bc8f0b6432b9b1c686a93cdca94a36418308 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 4 Mar 2020 17:47:21 +0100 Subject: Adaptations for Chromium 80 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Icaf68648cbc2c13a61fc3b208ff1e64ca36c90b6 Reviewed-by: Jüri Valdmann --- src/3rdparty | 2 +- src/buildtools/config/common.pri | 1 + src/buildtools/config/linux.pri | 5 + src/buildtools/config/mac_osx.pri | 3 +- src/buildtools/configure.json | 85 +++++--------- src/core/browser_accessibility_qt.cpp | 24 ++-- src/core/certificate_error_controller.cpp | 9 +- src/core/certificate_error_controller.h | 3 +- src/core/certificate_error_controller_p.h | 4 +- src/core/content_browser_client_qt.cpp | 127 ++++++++++++--------- src/core/content_browser_client_qt.h | 17 ++- src/core/content_client_qt.cpp | 6 +- src/core/content_main_delegate_qt.cpp | 2 +- src/core/core_chromium.pri | 8 +- src/core/download_manager_delegate_qt.cpp | 28 +---- src/core/download_manager_delegate_qt.h | 4 +- .../extensions/extensions_browser_client_qt.cpp | 36 ++++-- src/core/extensions/extensions_browser_client_qt.h | 7 +- src/core/favicon_manager.cpp | 1 + src/core/net/custom_url_loader_factory.cpp | 6 +- ...in_response_interceptor_url_loader_throttle.cpp | 2 +- ...ugin_response_interceptor_url_loader_throttle.h | 2 +- src/core/net/proxying_url_loader_factory_qt.cpp | 63 +++++----- src/core/net/proxying_url_loader_factory_qt.h | 5 +- src/core/net/ssl_host_state_delegate_qt.cpp | 2 +- src/core/net/ssl_host_state_delegate_qt.h | 2 +- src/core/net/system_network_context_manager.cpp | 22 ++-- src/core/ozone/BUILD.gn | 4 - src/core/ozone/gl_ozone_glx_qt.cpp | 7 +- src/core/ozone/gl_ozone_glx_qt.h | 2 +- src/core/ozone/ozone_platform_qt.cpp | 7 +- src/core/ozone/platform_window_qt.h | 4 +- src/core/permission_manager_qt.cpp | 1 + src/core/printing/print_view_manager_base_qt.cpp | 11 +- src/core/printing/print_view_manager_qt.cpp | 2 +- src/core/printing/printing_message_filter_qt.h | 4 - src/core/qtwebengine.gni | 6 +- src/core/qtwebengine_resources.gni | 12 +- src/core/render_widget_host_view_qt.cpp | 1 - src/core/renderer/content_renderer_client_qt.cpp | 66 +++++++---- src/core/renderer/content_renderer_client_qt.h | 14 +-- src/core/renderer/content_settings_observer_qt.cpp | 9 +- src/core/renderer/content_settings_observer_qt.h | 2 +- .../pepper_isolated_file_system_message_filter.cpp | 2 +- .../web_channel_ipc_transport_host.cpp | 4 +- .../renderer_host/web_channel_ipc_transport_host.h | 5 +- src/core/resource_bundle_qt.cpp | 4 +- src/core/visited_links_manager_qt.cpp | 18 +-- src/core/visited_links_manager_qt.h | 4 +- src/core/web_contents_adapter.cpp | 18 +-- src/core/web_contents_delegate_qt.cpp | 4 +- src/core/web_contents_delegate_qt.h | 2 +- src/core/web_contents_view_qt.cpp | 38 +++--- src/core/web_contents_view_qt.h | 2 +- src/core/web_engine_context.cpp | 9 +- src/core/web_engine_settings.cpp | 29 +++-- .../api/qquickwebenginecertificateerror.cpp | 4 + .../api/qquickwebenginecertificateerror_p.h | 1 + .../api/qwebenginecertificateerror.cpp | 3 + .../api/qwebenginecertificateerror.h | 1 + 60 files changed, 411 insertions(+), 365 deletions(-) (limited to 'src') diff --git a/src/3rdparty b/src/3rdparty index 9424dc7ce..6b151acc9 160000 --- a/src/3rdparty +++ b/src/3rdparty @@ -1 +1 @@ -Subproject commit 9424dc7ceeccf6e6d5edc7757edb39a7ae4983ab +Subproject commit 6b151acc9f31574c7b739433c538b90b989c9a23 diff --git a/src/buildtools/config/common.pri b/src/buildtools/config/common.pri index f2b4a854e..9824897f0 100644 --- a/src/buildtools/config/common.pri +++ b/src/buildtools/config/common.pri @@ -16,6 +16,7 @@ gn_args += \ enable_reporting=false \ enable_resource_whitelist_generation=false \ enable_swiftshader=false \ + angle_enable_swiftshader=false \ enable_web_auth=false \ enable_web_speech=false \ enable_widevine=true \ diff --git a/src/buildtools/config/linux.pri b/src/buildtools/config/linux.pri index 2aa345c21..c02af3909 100644 --- a/src/buildtools/config/linux.pri +++ b/src/buildtools/config/linux.pri @@ -192,6 +192,11 @@ host_build { } else { gn_args += use_alsa=false } + qtConfig(build-qtwebengine-core):qtConfig(webengine-system-xkbcommon) { + gn_args += use_xkbcommon=true + } else { + gn_args += use_xkbcommon=false + } !packagesExist(libpci): gn_args += use_libpci=false qtConfig(build-qtwebengine-core):qtConfig(webengine-ozone-x11) { diff --git a/src/buildtools/config/mac_osx.pri b/src/buildtools/config/mac_osx.pri index a7ed61214..01aca4ca7 100644 --- a/src/buildtools/config/mac_osx.pri +++ b/src/buildtools/config/mac_osx.pri @@ -29,7 +29,8 @@ gn_args += \ clang_use_chrome_plugins=false \ mac_deployment_target=\"$${QMAKE_MACOSX_DEPLOYMENT_TARGET}\" \ mac_sdk_min=\"$${QMAKE_MAC_SDK_VERSION}\" \ - use_external_popup_menu=false + use_external_popup_menu=false \ + angle_enable_vulkan=false qtConfig(build-qtwebengine-core):qtConfig(webengine-spellchecker) { qtConfig(webengine-native-spellchecker): gn_args += use_browser_spellchecker=true diff --git a/src/buildtools/configure.json b/src/buildtools/configure.json index c2531a744..1298ab916 100644 --- a/src/buildtools/configure.json +++ b/src/buildtools/configure.json @@ -32,6 +32,12 @@ { "type": "pkgConfig", "args": "libdrm" } ] }, + "webengine-xkbcommon": { + "label": "xkbcommon", + "sources": [ + { "type": "pkgConfig", "args": "xkbcommon" } + ] + }, "webengine-xcomposite": { "label": "xcomposite", "sources": [ @@ -143,10 +149,13 @@ "test" : { "main": [ "std::string s;", - "RE2 re2(s);" + "re2::FilteredRE2 fre2(1);", + "int id = 0;", + "fre2.Add(s, {}, &id);", + "const RE2 &re2 = fre2.GetRE2(id);" ] }, - "headers": "re2/re2.h", + "headers": "re2/filtered_re2.h", "sources": [ { "type": "pkgConfig", "args": "re2" } ] @@ -203,36 +212,6 @@ { "type": "pkgConfig", "args": "libxml-2.0 libxslt" } ] }, - "webengine-libdrm": { - "label": "libdrm", - "sources": [ - { "type": "pkgConfig", "args": "libdrm" } - ] - }, - "webengine-xcomposite": { - "label": "xcomposite", - "sources": [ - { "type": "pkgConfig", "args": "xcomposite" } - ] - }, - "webengine-xcursor": { - "label": "xcursor", - "sources": [ - { "type": "pkgConfig", "args": "xcursor" } - ] - }, - "webengine-xi": { - "label": "xi", - "sources": [ - { "type": "pkgConfig", "args": "xi" } - ] - }, - "webengine-xtst": { - "label": "xtst", - "sources": [ - { "type": "pkgConfig", "args": "xtst" } - ] - }, "webengine-ffmpeg": { "label": "libavcodec libavformat libavutil", "sources": [ @@ -242,7 +221,7 @@ "webengine-opus": { "label": "opus", "sources": [ - { "type": "pkgConfig", "args": "opus" } + { "type": "pkgConfig", "args": "opus >= 1.3.1" } ] }, "webengine-snappy": { @@ -317,6 +296,13 @@ ] } }, + "webengine-xkbcommon": { + "label": "system xkbcommon", + "type": "compile", + "test": { + "include": "xkbcommon/xkbcommon.h" + } + }, "webengine-ninja": { "label": "system ninja", "type": "detectNinja" @@ -467,6 +453,11 @@ "condition": "libs.webengine-libdrm", "output": [ "privateFeature" ] }, + "webengine-system-xkbcommon": { + "label": "xkbcommon", + "condition": "libs.webengine-xkbcommon && tests.webengine-xkbcommon", + "output": [ "privateFeature" ] + }, "webengine-system-xcomposite": { "label": "xcomposite", "condition": "libs.webengine-xcomposite", @@ -541,31 +532,6 @@ { "type": "varAssign", "name": "QMAKE_JUMBO_MERGE_LIMIT", "value": "tests.webengine-jumbo-build.merge_limit" } ] }, - "webengine-system-libdrm": { - "label": "libdrm", - "condition": "libs.webengine-libdrm", - "output": [ "privateFeature" ] - }, - "webengine-system-xcomposite": { - "label": "xcomposite", - "condition": "libs.webengine-xcomposite", - "output": [ "privateFeature" ] - }, - "webengine-system-xcursor": { - "label": "xcursor", - "condition": "libs.webengine-xcursor", - "output": [ "privateFeature" ] - }, - "webengine-system-xi": { - "label": "xi", - "condition": "libs.webengine-xi", - "output": [ "privateFeature" ] - }, - "webengine-system-xtst": { - "label": "xtst", - "condition": "libs.webengine-xtst", - "output": [ "privateFeature" ] - }, "webengine-system-harfbuzz": { "label": "harfbuzz", "condition": "config.unix && features.system-harfbuzz && libs.webengine-harfbuzz", @@ -786,7 +752,8 @@ "webengine-system-png", "webengine-system-jpeg", "webengine-system-harfbuzz", - "webengine-system-freetype" + "webengine-system-freetype", + "webengine-system-xkbcommon" ] } ] diff --git a/src/core/browser_accessibility_qt.cpp b/src/core/browser_accessibility_qt.cpp index d816678e3..6104fb1f8 100644 --- a/src/core/browser_accessibility_qt.cpp +++ b/src/core/browser_accessibility_qt.cpp @@ -225,15 +225,6 @@ QAccessible::Role BrowserAccessibilityQt::role() const return QAccessible::AlertMessage; case ax::mojom::Role::kAnchor: return QAccessible::Link; - - // REMINDER: annotation roles are removed from Chromium 80: https://chromium-review.googlesource.com/c/chromium/src/+/1907074 - case ax::mojom::Role::kAnnotationAttribution: - case ax::mojom::Role::kAnnotationCommentary: - case ax::mojom::Role::kAnnotationPresence: - case ax::mojom::Role::kAnnotationRevision: - case ax::mojom::Role::kAnnotationSuggestion: - return QAccessible::Section; - case ax::mojom::Role::kApplication: return QAccessible::Document; // returning Application here makes Qt return the top level app object case ax::mojom::Role::kArticle: @@ -258,6 +249,8 @@ QAccessible::Role BrowserAccessibilityQt::role() const return QAccessible::CheckBox; case ax::mojom::Role::kClient: return QAccessible::Client; + case ax::mojom::Role::kCode: + return QAccessible::StaticText; case ax::mojom::Role::kColorWell: return QAccessible::ColorChooser; case ax::mojom::Role::kColumn: @@ -270,6 +263,9 @@ QAccessible::Role BrowserAccessibilityQt::role() const return QAccessible::ComboBox; case ax::mojom::Role::kComplementary: return QAccessible::ComplementaryContent; + case ax::mojom::Role::kComment: + case ax::mojom::Role::kCommentSection: + return QAccessible::Section; case ax::mojom::Role::kContentDeletion: case ax::mojom::Role::kContentInsertion: return QAccessible::Grouping; @@ -348,6 +344,8 @@ QAccessible::Role BrowserAccessibilityQt::role() const return QAccessible::Document; case ax::mojom::Role::kEmbeddedObject: return QAccessible::Grouping; + case ax::mojom::Role::kEmphasis: + return QAccessible::StaticText; case ax::mojom::Role::kFeed: return QAccessible::Section; case ax::mojom::Role::kFigcaption: @@ -466,8 +464,12 @@ QAccessible::Role BrowserAccessibilityQt::role() const return QAccessible::Grouping; case ax::mojom::Role::kRegion: return QAccessible::Section; + case ax::mojom::Role::kRevision: + return QAccessible::Section; case ax::mojom::Role::kRow: return QAccessible::Row; + case ax::mojom::Role::kRowGroup: + return QAccessible::Section; case ax::mojom::Role::kRowHeader: return QAccessible::RowHeader; case ax::mojom::Role::kRuby: @@ -495,6 +497,10 @@ QAccessible::Role BrowserAccessibilityQt::role() const return QAccessible::StaticText; case ax::mojom::Role::kStatus: return QAccessible::Indicator; + case ax::mojom::Role::kStrong: + return QAccessible::StaticText; + case ax::mojom::Role::kSuggestion: + return QAccessible::Section; case ax::mojom::Role::kSvgRoot: return QAccessible::Graphic; case ax::mojom::Role::kSwitch: diff --git a/src/core/certificate_error_controller.cpp b/src/core/certificate_error_controller.cpp index f3b16357b..353228c2d 100644 --- a/src/core/certificate_error_controller.cpp +++ b/src/core/certificate_error_controller.cpp @@ -68,11 +68,12 @@ ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateNameConstraintViolatio ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateValidityTooLong, net::ERR_CERT_VALIDITY_TOO_LONG) ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateTransparencyRequired, net::ERR_CERTIFICATE_TRANSPARENCY_REQUIRED) ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateSymantecLegacy, net::ERR_CERT_SYMANTEC_LEGACY) +ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateKnownInterceptionBlocked, net::ERR_CERT_KNOWN_INTERCEPTION_BLOCKED) ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateErrorEnd, net::ERR_CERT_END) void CertificateErrorControllerPrivate::accept(bool accepted) { - callback.Run(accepted ? content::CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE : content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY); + std::move(callback).Run(accepted ? content::CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE : content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY); } CertificateErrorControllerPrivate::CertificateErrorControllerPrivate(int cert_error, @@ -81,14 +82,14 @@ CertificateErrorControllerPrivate::CertificateErrorControllerPrivate(int cert_er bool main_frame, bool fatal_error, bool strict_enforcement, - const base::Callback& cb + base::OnceCallback cb ) : certError(CertificateErrorController::CertificateError(cert_error)) , requestUrl(toQt(request_url)) , resourceType(main_frame ? CertificateErrorController::ResourceTypeMainFrame : CertificateErrorController::ResourceTypeOther) , fatalError(fatal_error) , strictEnforcement(strict_enforcement) - , callback(cb) + , callback(std::move(cb)) { if (auto cert = ssl_info.cert.get()) { validStart = toQt(cert->valid_start()); @@ -158,6 +159,8 @@ QString CertificateErrorController::errorString() const else return getQStringForMessageId(IDS_CERT_ERROR_NOT_YET_VALID_DESCRIPTION); case CertificateAuthorityInvalid: + case CertificateKnownInterceptionBlocked: + case CertificateSymantecLegacy: return getQStringForMessageId(IDS_CERT_ERROR_AUTHORITY_INVALID_DESCRIPTION); case CertificateContainsErrors: return getQStringForMessageId(IDS_CERT_ERROR_CONTAINS_ERRORS_DESCRIPTION); diff --git a/src/core/certificate_error_controller.h b/src/core/certificate_error_controller.h index 7c7db37ef..dc1c3cf54 100644 --- a/src/core/certificate_error_controller.h +++ b/src/core/certificate_error_controller.h @@ -85,7 +85,8 @@ public: CertificateValidityTooLong = -213, CertificateTransparencyRequired = -214, CertificateSymantecLegacy = -215, - CertificateErrorEnd = -217 // not an error, just an enum boundary + CertificateKnownInterceptionBlocked = -217, + CertificateErrorEnd = -218 // not an error, just an enum boundary }; CertificateError error() const; diff --git a/src/core/certificate_error_controller_p.h b/src/core/certificate_error_controller_p.h index ceae99853..b0b0bc658 100644 --- a/src/core/certificate_error_controller_p.h +++ b/src/core/certificate_error_controller_p.h @@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE class CertificateErrorControllerPrivate { public: - CertificateErrorControllerPrivate(int cert_error, const net::SSLInfo& ssl_info, const GURL& request_url, bool main_frame, bool fatal_error, bool strict_enforcement, const base::Callback& callback); + CertificateErrorControllerPrivate(int cert_error, const net::SSLInfo& ssl_info, const GURL& request_url, bool main_frame, bool fatal_error, bool strict_enforcement, base::OnceCallback callback); void accept(bool accepted); @@ -70,7 +70,7 @@ public: CertificateErrorController::ResourceType resourceType; bool fatalError; bool strictEnforcement; - const base::Callback callback; + base::OnceCallback callback; QList certificateChain; }; diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index d38a5916e..2c5ba36c8 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -54,7 +54,7 @@ #include "components/guest_view/browser/guest_view_base.h" #include "components/navigation_interception/intercept_navigation_throttle.h" #include "components/navigation_interception/navigation_params.h" -#include "components/network_hints/browser/network_hints_message_filter.h" +#include "components/network_hints/browser/simple_network_hints_handler_impl.h" #include "components/spellcheck/spellcheck_buildflags.h" #include "content/browser/renderer_host/render_view_host_delegate.h" #include "content/common/url_schemes.h" @@ -162,7 +162,6 @@ #include "content/public/browser/file_url_loader.h" #include "extensions/browser/extension_message_filter.h" #include "extensions/browser/guest_view/extensions_guest_view_message_filter.h" -#include "extensions/browser/io_thread_extension_message_filter.h" #include "extensions/common/constants.h" #include "common/extensions/extensions_client_qt.h" @@ -194,6 +193,43 @@ QT_BEGIN_NAMESPACE Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context(); QT_END_NAMESPACE +// Implement IsHandledProtocol as declared in //url/url_util_qt.h. +namespace url { +bool IsHandledProtocol(base::StringPiece scheme) +{ + static const char *const kProtocolList[] = { + url::kHttpScheme, + url::kHttpsScheme, +#if BUILDFLAG(ENABLE_WEBSOCKETS) + url::kWsScheme, + url::kWssScheme, +#endif // BUILDFLAG(ENABLE_WEBSOCKETS) + url::kFileScheme, + content::kChromeDevToolsScheme, +#if BUILDFLAG(ENABLE_EXTENSIONS) + extensions::kExtensionScheme, +#endif + content::kChromeUIScheme, + url::kDataScheme, + url::kAboutScheme, +#if !BUILDFLAG(DISABLE_FTP_SUPPORT) + url::kFtpScheme, +#endif // !BUILDFLAG(DISABLE_FTP_SUPPORT) + url::kBlobScheme, + url::kFileSystemScheme, + url::kQrcScheme, + }; + + for (const char *protocol : kProtocolList) { + if (scheme == protocol) + return true; + } + if (const auto cs = url::CustomScheme::FindScheme(scheme)) + return true; + return false; +} +} + namespace QtWebEngineCore { class QtShareGLContext : public gl::GLContext { @@ -301,8 +337,6 @@ void ContentBrowserClientQt::RenderProcessWillLaunch(content::RenderProcessHost const int id = host->GetID(); Profile *profile = Profile::FromBrowserContext(host->GetBrowserContext()); - host->AddFilter(new network_hints::NetworkHintsMessageFilter(id)); - // Allow requesting custom schemes. const auto policy = content::ChildProcessSecurityPolicy::GetInstance(); const auto profileAdapter = static_cast(profile)->profileAdapter(); @@ -318,7 +352,6 @@ void ContentBrowserClientQt::RenderProcessWillLaunch(content::RenderProcessHost #endif #if BUILDFLAG(ENABLE_EXTENSIONS) host->AddFilter(new extensions::ExtensionMessageFilter(id, profile)); - host->AddFilter(new extensions::IOThreadExtensionMessageFilter()); host->AddFilter(new extensions::ExtensionsGuestViewMessageFilter(id, profile)); #endif //ENABLE_EXTENSIONS @@ -363,7 +396,7 @@ void ContentBrowserClientQt::GetQuotaSettings(content::BrowserContext* context, base::OnceCallback)> callback) { storage::GetNominalDynamicSettings(partition->GetPath(), context->IsOffTheRecord(), - storage::GetDefaultDiskInfoHelper(), std::move(callback)); + storage::GetDefaultDeviceInfoHelper(), std::move(callback)); } // Copied from chrome/browser/ssl/ssl_error_handler.cc: @@ -398,7 +431,7 @@ void ContentBrowserClientQt::AllowCertificateError(content::WebContents *webCont const GURL &request_url, bool is_main_frame_request, bool strict_enforcement, - const base::Callback &callback) + base::OnceCallback callback) { WebContentsDelegateQt* contentsDelegate = static_cast(webContents->GetDelegate()); @@ -411,7 +444,7 @@ void ContentBrowserClientQt::AllowCertificateError(content::WebContents *webCont is_main_frame_request, IsCertErrorFatal(cert_error), strict_enforcement, - callback))); + std::move(callback)))); contentsDelegate->allowCertificateError(errorController); } @@ -435,12 +468,12 @@ base::OnceClosure ContentBrowserClientQt::SelectClientCertificate(content::WebCo return base::OnceClosure(); } -std::unique_ptr ContentBrowserClientQt::CreateClientCertStore(content::ResourceContext *resource_context) +std::unique_ptr ContentBrowserClientQt::CreateClientCertStore(content::BrowserContext *browser_context) { - if (!resource_context) + if (!browser_context) return nullptr; - return ProfileIODataQt::FromResourceContext(resource_context)->CreateClientCertStore(); + return ProfileIODataQt::FromBrowserContext(browser_context)->CreateClientCertStore(); } std::string ContentBrowserClientQt::GetApplicationLocale() @@ -490,7 +523,7 @@ void ContentBrowserClientQt::GetAdditionalAllowedSchemesForFileSystem(std::vecto void ContentBrowserClientQt::GetAdditionalMappedFilesForChildProcess(const base::CommandLine& command_line, int child_process_id, content::PosixFileDescriptorInfo* mappings) { const std::string &locale = GetApplicationLocale(); - const base::FilePath &locale_file_path = ui::ResourceBundle::GetSharedInstance().GetLocaleFilePath(locale, true); + const base::FilePath &locale_file_path = ui::ResourceBundle::GetSharedInstance().GetLocaleFilePath(locale); if (locale_file_path.empty()) return; @@ -599,6 +632,20 @@ void ContentBrowserClientQt::BindHostReceiverForRenderer(content::RenderProcessH #endif // BUILDFLAG(ENABLE_SPELLCHECK) } +static void BindNetworkHintsHandler(content::RenderFrameHost *frame_host, + mojo::PendingReceiver receiver) +{ + network_hints::SimpleNetworkHintsHandlerImpl::Create(frame_host, std::move(receiver)); +} + +void ContentBrowserClientQt::RegisterBrowserInterfaceBindersForFrame( + content::RenderFrameHost *render_frame_host, + service_manager::BinderMapWithContext *map) +{ + Q_UNUSED(render_frame_host); + map->Add(base::BindRepeating(&BindNetworkHintsHandler)); +} + void ContentBrowserClientQt::RunServiceInstance(const service_manager::Identity &identity, mojo::PendingReceiver *receiver) { @@ -616,8 +663,6 @@ base::Optional ContentBrowserClientQt::GetServiceMani { if (name == content::mojom::kBrowserServiceName) return GetQtWebEngineContentBrowserOverlayManifest(); - else if (name == content::mojom::kRendererServiceName) - return GetQtWebEngineContentRendererOverlayManifest(); return base::nullopt; } @@ -763,11 +808,11 @@ bool ContentBrowserClientQt::AllowWorkerIndexedDB(const GURL &url, } static void LaunchURL(const GURL& url, - const content::WebContents::Getter& web_contents_getter, + base::OnceCallback web_contents_getter, ui::PageTransition page_transition, bool is_main_frame, bool has_user_gesture) { Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); - content::WebContents* webContents = web_contents_getter.Run(); + content::WebContents* webContents = std::move(web_contents_getter).Run(); if (!webContents) return; @@ -783,26 +828,26 @@ static void LaunchURL(const GURL& url, } -bool ContentBrowserClientQt::HandleExternalProtocol( - const GURL &url, - content::WebContents::Getter web_contents_getter, +bool ContentBrowserClientQt::HandleExternalProtocol(const GURL &url, + base::OnceCallback web_contents_getter, int child_id, content::NavigationUIData *navigation_data, bool is_main_frame, ui::PageTransition page_transition, bool has_user_gesture, const base::Optional &initiating_origin, - network::mojom::URLLoaderFactoryPtr *out_factory) + mojo::PendingRemote *out_factory) { // Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); Q_UNUSED(child_id); Q_UNUSED(navigation_data); + Q_UNUSED(initiating_origin); Q_UNUSED(out_factory); base::PostTask(FROM_HERE, {content::BrowserThread::UI}, base::BindOnce(&LaunchURL, url, - web_contents_getter, + std::move(web_contents_getter), page_transition, is_main_frame, has_user_gesture)); @@ -826,7 +871,8 @@ public: } void WillRedirectRequest(net::RedirectInfo *redirect_info, - const network::ResourceResponseHead &response_head, bool *defer, + const network::mojom::URLResponseHead &response_head, + bool *defer, std::vector *to_be_removed_headers, net::HttpRequestHeaders *modified_headers) override { @@ -921,34 +967,7 @@ std::vector> ContentBrowserClientQt bool ContentBrowserClientQt::IsHandledURL(const GURL &url) { - static const char *const kProtocolList[] = { - url::kFileScheme, - content::kChromeDevToolsScheme, -#if BUILDFLAG(ENABLE_EXTENSIONS) - extensions::kExtensionScheme, -#endif - content::kChromeUIScheme, - url::kDataScheme, - url::kAboutScheme, -#if !BUILDFLAG(DISABLE_FTP_SUPPORT) - url::kFtpScheme, -#endif // !BUILDFLAG(DISABLE_FTP_SUPPORT) - url::kBlobScheme, - url::kFileSystemScheme, - url::kQrcScheme, - }; - - // We don't check url.IsCustom() here because we don't - // know if the registered protocol is installed in the - // profile that will be used to load the URL. - - const std::string scheme = url.scheme(); - - for (const char *protocol : kProtocolList) { - if (scheme == protocol) - return true; - } - return net::URLRequest::IsHandledProtocol(scheme); + return url::IsHandledProtocol(url.scheme()); } std::unique_ptr ContentBrowserClientQt::CreateLoginDelegate( @@ -1000,8 +1019,10 @@ bool ContentBrowserClientQt::ShouldUseSpareRenderProcessHost(content::BrowserCon return ContentBrowserClient::ShouldUseSpareRenderProcessHost(browser_context, site_url); } -bool ContentBrowserClientQt::ShouldTreatURLSchemeAsFirstPartyWhenTopLevel(base::StringPiece scheme) +bool ContentBrowserClientQt::ShouldTreatURLSchemeAsFirstPartyWhenTopLevel(base::StringPiece scheme, bool is_embedded_origin_secure) { + if (is_embedded_origin_secure && scheme == content::kChromeUIScheme) + return true; #if BUILDFLAG(ENABLE_EXTENSIONS) return scheme == extensions::kExtensionScheme; #else @@ -1185,9 +1206,11 @@ bool ContentBrowserClientQt::WillCreateURLLoaderFactory( int render_process_id, URLLoaderFactoryType type, const url::Origin &request_initiator, + base::Optional navigation_id, mojo::PendingReceiver *factory_receiver, mojo::PendingRemote *header_client, - bool *bypass_redirect_checks) + bool *bypass_redirect_checks, + network::mojom::URLLoaderFactoryOverridePtr *factory_override) { if (!base::FeatureList::IsEnabled(network::features::kNetworkService)) return false; diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h index d828d44b6..341564574 100644 --- a/src/core/content_browser_client_qt.h +++ b/src/core/content_browser_client_qt.h @@ -98,12 +98,12 @@ public: const GURL &request_url, bool is_main_frame_request, bool strict_enforcement, - const base::Callback &callback) override; + base::OnceCallback callback) override; base::OnceClosure SelectClientCertificate(content::WebContents* web_contents, net::SSLCertRequestInfo* cert_request_info, net::ClientCertIdentityList client_certs, std::unique_ptr delegate) override; - std::unique_ptr CreateClientCertStore(content::ResourceContext *resource_context) override; + std::unique_ptr CreateClientCertStore(content::BrowserContext *browser_context) override; content::DevToolsManagerDelegate *GetDevToolsManagerDelegate() override; content::PlatformNotificationService * GetPlatformNotificationService(content::BrowserContext *browser_context) override; @@ -120,6 +120,8 @@ public: mojo::ScopedMessagePipeHandle interface_pipe) override; void BindHostReceiverForRenderer(content::RenderProcessHost *render_process_host, mojo::GenericPendingReceiver receiver) override; + void RegisterBrowserInterfaceBindersForFrame(content::RenderFrameHost *render_frame_host, + service_manager::BinderMapWithContext *map) override; void RunServiceInstance(const service_manager::Identity &identity, mojo::PendingReceiver *receiver) override; @@ -186,7 +188,8 @@ public: bool DoesSiteRequireDedicatedProcess(content::BrowserContext *browser_context, const GURL &effective_site_url) override; bool ShouldUseSpareRenderProcessHost(content::BrowserContext *browser_context, const GURL& site_url) override; - bool ShouldTreatURLSchemeAsFirstPartyWhenTopLevel(base::StringPiece scheme) override; + bool ShouldTreatURLSchemeAsFirstPartyWhenTopLevel(base::StringPiece scheme, + bool is_embedded_origin_secure) override; #if defined(Q_OS_LINUX) void GetAdditionalMappedFilesForChildProcess(const base::CommandLine& command_line, int child_process_id, content::PosixFileDescriptorInfo* mappings) override; @@ -208,14 +211,14 @@ public: bool HandleExternalProtocol( const GURL &url, - base::Callback web_contents_getter, + base::OnceCallback web_contents_getter, int child_id, content::NavigationUIData *navigation_data, bool is_main_frame, ui::PageTransition page_transition, bool has_user_gesture, const base::Optional &initiating_origin, - network::mojom::URLLoaderFactoryPtr *out_factory) override; + mojo::PendingRemote *out_factory) override; std::vector> CreateURLLoaderThrottles( const network::ResourceRequest &request, content::BrowserContext *browser_context, @@ -232,9 +235,11 @@ public: int render_process_id, URLLoaderFactoryType type, const url::Origin &request_initiator, + base::Optional navigation_id, mojo::PendingReceiver *factory_receiver, mojo::PendingRemote *header_client, - bool *bypass_redirect_checks) override; + bool *bypass_redirect_checks, + network::mojom::URLLoaderFactoryOverridePtr *factory_override) override; scoped_refptr GetSystemSharedURLLoaderFactory() override; network::mojom::NetworkContext *GetSystemNetworkContext() override; void OnNetworkServiceCreated(network::mojom::NetworkService *network_service) override; diff --git a/src/core/content_client_qt.cpp b/src/core/content_client_qt.cpp index 6f8fc04f9..1ab7e5d8e 100644 --- a/src/core/content_client_qt.cpp +++ b/src/core/content_client_qt.cpp @@ -347,8 +347,8 @@ static bool IsWidevineAvailable(base::FilePath *cdm_path, // Add the supported encryption schemes as if they came from the // component manifest. This list must match the CDM that is being // bundled with Chrome. - capability->encryption_schemes.insert(media::EncryptionMode::kCenc); - capability->encryption_schemes.insert(media::EncryptionMode::kCbcs); + capability->encryption_schemes.insert(media::EncryptionScheme::kCenc); + capability->encryption_schemes.insert(media::EncryptionScheme::kCbcs); // Temporary session is always supported. capability->session_types.insert(media::CdmSessionType::kTemporary); @@ -391,7 +391,7 @@ void ContentClientQt::AddContentDecryptionModules(std::vector // Supported codecs are hard-coded in ExternalClearKeyProperties. content::CdmCapability capability( - {}, {media::EncryptionMode::kCenc, media::EncryptionMode::kCbcs}, + {}, {media::EncryptionScheme::kCenc, media::EncryptionScheme::kCbcs}, {media::CdmSessionType::kTemporary, media::CdmSessionType::kPersistentLicense}, {}); diff --git a/src/core/content_main_delegate_qt.cpp b/src/core/content_main_delegate_qt.cpp index ff6bf4366..708d175f3 100644 --- a/src/core/content_main_delegate_qt.cpp +++ b/src/core/content_main_delegate_qt.cpp @@ -107,7 +107,7 @@ struct LazyDirectoryListerCacher dict.SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr"); std::string html = webui::GetI18nTemplateHtml( - ui::ResourceBundle::GetSharedInstance().DecompressDataResource(IDR_DIR_HEADER_HTML), + ui::ResourceBundle::GetSharedInstance().LoadDataResourceString(IDR_DIR_HEADER_HTML), &dict); html_data = base::RefCountedString::TakeString(&html); } diff --git a/src/core/core_chromium.pri b/src/core/core_chromium.pri index ac118101a..6a8b8c4bd 100644 --- a/src/core/core_chromium.pri +++ b/src/core/core_chromium.pri @@ -118,7 +118,6 @@ SOURCES = \ renderer/render_view_observer_qt.cpp \ renderer/render_thread_observer_qt.cpp \ renderer/user_resource_controller.cpp \ - renderer/plugins/loadable_plugin_placeholder_qt.cpp \ renderer/plugins/plugin_placeholder_qt.cpp \ renderer_host/render_view_observer_host_qt.cpp \ renderer_host/user_resource_controller_host.cpp \ @@ -231,7 +230,6 @@ HEADERS = \ renderer/render_view_observer_qt.h \ renderer/render_thread_observer_qt.h \ renderer/user_resource_controller.h \ - renderer/plugins/loadable_plugin_placeholder_qt.h \ renderer/plugins/plugin_placeholder_qt.h \ renderer_host/render_view_observer_host_qt.h \ renderer_host/user_resource_controller_host.h \ @@ -269,14 +267,16 @@ qtConfig(webengine-pepper-plugins) { renderer_host/pepper/pepper_host_factory_qt.cpp \ renderer_host/pepper/pepper_isolated_file_system_message_filter.cpp \ renderer/pepper/pepper_flash_renderer_host_qt.cpp \ - renderer/pepper/pepper_renderer_host_factory_qt.cpp + renderer/pepper/pepper_renderer_host_factory_qt.cpp \ + renderer/plugins/loadable_plugin_placeholder_qt.cpp HEADERS += \ renderer_host/pepper/pepper_flash_browser_host_qt.h \ renderer_host/pepper/pepper_host_factory_qt.h \ renderer_host/pepper/pepper_isolated_file_system_message_filter.h \ renderer/pepper/pepper_flash_renderer_host_qt.h \ - renderer/pepper/pepper_renderer_host_factory_qt.h + renderer/pepper/pepper_renderer_host_factory_qt.h \ + renderer/plugins/loadable_plugin_placeholder_qt.h } qtConfig(webengine-printing-and-pdf) { diff --git a/src/core/download_manager_delegate_qt.cpp b/src/core/download_manager_delegate_qt.cpp index fe7f7c57b..ebf498fdf 100644 --- a/src/core/download_manager_delegate_qt.cpp +++ b/src/core/download_manager_delegate_qt.cpp @@ -241,7 +241,7 @@ void DownloadManagerDelegateQt::ChooseSavePath(content::WebContents *web_content const base::FilePath &suggested_path, const base::FilePath::StringType &default_extension, bool can_save_as_complete, - const content::SavePackagePathPickedCallback &callback) + content::SavePackagePathPickedCallback callback) { Q_UNUSED(default_extension); Q_UNUSED(can_save_as_complete); @@ -308,29 +308,9 @@ void DownloadManagerDelegateQt::ChooseSavePath(content::WebContents *web_content if (!info.accepted) return; - callback.Run(toFilePath(info.path), static_cast(info.savePageFormat), - base::Bind(&DownloadManagerDelegateQt::savePackageDownloadCreated, - m_weakPtrFactory.GetWeakPtr())); -} - -bool DownloadManagerDelegateQt::IsMostRecentDownloadItemAtFilePath(download::DownloadItem *download) -{ - content::BrowserContext *context = content::DownloadItemUtils::GetBrowserContext(download); - std::vector all_downloads; - - content::DownloadManager* manager = - content::BrowserContext::GetDownloadManager(context); - if (manager) - manager->GetAllDownloads(&all_downloads); - - for (const auto* item : all_downloads) { - if (item->GetGuid() == download->GetGuid() || - item->GetTargetFilePath() != download->GetTargetFilePath()) - continue; - if (item->GetState() == download::DownloadItem::IN_PROGRESS) - return false; - } - return true; + std::move(callback).Run(toFilePath(info.path), static_cast(info.savePageFormat), + base::Bind(&DownloadManagerDelegateQt::savePackageDownloadCreated, + m_weakPtrFactory.GetWeakPtr())); } void DownloadManagerDelegateQt::savePackageDownloadCreated(download::DownloadItem *item) diff --git a/src/core/download_manager_delegate_qt.h b/src/core/download_manager_delegate_qt.h index 4634790cc..0cdbd6ee3 100644 --- a/src/core/download_manager_delegate_qt.h +++ b/src/core/download_manager_delegate_qt.h @@ -82,9 +82,7 @@ public: const base::FilePath &suggested_path, const base::FilePath::StringType &default_extension, bool can_save_as_complete, - const content::SavePackagePathPickedCallback &callback) override; - bool IsMostRecentDownloadItemAtFilePath(download::DownloadItem* download) override; - + content::SavePackagePathPickedCallback callback) override; void cancelDownload(quint32 downloadId); void pauseDownload(quint32 downloadId); diff --git a/src/core/extensions/extensions_browser_client_qt.cpp b/src/core/extensions/extensions_browser_client_qt.cpp index a91127192..8b5da3d60 100644 --- a/src/core/extensions/extensions_browser_client_qt.cpp +++ b/src/core/extensions/extensions_browser_client_qt.cpp @@ -63,13 +63,13 @@ #include "extensions/browser/event_router.h" #include "extensions/browser/extension_host_delegate.h" #include "extensions/browser/extension_protocols.h" +#include "extensions/browser/extensions_browser_interface_binders.h" #include "extensions/browser/mojo/interface_registration.h" #include "extensions/browser/url_request_util.h" #include "extensions/common/file_util.h" #include "mojo/public/cpp/bindings/strong_binding.h" #include "net/base/completion_once_callback.h" #include "net/base/mime_util.h" -#include "net/url_request/url_request_simple_job.h" #include "services/network/public/cpp/resource_response.h" #include "services/network/public/mojom/url_loader.mojom.h" #include "third_party/zlib/google/compression_utils.h" @@ -144,9 +144,11 @@ scoped_refptr GetResource(int resource_id, const std::st class ResourceBundleFileLoader : public network::mojom::URLLoader { public: - static void CreateAndStart(const network::ResourceRequest &request, network::mojom::URLLoaderRequest loader, - network::mojom::URLLoaderClientPtrInfo client_info, const base::FilePath &filename, - int resource_id, const std::string &content_security_policy, bool send_cors_header) + static void CreateAndStart(const network::ResourceRequest &request, + mojo::PendingReceiver loader, + mojo::PendingRemote client_info, + const base::FilePath &filename, int resource_id, + const std::string &content_security_policy, bool send_cors_header) { // Owns itself. Will live as long as its URLLoader and URLLoaderClientPtr // bindings are alive - essentially until either the client gives up or all @@ -174,10 +176,12 @@ private: } ~ResourceBundleFileLoader() override = default; - void Start(const network::ResourceRequest &request, network::mojom::URLLoaderRequest loader, - network::mojom::URLLoaderClientPtrInfo client_info, const base::FilePath &filename, int resource_id) + void Start(const network::ResourceRequest &request, + mojo::PendingReceiver loader, + mojo::PendingRemote client_info_remote, + const base::FilePath &filename, int resource_id) { - client_.Bind(std::move(client_info)); + client_.Bind(std::move(client_info_remote)); binding_.Bind(std::move(loader)); binding_.set_connection_error_handler( base::BindOnce(&ResourceBundleFileLoader::OnBindingError, base::Unretained(this))); @@ -364,14 +368,14 @@ base::FilePath ExtensionsBrowserClientQt::GetBundleResourcePath(const network::R // Creates and starts a URLLoader to load an extension resource from the // embedder's resource bundle (.pak) files. Used for component extensions. void ExtensionsBrowserClientQt::LoadResourceFromResourceBundle(const network::ResourceRequest &request, - network::mojom::URLLoaderRequest loader, + mojo::PendingReceiver loader, const base::FilePath &resource_relative_path, int resource_id, const std::string &content_security_policy, - network::mojom::URLLoaderClientPtr client, + mojo::PendingRemote client, bool send_cors_header) { - ResourceBundleFileLoader::CreateAndStart(request, std::move(loader), client.PassInterface(), resource_relative_path, + ResourceBundleFileLoader::CreateAndStart(request, std::move(loader), std::move(client), resource_relative_path, resource_id, content_security_policy, send_cors_header); } @@ -460,6 +464,18 @@ void ExtensionsBrowserClientQt::RegisterExtensionInterfaces(service_manager::Bin RegisterInterfacesForExtension(registry, render_frame_host, extension); } +void ExtensionsBrowserClientQt::RegisterBrowserInterfaceBindersForFrame( + service_manager::BinderMapWithContext *binder_map, + content::RenderFrameHost* render_frame_host, + const Extension* extension) const +{ + PopulateExtensionFrameBinders(binder_map, render_frame_host, extension); + + // FIXME Do we need something from here? + // PopulateChromeFrameBindersForExtension(binder_map, render_frame_host, + // extension); +} + std::unique_ptr ExtensionsBrowserClientQt::CreateRuntimeAPIDelegate(content::BrowserContext *context) const { // TODO(extensions): Implement to support Apps. diff --git a/src/core/extensions/extensions_browser_client_qt.h b/src/core/extensions/extensions_browser_client_qt.h index 1a90bae95..97da83240 100644 --- a/src/core/extensions/extensions_browser_client_qt.h +++ b/src/core/extensions/extensions_browser_client_qt.h @@ -91,7 +91,8 @@ public: bool IsRunningInForcedAppMode() override; bool IsLoggedInAsPublicAccount() override; ExtensionSystemProvider *GetExtensionSystemFactory() override; -// void RegisterExtensionFunctions(ExtensionFunctionRegistry *registry) const; + void RegisterBrowserInterfaceBindersForFrame(service_manager::BinderMapWithContext *, + content::RenderFrameHost *, const extensions::Extension *) const override; std::unique_ptr CreateRuntimeAPIDelegate(content::BrowserContext *context) const override; void RegisterExtensionInterfaces(service_manager::BinderRegistryWithArgs *registry, content::RenderFrameHost *render_frame_host, @@ -122,11 +123,11 @@ public: // Creates and starts a URLLoader to load an extension resource from the // embedder's resource bundle (.pak) files. Used for component extensions. void LoadResourceFromResourceBundle(const network::ResourceRequest &request, - network::mojom::URLLoaderRequest loader, + mojo::PendingReceiver loader, const base::FilePath &resource_relative_path, int resource_id, const std::string &content_security_policy, - network::mojom::URLLoaderClientPtr client, + mojo::PendingRemote client, bool send_cors_header) override; // Returns the locale used by the application. diff --git a/src/core/favicon_manager.cpp b/src/core/favicon_manager.cpp index a06da6769..412aab90d 100644 --- a/src/core/favicon_manager.cpp +++ b/src/core/favicon_manager.cpp @@ -96,6 +96,7 @@ int FaviconManager::downloadIcon(const QUrl &url) id = m_webContents->DownloadImage( toGurl(url), true, // is_favicon + 0, // preferred_size maxSize, false, // normal cache policy base::Bind(&FaviconManager::iconDownloadFinished, m_weakFactory->GetWeakPtr())); diff --git a/src/core/net/custom_url_loader_factory.cpp b/src/core/net/custom_url_loader_factory.cpp index a96b35696..e5f580536 100644 --- a/src/core/net/custom_url_loader_factory.cpp +++ b/src/core/net/custom_url_loader_factory.cpp @@ -441,12 +441,12 @@ public: ~CustomURLLoaderFactory() override = default; // network::mojom::URLLoaderFactory: - void CreateLoaderAndStart(network::mojom::URLLoaderRequest loader, + void CreateLoaderAndStart(mojo::PendingReceiver loader, int32_t routing_id, int32_t request_id, uint32_t options, const network::ResourceRequest &request, - network::mojom::URLLoaderClientPtr client, + mojo::PendingRemote client, const net::MutableNetworkTrafficAnnotationTag &traffic_annotation) override { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); @@ -457,7 +457,7 @@ public: m_taskRunner->PostTask(FROM_HERE, base::BindOnce(&CustomURLLoader::CreateAndStart, request, - std::move(loader), client.PassInterface(), + std::move(loader), std::move(client), m_profileAdapter)); } 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 2b6158f4a..d854a556c 100644 --- a/src/core/net/plugin_response_interceptor_url_loader_throttle.cpp +++ b/src/core/net/plugin_response_interceptor_url_loader_throttle.cpp @@ -104,7 +104,7 @@ PluginResponseInterceptorURLLoaderThrottle::PluginResponseInterceptorURLLoaderTh {} void PluginResponseInterceptorURLLoaderThrottle::WillProcessResponse(const GURL &response_url, - network::ResourceResponseHead *response_head, + network::mojom::URLResponseHead *response_head, bool *defer) { Q_UNUSED(defer); diff --git a/src/core/net/plugin_response_interceptor_url_loader_throttle.h b/src/core/net/plugin_response_interceptor_url_loader_throttle.h index 1fc9e654f..7b9db6490 100644 --- a/src/core/net/plugin_response_interceptor_url_loader_throttle.h +++ b/src/core/net/plugin_response_interceptor_url_loader_throttle.h @@ -61,7 +61,7 @@ public: private: // content::URLLoaderThrottle overrides; - void WillProcessResponse(const GURL &response_url, network::ResourceResponseHead *response_head, bool *defer) override; + void WillProcessResponse(const GURL &response_url, network::mojom::URLResponseHead *response_head, bool *defer) override; content::ResourceContext *m_resource_context = nullptr; content::BrowserContext *m_browser_context = nullptr; diff --git a/src/core/net/proxying_url_loader_factory_qt.cpp b/src/core/net/proxying_url_loader_factory_qt.cpp index 4931bb3e3..71f710737 100644 --- a/src/core/net/proxying_url_loader_factory_qt.cpp +++ b/src/core/net/proxying_url_loader_factory_qt.cpp @@ -97,8 +97,9 @@ public: const network::ResourceRequest &request, const net::MutableNetworkTrafficAnnotationTag &traffic_annotation, ProfileIODataQt *profileData, - network::mojom::URLLoaderRequest loader_request, network::mojom::URLLoaderClientPtr client, - network::mojom::URLLoaderFactoryPtr target_factory); + mojo::PendingReceiver loader, + mojo::PendingRemote client, + mojo::PendingRemote target_factory); ~InterceptedRequest() override; void Start(); @@ -158,12 +159,12 @@ private: QWebEngineUrlRequestInfo m_requestInfo; ProfileIODataQt *m_profileData; - mojo::Binding proxied_loader_binding_; - network::mojom::URLLoaderClientPtr target_client_; + mojo::Receiver proxied_loader_receiver_; + mojo::Remote target_client_; - mojo::Binding proxied_client_binding_; - network::mojom::URLLoaderPtr target_loader_; - network::mojom::URLLoaderFactoryPtr target_factory_; + mojo::Receiver proxied_client_receiver_{this}; + mojo::Remote target_loader_; + mojo::Remote target_factory_; base::WeakPtrFactory m_weakFactory; base::WeakPtr m_weakPtr; @@ -174,9 +175,9 @@ InterceptedRequest::InterceptedRequest(int process_id, uint64_t request_id, int3 const network::ResourceRequest &request, const net::MutableNetworkTrafficAnnotationTag &traffic_annotation, ProfileIODataQt *profileData, - network::mojom::URLLoaderRequest loader_request, - network::mojom::URLLoaderClientPtr client, - network::mojom::URLLoaderFactoryPtr target_factory) + mojo::PendingReceiver loader_receiver, + mojo::PendingRemote client, + mojo::PendingRemote target_factory) : process_id_(process_id) , request_id_(request_id) , routing_id_(routing_id) @@ -184,18 +185,17 @@ InterceptedRequest::InterceptedRequest(int process_id, uint64_t request_id, int3 , request_(request) , traffic_annotation_(traffic_annotation) , m_profileData(profileData) - , proxied_loader_binding_(this, std::move(loader_request)) + , proxied_loader_receiver_(this, std::move(loader_receiver)) , target_client_(std::move(client)) - , proxied_client_binding_(this) , target_factory_(std::move(target_factory)) , m_weakFactory(this) , m_weakPtr(m_weakFactory.GetWeakPtr()) { // If there is a client error, clean up the request. - target_client_.set_connection_error_handler( - base::BindOnce(&InterceptedRequest::OnURLLoaderClientError, m_weakFactory.GetWeakPtr())); - proxied_loader_binding_.set_connection_error_with_reason_handler( - base::BindOnce(&InterceptedRequest::OnURLLoaderError, m_weakFactory.GetWeakPtr())); + target_client_.set_disconnect_handler( + base::BindOnce(&InterceptedRequest::OnURLLoaderClientError, m_weakFactory.GetWeakPtr())); + proxied_loader_receiver_.set_disconnect_with_reason_handler( + base::BindOnce(&InterceptedRequest::OnURLLoaderError, m_weakFactory.GetWeakPtr())); } InterceptedRequest::~InterceptedRequest() @@ -341,10 +341,9 @@ void InterceptedRequest::ContinueAfterIntercept() } if (!target_loader_ && target_factory_) { - network::mojom::URLLoaderClientPtr proxied_client; - proxied_client_binding_.Bind(mojo::MakeRequest(&proxied_client)); - target_factory_->CreateLoaderAndStart(mojo::MakeRequest(&target_loader_), routing_id_, request_id_, options_, - request_, std::move(proxied_client), traffic_annotation_); + target_factory_->CreateLoaderAndStart(target_loader_.BindNewPipeAndPassReceiver(), routing_id_, request_id_, + options_, request_, proxied_client_receiver_.BindNewPipeAndPassRemote(), + traffic_annotation_); } } @@ -460,18 +459,18 @@ void InterceptedRequest::CallOnComplete(const network::URLLoaderCompletionStatus if (target_client_) target_client_->OnComplete(status); - if (proxied_loader_binding_ && wait_for_loader_error) { - // Don't delete |this| yet, in case the |proxied_loader_binding_|'s + if (proxied_loader_receiver_.is_bound() && wait_for_loader_error) { + // Since the original client is gone no need to continue loading the + // request. + proxied_client_receiver_.reset(); + target_loader_.reset(); + + // Don't delete |this| yet, in case the |proxied_loader_receiver_|'s // error_handler is called with a reason to indicate an error which we want // to send to the client bridge. Also reset |target_client_| so we don't // get its error_handler called and then delete |this|. target_client_.reset(); - // Since the original client is gone no need to continue loading the - // request. - proxied_client_binding_.Close(); - target_loader_.reset(); - // In case there are pending checks as to whether this request should be // intercepted, we don't want that causing |target_client_| to be used // later. @@ -523,10 +522,10 @@ void ProxyingURLLoaderFactoryQt::CreateProxy(int process_id, new ProxyingURLLoaderFactoryQt(process_id, resourceContext, std::move(loader_receiver), std::move(target_factory_info)); } -void ProxyingURLLoaderFactoryQt::CreateLoaderAndStart(network::mojom::URLLoaderRequest loader, int32_t routing_id, - int32_t request_id, uint32_t options, +void ProxyingURLLoaderFactoryQt::CreateLoaderAndStart(mojo::PendingReceiver loader, + int32_t routing_id, int32_t request_id, uint32_t options, const network::ResourceRequest &request, - network::mojom::URLLoaderClientPtr client, + mojo::PendingRemote client, const net::MutableNetworkTrafficAnnotationTag &traffic_annotation) { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); @@ -541,9 +540,9 @@ void ProxyingURLLoaderFactoryQt::CreateLoaderAndStart(network::mojom::URLLoaderR return; } - network::mojom::URLLoaderFactoryPtr target_factory_clone; + mojo::PendingRemote target_factory_clone; if (m_targetFactory) - m_targetFactory->Clone(mojo::MakeRequest(&target_factory_clone)); + m_targetFactory->Clone(target_factory_clone.InitWithNewPipeAndPassReceiver()); // Will manage its own lifetime InterceptedRequest *req = new InterceptedRequest(m_processId, request_id, routing_id, options, request, diff --git a/src/core/net/proxying_url_loader_factory_qt.h b/src/core/net/proxying_url_loader_factory_qt.h index 0a436fd81..ba19bab97 100644 --- a/src/core/net/proxying_url_loader_factory_qt.h +++ b/src/core/net/proxying_url_loader_factory_qt.h @@ -78,9 +78,10 @@ public: mojo::PendingReceiver loader_receiver, network::mojom::URLLoaderFactoryPtrInfo target_factory_info); - void CreateLoaderAndStart(network::mojom::URLLoaderRequest loader, int32_t routing_id, int32_t request_id, + void CreateLoaderAndStart(mojo::PendingReceiver loader, + int32_t routing_id, int32_t request_id, uint32_t options, const network::ResourceRequest &request, - network::mojom::URLLoaderClientPtr client, + mojo::PendingRemote client, const net::MutableNetworkTrafficAnnotationTag &traffic_annotation) override; void Clone(mojo::PendingReceiver receiver) override; diff --git a/src/core/net/ssl_host_state_delegate_qt.cpp b/src/core/net/ssl_host_state_delegate_qt.cpp index f327717e9..3f3f95c83 100644 --- a/src/core/net/ssl_host_state_delegate_qt.cpp +++ b/src/core/net/ssl_host_state_delegate_qt.cpp @@ -83,7 +83,7 @@ void SSLHostStateDelegateQt::AllowCert(const std::string &host, const net::X509C } // Clear all allow preferences. -void SSLHostStateDelegateQt::Clear(const base::Callback &host_filter) +void SSLHostStateDelegateQt::Clear(base::RepeatingCallback host_filter) { if (host_filter.is_null()) { m_certPolicyforHost.clear(); diff --git a/src/core/net/ssl_host_state_delegate_qt.h b/src/core/net/ssl_host_state_delegate_qt.h index b3b89f117..26e503eb5 100644 --- a/src/core/net/ssl_host_state_delegate_qt.h +++ b/src/core/net/ssl_host_state_delegate_qt.h @@ -67,7 +67,7 @@ public: // content::SSLHostStateDelegate implementation: void AllowCert(const std::string &, const net::X509Certificate &cert, int error) override; - void Clear(const base::Callback &host_filter) override; + void Clear(base::RepeatingCallback host_filter) override; CertJudgment QueryPolicy(const std::string &host, const net::X509Certificate &cert, int error) override; void HostRanInsecureContent(const std::string &host, int child_id, InsecureContentType content_type) override; bool DidHostRunInsecureContent(const std::string &host, int child_id, InsecureContentType content_type) override; diff --git a/src/core/net/system_network_context_manager.cpp b/src/core/net/system_network_context_manager.cpp index 2c5f49615..bc42a684d 100644 --- a/src/core/net/system_network_context_manager.cpp +++ b/src/core/net/system_network_context_manager.cpp @@ -74,7 +74,7 @@ #include "net/net_buildflags.h" #include "net/third_party/uri_template/uri_template.h" #include "services/network/network_service.h" -#include "services/network/public/cpp/cross_thread_shared_url_loader_factory_info.h" +#include "services/network/public/cpp/cross_thread_pending_shared_url_loader_factory.h" #include "services/network/public/cpp/features.h" #include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/public/mojom/host_resolver.mojom.h" @@ -122,19 +122,23 @@ public: // mojom::URLLoaderFactory implementation: - void CreateLoaderAndStart(network::mojom::URLLoaderRequest request, int32_t routing_id, int32_t request_id, - uint32_t options, const network::ResourceRequest &url_request, - network::mojom::URLLoaderClientPtr client, + void CreateLoaderAndStart(mojo::PendingReceiver receiver, + int32_t routing_id, + int32_t request_id, + uint32_t options, + const network::ResourceRequest &url_request, + mojo::PendingRemote client, const net::MutableNetworkTrafficAnnotationTag &traffic_annotation) override { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); if (!manager_) return; - manager_->GetURLLoaderFactory()->CreateLoaderAndStart(std::move(request), routing_id, request_id, options, - url_request, std::move(client), traffic_annotation); + manager_->GetURLLoaderFactory()->CreateLoaderAndStart( + std::move(receiver), routing_id, request_id, options, url_request, + std::move(client), traffic_annotation); } - void Clone(mojo::PendingReceiver receiver) + void Clone(mojo::PendingReceiver receiver) override { if (!manager_) return; @@ -142,10 +146,10 @@ public: } // SharedURLLoaderFactory implementation: - std::unique_ptr Clone() override + std::unique_ptr Clone() override { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - return std::make_unique(this); + return std::make_unique(this); } void Shutdown() { manager_ = nullptr; } diff --git a/src/core/ozone/BUILD.gn b/src/core/ozone/BUILD.gn index b96d8a47a..4d27f8877 100644 --- a/src/core/ozone/BUILD.gn +++ b/src/core/ozone/BUILD.gn @@ -18,8 +18,4 @@ source_set("qt") { ] defines = [ "OZONE_IMPLEMENTATION" ] - - if (is_linux && !is_desktop_linux) { - deps += [ "//ui/events/ozone:events_ozone_evdev"] - } } diff --git a/src/core/ozone/gl_ozone_glx_qt.cpp b/src/core/ozone/gl_ozone_glx_qt.cpp index f934a5c80..0c54299ba 100644 --- a/src/core/ozone/gl_ozone_glx_qt.cpp +++ b/src/core/ozone/gl_ozone_glx_qt.cpp @@ -95,9 +95,10 @@ bool GLOzoneGLXQt::InitializeStaticGLBindings( return true; } -void GLOzoneGLXQt::InitializeDebugGLBindings() { - gl::InitializeDebugGLBindingsGL(); - gl::InitializeDebugGLBindingsGLX(); +void GLOzoneGLXQt::InitializeLogGLBindings() +{ + gl::InitializeLogGLBindingsGL(); + gl::InitializeLogGLBindingsGLX(); } void GLOzoneGLXQt::SetDisabledExtensionsPlatform( diff --git a/src/core/ozone/gl_ozone_glx_qt.h b/src/core/ozone/gl_ozone_glx_qt.h index 1596ea12f..8f85ea23b 100644 --- a/src/core/ozone/gl_ozone_glx_qt.h +++ b/src/core/ozone/gl_ozone_glx_qt.h @@ -54,7 +54,7 @@ public: bool InitializeGLOneOffPlatform() override; bool InitializeStaticGLBindings(gl::GLImplementation implementation) override; - void InitializeDebugGLBindings() override; + void InitializeLogGLBindings() override; bool InitializeExtensionSettingsOneOffPlatform() override; void ShutdownGL() override; void SetDisabledExtensionsPlatform( diff --git a/src/core/ozone/ozone_platform_qt.cpp b/src/core/ozone/ozone_platform_qt.cpp index 887bc167e..fb5af18c5 100644 --- a/src/core/ozone/ozone_platform_qt.cpp +++ b/src/core/ozone/ozone_platform_qt.cpp @@ -48,6 +48,7 @@ #include "ui/ozone/public/gpu_platform_support_host.h" #include "ui/ozone/public/input_controller.h" #include "ui/ozone/public/ozone_platform.h" +#include "ui/ozone/public/platform_screen.h" #include "ui/ozone/public/system_input_injector.h" #include "ui/platform_window/platform_window_delegate.h" #include "ui/platform_window/platform_window_init_properties.h" @@ -67,13 +68,13 @@ public: ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override; ui::CursorFactoryOzone* GetCursorFactoryOzone() override; GpuPlatformSupportHost* GetGpuPlatformSupportHost() override; - std::unique_ptr CreatePlatformWindow(PlatformWindowDelegate* delegate, PlatformWindowInitProperties properties) override; + std::unique_ptr CreatePlatformWindow(PlatformWindowDelegate* delegate, PlatformWindowInitProperties properties) override; std::unique_ptr CreateNativeDisplayDelegate() override; ui::InputController* GetInputController() override; std::unique_ptr CreateSystemInputInjector() override; ui::OverlayManagerOzone* GetOverlayManager() override; std::unique_ptr CreateInputMethod(internal::InputMethodDelegate *delegate) override; - + std::unique_ptr CreateScreen() override { return nullptr; } private: void InitializeUI(const ui::OzonePlatform::InitParams &) override; void InitializeGPU(const ui::OzonePlatform::InitParams &) override; @@ -108,7 +109,7 @@ GpuPlatformSupportHost* OzonePlatformQt::GetGpuPlatformSupportHost() return gpu_platform_support_host_.get(); } -std::unique_ptr OzonePlatformQt::CreatePlatformWindow(PlatformWindowDelegate* delegate, PlatformWindowInitProperties properties) +std::unique_ptr OzonePlatformQt::CreatePlatformWindow(PlatformWindowDelegate* delegate, PlatformWindowInitProperties properties) { return base::WrapUnique(new PlatformWindowQt(delegate, properties.bounds)); } diff --git a/src/core/ozone/platform_window_qt.h b/src/core/ozone/platform_window_qt.h index 344e9b115..b1021df9d 100644 --- a/src/core/ozone/platform_window_qt.h +++ b/src/core/ozone/platform_window_qt.h @@ -45,12 +45,12 @@ #include "ui/events/platform/platform_event_dispatcher.h" #include "ui/gfx/geometry/point.h" #include "ui/gfx/geometry/rect.h" -#include "ui/platform_window/platform_window_base.h" +#include "ui/platform_window/platform_window.h" #include "ui/platform_window/platform_window_delegate.h" namespace ui { -class PlatformWindowQt : public PlatformWindowBase, public PlatformEventDispatcher +class PlatformWindowQt : public PlatformWindow, public PlatformEventDispatcher { public: PlatformWindowQt(PlatformWindowDelegate* delegate, const gfx::Rect& bounds); diff --git a/src/core/permission_manager_qt.cpp b/src/core/permission_manager_qt.cpp index decc6dd7c..c6eb2c238 100644 --- a/src/core/permission_manager_qt.cpp +++ b/src/core/permission_manager_qt.cpp @@ -82,6 +82,7 @@ ProfileAdapter::PermissionType toQt(content::PermissionType type) case content::PermissionType::PERIODIC_BACKGROUND_SYNC: case content::PermissionType::WAKE_LOCK_SCREEN: case content::PermissionType::WAKE_LOCK_SYSTEM: + case content::PermissionType::NFC: case content::PermissionType::NUM: NOTIMPLEMENTED() << "Unsupported permission type: " << static_cast(type); break; diff --git a/src/core/printing/print_view_manager_base_qt.cpp b/src/core/printing/print_view_manager_base_qt.cpp index 0cc334776..34c86e506 100644 --- a/src/core/printing/print_view_manager_base_qt.cpp +++ b/src/core/printing/print_view_manager_base_qt.cpp @@ -48,7 +48,6 @@ #include "web_engine_context.h" #include "base/memory/ref_counted_memory.h" -#include "base/memory/shared_memory.h" #include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop_current.h" #include "base/run_loop.h" @@ -427,12 +426,8 @@ void PrintViewManagerBaseQt::ReleasePrintJob() if (!m_printJob.get()) return; - if (rfh) { - auto msg = std::make_unique(rfh->GetRoutingID(), - m_didPrintingSucceed); - rfh->Send(msg.release()); - } - + if (rfh) + GetPrintRenderFrame(rfh)->PrintingDone(m_didPrintingSucceed); m_registrar.Remove(this, chrome::NOTIFICATION_PRINT_JOB_EVENT, content::Source(m_printJob.get())); @@ -543,7 +538,7 @@ void PrintViewManagerBaseQt::StopWorker(int documentCookie) void PrintViewManagerBaseQt::SendPrintingEnabled(bool enabled, content::RenderFrameHost* rfh) { - rfh->Send(new PrintMsg_SetPrintingEnabled(rfh->GetRoutingID(), enabled)); + GetPrintRenderFrame(rfh)->SetPrintingEnabled(enabled); } } // namespace QtWebEngineCore diff --git a/src/core/printing/print_view_manager_qt.cpp b/src/core/printing/print_view_manager_qt.cpp index ebaad9a80..79e92fd6a 100644 --- a/src/core/printing/print_view_manager_qt.cpp +++ b/src/core/printing/print_view_manager_qt.cpp @@ -270,7 +270,7 @@ bool PrintViewManagerQt::PrintToPDFInternal(const QPageLayout &pageLayout, return false; content::RenderFrameHost* rfh = web_contents()->GetMainFrame(); - GetPrintRenderFrame(rfh)->InitiatePrintPreview(nullptr, false); + GetPrintRenderFrame(rfh)->InitiatePrintPreview(mojo::PendingAssociatedRemote(), false); DCHECK(!m_printPreviewRfh); m_printPreviewRfh = rfh; diff --git a/src/core/printing/printing_message_filter_qt.h b/src/core/printing/printing_message_filter_qt.h index 88559d3df..89e473dcf 100644 --- a/src/core/printing/printing_message_filter_qt.h +++ b/src/core/printing/printing_message_filter_qt.h @@ -50,10 +50,6 @@ #include "components/prefs/pref_member.h" #include "content/public/browser/browser_message_filter.h" -#if defined(OS_WIN) -#include "base/memory/shared_memory.h" -#endif - struct PrintHostMsg_PreviewIds; struct PrintHostMsg_ScriptedPrint_Params; diff --git a/src/core/qtwebengine.gni b/src/core/qtwebengine.gni index f17f28495..a5628bb88 100644 --- a/src/core/qtwebengine.gni +++ b/src/core/qtwebengine.gni @@ -22,7 +22,7 @@ deps = [ "//components/keyed_service/content", "//components/navigation_interception", "//components/network_hints/browser", - "//components/network_hints/common", + "//components/network_hints/common:mojo_bindings", "//components/network_hints/renderer", "//components/visitedlink/browser", "//components/visitedlink/renderer", @@ -34,7 +34,7 @@ deps = [ "//content/public/app:browser", "//content", "//media:media_buildflags", - "//net:net_with_v8", + "//net", "//services/proxy_resolver:lib", "//skia", "//third_party/blink/public:blink", @@ -48,7 +48,7 @@ deps = [ ] if (enable_webrtc) { - deps += [ "//third_party/webrtc_overrides" ] + deps += [ "//third_party/webrtc_overrides:webrtc_component" ] } if (use_ozone) { diff --git a/src/core/qtwebengine_resources.gni b/src/core/qtwebengine_resources.gni index 749546741..4f6c51d81 100644 --- a/src/core/qtwebengine_resources.gni +++ b/src/core/qtwebengine_resources.gni @@ -25,6 +25,7 @@ repack("qtwebengine_repack_resources") { "$root_gen_dir/chrome/common_resources.pak", "$root_gen_dir/chrome/quota_internals_resources.pak", "$root_gen_dir/components/components_resources.pak", + "$root_gen_dir/content/browser/resources/media/media_internals_resources.pak", "$root_gen_dir/content/content_resources.pak", "$root_gen_dir/mojo/public/js/mojo_bindings_resources.pak", "$root_gen_dir/net/net_resources.pak", @@ -34,10 +35,11 @@ repack("qtwebengine_repack_resources") { output = "$root_out_dir/qtwebengine_resources.pak" deps = [ "//qtwebengine/browser:qt_webengine_resources", - "//chrome/browser/resources:quota_internals_resources", + "//chrome/browser/resources/quota_internals:quota_internals_resources", "//chrome/browser:resources_grit", "//chrome/common:resources_grit", "//components/resources:components_resources_grit", + "//content/browser/resources/media:media_internals_resources", "//content:resources_grit", "//mojo/public/js:resources", "//net:net_resources_grit", @@ -58,6 +60,14 @@ repack("qtwebengine_repack_resources") { ] } + if (enable_webrtc) { + sources += [ + "$root_gen_dir/content/browser/webrtc/resources/webrtc_internals_resources.pak", + ] + deps += [ + "//content/browser/webrtc/resources", + ] + } } repack("qtwebengine_repack_resources_100") { diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index c1b1791cf..813ce4be9 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -1840,7 +1840,6 @@ const viz::LocalSurfaceIdAllocation &RenderWidgetHostViewQt::GetLocalSurfaceIdAl void RenderWidgetHostViewQt::TakeFallbackContentFrom(content::RenderWidgetHostView *view) { DCHECK(!static_cast(view)->IsRenderWidgetHostViewChildFrame()); - DCHECK(!static_cast(view)->IsRenderWidgetHostViewGuest()); RenderWidgetHostViewQt *viewQt = static_cast(view); base::Optional color = viewQt->GetBackgroundColor(); if (color) diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp index f7c8a497b..b2138a82a 100644 --- a/src/core/renderer/content_renderer_client_qt.cpp +++ b/src/core/renderer/content_renderer_client_qt.cpp @@ -39,7 +39,6 @@ #include "renderer/content_renderer_client_qt.h" -#include "common/qt_messages.h" #include "extensions/buildflags/buildflags.h" #include "printing/buildflags/buildflags.h" #include "renderer/content_settings_observer_qt.h" @@ -53,20 +52,20 @@ #include "components/error_page/common/error.h" #include "components/error_page/common/error_page_params.h" #include "components/error_page/common/localized_error.h" -#include "components/network_hints/renderer/prescient_networking_dispatcher.h" +#include "components/network_hints/renderer/web_prescient_networking_impl.h" #if QT_CONFIG(webengine_printing_and_pdf) #include "components/printing/renderer/print_render_frame_helper.h" #endif -#include "components/visitedlink/renderer/visitedlink_slave.h" +#include "components/visitedlink/renderer/visitedlink_reader.h" #include "components/web_cache/renderer/web_cache_impl.h" #include "content/public/renderer/render_frame.h" #include "content/public/child/child_thread.h" -#include "content/public/common/service_manager_connection.h" -#include "content/public/common/simple_connection_filter.h" +#include "content/public/common/url_constants.h" #include "content/public/renderer/render_thread.h" #include "content/public/renderer/render_view.h" #include "media/base/key_system_properties.h" #include "media/media_buildflags.h" +#include "mojo/public/cpp/bindings/binder_map.h" #include "net/base/net_errors.h" #include "services/service_manager/public/cpp/connector.h" #include "services/service_manager/public/cpp/interface_provider.h" @@ -82,6 +81,7 @@ #include "renderer/print_web_view_helper_delegate_qt.h" #endif +#include "common/qt_messages.h" #include "renderer/render_frame_observer_qt.h" #include "renderer/render_view_observer_qt.h" #include "renderer/render_thread_observer_qt.h" @@ -134,16 +134,9 @@ void ContentRendererClientQt::RenderThreadStarted() { content::RenderThread *renderThread = content::RenderThread::Get(); m_renderThreadObserver.reset(new RenderThreadObserverQt()); - m_visitedLinkSlave.reset(new visitedlink::VisitedLinkSlave); + m_visitedLinkReader.reset(new visitedlink::VisitedLinkReader); m_webCacheImpl.reset(new web_cache::WebCacheImpl()); - m_prescientNetworkingDispatcher.reset(new network_hints::PrescientNetworkingDispatcher()); - - auto registry = std::make_unique(); - registry->AddInterface(m_visitedLinkSlave->GetBindCallback(), base::ThreadTaskRunnerHandle::Get()); - content::ChildThread::Get()->GetServiceManagerConnection()->AddConnectionFilter( - std::make_unique(std::move(registry))); - renderThread->AddObserver(m_renderThreadObserver.data()); renderThread->AddObserver(UserResourceController::instance()); @@ -174,6 +167,26 @@ void ContentRendererClientQt::RenderThreadStarted() #endif } +void ContentRendererClientQt::ExposeInterfacesToBrowser(mojo::BinderMap* binders) +{ + binders->Add(m_visitedLinkReader->GetBindCallback(), base::SequencedTaskRunnerHandle::Get()); + + binders->Add(base::BindRepeating(&web_cache::WebCacheImpl::BindReceiver, + base::Unretained(m_webCacheImpl.get())), + base::SequencedTaskRunnerHandle::Get()); + +#if QT_CONFIG(webengine_spellchecker) + binders->Add(base::BindRepeating( + [](ContentRendererClientQt *client, + mojo::PendingReceiver receiver) { + if (!client->m_spellCheck) + client->InitSpellCheck(); + client->m_spellCheck->BindReceiver(std::move(receiver)); + }, this), + base::SequencedTaskRunnerHandle::Get()); +#endif +} + void ContentRendererClientQt::RenderViewCreated(content::RenderView *render_view) { // RenderViewObservers destroy themselves with their RenderView. @@ -298,7 +311,7 @@ void ContentRendererClientQt::GetNavigationErrorStringsInternal(content::RenderF resourceId = IDR_NET_ERROR_HTML; - std::string extracted_string = ui::ResourceBundle::GetSharedInstance().DecompressDataResource(resourceId); + std::string extracted_string = ui::ResourceBundle::GetSharedInstance().LoadDataResourceString(resourceId); const base::StringPiece template_html(extracted_string.data(), extracted_string.size()); if (template_html.empty()) NOTREACHED() << "unable to load template. ID: " << resourceId; @@ -309,17 +322,17 @@ void ContentRendererClientQt::GetNavigationErrorStringsInternal(content::RenderF uint64_t ContentRendererClientQt::VisitedLinkHash(const char *canonicalUrl, size_t length) { - return m_visitedLinkSlave->ComputeURLFingerprint(canonicalUrl, length); + return m_visitedLinkReader->ComputeURLFingerprint(canonicalUrl, length); } bool ContentRendererClientQt::IsLinkVisited(uint64_t linkHash) { - return m_visitedLinkSlave->IsVisited(linkHash); + return m_visitedLinkReader->IsVisited(linkHash); } -blink::WebPrescientNetworking *ContentRendererClientQt::GetPrescientNetworking() +std::unique_ptr ContentRendererClientQt::CreatePrescientNetworking(content::RenderFrame *render_frame) { - return m_prescientNetworkingDispatcher.get(); + return std::make_unique(render_frame); } bool ContentRendererClientQt::OverrideCreatePlugin(content::RenderFrame *render_frame, @@ -586,25 +599,32 @@ void ContentRendererClientQt::AddSupportedKeySystems(std::vectorWillSendRequest(frame, transition_type, url, initiator_origin, new_url, - attach_same_site_cookies); + ExtensionsRendererClientQt::GetInstance()->WillSendRequest(frame, transition_type, url, /*site_for_cookies,*/ + initiator_origin, new_url, attach_same_site_cookies); if (!new_url->is_empty()) return; #endif - content::ContentRendererClient::WillSendRequest(frame, transition_type, url, initiator_origin, new_url, - attach_same_site_cookies); +} + +bool ContentRendererClientQt::RequiresWebComponentsV0(const GURL &url) +{ + Q_UNUSED(url); + // Google services still presents pages using these features + // to Chromium 80 based browsers (YouTube in particular). + return true; } } // namespace QtWebEngineCore diff --git a/src/core/renderer/content_renderer_client_qt.h b/src/core/renderer/content_renderer_client_qt.h index da70d29a8..f2e725453 100644 --- a/src/core/renderer/content_renderer_client_qt.h +++ b/src/core/renderer/content_renderer_client_qt.h @@ -57,12 +57,8 @@ namespace error_page { class Error; } -namespace network_hints { -class PrescientNetworkingDispatcher; -} - namespace visitedlink { -class VisitedLinkSlave; +class VisitedLinkReader; } namespace web_cache { @@ -91,6 +87,7 @@ public: // content::ContentRendererClient: void RenderThreadStarted() override; + void ExposeInterfacesToBrowser(mojo::BinderMap* binders) override; void RenderViewCreated(content::RenderView *render_view) override; void RenderFrameCreated(content::RenderFrame *render_frame) override; bool ShouldSuppressErrorPage(content::RenderFrame *, const GURL &) override; @@ -108,7 +105,7 @@ public: uint64_t VisitedLinkHash(const char *canonical_url, size_t length) override; bool IsLinkVisited(uint64_t linkHash) override; - blink::WebPrescientNetworking *GetPrescientNetworking() override; + std::unique_ptr CreatePrescientNetworking(content::RenderFrame *render_frame) override; void AddSupportedKeySystems(std::vector> *key_systems) override; void RunScriptsAtDocumentStart(content::RenderFrame *render_frame) override; @@ -125,11 +122,13 @@ public: void WillSendRequest(blink::WebLocalFrame *frame, ui::PageTransition transition_type, const blink::WebURL &url, + const blink::WebURL &site_for_cookies, const url::Origin *initiator_origin, GURL *new_url, bool *attach_same_site_cookies) override; void BindReceiverOnMainThread(mojo::GenericPendingReceiver receiver) override; + bool RequiresWebComponentsV0(const GURL &url) override; #if BUILDFLAG(ENABLE_PLUGINS) static blink::WebPlugin* CreatePlugin(content::RenderFrame* render_frame, @@ -148,14 +147,13 @@ private: const error_page::Error &error, std::string *errorHtml); QScopedPointer m_renderThreadObserver; - QScopedPointer m_visitedLinkSlave; + QScopedPointer m_visitedLinkReader; QScopedPointer m_webCacheImpl; #if QT_CONFIG(webengine_spellchecker) QScopedPointer m_spellCheck; #endif service_manager::BinderRegistry m_registry; - std::unique_ptr m_prescientNetworkingDispatcher; DISALLOW_COPY_AND_ASSIGN(ContentRendererClientQt); }; diff --git a/src/core/renderer/content_settings_observer_qt.cpp b/src/core/renderer/content_settings_observer_qt.cpp index fc7019367..df9b77037 100644 --- a/src/core/renderer/content_settings_observer_qt.cpp +++ b/src/core/renderer/content_settings_observer_qt.cpp @@ -59,8 +59,8 @@ namespace { bool IsUniqueFrame(blink::WebFrame *frame) { - return frame->GetSecurityOrigin().IsUnique() || - frame->Top()->GetSecurityOrigin().IsUnique(); + return frame->GetSecurityOrigin().IsOpaque() || + frame->Top()->GetSecurityOrigin().IsOpaque(); } } // namespace @@ -139,14 +139,15 @@ void ContentSettingsObserverQt::RequestFileSystemAccessAsync(base::OnceCallback< url::Origin(frame->Top()->GetSecurityOrigin()).GetURL())); } -bool ContentSettingsObserverQt::AllowIndexedDB(const WebSecurityOrigin &origin) +bool ContentSettingsObserverQt::AllowIndexedDB() { blink::WebFrame *frame = render_frame()->GetWebFrame(); if (IsUniqueFrame(frame)) return false; bool result = false; - Send(new QtWebEngineHostMsg_AllowIndexedDB(routing_id(), url::Origin(origin).GetURL(), + Send(new QtWebEngineHostMsg_AllowIndexedDB(routing_id(), + url::Origin(frame->GetSecurityOrigin()).GetURL(), url::Origin(frame->Top()->GetSecurityOrigin()).GetURL(), &result)); return result; } diff --git a/src/core/renderer/content_settings_observer_qt.h b/src/core/renderer/content_settings_observer_qt.h index 71e1fbca5..0c69d289c 100644 --- a/src/core/renderer/content_settings_observer_qt.h +++ b/src/core/renderer/content_settings_observer_qt.h @@ -69,7 +69,7 @@ public: // blink::WebContentSettingsClient: bool AllowDatabase() override; void RequestFileSystemAccessAsync(base::OnceCallback callback) override; - bool AllowIndexedDB(const blink::WebSecurityOrigin &origin) override; + bool AllowIndexedDB() override; bool AllowStorage(bool local) override; private: diff --git a/src/core/renderer_host/pepper/pepper_isolated_file_system_message_filter.cpp b/src/core/renderer_host/pepper/pepper_isolated_file_system_message_filter.cpp index bd93f0dd3..6e9efb5ad 100644 --- a/src/core/renderer_host/pepper/pepper_isolated_file_system_message_filter.cpp +++ b/src/core/renderer_host/pepper/pepper_isolated_file_system_message_filter.cpp @@ -58,7 +58,7 @@ #include "ppapi/host/ppapi_host.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/shared_impl/file_system_util.h" -#include "storage/browser/fileapi/isolated_context.h" +#include "storage/browser/file_system/isolated_context.h" namespace QtWebEngineCore { 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 c071a566a..9ed3749ad 100644 --- a/src/core/renderer_host/web_channel_ipc_transport_host.cpp +++ b/src/core/renderer_host/web_channel_ipc_transport_host.cpp @@ -74,7 +74,7 @@ WebChannelIPCTransportHost::WebChannelIPCTransportHost(content::WebContents *con : QWebChannelAbstractTransport(parent) , content::WebContentsObserver(contents) , m_worldId(worldId) - , m_binding(contents, this) + , m_receiver(contents, this) { for (content::RenderFrameHost *frame : contents->GetAllFrames()) setWorldId(frame, worldId); @@ -136,7 +136,7 @@ void WebChannelIPCTransportHost::DispatchWebChannelMessage(const std::vectorGetMainFrame(); - if (m_binding.GetCurrentTargetFrame() != frame) { + if (m_receiver.GetCurrentTargetFrame() != frame) { return; } 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 d53b24b6b..a1575355a 100644 --- a/src/core/renderer_host/web_channel_ipc_transport_host.h +++ b/src/core/renderer_host/web_channel_ipc_transport_host.h @@ -43,8 +43,7 @@ #include "qtwebenginecoreglobal.h" #include "content/public/browser/web_contents_observer.h" -#include "services/service_manager/public/cpp/binder_registry.h" -#include "content/public/browser/web_contents_binding_set.h" +#include "content/public/browser/web_contents_receiver_set.h" #include "qtwebengine/browser/qtwebchannel.mojom.h" #include @@ -82,7 +81,7 @@ private: // Empty only during construction/destruction. Synchronized to all the // WebChannelIPCTransports/RenderFrames in the observed WebContents. uint32_t m_worldId; - content::WebContentsFrameBindingSet m_binding; + content::WebContentsFrameReceiverSet m_receiver; }; } // namespace diff --git a/src/core/resource_bundle_qt.cpp b/src/core/resource_bundle_qt.cpp index 0e80859ae..61b0f3021 100644 --- a/src/core/resource_bundle_qt.cpp +++ b/src/core/resource_bundle_qt.cpp @@ -87,7 +87,7 @@ bool ResourceBundle::LocaleDataPakExists(const std::string& locale) } #endif - return !GetLocaleFilePath(locale, true).empty(); + return !GetLocaleFilePath(locale).empty(); } std::string ResourceBundle::LoadLocaleResources(const std::string& pref_locale) @@ -108,7 +108,7 @@ std::string ResourceBundle::LoadLocaleResources(const std::string& pref_locale) base::FilePath locale_file_path = GetOverriddenPakPath(); if (locale_file_path.empty()) - locale_file_path = GetLocaleFilePath(app_locale, true); + locale_file_path = GetLocaleFilePath(app_locale); if (locale_file_path.empty()) { // It's possible that there is no locale.pak. diff --git a/src/core/visited_links_manager_qt.cpp b/src/core/visited_links_manager_qt.cpp index d4885e8e8..37343cc39 100644 --- a/src/core/visited_links_manager_qt.cpp +++ b/src/core/visited_links_manager_qt.cpp @@ -45,12 +45,12 @@ #include #include "components/visitedlink/browser/visitedlink_delegate.h" -#include "components/visitedlink/browser/visitedlink_master.h" +#include "components/visitedlink/browser/visitedlink_writer.h" namespace QtWebEngineCore { namespace { -class BasicUrlIterator : public visitedlink::VisitedLinkMaster::URLIterator { +class BasicUrlIterator : public visitedlink::VisitedLinkWriter::URLIterator { public: BasicUrlIterator(const QList &urls) : m_urls(urls) {} virtual const GURL& NextURL() { m_currentUrl = toGurl(m_urls.takeFirst()); return m_currentUrl; } @@ -76,18 +76,18 @@ public: void VisitedLinksManagerQt::deleteAllVisitedLinkData() { - m_visitedLinkMaster->DeleteAllURLs(); + m_visitedLinkWriter->DeleteAllURLs(); } void VisitedLinksManagerQt::deleteVisitedLinkDataForUrls(const QList &urlsToDelete) { BasicUrlIterator iterator(urlsToDelete); - m_visitedLinkMaster->DeleteURLs(&iterator); + m_visitedLinkWriter->DeleteURLs(&iterator); } bool VisitedLinksManagerQt::containsUrl(const QUrl &url) const { - return m_visitedLinkMaster->IsVisited(toGurl(url)); + return m_visitedLinkWriter->IsVisited(toGurl(url)); } static void ensureDirectoryExists(const base::FilePath &path) @@ -111,8 +111,8 @@ VisitedLinksManagerQt::VisitedLinksManagerQt(ProfileQt *profile, bool persistVis Q_ASSERT(profile); if (persistVisitedLinks) ensureDirectoryExists(profile->GetPath()); - m_visitedLinkMaster.reset(new visitedlink::VisitedLinkMaster(profile, m_delegate.data(), persistVisitedLinks)); - m_visitedLinkMaster->Init(); + m_visitedLinkWriter.reset(new visitedlink::VisitedLinkWriter(profile, m_delegate.data(), persistVisitedLinks)); + m_visitedLinkWriter->Init(); } VisitedLinksManagerQt::~VisitedLinksManagerQt() @@ -121,8 +121,8 @@ VisitedLinksManagerQt::~VisitedLinksManagerQt() void VisitedLinksManagerQt::addUrl(const GURL &urlToAdd) { - Q_ASSERT(m_visitedLinkMaster); - m_visitedLinkMaster->AddURL(urlToAdd); + Q_ASSERT(m_visitedLinkWriter); + m_visitedLinkWriter->AddURL(urlToAdd); } } // namespace QtWebEngineCore diff --git a/src/core/visited_links_manager_qt.h b/src/core/visited_links_manager_qt.h index ecac8f30f..c4e24ce1f 100644 --- a/src/core/visited_links_manager_qt.h +++ b/src/core/visited_links_manager_qt.h @@ -60,7 +60,7 @@ class QUrl; QT_END_NAMESPACE namespace visitedlink { -class VisitedLinkMaster; +class VisitedLinkWriter; } class GURL; @@ -85,7 +85,7 @@ private: void addUrl(const GURL &); friend class WebContentsDelegateQt; - QScopedPointer m_visitedLinkMaster; + QScopedPointer m_visitedLinkWriter; QScopedPointer m_delegate; }; diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 9cecb9ecb..61f8e5da0 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -86,9 +86,9 @@ #include "content/public/common/url_constants.h" #include "content/public/common/web_preferences.h" #include "extensions/buildflags/buildflags.h" +#include "third_party/blink/public/common/media/media_player_action.h" #include "third_party/blink/public/common/page/page_zoom.h" #include "third_party/blink/public/common/peerconnection/webrtc_ip_handling_policy.h" -#include "third_party/blink/public/web/web_media_player_action.h" #include "printing/buildflags/buildflags.h" #include "ui/base/clipboard/clipboard.h" #include "ui/base/clipboard/clipboard_constants.h" @@ -239,7 +239,7 @@ static void callbackOnPdfSavingFinished(WebContentsAdapterClient *adapterClient, static std::unique_ptr createBlankWebContents(WebContentsAdapterClient *adapterClient, content::BrowserContext *browserContext) { - content::WebContents::CreateParams create_params(browserContext, NULL); + content::WebContents::CreateParams create_params(browserContext, nullptr); create_params.routing_id = MSG_ROUTING_NONE; create_params.initially_hidden = true; @@ -1175,22 +1175,22 @@ void WebContentsAdapter::copyImageAt(const QPoint &location) m_webContents->GetRenderViewHost()->GetMainFrame()->CopyImageAt(location.x(), location.y()); } -static blink::WebMediaPlayerAction::Type toBlinkMediaPlayerActionType(WebContentsAdapter::MediaPlayerAction action) +static blink::MediaPlayerAction::Type toBlinkMediaPlayerActionType(WebContentsAdapter::MediaPlayerAction action) { switch (action) { case WebContentsAdapter::MediaPlayerPlay: - return blink::WebMediaPlayerAction::Type::kPlay; + return blink::MediaPlayerAction::Type::kPlay; case WebContentsAdapter::MediaPlayerMute: - return blink::WebMediaPlayerAction::Type::kMute; + return blink::MediaPlayerAction::Type::kMute; case WebContentsAdapter::MediaPlayerLoop: - return blink::WebMediaPlayerAction::Type::kLoop; + return blink::MediaPlayerAction::Type::kLoop; case WebContentsAdapter::MediaPlayerControls: - return blink::WebMediaPlayerAction::Type::kControls; + return blink::MediaPlayerAction::Type::kControls; case WebContentsAdapter::MediaPlayerNoAction: break; } NOTREACHED(); - return (blink::WebMediaPlayerAction::Type)-1; + return (blink::MediaPlayerAction::Type)-1; } void WebContentsAdapter::executeMediaPlayerActionAt(const QPoint &location, MediaPlayerAction action, bool enable) @@ -1198,7 +1198,7 @@ void WebContentsAdapter::executeMediaPlayerActionAt(const QPoint &location, Medi CHECK_INITIALIZED(); if (action == MediaPlayerNoAction) return; - blink::WebMediaPlayerAction blinkAction(toBlinkMediaPlayerActionType(action), enable); + blink::MediaPlayerAction blinkAction(toBlinkMediaPlayerActionType(action), enable); m_webContents->GetRenderViewHost()->GetMainFrame()->ExecuteMediaPlayerActionAtLocation(toGfx(location), blinkAction); } diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index e97536593..d1cdb8d9f 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -156,7 +156,7 @@ content::WebContents *WebContentsDelegateQt::OpenURLFromTab(content::WebContents load_url_params.override_user_agent = content::NavigationController::UA_OVERRIDE_TRUE; load_url_params.href_translate = params.href_translate; load_url_params.reload_type = params.reload_type; - if (params.uses_post) { + if (params.post_data) { load_url_params.load_type = content::NavigationController::LOAD_TYPE_HTTP_POST; load_url_params.post_data = params.post_data; } @@ -255,7 +255,7 @@ void WebContentsDelegateQt::CloseContents(content::WebContents *source) GetJavaScriptDialogManager(source)->CancelDialogs(source, /* whatever?: */false); } -void WebContentsDelegateQt::LoadProgressChanged(content::WebContents */*source*/, double progress) +void WebContentsDelegateQt::LoadProgressChanged(double progress) { if (!m_loadingErrorFrameList.isEmpty()) return; diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h index 6818fa551..81d6c8671 100644 --- a/src/core/web_contents_delegate_qt.h +++ b/src/core/web_contents_delegate_qt.h @@ -122,7 +122,7 @@ public: void NavigationStateChanged(content::WebContents* source, content::InvalidateTypes changed_flags) override; void AddNewContents(content::WebContents *source, std::unique_ptr new_contents, WindowOpenDisposition disposition, const gfx::Rect &initial_pos, bool user_gesture, bool *was_blocked) override; void CloseContents(content::WebContents *source) override; - void LoadProgressChanged(content::WebContents* source, double progress) override; + void LoadProgressChanged(double progress) override; bool HandleKeyboardEvent(content::WebContents *source, const content::NativeWebKeyboardEvent &event) override; content::ColorChooser* OpenColorChooser(content::WebContents *source, SkColor color, const std::vector &suggestions) override; void WebContentsCreated(content::WebContents *source_contents, int opener_render_process_id, int opener_render_frame_id, diff --git a/src/core/web_contents_view_qt.cpp b/src/core/web_contents_view_qt.cpp index 139450cd8..7f6bfe34f 100644 --- a/src/core/web_contents_view_qt.cpp +++ b/src/core/web_contents_view_qt.cpp @@ -57,6 +57,8 @@ #include "content/browser/web_contents/web_contents_impl.h" #include "content/public/browser/web_contents_delegate.h" #include "content/public/common/context_menu_params.h" +#include "third_party/blink/public/common/context_menu_data/edit_flags.h" +#include "third_party/blink/public/common/context_menu_data/media_type.h" #include "ui/gfx/image/image_skia.h" #include @@ -87,7 +89,7 @@ void WebContentsViewQt::setClient(WebContentsAdapterClient* client) } } -content::RenderWidgetHostViewBase* WebContentsViewQt::CreateViewForWidget(content::RenderWidgetHost* render_widget_host, bool is_guest_view_hack) +content::RenderWidgetHostViewBase* WebContentsViewQt::CreateViewForWidget(content::RenderWidgetHost *render_widget_host) { RenderWidgetHostViewQt *view = new RenderWidgetHostViewQt(render_widget_host); @@ -158,13 +160,13 @@ void WebContentsViewQt::FocusThroughTabTraversal(bool reverse) } -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeNone, blink::WebContextMenuData::kMediaTypeNone) -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeImage, blink::WebContextMenuData::kMediaTypeImage) -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeVideo, blink::WebContextMenuData::kMediaTypeVideo) -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeAudio, blink::WebContextMenuData::kMediaTypeAudio) -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeCanvas, blink::WebContextMenuData::kMediaTypeCanvas) -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeFile, blink::WebContextMenuData::kMediaTypeFile) -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypePlugin, blink::WebContextMenuData::kMediaTypePlugin) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeNone, blink::ContextMenuDataMediaType::kNone) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeImage, blink::ContextMenuDataMediaType::kImage) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeVideo, blink::ContextMenuDataMediaType::kVideo) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeAudio, blink::ContextMenuDataMediaType::kAudio) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeCanvas, blink::ContextMenuDataMediaType::kCanvas) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeFile, blink::ContextMenuDataMediaType::kFile) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypePlugin, blink::ContextMenuDataMediaType::kPlugin) ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaNone, blink::WebContextMenuData::kMediaNone) ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaInError, blink::WebContextMenuData::kMediaInError) @@ -178,16 +180,16 @@ ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaControls, blink::WebContextMen ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaCanPrint, blink::WebContextMenuData::kMediaCanPrint) ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaCanRotate, blink::WebContextMenuData::kMediaCanRotate) -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanDoNone, blink::WebContextMenuData::kCanDoNone) -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanUndo, blink::WebContextMenuData::kCanUndo) -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanRedo, blink::WebContextMenuData::kCanRedo) -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanCut, blink::WebContextMenuData::kCanCut) -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanCopy, blink::WebContextMenuData::kCanCopy) -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanPaste, blink::WebContextMenuData::kCanPaste) -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanDelete, blink::WebContextMenuData::kCanDelete) -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanSelectAll, blink::WebContextMenuData::kCanSelectAll) -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanTranslate, blink::WebContextMenuData::kCanTranslate) -ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanEditRichly, blink::WebContextMenuData::kCanEditRichly) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanDoNone, blink::kCanDoNone) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanUndo, blink::kCanUndo) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanRedo, blink::kCanRedo) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanCut, blink::kCanCut) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanCopy, blink::kCanCopy) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanPaste, blink::kCanPaste) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanDelete, blink::kCanDelete) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanSelectAll, blink::kCanSelectAll) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanTranslate, blink::kCanTranslate) +ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanEditRichly, blink::kCanEditRichly) static inline WebEngineContextMenuData fromParams(const content::ContextMenuParams ¶ms) { diff --git a/src/core/web_contents_view_qt.h b/src/core/web_contents_view_qt.h index 6f5ffdb86..3dcb648bf 100644 --- a/src/core/web_contents_view_qt.h +++ b/src/core/web_contents_view_qt.h @@ -70,7 +70,7 @@ public: WebContentsAdapterClient *client() { return m_client; } // content::WebContentsView overrides: - content::RenderWidgetHostViewBase *CreateViewForWidget(content::RenderWidgetHost* render_widget_host, bool is_guest_view_hack) override; + content::RenderWidgetHostViewBase *CreateViewForWidget(content::RenderWidgetHost *render_widget_host) override; void CreateView(gfx::NativeView context) override; diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 1fa12885f..5e6a18e5b 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -589,9 +589,10 @@ WebEngineContext::WebEngineContext() appendToFeatureList(disableFeatures, features::kFontSrcLocalMatching.name); #endif -#if QT_CONFIG(webengine_printing_and_pdf) - appendToFeatureList(disableFeatures, printing::features::kUsePdfCompositorServiceForPrint.name); -#endif + // We don't support the skia renderer (enabled by default on Linux since 80) + appendToFeatureList(disableFeatures, features::kUseSkiaRenderer.name); + + appendToFeatureList(disableFeatures, network::features::kDnsOverHttpsUpgrade.name); // Explicitly tell Chromium about default-on features we do not support appendToFeatureList(disableFeatures, features::kBackgroundFetch.name); @@ -629,7 +630,7 @@ WebEngineContext::WebEngineContext() // Viz Display Compositor is enabled by default since 73. Doesn't work for us (also implies SurfaceSynchronization) appendToFeatureList(disableFeatures, features::kVizDisplayCompositor.name); // VideoSurfaceLayer is enabled by default since 75. We don't support it. - appendToFeatureList(disableFeatures, media::kUseSurfaceLayerForVideo.name); + appendToFeatureList(enableFeatures, media::kDisableSurfaceLayerForVideo.name); } appendToFeatureSwitch(parsedCommandLine, switches::kDisableFeatures, disableFeatures); diff --git a/src/core/web_engine_settings.cpp b/src/core/web_engine_settings.cpp index c54570b33..edd72a117 100644 --- a/src/core/web_engine_settings.cpp +++ b/src/core/web_engine_settings.cpp @@ -404,18 +404,23 @@ void WebEngineSettings::applySettingsToWebPreferences(content::WebPreferences *p // Set the theme colors. Based on chrome_content_browser_client.cc: const ui::NativeTheme *webTheme = ui::NativeTheme::GetInstanceForWeb(); - if (webTheme) { - switch (webTheme->GetPreferredColorScheme()) { - case ui::NativeTheme::PreferredColorScheme::kDark: - prefs->preferred_color_scheme = blink::PreferredColorScheme::kDark; - break; - case ui::NativeTheme::PreferredColorScheme::kLight: - prefs->preferred_color_scheme = blink::PreferredColorScheme::kLight; - break; - case ui::NativeTheme::PreferredColorScheme::kNoPreference: - prefs->preferred_color_scheme = blink::PreferredColorScheme::kNoPreference; - } - } + // WebPreferences::preferred_color_scheme was deleted in Chromium 80, but it + // will make a comeback in Chromium 82... + // + // See also: https://chromium-review.googlesource.com/c/chromium/src/+/2079192 + // + // if (webTheme) { + // switch (webTheme->GetPreferredColorScheme()) { + // case ui::NativeTheme::PreferredColorScheme::kDark: + // prefs->preferred_color_scheme = blink::PreferredColorScheme::kDark; + // break; + // case ui::NativeTheme::PreferredColorScheme::kLight: + // prefs->preferred_color_scheme = blink::PreferredColorScheme::kLight; + // break; + // case ui::NativeTheme::PreferredColorScheme::kNoPreference: + // prefs->preferred_color_scheme = blink::PreferredColorScheme::kNoPreference; + // } + // } // Apply native CaptionStyle parameters. base::Optional style; diff --git a/src/webengine/api/qquickwebenginecertificateerror.cpp b/src/webengine/api/qquickwebenginecertificateerror.cpp index 855e61817..63beb1bae 100644 --- a/src/webengine/api/qquickwebenginecertificateerror.cpp +++ b/src/webengine/api/qquickwebenginecertificateerror.cpp @@ -200,6 +200,10 @@ QUrl QQuickWebEngineCertificateError::url() const \value WebEngineCertificateError.CertificateTransparencyRequired Certificate Transparency was required for this connection, but the server did not provide CT information that complied with the policy. (Added in 5.8) + \value WebEngineCertificateError.CertificateKnownInterceptionBlocked + The certificate is known to be used for interception by an entity other + the device owner. (Added in 5.15) + */ QQuickWebEngineCertificateError::Error QQuickWebEngineCertificateError::error() const { diff --git a/src/webengine/api/qquickwebenginecertificateerror_p.h b/src/webengine/api/qquickwebenginecertificateerror_p.h index 77fbe27aa..4a8ef6ae0 100644 --- a/src/webengine/api/qquickwebenginecertificateerror_p.h +++ b/src/webengine/api/qquickwebenginecertificateerror_p.h @@ -85,6 +85,7 @@ public: CertificateNameConstraintViolation = -212, CertificateValidityTooLong = -213, CertificateTransparencyRequired = -214, + CertificateKnownInterceptionBlocked = -217, }; Q_ENUM(Error) diff --git a/src/webenginewidgets/api/qwebenginecertificateerror.cpp b/src/webenginewidgets/api/qwebenginecertificateerror.cpp index 3f20b6483..d86019af8 100644 --- a/src/webenginewidgets/api/qwebenginecertificateerror.cpp +++ b/src/webenginewidgets/api/qwebenginecertificateerror.cpp @@ -147,6 +147,9 @@ QWebEngineCertificateError::~QWebEngineCertificateError() \value CertificateValidityTooLong The certificate has a validity period that is too long. (Added in Qt 5.7) \value CertificateTransparencyRequired Certificate Transparency was required for this connection, but the server did not provide CT information that complied with the policy. (Added in Qt 5.8) + \value CertificateKnownInterceptionBlocked The certificate is known to be + used for interception by an entity other the device owner. (Added in + 5.15) */ /*! diff --git a/src/webenginewidgets/api/qwebenginecertificateerror.h b/src/webenginewidgets/api/qwebenginecertificateerror.h index d3a19edfc..a32f7ab8e 100644 --- a/src/webenginewidgets/api/qwebenginecertificateerror.h +++ b/src/webenginewidgets/api/qwebenginecertificateerror.h @@ -73,6 +73,7 @@ public: CertificateNameConstraintViolation = -212, CertificateValidityTooLong = -213, CertificateTransparencyRequired = -214, + CertificateKnownInterceptionBlocked = -217, }; Error error() const; -- cgit v1.2.3 From e39c986dd476daee33272de19882b82552480880 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 6 Apr 2020 14:56:45 +0200 Subject: Fix hardware accelerated video decoding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Copy initialization from gpu_main.cc to our setup. Change-Id: I8b32df76783da7783f033c3e15dd3b20b48152a8 Reviewed-by: Jüri Valdmann --- src/core/content_main_delegate_qt.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src') diff --git a/src/core/content_main_delegate_qt.cpp b/src/core/content_main_delegate_qt.cpp index 708d175f3..f93a3c0ea 100644 --- a/src/core/content_main_delegate_qt.cpp +++ b/src/core/content_main_delegate_qt.cpp @@ -48,6 +48,7 @@ #include "content/public/browser/browser_main_runner.h" #include "content/public/common/content_paths.h" #include "content/public/common/content_switches.h" +#include "media/gpu/buildflags.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/ui_base_paths.h" #include "ui/base/resource/resource_bundle.h" @@ -71,8 +72,23 @@ #include "ui/base/ui_base_switches.h" #endif +// must be included before vaapi_wrapper.h #include +#if defined(OS_WIN) +#include "media/gpu/windows/dxva_video_decode_accelerator_win.h" +#include "media/gpu/windows/media_foundation_video_encode_accelerator_win.h" +#endif + +#if defined(OS_MACOSX) +#include "content/public/common/content_features.h" +#include "media/gpu/mac/vt_video_decode_accelerator_mac.h" +#endif + +#if BUILDFLAG(USE_VAAPI) +#include "media/gpu/vaapi/vaapi_wrapper.h" +#endif + namespace content { ContentClient *GetContentClient(); } @@ -188,6 +204,22 @@ void ContentMainDelegateQt::PreSandboxStartup() if (parsedCommandLine->HasSwitch(switches::kSingleProcess)) setlocale(LC_NUMERIC, "C"); #endif + + // from gpu_main.cc: +#if BUILDFLAG(USE_VAAPI) + media::VaapiWrapper::PreSandboxInitialization(); +#endif +#if defined(OS_WIN) + media::DXVAVideoDecodeAccelerator::PreSandboxInitialization(); + media::MediaFoundationVideoEncodeAccelerator::PreSandboxInitialization(); +#endif + +#if defined(OS_MACOSX) + if (base::FeatureList::IsEnabled(features::kMacV2GPUSandbox)) { + TRACE_EVENT0("gpu", "Initialize VideoToolbox"); + media::InitializeVideoToolbox(); + } +#endif } content::ContentBrowserClient *ContentMainDelegateQt::CreateContentBrowserClient() -- cgit v1.2.3 From 9136c16ae640aec8ab393237ce1a1c7f89c8bb1d Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 7 Apr 2020 10:58:38 +0200 Subject: Avoid HTML encodings in default JS QMessageBox'es Escape any HTML encodings, as we have no convenient way to set formating to Qt::PlainText. Fixes: QTBUG-83338 Change-Id: I4d8cb05fe643eb018d3e40119c629e7304fe0813 Reviewed-by: Kirill Burtsev --- src/webenginewidgets/api/qwebenginepage.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index 850a29a16..7e02130c9 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -2345,7 +2345,9 @@ void QWebEnginePage::javaScriptAlert(const QUrl &securityOrigin, const QString & { Q_UNUSED(securityOrigin); #if QT_CONFIG(messagebox) - QMessageBox::information(view(), QStringLiteral("Javascript Alert - %1").arg(url().toString()), msg); + QMessageBox::information(view(), + QStringLiteral("Javascript Alert - %1").arg(url().toString()), + msg.toHtmlEscaped()); #else Q_UNUSED(msg); #endif // QT_CONFIG(messagebox) @@ -2355,7 +2357,11 @@ bool QWebEnginePage::javaScriptConfirm(const QUrl &securityOrigin, const QString { Q_UNUSED(securityOrigin); #if QT_CONFIG(messagebox) - return (QMessageBox::information(view(), QStringLiteral("Javascript Confirm - %1").arg(url().toString()), msg, QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok); + return (QMessageBox::information(view(), + QStringLiteral("Javascript Confirm - %1").arg(url().toString()), + msg.toHtmlEscaped(), + QMessageBox::Ok, + QMessageBox::Cancel) == QMessageBox::Ok); #else Q_UNUSED(msg); return false; @@ -2368,7 +2374,12 @@ bool QWebEnginePage::javaScriptPrompt(const QUrl &securityOrigin, const QString #if QT_CONFIG(inputdialog) bool ret = false; if (result) - *result = QInputDialog::getText(view(), QStringLiteral("Javascript Prompt - %1").arg(url().toString()), msg, QLineEdit::Normal, defaultValue, &ret); + *result = QInputDialog::getText(view(), + QStringLiteral("Javascript Prompt - %1").arg(url().toString()), + msg.toHtmlEscaped(), + QLineEdit::Normal, + defaultValue.toHtmlEscaped(), + &ret); return ret; #else Q_UNUSED(msg); -- cgit v1.2.3 From 07788b74f3cd2d257abe70c13f38d2b0ebb230ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCri=20Valdmann?= Date: Wed, 8 Apr 2020 09:59:08 +0200 Subject: Update Chromium This pulls in the following changes: * c81ff02d Fix ozone builds of ANGLE * 6c9c6c8b Fix skia crash on Windows after 77-merge * 10f68b30 Fix viz crash when cleanup * b25b21fa Stop sending ViewMsg_SetBackgroundOpaque to renderer Change-Id: I14059823b1ae1510f86c3850e1654a224df01684 Reviewed-by: Michal Klocek --- src/3rdparty | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/3rdparty b/src/3rdparty index 6b151acc9..c81ff02d7 160000 --- a/src/3rdparty +++ b/src/3rdparty @@ -1 +1 @@ -Subproject commit 6b151acc9f31574c7b739433c538b90b989c9a23 +Subproject commit c81ff02d7fc7695a62d6543e34b73a75071f7d78 -- cgit v1.2.3 From cee8776777e72f2820f04f1df00e2aeebbf9af49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCri=20Valdmann?= Date: Fri, 3 Apr 2020 12:40:27 +0200 Subject: Fix DisplaySoftwareOutputSurface swap with transparent background Change QPainter's compositing mode from the default SourceOver (alpha-blending) to Source (copy). Fixes: QTBUG-81250 Change-Id: I670772b77cdd89ec42de96808608693ad50f726a Reviewed-by: Allan Sandfeld Jensen --- src/core/compositor/display_software_output_surface.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/core/compositor/display_software_output_surface.cpp b/src/core/compositor/display_software_output_surface.cpp index 5d3c7a6f6..ba99799f0 100644 --- a/src/core/compositor/display_software_output_surface.cpp +++ b/src/core/compositor/display_software_output_surface.cpp @@ -137,7 +137,9 @@ QSGNode *DisplaySoftwareOutputSurface::Device::updatePaintNode( skPixmap.rowBytes(), imageFormat(skPixmap.colorType())); if (m_image.size() == image.size()) { QRect damageRect = toQt(damage_rect_); - QPainter(&m_image).drawImage(damageRect, image, damageRect); + QPainter painter(&m_image); + painter.setCompositionMode(QPainter::CompositionMode_Source); + painter.drawImage(damageRect, image, damageRect); } else { m_image = image; m_image.detach(); -- cgit v1.2.3 From 9edaf3675cb8e94372bff579cbaec022ca26ee21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCri=20Valdmann?= Date: Fri, 3 Apr 2020 12:33:33 +0200 Subject: Use SetBaseBackgroundColorOverride for setting background color The normal WebViewImpl::SetBaseBackgroundColor expects to be called only during certain lifecycle states, otherwise a DCHECK will be triggered. Whereas the *Override version forces a lifecycle update. Needs 3rdparty change to stop RenderWidgetHostViewBase::SetBaseBackgroundColor from clearing the override color when switching between opaque and transparent colors though. Change-Id: If4c1e22886d7ebc7d87ca880dd9c6a659855a931 Reviewed-by: Peter Varga --- src/core/renderer/render_view_observer_qt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/core/renderer/render_view_observer_qt.cpp b/src/core/renderer/render_view_observer_qt.cpp index 731d8b97d..5b0b9a77d 100644 --- a/src/core/renderer/render_view_observer_qt.cpp +++ b/src/core/renderer/render_view_observer_qt.cpp @@ -73,7 +73,7 @@ void RenderViewObserverQt::onFetchDocumentInnerText(quint64 requestId) void RenderViewObserverQt::onSetBackgroundColor(quint32 color) { - render_view()->GetWebView()->SetBaseBackgroundColor(color); + render_view()->GetWebView()->SetBaseBackgroundColorOverride(color); } void RenderViewObserverQt::OnDestruct() -- cgit v1.2.3 From 29875ab2df9377a90e2f201a40325750b601f94d Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Fri, 27 Mar 2020 10:00:50 +0100 Subject: Mark cleanup for ImageTransportFactory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On viz cleanup we should not try to use viz process transport factory, use the same code path as compositor would have been already destroyed. Task-number: QTBUG-83040 Task-number: QTBUG-79864 Change-Id: I0f91b99cd5545d65500c3733ae097893d53b1cab Reviewed-by: Tamas Zakor Reviewed-by: Jüri Valdmann --- src/core/web_engine_context.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 5e6a18e5b..88f5be726 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -53,6 +53,7 @@ #include "chrome/common/chrome_switches.h" #include "content/gpu/gpu_child_thread.h" #include "content/browser/compositor/surface_utils.h" +#include "content/browser/compositor/viz_process_transport_factory.h" #include "components/viz/host/host_frame_sink_manager.h" #if QT_CONFIG(webengine_printing_and_pdf) #include "chrome/browser/printing/print_job_manager.h" @@ -255,6 +256,8 @@ static void cleanupVizProcess() return; waitForViz = true; content::GetHostFrameSinkManager()->SetConnectionLostCallback(base::DoNothing()); + auto factory = static_cast(content::ImageTransportFactory::GetInstance()); + factory->PrepareForShutDown(); vizCompositorThreadRunner->CleanupForShutdown(base::BindOnce(&completeVizCleanup)); } -- cgit v1.2.3 From f24d51057d77978af9a3747e7ebfd8cddc9df3ad Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 8 Apr 2020 10:24:21 +0200 Subject: Update documented chromium version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: QTBUG-82763 Change-Id: Idf5cd91ec520aabe2b42b31ed0d2b32fcaec0272 Reviewed-by: Jüri Valdmann --- src/webengine/doc/src/qtwebengine-overview.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/webengine/doc/src/qtwebengine-overview.qdoc b/src/webengine/doc/src/qtwebengine-overview.qdoc index 3533b0327..1c30f9858 100644 --- a/src/webengine/doc/src/qtwebengine-overview.qdoc +++ b/src/webengine/doc/src/qtwebengine-overview.qdoc @@ -89,7 +89,7 @@ \l{https://chromium.googlesource.com/chromium/src/+/master/docs/chromium_browser_vs_google_chrome.md}{overview} that is part of the documentation in the \l {Chromium Project} upstream source tree. - This version of \QWE is based on Chromium version 77.0.3865, with additional security + This version of \QWE is based on Chromium version 80.0.3987, with additional security fixes from newer versions. \section2 Qt WebEngine Process -- cgit v1.2.3 From b0234f390c170fd6604be6ca50a13a5597900662 Mon Sep 17 00:00:00 2001 From: Kirill Burtsev Date: Thu, 9 Apr 2020 13:06:01 +0200 Subject: Fix crash on fence create after failure to make context current MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GLFence::Create requires valid current gl context, which is not the case if InProcCommandBuffer::MakeCurrent fails: driver and api structures will be null after context loss (for examples on os resume with desktop gl), that triggers access violation. Fixes: QTBUG-82656 Change-Id: If46a252147d1d3a0be7d2b19f7bbc36ac1dd338a Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Jüri Valdmann --- src/core/compositor/display_overrides.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/core/compositor/display_overrides.cpp b/src/core/compositor/display_overrides.cpp index 494c7b4d4..89bf8ad2f 100644 --- a/src/core/compositor/display_overrides.cpp +++ b/src/core/compositor/display_overrides.cpp @@ -76,7 +76,10 @@ void gpu::InProcessCommandBuffer::GetTextureQt( void gpu::InProcessCommandBuffer::GetTextureQtOnGpuThread( unsigned int client_id, GetTextureCallback callback) { - MakeCurrent(); + if (!MakeCurrent()) { + LOG(ERROR) << "MakeCurrent failed for GetTextureQt"; + return; + } gpu::TextureBase *texture = decoder_->GetTextureBase(client_id); std::move(callback).Run(texture ? texture->service_id() : 0, gl::GLFence::Create()); } -- cgit v1.2.3 From 5d2026cb04ef8fd408e5722a84e2affb5b9a3119 Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Tue, 7 Apr 2020 10:09:37 +0200 Subject: Fix macOS build after 10.15.4 QMAKE_MAC_SDK_VERSION is set by /usr/bin/xcrun --sdk macosx --show-sdk-version in qtbase/mkpecs/features/mac/sdk.prf From 10.15.4, xcrun outputs the SDK version in Major.Minor.Patch format instead of Major.Minor. mac_sdk_min gn arg is expected to be in Major.Minor format, therefor pass only the first 2 revision numbers to gn. Fixes: QTBUG-83318 Change-Id: I3af523dd5df8149fb5cd57b259c2bed889db88b5 Reviewed-by: Allan Sandfeld Jensen --- src/buildtools/config/mac_osx.pri | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/buildtools/config/mac_osx.pri b/src/buildtools/config/mac_osx.pri index 01aca4ca7..9373928de 100644 --- a/src/buildtools/config/mac_osx.pri +++ b/src/buildtools/config/mac_osx.pri @@ -9,6 +9,10 @@ isEmpty(QMAKE_MAC_SDK_VERSION) { isEmpty(QMAKE_MAC_SDK_VERSION): error("Could not resolve SDK version for \'$${QMAKE_MAC_SDK}\'") } +# chromium/build/mac/find_sdk.py expects the SDK version (mac_sdk_min) in Major.Minor format. +# If Patch version is provided it fails with "Exception: No Major.Minor.Patch+ SDK found" +QMAKE_MAC_SDK_VERSION_MAJOR_MINOR = $$section(QMAKE_MAC_SDK_VERSION, ".", 0, 1) + QMAKE_CLANG_DIR = "/usr" QMAKE_CLANG_PATH = $$eval(QMAKE_MAC_SDK.macx-clang.$${QMAKE_MAC_SDK}.QMAKE_CXX) !isEmpty(QMAKE_CLANG_PATH) { @@ -28,7 +32,7 @@ gn_args += \ clang_base_path=\"$${QMAKE_CLANG_DIR}\" \ clang_use_chrome_plugins=false \ mac_deployment_target=\"$${QMAKE_MACOSX_DEPLOYMENT_TARGET}\" \ - mac_sdk_min=\"$${QMAKE_MAC_SDK_VERSION}\" \ + mac_sdk_min=\"$${QMAKE_MAC_SDK_VERSION_MAJOR_MINOR}\" \ use_external_popup_menu=false \ angle_enable_vulkan=false -- cgit v1.2.3 From a3bc7f797d740da416b858806ce9fcfb46e77ac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCri=20Valdmann?= Date: Wed, 8 Apr 2020 13:21:43 +0200 Subject: Delete last network service feature checks Network service is required. Task-number: QTBUG-83394 Change-Id: I8b636730eba5bd2ba5895e072e134c3b1fb786d1 Reviewed-by: Allan Sandfeld Jensen --- src/core/content_browser_client_qt.cpp | 10 ---------- src/core/login_delegate_qt.cpp | 15 --------------- src/core/login_delegate_qt.h | 3 --- src/core/net/system_network_context_manager.cpp | 12 ------------ src/core/net/system_network_context_manager.h | 5 ----- 5 files changed, 45 deletions(-) (limited to 'src') diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index 2c5ba36c8..22dbc173b 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -1058,9 +1058,6 @@ network::mojom::NetworkContext *ContentBrowserClientQt::GetSystemNetworkContext( void ContentBrowserClientQt::OnNetworkServiceCreated(network::mojom::NetworkService *network_service) { - if (!base::FeatureList::IsEnabled(network::features::kNetworkService)) - return; - if (!SystemNetworkContextManager::GetInstance()) SystemNetworkContextManager::CreateInstance(); @@ -1096,7 +1093,6 @@ std::vector ContentBrowserClientQt::GetNetworkContextsParentDire void ContentBrowserClientQt::RegisterNonNetworkNavigationURLLoaderFactories(int frame_tree_node_id, NonNetworkURLLoaderFactoryMap *factories) { - DCHECK(base::FeatureList::IsEnabled(network::features::kNetworkService)); content::WebContents *web_contents = content::WebContents::FromFrameTreeNodeId(frame_tree_node_id); Profile *profile = Profile::FromBrowserContext(web_contents->GetBrowserContext()); ProfileAdapter *profileAdapter = static_cast(profile)->profileAdapter(); @@ -1115,7 +1111,6 @@ void ContentBrowserClientQt::RegisterNonNetworkNavigationURLLoaderFactories(int void ContentBrowserClientQt::RegisterNonNetworkWorkerMainResourceURLLoaderFactories(content::BrowserContext *browser_context, NonNetworkURLLoaderFactoryMap *factories) { - DCHECK(base::FeatureList::IsEnabled(network::features::kNetworkService)); Profile *profile = Profile::FromBrowserContext(browser_context); ProfileAdapter *profileAdapter = static_cast(profile)->profileAdapter(); @@ -1126,8 +1121,6 @@ void ContentBrowserClientQt::RegisterNonNetworkWorkerMainResourceURLLoaderFactor void ContentBrowserClientQt::RegisterNonNetworkSubresourceURLLoaderFactories(int render_process_id, int render_frame_id, NonNetworkURLLoaderFactoryMap *factories) { - if (!base::FeatureList::IsEnabled(network::features::kNetworkService)) - return; content::RenderProcessHost *process_host = content::RenderProcessHost::FromID(render_process_id); Profile *profile = Profile::FromBrowserContext(process_host->GetBrowserContext()); ProfileAdapter *profileAdapter = static_cast(profile)->profileAdapter(); @@ -1212,9 +1205,6 @@ bool ContentBrowserClientQt::WillCreateURLLoaderFactory( bool *bypass_redirect_checks, network::mojom::URLLoaderFactoryOverridePtr *factory_override) { - if (!base::FeatureList::IsEnabled(network::features::kNetworkService)) - return false; - auto proxied_receiver = std::move(*factory_receiver); network::mojom::URLLoaderFactoryPtrInfo target_factory_info; *factory_receiver = mojo::MakeRequest(&target_factory_info); diff --git a/src/core/login_delegate_qt.cpp b/src/core/login_delegate_qt.cpp index 1b9c22191..7942c8279 100644 --- a/src/core/login_delegate_qt.cpp +++ b/src/core/login_delegate_qt.cpp @@ -87,11 +87,6 @@ LoginDelegateQt::LoginDelegateQt(const net::AuthChallengeInfo &authInfo, base::BindOnce(&LoginDelegateQt::triggerDialog, m_weakFactory.GetWeakPtr())); } -LoginDelegateQt::~LoginDelegateQt() -{ - destroy(); -} - QUrl LoginDelegateQt::url() const { return toQt(m_url); @@ -152,16 +147,6 @@ void LoginDelegateQt::sendAuthToRequester(bool success, const QString &user, con else std::move(m_auth_required_callback).Run(base::nullopt); } - - // With network service the auth callback has already deleted us. - if (!base::FeatureList::IsEnabled(network::features::kNetworkService)) - destroy(); -} - -void LoginDelegateQt::destroy() -{ - m_dialogController.reset(); - m_auth_required_callback.Reset(); } } // namespace QtWebEngineCore diff --git a/src/core/login_delegate_qt.h b/src/core/login_delegate_qt.h index 116fe3c56..7b8d869e1 100644 --- a/src/core/login_delegate_qt.h +++ b/src/core/login_delegate_qt.h @@ -66,8 +66,6 @@ public: bool first_auth_attempt, LoginAuthRequiredCallback auth_required_callback); - ~LoginDelegateQt() override; - QUrl url() const; QString realm() const; QString host() const; @@ -78,7 +76,6 @@ public: private: void triggerDialog(); - void destroy(); net::AuthChallengeInfo m_authInfo; diff --git a/src/core/net/system_network_context_manager.cpp b/src/core/net/system_network_context_manager.cpp index bc42a684d..43b2b2557 100644 --- a/src/core/net/system_network_context_manager.cpp +++ b/src/core/net/system_network_context_manager.cpp @@ -166,12 +166,6 @@ private: network::mojom::NetworkContext *SystemNetworkContextManager::GetContext() { - if (!base::FeatureList::IsEnabled(network::features::kNetworkService)) { - // SetUp should already have been called. - DCHECK(io_thread_network_context_); - return io_thread_network_context_.get(); - } - if (!network_service_network_context_ || network_service_network_context_.encountered_error()) { // This should call into OnNetworkServiceCreated(), which will re-create // the network service, if needed. There's a chance that it won't be @@ -211,10 +205,6 @@ void SystemNetworkContextManager::SetUp( network::mojom::HttpAuthStaticParamsPtr *http_auth_static_params, network::mojom::HttpAuthDynamicParamsPtr *http_auth_dynamic_params, bool *is_quic_allowed) { - if (!base::FeatureList::IsEnabled(network::features::kNetworkService)) { - *network_context_request = mojo::MakeRequest(&io_thread_network_context_); - *network_context_params = CreateNetworkContextParams(); - } *is_quic_allowed = false; *http_auth_static_params = CreateHttpAuthStaticParams(); *http_auth_dynamic_params = CreateHttpAuthDynamicParams(); @@ -254,8 +244,6 @@ SystemNetworkContextManager::~SystemNetworkContextManager() void SystemNetworkContextManager::OnNetworkServiceCreated(network::mojom::NetworkService *network_service) { - if (!base::FeatureList::IsEnabled(network::features::kNetworkService)) - return; // Disable QUIC globally network_service->DisableQuic(); diff --git a/src/core/net/system_network_context_manager.h b/src/core/net/system_network_context_manager.h index 288af5195..e429453a2 100644 --- a/src/core/net/system_network_context_manager.h +++ b/src/core/net/system_network_context_manager.h @@ -169,11 +169,6 @@ private: // enabled. nullptr, otherwise. network::mojom::NetworkContextPtr network_service_network_context_; - // This is a NetworkContext that wraps the IOThread's SystemURLRequestContext. - // Always initialized in SetUp, but it's only returned by Context() when the - // network service is disabled. - network::mojom::NetworkContextPtr io_thread_network_context_; - // URLLoaderFactory backed by the NetworkContext returned by GetContext(), so // consumers don't all need to create their own factory. scoped_refptr shared_url_loader_factory_; -- cgit v1.2.3 From 8cd89e807b58c4ac750b5719ddde319741a7edb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCri=20Valdmann?= Date: Wed, 8 Apr 2020 13:59:48 +0200 Subject: ProfileIODataQt: remove more remains of non network service code Task-number: QTBUG-83394 Change-Id: Ib1b4431ac75ae7e988bf62580e2bfb690840f54a Reviewed-by: Allan Sandfeld Jensen --- src/core/profile_adapter.cpp | 17 +--- src/core/profile_adapter.h | 1 - src/core/profile_io_data_qt.cpp | 185 +--------------------------------------- src/core/profile_io_data_qt.h | 48 ----------- 4 files changed, 2 insertions(+), 249 deletions(-) (limited to 'src') diff --git a/src/core/profile_adapter.cpp b/src/core/profile_adapter.cpp index e9e2a2c5d..c27883b65 100644 --- a/src/core/profile_adapter.cpp +++ b/src/core/profile_adapter.cpp @@ -318,21 +318,6 @@ void ProfileAdapter::setCachePath(const QString &path) m_profile->m_profileIOData->resetNetworkContext(); } -QString ProfileAdapter::cookiesPath() const -{ - if (m_offTheRecord) - return QString(); - QString basePath = dataPath(); - 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(); -} - QString ProfileAdapter::httpCachePath() const { if (m_offTheRecord) @@ -393,7 +378,7 @@ void ProfileAdapter::setHttpCacheType(ProfileAdapter::HttpCacheType newhttpCache ProfileAdapter::PersistentCookiesPolicy ProfileAdapter::persistentCookiesPolicy() const { - if (isOffTheRecord() || cookiesPath().isEmpty()) + if (isOffTheRecord() || dataPath().isEmpty()) return NoPersistentCookies; return m_persistentCookiesPolicy; } diff --git a/src/core/profile_adapter.h b/src/core/profile_adapter.h index 1b89a8004..60d04273b 100644 --- a/src/core/profile_adapter.h +++ b/src/core/profile_adapter.h @@ -123,7 +123,6 @@ public: void setCachePath(const QString &path); QString httpCachePath() const; - QString cookiesPath() const; QString httpUserAgent() const; void setHttpUserAgent(const QString &userAgent); diff --git a/src/core/profile_io_data_qt.cpp b/src/core/profile_io_data_qt.cpp index 91af8d544..fd073f208 100644 --- a/src/core/profile_io_data_qt.cpp +++ b/src/core/profile_io_data_qt.cpp @@ -43,7 +43,6 @@ #include "content/browser/storage_partition_impl.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" -#include "content/public/browser/browsing_data_remover.h" #include "content/public/browser/shared_cors_origin_access_list.h" #include "content/public/common/content_features.h" #include "net/ssl/ssl_config_service_defaults.h" @@ -58,8 +57,6 @@ #include "type_conversion.h" #include -#include - #include namespace QtWebEngineCore { @@ -69,7 +66,6 @@ ProfileIODataQt::ProfileIODataQt(ProfileQt *profile) #if QT_CONFIG(ssl) m_clientCertificateStoreData(new ClientCertificateStoreData), #endif - m_removerObserver(this), m_weakPtrFactory(this) { if (content::BrowserThread::IsThreadInitialized(content::BrowserThread::UI)) @@ -106,14 +102,6 @@ void ProfileIODataQt::shutdownOnUIThread() } } -net::URLRequestContext *ProfileIODataQt::urlRequestContext() -{ - DCHECK_CURRENTLY_ON(content::BrowserThread::IO); - if (!m_initialized) - initializeOnIOThread(); - return nullptr; -} - content::ResourceContext *ProfileIODataQt::resourceContext() { return m_resourceContext.get(); @@ -126,29 +114,12 @@ extensions::ExtensionSystemQt* ProfileIODataQt::GetExtensionSystem() } #endif // BUILDFLAG(ENABLE_EXTENSIONS) -base::WeakPtr ProfileIODataQt::getWeakPtrOnUIThread() -{ - DCHECK_CURRENTLY_ON(content::BrowserThread::UI); - DCHECK(m_initialized); - return m_weakPtr; -} - base::WeakPtr ProfileIODataQt::getWeakPtrOnIOThread() { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); return m_weakPtrFactory.GetWeakPtr(); } -void ProfileIODataQt::initializeOnIOThread() -{ - // this binds factory to io thread - m_weakPtr = m_weakPtrFactory.GetWeakPtr(); - const std::lock_guard lock(m_mutex); - generateAllStorage(); - setGlobalCertificateVerification(); - m_initialized = true; -} - void ProfileIODataQt::initializeOnUIThread() { m_profileAdapter = m_profile->profileAdapter(); @@ -159,52 +130,15 @@ void ProfileIODataQt::initializeOnUIThread() m_proxyConfigMonitor.reset(new ProxyConfigMonitor(m_profile->GetPrefs())); } -void ProfileIODataQt::generateAllStorage() -{ - Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); - const std::lock_guard lock(m_mutex); - m_updateAllStorage = false; -} - -void ProfileIODataQt::regenerateJobFactory() -{ - Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); - - const std::lock_guard lock(m_mutex); - m_updateJobFactory = false; - - if (m_customUrlSchemes == m_installedCustomSchemes) - return; - - m_installedCustomSchemes = m_customUrlSchemes; -} - -void ProfileIODataQt::setGlobalCertificateVerification() -{ - Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); - const std::lock_guard lock(m_mutex); -} - -void ProfileIODataQt::setRequestContextData(content::ProtocolHandlerMap *protocolHandlers, - content::URLRequestInterceptorScopedVector request_interceptors) -{ - Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); - Q_ASSERT(!m_initialized); - m_requestInterceptors = std::move(request_interceptors); - std::swap(m_protocolHandlers, *protocolHandlers); -} - void ProfileIODataQt::setFullConfiguration() { Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); m_persistentCookiesPolicy = m_profileAdapter->persistentCookiesPolicy(); - m_cookiesPath = m_profileAdapter->cookiesPath(); m_httpAcceptLanguage = m_profileAdapter->httpAcceptLanguage(); m_httpUserAgent = m_profileAdapter->httpUserAgent(); m_httpCacheType = m_profileAdapter->httpCacheType(); m_httpCachePath = m_profileAdapter->httpCachePath(); m_httpCacheMaxSize = m_profileAdapter->httpCacheMaxSize(); - m_customUrlSchemes = m_profileAdapter->customUrlSchemes(); m_useForGlobalCertificateVerification = m_profileAdapter->isUsedForGlobalCertificateVerification(); m_dataPath = m_profileAdapter->dataPath(); } @@ -221,85 +155,6 @@ void ProfileIODataQt::resetNetworkContext() })); } -void ProfileIODataQt::requestStorageGeneration() { - Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); - const std::lock_guard lock(m_mutex); - if (m_initialized && !m_updateAllStorage) { - m_updateAllStorage = true; - base::PostTask(FROM_HERE, {content::BrowserThread::IO}, - base::BindOnce(&ProfileIODataQt::generateAllStorage, m_weakPtr)); - } -} - -void ProfileIODataQt::updateStorageSettings() -{ - Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); - - const std::lock_guard lock(m_mutex); - setFullConfiguration(); - - if (!m_pendingStorageRequestGeneration) - requestStorageGeneration(); -} - -void ProfileIODataQt::updateCookieStore() -{ - Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); - const std::lock_guard lock(m_mutex); - m_persistentCookiesPolicy = m_profileAdapter->persistentCookiesPolicy(); - m_cookiesPath = m_profileAdapter->cookiesPath(); - if (!m_pendingStorageRequestGeneration) - requestStorageGeneration(); -} - -void ProfileIODataQt::updateUserAgent() -{ - Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); - const std::lock_guard lock(m_mutex); - m_httpAcceptLanguage = m_profileAdapter->httpAcceptLanguage(); - m_httpUserAgent = m_profileAdapter->httpUserAgent(); - if (!m_pendingStorageRequestGeneration) - requestStorageGeneration(); -} - -void ProfileIODataQt::updateHttpCache() -{ - Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); - const std::lock_guard lock(m_mutex); - m_httpCacheType = m_profileAdapter->httpCacheType(); - m_httpCachePath = m_profileAdapter->httpCachePath(); - m_httpCacheMaxSize = m_profileAdapter->httpCacheMaxSize(); - - if (m_httpCacheType == ProfileAdapter::NoCache) { - m_pendingStorageRequestGeneration = true; - content::BrowsingDataRemover *remover = - content::BrowserContext::GetBrowsingDataRemover(m_profileAdapter->profile()); - remover->AddObserver(&m_removerObserver); - remover->RemoveAndReply(base::Time(), base::Time::Max(), - content::BrowsingDataRemover::DATA_TYPE_CACHE, - content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB | - content::BrowsingDataRemover::ORIGIN_TYPE_PROTECTED_WEB, - &m_removerObserver); - return; - } - if (!m_pendingStorageRequestGeneration) - requestStorageGeneration(); -} - -void ProfileIODataQt::updateJobFactory() -{ - Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); - const std::lock_guard lock(m_mutex); - - m_customUrlSchemes = m_profileAdapter->customUrlSchemes(); - - if (m_initialized && !m_updateJobFactory) { - m_updateJobFactory = true; - base::PostTask(FROM_HERE, {content::BrowserThread::IO}, - base::BindOnce(&ProfileIODataQt::regenerateJobFactory, m_weakPtr)); - } -} - void ProfileIODataQt::updateRequestInterceptor() { Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); @@ -343,29 +198,11 @@ void ProfileIODataQt::releaseInterceptor() m_mutex.unlock(); } -bool ProfileIODataQt::canSetCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &url) const -{ - return m_cookieDelegate->canSetCookie(firstPartyUrl,cookieLine, url); -} - bool ProfileIODataQt::canGetCookies(const QUrl &firstPartyUrl, const QUrl &url) const { return m_cookieDelegate->canGetCookies(firstPartyUrl, url); } -void ProfileIODataQt::updateUsedForGlobalCertificateVerification() -{ - Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); - const std::lock_guard lock(m_mutex); - if (m_useForGlobalCertificateVerification == m_profileAdapter->isUsedForGlobalCertificateVerification()) - return; - m_useForGlobalCertificateVerification = m_profileAdapter->isUsedForGlobalCertificateVerification(); - - if (m_useForGlobalCertificateVerification) - base::PostTask(FROM_HERE, {content::BrowserThread::IO}, - base::BindOnce(&ProfileIODataQt::setGlobalCertificateVerification, m_weakPtr)); -} - #if QT_CONFIG(ssl) ClientCertificateStoreData *ProfileIODataQt::clientCertificateStoreData() { @@ -384,7 +221,7 @@ std::unique_ptr ProfileIODataQt::CreateClientCertStore() network::mojom::NetworkContextParamsPtr ProfileIODataQt::CreateNetworkContextParams() { - updateStorageSettings(); + setFullConfiguration(); network::mojom::NetworkContextParamsPtr network_context_params = SystemNetworkContextManager::GetInstance()->CreateDefaultNetworkContextParams(); @@ -447,24 +284,4 @@ ProfileIODataQt *ProfileIODataQt::FromResourceContext(content::ResourceContext * return static_cast(resource_context)->m_io_data; } -void ProfileIODataQt::removeBrowsingDataRemoverObserver() -{ - content::BrowsingDataRemover *remover = - content::BrowserContext::GetBrowsingDataRemover(m_profileAdapter->profile()); - remover->RemoveObserver(&m_removerObserver); -} - -BrowsingDataRemoverObserverQt::BrowsingDataRemoverObserverQt(ProfileIODataQt *profileIOData) - : m_profileIOData(profileIOData) -{ -} - -void BrowsingDataRemoverObserverQt::OnBrowsingDataRemoverDone() -{ - Q_ASSERT(m_profileIOData->m_pendingStorageRequestGeneration); - m_profileIOData->requestStorageGeneration(); - m_profileIOData->removeBrowsingDataRemoverObserver(); - m_profileIOData->m_pendingStorageRequestGeneration = false; -} - } // namespace QtWebEngineCore diff --git a/src/core/profile_io_data_qt.h b/src/core/profile_io_data_qt.h index fcd209bf8..6d9dd1a45 100644 --- a/src/core/profile_io_data_qt.h +++ b/src/core/profile_io_data_qt.h @@ -40,10 +40,8 @@ #ifndef PROFILE_IO_DATA_QT_H #define PROFILE_IO_DATA_QT_H -#include "content/public/browser/browsing_data_remover.h" #include "chrome/browser/profiles/profile.h" #include "extensions/buildflags/buildflags.h" -#include "services/network/cookie_settings.h" #include "net/proxy_config_monitor.h" #include "profile_adapter.h" @@ -67,18 +65,6 @@ struct ClientCertificateStoreData; class ProfileIODataQt; class ProfileQt; - -class BrowsingDataRemoverObserverQt : public content::BrowsingDataRemover::Observer { -public: - BrowsingDataRemoverObserverQt(ProfileIODataQt *profileIOData); - - void OnBrowsingDataRemoverDone() override; - -private: - ProfileIODataQt *m_profileIOData; -}; - - // ProfileIOData contains data that lives on the IOthread // we still use shared memebers and use mutex which breaks // idea for this object, but this is wip. @@ -91,21 +77,14 @@ public: QPointer profileAdapter(); content::ResourceContext *resourceContext(); - net::URLRequestContext *urlRequestContext(); #if BUILDFLAG(ENABLE_EXTENSIONS) extensions::ExtensionSystemQt* GetExtensionSystem(); #endif // BUILDFLAG(ENABLE_EXTENSIONS) - void initializeOnIOThread(); void initializeOnUIThread(); // runs on ui thread void shutdownOnUIThread(); // runs on ui thread - void cancelAllUrlRequests(); - void generateAllStorage(); - void regenerateJobFactory(); - bool canSetCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &url) const; bool canGetCookies(const QUrl &firstPartyUrl, const QUrl &url) const; - void setGlobalCertificateVerification(); // Used in NetworkDelegateQt::OnBeforeURLRequest. bool isInterceptorDeprecated() const; // Remove for Qt6 @@ -113,18 +92,9 @@ public: void releaseInterceptor(); QWebEngineUrlRequestInterceptor *requestInterceptor(); - void setRequestContextData(content::ProtocolHandlerMap *protocolHandlers, - content::URLRequestInterceptorScopedVector request_interceptors); void setFullConfiguration(); // runs on ui thread void resetNetworkContext(); // runs on ui thread - void updateStorageSettings(); // runs on ui thread - void updateUserAgent(); // runs on ui thread - void updateCookieStore(); // runs on ui thread - void updateHttpCache(); // runs on ui thread - void updateJobFactory(); // runs on ui thread void updateRequestInterceptor(); // runs on ui thread - void requestStorageGeneration(); //runs on ui thread - void updateUsedForGlobalCertificateVerification(); // runs on ui thread bool hasPageInterceptors(); network::mojom::NetworkContextParamsPtr CreateNetworkContextParams(); @@ -137,19 +107,13 @@ public: static ProfileIODataQt *FromResourceContext(content::ResourceContext *resource_context); base::WeakPtr getWeakPtrOnIOThread(); - base::WeakPtr getWeakPtrOnUIThread(); CookieMonsterDelegateQt *cookieDelegate() const { return m_cookieDelegate.get(); } private: - void removeBrowsingDataRemoverObserver(); - ProfileQt *m_profile; std::unique_ptr m_resourceContext; - base::WeakPtr m_weakPtr; scoped_refptr m_cookieDelegate; - content::URLRequestInterceptorScopedVector m_requestInterceptors; - content::ProtocolHandlerMap m_protocolHandlers; QPointer m_profileAdapter; // never dereferenced in IO thread and it is passed by qpointer ProfileAdapter::PersistentCookiesPolicy m_persistentCookiesPolicy; std::unique_ptr m_proxyConfigMonitor; @@ -157,15 +121,11 @@ private: #if QT_CONFIG(ssl) ClientCertificateStoreData *m_clientCertificateStoreData; #endif - QString m_cookiesPath; QString m_httpAcceptLanguage; QString m_httpUserAgent; ProfileAdapter::HttpCacheType m_httpCacheType; QString m_httpCachePath; - QList m_customUrlSchemes; - QList m_installedCustomSchemes; QWebEngineUrlRequestInterceptor* m_requestInterceptor = nullptr; - network::CookieSettings m_cookieSettings; #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) QMutex m_mutex{QMutex::Recursive}; using QRecursiveMutex = QMutex; @@ -173,20 +133,12 @@ private: QRecursiveMutex m_mutex; #endif int m_httpCacheMaxSize = 0; - bool m_initialized = false; - bool m_updateAllStorage = false; - bool m_updateJobFactory = false; - bool m_ignoreCertificateErrors = false; bool m_useForGlobalCertificateVerification = false; bool m_hasPageInterceptors = false; - BrowsingDataRemoverObserverQt m_removerObserver; base::WeakPtrFactory m_weakPtrFactory; // this should be always the last member QString m_dataPath; - bool m_pendingStorageRequestGeneration = false; volatile bool m_isInterceptorDeprecated = false; // Remove for Qt6 DISALLOW_COPY_AND_ASSIGN(ProfileIODataQt); - - friend class BrowsingDataRemoverObserverQt; }; } // namespace QtWebEngineCore -- cgit v1.2.3 From 4a02c770db7552b7298d8b71e061558b8d16b13a Mon Sep 17 00:00:00 2001 From: Tamas Zakor Date: Tue, 7 Apr 2020 22:48:46 +0200 Subject: Use WebContents instead of FrameTreeNode when set first party url Change-Id: Ia69b4aa17396229bf303ef231a08ff135f425249 Reviewed-by: Allan Sandfeld Jensen --- src/core/net/proxying_url_loader_factory_qt.cpp | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/core/net/proxying_url_loader_factory_qt.cpp b/src/core/net/proxying_url_loader_factory_qt.cpp index 71f710737..a7dc8a48c 100644 --- a/src/core/net/proxying_url_loader_factory_qt.cpp +++ b/src/core/net/proxying_url_loader_factory_qt.cpp @@ -207,22 +207,15 @@ void InterceptedRequest::Start() { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); - content::FrameTreeNode *frameTreeNode = nullptr; + content::WebContents *webContents = nullptr; if (process_id_) { - content::RenderFrameHostImpl *renderFrameHost = content::RenderFrameHostImpl::FromID(process_id_, - request_.render_frame_id); - if (renderFrameHost) - frameTreeNode = renderFrameHost->frame_tree_node(); - } else { - frameTreeNode = content::FrameTreeNode::GloballyFindByID(request_.render_frame_id); - } - // Follows a similar path to the root as RenderFrameHostImpl::CalculateSiteForCookies() - if (frameTreeNode && frameTreeNode->frame_tree() - && frameTreeNode->frame_tree()->root() - && frameTreeNode->frame_tree()->root()->current_frame_host()) - m_topDocumentUrl = frameTreeNode->frame_tree()->root()->current_frame_host()->GetLastCommittedURL(); - else - LOG(INFO) << "InterceptedRequest::Start() - null frameTreeNode or path to top frame"; + content::RenderFrameHost *frameHost = content::RenderFrameHost::FromID(process_id_, request_.render_frame_id); + webContents = content::WebContents::FromRenderFrameHost(frameHost); + } else + webContents = content::WebContents::FromFrameTreeNodeId(request_.render_frame_id); + + if (webContents) + m_topDocumentUrl = static_cast(webContents)->GetLastCommittedURL(); base::PostTask(FROM_HERE, {content::BrowserThread::IO}, base::BindOnce(&InterceptedRequest::Restart, m_weakPtr)); -- cgit v1.2.3 From e6d4d15b03fa67524269bc8e1beb04dcc704db03 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 8 Apr 2020 11:41:36 +0200 Subject: Fix builds against Qt 5.12 We need to provide the last update possibility for Qt 5.12. Change-Id: I3dbf327ad5ef149046744ed2db57a1d56dc8e7fd Reviewed-by: Michal Klocek --- src/tools/qwebengine_convert_dict/main.cpp | 32 +++++++++++------------ src/webenginewidgets/api/qwebenginedownloaditem.h | 7 +++++ 2 files changed, 23 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/tools/qwebengine_convert_dict/main.cpp b/src/tools/qwebengine_convert_dict/main.cpp index 0ebba96b1..5c95f6d69 100644 --- a/src/tools/qwebengine_convert_dict/main.cpp +++ b/src/tools/qwebengine_convert_dict/main.cpp @@ -84,7 +84,7 @@ inline bool VerifyWords(const convert_dict::DicReader::WordList& org_words, hunspell::BDictReader reader; if (!reader.Init(reinterpret_cast(serialized.data()), serialized.size())) { - out << "BDict is invalid" << Qt::endl; + out << "BDict is invalid\n"; return false; } hunspell::WordIterator iter = reader.GetAllWordIterator(); @@ -96,7 +96,7 @@ inline bool VerifyWords(const convert_dict::DicReader::WordList& org_words, for (size_t i = 0; i < org_words.size(); i++) { int affix_matches = iter.Advance(buf, buf_size, affix_ids); if (affix_matches == 0) { - out << "Found the end before we expected" << Qt::endl; + out << "Found the end before we expected\n"; return false; } @@ -104,7 +104,7 @@ inline bool VerifyWords(const convert_dict::DicReader::WordList& org_words, out << "Word does not match!\n" << " Index: " << i << "\n" << " Expected: " << QString::fromStdString(org_words[i].first) << "\n" - << " Actual: " << QString::fromUtf8(buf) << Qt::endl; + << " Actual: " << QString::fromUtf8(buf) << "\n"; return false; } @@ -118,7 +118,7 @@ inline bool VerifyWords(const convert_dict::DicReader::WordList& org_words, << " Index: " << i << "\n" << " Word: " << QString::fromUtf8(buf) << "\n" << " Expected: " << expectedAffixes << "\n" - << " Actual: " << actualAffixes << Qt::endl; + << " Actual: " << actualAffixes << "\n"; return false; } } @@ -148,7 +148,7 @@ int main(int argc, char *argv[]) out << "Usage: qwebengine_convert_dict \n\nExample:\n" "qwebengine_convert_dict ./en-US.dic ./en-US.bdic\nwill read en-US.dic, " "en-US.dic_delta, and en-US.aff from the current directory and generate " - "en-US.bdic\n" << Qt::endl; + "en-US.bdic\n\n"; return 1; } @@ -184,7 +184,7 @@ int main(int argc, char *argv[]) out << "Couldn't find ICU data directory. Please check that the following path exists: " << icuDataDir << "\nAlternatively provide the directory path via the QT_WEBENGINE_ICU_DAT_DIR " - "environment variable.\n" << Qt::endl; + "environment variable.\n\n"; return 1; } @@ -196,21 +196,21 @@ int main(int argc, char *argv[]) base::FilePath file_out_path = toFilePath(argv[2]); base::FilePath aff_path = file_in_path.ReplaceExtension(FILE_PATH_LITERAL(".aff")); - out << "Reading " << toQt(aff_path.value()) << Qt::endl; + out << "Reading " << toQt(aff_path.value()) << "\n"; convert_dict::AffReader aff_reader(aff_path); if (!aff_reader.Read()) { - out << "Unable to read the aff file." << Qt::endl; + out << "Unable to read the aff file.\n"; return 1; } base::FilePath dic_path = file_in_path.ReplaceExtension(FILE_PATH_LITERAL(".dic")); - out << "Reading " << toQt(dic_path.value()) << Qt::endl; + out << "Reading " << toQt(dic_path.value()) << "\n"; // DicReader will also read the .dic_delta file. convert_dict::DicReader dic_reader(dic_path); if (!dic_reader.Read(&aff_reader)) { - out << "Unable to read the dic file." << Qt::endl; + out << "Unable to read the dic file.\n"; return 1; } @@ -222,27 +222,27 @@ int main(int argc, char *argv[]) writer.SetOtherCommands(aff_reader.other_commands()); writer.SetWords(dic_reader.words()); - out << "Serializing..." << Qt::endl; + out << "Serializing...\n"; std::string serialized = writer.GetBDict(); - out << "Verifying..." << Qt::endl; + out << "Verifying...\n"; if (!VerifyWords(dic_reader.words(), serialized, out)) { - out << "ERROR converting, the dictionary does not check out OK." << Qt::endl; + out << "ERROR converting, the dictionary does not check out OK.\n"; return 1; } - out << "Writing " << toQt(file_out_path.value()) << Qt::endl; + out << "Writing " << toQt(file_out_path.value()) << "\n"; FILE *out_file = base::OpenFile(file_out_path, "wb"); if (!out_file) { - out << "ERROR writing file" << Qt::endl; + out << "ERROR writing file\n"; return 1; } size_t written = fwrite(&serialized[0], 1, serialized.size(), out_file); Q_ASSERT(written == serialized.size()); base::CloseFile(out_file); - out << "Success. Dictionary converted." << Qt::endl; + out << "Success. Dictionary converted.\n"; return 0; } diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.h b/src/webenginewidgets/api/qwebenginedownloaditem.h index 8d98799a3..094054079 100644 --- a/src/webenginewidgets/api/qwebenginedownloaditem.h +++ b/src/webenginewidgets/api/qwebenginedownloaditem.h @@ -119,10 +119,17 @@ public: QUrl url() const; QString mimeType() const; #if QT_DEPRECATED_SINCE(5, 14) +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) QT_DEPRECATED_VERSION_X(5, 14, "Use downloadDirectory() and downloadFileName() instead") QString path() const; QT_DEPRECATED_VERSION_X(5, 14, "Use setDownloadDirectory() and setDownloadFileName() instead") void setPath(QString path); +#else + QT_DEPRECATED_X("Use downloadDirectory() and downloadFileName() instead") + QString path() const; + QT_DEPRECATED_X("Use setDownloadDirectory() and setDownloadFileName() instead") + void setPath(QString path); +#endif #endif bool isFinished() const; bool isPaused() const; -- cgit v1.2.3 From 1b6457bb93aabc324495d1f0b1bef85762d56451 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCri=20Valdmann?= Date: Thu, 14 Nov 2019 14:25:58 +0100 Subject: Enable viz unless --disable-viz-display-compositor is given Since we now support running the GPU service on the UI thread even with viz, there's no longer any need for a --enable-viz-display-compositor flag. Fixes: QTBUG-79864 Change-Id: I86f6282a17e1e0ed56a91373eb2a2753085e981a Reviewed-by: Allan Sandfeld Jensen --- src/core/web_engine_context.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src') diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 88f5be726..17742e1d7 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -569,10 +569,8 @@ WebEngineContext::WebEngineContext() #endif threadedGpu = threadedGpu && !qEnvironmentVariableIsSet(kDisableInProcGpuThread); - bool enableViz = ((threadedGpu && !parsedCommandLine->HasSwitch("disable-viz-display-compositor")) - || parsedCommandLine->HasSwitch("enable-viz-display-compositor")); + bool enableViz = !parsedCommandLine->HasSwitch("disable-viz-display-compositor"); parsedCommandLine->RemoveSwitch("disable-viz-display-compositor"); - parsedCommandLine->RemoveSwitch("enable-viz-display-compositor"); std::string disableFeatures; std::string enableFeatures; -- cgit v1.2.3 From 0375890c48223f0b7d400b6abaa338c6f44796d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCri=20Valdmann?= Date: Thu, 9 Apr 2020 12:46:05 +0200 Subject: Disable accelerated and offscreen canvas for old renderer Offscreen canvas requires surface embedding which is a viz-only feature. Accelerated canvas uses gpu memory buffers which don't work with old renderer. Updates src/3rdparty with dependent change * 757b9f45 Expose WebPreferences::disable_features_depending_on_viz Fixes: QTBUG-56147 Change-Id: I90322f05554af43de5db9e386929d4faf5e65b6d Reviewed-by: Allan Sandfeld Jensen --- src/3rdparty | 2 +- src/core/web_engine_settings.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/3rdparty b/src/3rdparty index c81ff02d7..757b9f459 160000 --- a/src/3rdparty +++ b/src/3rdparty @@ -1 +1 @@ -Subproject commit c81ff02d7fc7695a62d6543e34b73a75071f7d78 +Subproject commit 757b9f459d3770644ad83d2faf26a7539c65023f diff --git a/src/core/web_engine_settings.cpp b/src/core/web_engine_settings.cpp index edd72a117..b9aa941a1 100644 --- a/src/core/web_engine_settings.cpp +++ b/src/core/web_engine_settings.cpp @@ -45,6 +45,7 @@ #include "base/command_line.h" #include "chrome/common/chrome_switches.h" +#include "components/viz/common/features.h" #include "content/browser/gpu/gpu_process_host.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" @@ -388,6 +389,11 @@ void WebEngineSettings::applySettingsToWebPreferences(content::WebPreferences *p prefs->dom_paste_enabled = testAttribute(JavascriptCanPaste); prefs->dns_prefetching_enabled = testAttribute(DnsPrefetchEnabled); + if (!features::IsVizDisplayCompositorEnabled()) { + prefs->accelerated_2d_canvas_enabled = false; + prefs->disable_features_depending_on_viz = true; + } + // Fonts settings. prefs->standard_font_family_map[content::kCommonScript] = toString16(fontFamily(StandardFont)); prefs->fixed_font_family_map[content::kCommonScript] = toString16(fontFamily(FixedFont)); -- cgit v1.2.3 From 0ac8e8197f2c746db46ff10461c691678353ac23 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 8 Apr 2020 12:51:58 +0200 Subject: Update build requirements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update to requiring macOS 10.13 and Xcode 10. Change-Id: I50aae730096da76e8917041211e7c143a69941eb Reviewed-by: Jüri Valdmann --- src/webengine/doc/src/qtwebengine-platform-notes.qdoc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/webengine/doc/src/qtwebengine-platform-notes.qdoc b/src/webengine/doc/src/qtwebengine-platform-notes.qdoc index 1af2141b1..982363bb2 100644 --- a/src/webengine/doc/src/qtwebengine-platform-notes.qdoc +++ b/src/webengine/doc/src/qtwebengine-platform-notes.qdoc @@ -87,7 +87,7 @@ \section2 Linux On Linux, Clang or GCC version 5 or later is required. - Supported configurations are \c linux-g++ and \c{linux-clang}. + Supported configurations are \c linux-g++, \c{linux-clang} and \c{linux-clang-libc++} \QWE requires \c pkg-config to detect most of its dependencies. The following \c pkg-config files are required: @@ -117,9 +117,9 @@ On \macos, the following are required: \list - \li \macos 10.12 or later - \li Xcode 8.3.3 or later - \li \macos 10.12 SDK or later + \li \macos 10.13 or later + \li Xcode 10.0 or later + \li \macos 10.13 SDK or later \endlist \note \QWE cannot be built for the 32-bit mode of \macos (using the @@ -128,8 +128,8 @@ \section1 Using Earlier Qt Versions to Build \QWE Building \QWE with earlier Qt versions (down to the last LTS - version) is supported. It means that \QWE 5.11 can be built with - Qt 5.9.x, Qt 5.10.x, and Qt 5.11. + version) is supported. It means that \QWE 5.15 can be built with + Qt 5.12.x, Qt 5.14.x, and Qt 5.15. To use an earlier Qt version to build Qt Webengine: -- cgit v1.2.3 From 3125f1ac3951c63c20110c7e3946ca281cebbdf3 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 14 Apr 2020 12:47:08 +0200 Subject: Remove ExtensionsBrowserAPIProviderQt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don't add any extension API beyond the core ones and are just duplicating what CoreExtensionsBrowserAPIProvider does. Change-Id: Ia50f89e7e23dc0e155f8f2e01b4f7f1e262cbe53 Reviewed-by: Jüri Valdmann --- src/core/core_chromium.pri | 2 - .../extensions_browser_api_provider_qt.cpp | 54 ------------------- .../extensions_browser_api_provider_qt.h | 62 ---------------------- .../extensions/extensions_browser_client_qt.cpp | 12 ----- 4 files changed, 130 deletions(-) delete mode 100644 src/core/extensions/extensions_browser_api_provider_qt.cpp delete mode 100644 src/core/extensions/extensions_browser_api_provider_qt.h (limited to 'src') diff --git a/src/core/core_chromium.pri b/src/core/core_chromium.pri index 6a8b8c4bd..e1f5cd7ac 100644 --- a/src/core/core_chromium.pri +++ b/src/core/core_chromium.pri @@ -334,7 +334,6 @@ qtConfig(webengine-extensions) { extensions/extension_system_factory_qt.cpp \ extensions/extension_web_contents_observer_qt.cpp \ extensions/extensions_api_client_qt.cpp \ - extensions/extensions_browser_api_provider_qt.cpp \ extensions/extensions_browser_client_qt.cpp \ extensions/mime_handler_view_guest_delegate_qt.cpp \ net/plugin_response_interceptor_url_loader_throttle.cpp \ @@ -351,7 +350,6 @@ qtConfig(webengine-extensions) { extensions/extension_system_factory_qt.h \ extensions/extension_web_contents_observer_qt.h \ extensions/extensions_api_client_qt.h \ - extensions/extensions_browser_api_provider_qt.h \ extensions/extensions_browser_client_qt.h \ extensions/mime_handler_view_guest_delegate_qt.h \ net/plugin_response_interceptor_url_loader_throttle.h \ diff --git a/src/core/extensions/extensions_browser_api_provider_qt.cpp b/src/core/extensions/extensions_browser_api_provider_qt.cpp deleted file mode 100644 index 731dfb0fd..000000000 --- a/src/core/extensions/extensions_browser_api_provider_qt.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 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$ -** -****************************************************************************/ - -#include "extensions_browser_api_provider_qt.h" - -#include "extensions/browser/api/generated_api_registration.h" - -namespace extensions { -ExtensionsBrowserAPIProviderQt::ExtensionsBrowserAPIProviderQt() = default; -ExtensionsBrowserAPIProviderQt::~ExtensionsBrowserAPIProviderQt() = default; - -void ExtensionsBrowserAPIProviderQt::RegisterExtensionFunctions(ExtensionFunctionRegistry *registry) -{ - api::GeneratedFunctionRegistry::RegisterAll(registry); -} - - -} diff --git a/src/core/extensions/extensions_browser_api_provider_qt.h b/src/core/extensions/extensions_browser_api_provider_qt.h deleted file mode 100644 index f1d10ac95..000000000 --- a/src/core/extensions/extensions_browser_api_provider_qt.h +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 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 EXTENSIONS_API_PROVIDER_QT_H -#define EXTENSIONS_API_PROVIDER_QT_H - -#include "extensions/browser/extensions_browser_api_provider.h" -#include "base/macros.h" - -namespace extensions { - -class ExtensionsBrowserAPIProviderQt : public ExtensionsBrowserAPIProvider -{ -public: - ExtensionsBrowserAPIProviderQt(); - ~ExtensionsBrowserAPIProviderQt() override; - - void RegisterExtensionFunctions(ExtensionFunctionRegistry *registry) override; - -private: - DISALLOW_COPY_AND_ASSIGN(ExtensionsBrowserAPIProviderQt); -}; - -} - -#endif // EXTENSIONS_API_PROVIDER_QT_H diff --git a/src/core/extensions/extensions_browser_client_qt.cpp b/src/core/extensions/extensions_browser_client_qt.cpp index 8b5da3d60..1b2bb51f4 100644 --- a/src/core/extensions/extensions_browser_client_qt.cpp +++ b/src/core/extensions/extensions_browser_client_qt.cpp @@ -79,7 +79,6 @@ #include "extension_system_factory_qt.h" #include "extension_web_contents_observer_qt.h" #include "extensions_api_client_qt.h" -#include "extensions_browser_api_provider_qt.h" #include "extensions_browser_client_qt.h" #include "web_engine_library_info.h" @@ -274,7 +273,6 @@ ExtensionsBrowserClientQt::ExtensionsBrowserClientQt() , resource_manager_(new ComponentExtensionResourceManagerQt) { AddAPIProvider(std::make_unique()); - AddAPIProvider(std::make_unique()); } ExtensionsBrowserClientQt::~ExtensionsBrowserClientQt() @@ -451,12 +449,6 @@ ExtensionSystemProvider *ExtensionsBrowserClientQt::GetExtensionSystemFactory() return ExtensionSystemFactoryQt::GetInstance(); } -// void ExtensionsBrowserClientQt::RegisterExtensionFunctions(ExtensionFunctionRegistry *registry) const -//{ -// // Register core extension-system APIs. -// api::GeneratedFunctionRegistry::RegisterAll(registry); -//} - void ExtensionsBrowserClientQt::RegisterExtensionInterfaces(service_manager::BinderRegistryWithArgs *registry, content::RenderFrameHost *render_frame_host, const Extension *extension) const @@ -470,10 +462,6 @@ void ExtensionsBrowserClientQt::RegisterBrowserInterfaceBindersForFrame( const Extension* extension) const { PopulateExtensionFrameBinders(binder_map, render_frame_host, extension); - - // FIXME Do we need something from here? - // PopulateChromeFrameBindersForExtension(binder_map, render_frame_host, - // extension); } std::unique_ptr ExtensionsBrowserClientQt::CreateRuntimeAPIDelegate(content::BrowserContext *context) const -- cgit v1.2.3 From eb96f424587c5da4eabe1306e4c277879a245c02 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 24 Jun 2019 14:41:46 +0200 Subject: Join some features request and response functions Will make it easier to expands with more features in the future Change-Id: Ic7c1aca23a543c95a4873471c918f74606be2053 Reviewed-by: Kirill Burtsev --- src/core/permission_manager_qt.cpp | 37 ++++++++++++++++------------- src/core/web_contents_adapter.cpp | 10 ++------ src/core/web_contents_adapter.h | 3 +-- src/core/web_contents_adapter_client.h | 6 ++--- src/core/web_contents_delegate_qt.cpp | 9 ++----- src/core/web_contents_delegate_qt.h | 3 +-- src/webengine/api/qquickwebengineview.cpp | 23 ++++++++++++------ src/webengine/api/qquickwebengineview_p_p.h | 3 +-- src/webenginewidgets/api/qwebenginepage.cpp | 32 +++++++++++++++---------- src/webenginewidgets/api/qwebenginepage_p.h | 3 +-- 10 files changed, 67 insertions(+), 62 deletions(-) (limited to 'src') diff --git a/src/core/permission_manager_qt.cpp b/src/core/permission_manager_qt.cpp index c6eb2c238..16a7b25bf 100644 --- a/src/core/permission_manager_qt.cpp +++ b/src/core/permission_manager_qt.cpp @@ -52,7 +52,7 @@ namespace QtWebEngineCore { -ProfileAdapter::PermissionType toQt(content::PermissionType type) +static ProfileAdapter::PermissionType toQt(content::PermissionType type) { switch (type) { case content::PermissionType::GEOLOCATION: @@ -90,6 +90,18 @@ ProfileAdapter::PermissionType toQt(content::PermissionType type) return ProfileAdapter::UnsupportedPermission; } +static bool canRequestPermissionFor(ProfileAdapter::PermissionType type) +{ + switch (type) { + case ProfileAdapter::GeolocationPermission: + case ProfileAdapter::NotificationPermission: + return true; + default: + break; + } + return false; +} + PermissionManagerQt::PermissionManagerQt() : m_requestIdCount(0) , m_subscriberIdCount(0) @@ -170,10 +182,7 @@ int PermissionManagerQt::RequestPermission(content::PermissionType permission, Q_ASSERT(contentsDelegate); ProfileAdapter::PermissionType permissionType = toQt(permission); - if (permissionType == ProfileAdapter::UnsupportedPermission) { - std::move(callback).Run(blink::mojom::PermissionStatus::DENIED); - return content::PermissionController::kNoPendingOperation; - } else if (permissionType == ProfileAdapter::ClipboardRead) { + if (permissionType == ProfileAdapter::ClipboardRead) { WebEngineSettings *settings = contentsDelegate->webEngineSettings(); if (settings->testAttribute(WebEngineSettings::JavascriptCanAccessClipboard) && settings->testAttribute(WebEngineSettings::JavascriptCanPaste)) @@ -181,19 +190,15 @@ int PermissionManagerQt::RequestPermission(content::PermissionType permission, else std::move(callback).Run(blink::mojom::PermissionStatus::DENIED); return content::PermissionController::kNoPendingOperation; + } else if (!canRequestPermissionFor(permissionType)) { + std::move(callback).Run(blink::mojom::PermissionStatus::DENIED); + return content::PermissionController::kNoPendingOperation; } - // Audio and video-capture should not come this way currently - Q_ASSERT(permissionType != ProfileAdapter::AudioCapturePermission - && permissionType != ProfileAdapter::VideoCapturePermission); int request_id = ++m_requestIdCount; auto requestOrigin = toQt(requesting_origin); m_requests.push_back({ request_id, permissionType, requestOrigin, std::move(callback) }); - if (permissionType == ProfileAdapter::GeolocationPermission) - contentsDelegate->requestGeolocationPermission(requestOrigin); - else if (permissionType == ProfileAdapter::NotificationPermission) - contentsDelegate->requestUserNotificationPermission(requestOrigin); - + contentsDelegate->requestFeaturePermission(permissionType, requestOrigin); return request_id; } @@ -236,10 +241,8 @@ int PermissionManagerQt::RequestPermissions(const std::vectorrequestGeolocationPermission(requestOrigin); - else if (permissionType == ProfileAdapter::NotificationPermission) - contentsDelegate->requestUserNotificationPermission(requestOrigin); + if (canRequestPermissionFor(permissionType)) + contentsDelegate->requestFeaturePermission(permissionType, requestOrigin); } return request_id; } diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 61f8e5da0..a97db169b 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -1356,16 +1356,10 @@ void WebContentsAdapter::grantMediaAccessPermission(const QUrl &securityOrigin, MediaCaptureDevicesDispatcher::GetInstance()->handleMediaAccessPermissionResponse(m_webContents.get(), securityOrigin, flags); } -void WebContentsAdapter::runGeolocationRequestCallback(const QUrl &securityOrigin, bool allowed) +void WebContentsAdapter::runFeatureRequestCallback(const QUrl &securityOrigin, ProfileAdapter::PermissionType feature, bool allowed) { CHECK_INITIALIZED(); - m_profileAdapter->permissionRequestReply(securityOrigin, ProfileAdapter::GeolocationPermission, allowed); -} - -void WebContentsAdapter::runUserNotificationRequestCallback(const QUrl &securityOrigin, bool allowed) -{ - CHECK_INITIALIZED(); - m_profileAdapter->permissionRequestReply(securityOrigin, ProfileAdapter::NotificationPermission, allowed); + m_profileAdapter->permissionRequestReply(securityOrigin, feature, allowed); } void WebContentsAdapter::grantMouseLockPermission(bool granted) diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h index ef9d21b8f..1a76cd3c1 100644 --- a/src/core/web_contents_adapter.h +++ b/src/core/web_contents_adapter.h @@ -192,9 +192,8 @@ public: void devToolsFrontendDestroyed(DevToolsFrontendQt *frontend); void grantMediaAccessPermission(const QUrl &securityOrigin, WebContentsAdapterClient::MediaRequestFlags flags); - void runGeolocationRequestCallback(const QUrl &securityOrigin, bool allowed); void grantMouseLockPermission(bool granted); - void runUserNotificationRequestCallback(const QUrl &securityOrigin, bool allowed); + void runFeatureRequestCallback(const QUrl &securityOrigin, ProfileAdapter::PermissionType feature, bool allowed); void setBackgroundColor(const QColor &color); QAccessibleInterface *browserAccessible(); diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h index 3a75185f8..04df0450c 100644 --- a/src/core/web_contents_adapter_client.h +++ b/src/core/web_contents_adapter_client.h @@ -53,6 +53,8 @@ #include "qtwebenginecoreglobal_p.h" +#include "profile_adapter.h" + #include #include #include @@ -76,7 +78,6 @@ struct DropData; namespace QtWebEngineCore { class AuthenticationDialogController; -class ProfileAdapter; class ColorChooserController; class FilePickerController; class JavaScriptDialogController; @@ -489,12 +490,11 @@ public: virtual QObject *accessibilityParentObject() = 0; virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID) = 0; virtual void authenticationRequired(QSharedPointer) = 0; - virtual void runGeolocationPermissionRequest(const QUrl &securityOrigin) = 0; + virtual void runFeaturePermissionRequest(ProfileAdapter::PermissionType, const QUrl &securityOrigin) = 0; virtual void runMediaAccessPermissionRequest(const QUrl &securityOrigin, MediaRequestFlags requestFlags) = 0; virtual void runMouseLockPermissionRequest(const QUrl &securityOrigin) = 0; virtual void runQuotaRequest(QWebEngineQuotaRequest) = 0; virtual void runRegisterProtocolHandlerRequest(QWebEngineRegisterProtocolHandlerRequest) = 0; - virtual void runUserNotificationPermissionRequest(const QUrl &securityOrigin) = 0; virtual WebEngineSettings *webEngineSettings() const = 0; RenderProcessTerminationStatus renderProcessExitStatus(int); virtual void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, int exitCode) = 0; diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index d1cdb8d9f..fada874a3 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -683,14 +683,9 @@ void WebContentsDelegateQt::selectClientCert(const QSharedPointerselectClientCert(selectController); } -void WebContentsDelegateQt::requestGeolocationPermission(const QUrl &requestingOrigin) +void WebContentsDelegateQt::requestFeaturePermission(ProfileAdapter::PermissionType feature, const QUrl &requestingOrigin) { - m_viewClient->runGeolocationPermissionRequest(requestingOrigin); -} - -void WebContentsDelegateQt::requestUserNotificationPermission(const QUrl &requestingOrigin) -{ - m_viewClient->runUserNotificationPermissionRequest(requestingOrigin); + m_viewClient->runFeaturePermissionRequest(feature, requestingOrigin); } extern WebContentsAdapterClient::NavigationType pageTransitionToNavigationType(ui::PageTransition transition); diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h index 81d6c8671..f32b02caf 100644 --- a/src/core/web_contents_delegate_qt.h +++ b/src/core/web_contents_delegate_qt.h @@ -172,8 +172,7 @@ public: void overrideWebPreferences(content::WebContents *, content::WebPreferences*); void allowCertificateError(const QSharedPointer &); void selectClientCert(const QSharedPointer &); - void requestGeolocationPermission(const QUrl &requestingOrigin); - void requestUserNotificationPermission(const QUrl &requestingOrigin); + void requestFeaturePermission(ProfileAdapter::PermissionType feature, const QUrl &requestingOrigin); void launchExternalURL(const QUrl &url, ui::PageTransition page_transition, bool is_main_frame, bool has_user_gesture); FaviconManager *faviconManager(); FindTextHelper *findTextHelper(); diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index bcbf95569..7052afe42 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -316,16 +316,25 @@ void QQuickWebEngineViewPrivate::selectClientCert(const QSharedPointerfeaturePermissionRequested(url, QQuickWebEngineView::Geolocation); + switch (type) { + case QtWebEngineCore::ProfileAdapter::NotificationPermission: + return QQuickWebEngineView::Notifications; + case QtWebEngineCore::ProfileAdapter::GeolocationPermission: + return QQuickWebEngineView::Geolocation; + default: + break; + } + Q_UNREACHABLE(); + return QQuickWebEngineView::Feature(-1); } -void QQuickWebEngineViewPrivate::runUserNotificationPermissionRequest(const QUrl &url) + +void QQuickWebEngineViewPrivate::runFeaturePermissionRequest(QtWebEngineCore::ProfileAdapter::PermissionType permission, const QUrl &url) { Q_Q(QQuickWebEngineView); - Q_EMIT q->featurePermissionRequested(url, QQuickWebEngineView::Notifications); + Q_EMIT q->featurePermissionRequested(url, toFeature(permission)); } void QQuickWebEngineViewPrivate::showColorDialog(QSharedPointer controller) @@ -1629,7 +1638,7 @@ void QQuickWebEngineView::grantFeaturePermission(const QUrl &securityOrigin, QQu d_ptr->adapter->grantMediaAccessPermission(securityOrigin, WebContentsAdapterClient::MediaRequestFlags(WebContentsAdapterClient::MediaAudioCapture | WebContentsAdapterClient::MediaVideoCapture)); break; case Geolocation: - d_ptr->adapter->runGeolocationRequestCallback(securityOrigin, granted); + d_ptr->adapter->runFeatureRequestCallback(securityOrigin, ProfileAdapter::GeolocationPermission, granted); break; case DesktopVideoCapture: d_ptr->adapter->grantMediaAccessPermission(securityOrigin, WebContentsAdapterClient::MediaDesktopVideoCapture); @@ -1642,7 +1651,7 @@ void QQuickWebEngineView::grantFeaturePermission(const QUrl &securityOrigin, QQu WebContentsAdapterClient::MediaDesktopVideoCapture)); break; case Notifications: - d_ptr->adapter->runUserNotificationRequestCallback(securityOrigin, granted); + d_ptr->adapter->runFeatureRequestCallback(securityOrigin, ProfileAdapter::NotificationPermission, granted); break; default: Q_UNREACHABLE(); diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h index 6f9b552ec..5c884e36e 100644 --- a/src/webengine/api/qquickwebengineview_p_p.h +++ b/src/webengine/api/qquickwebengineview_p_p.h @@ -148,8 +148,7 @@ public: QtWebEngineCore::WebEngineSettings *webEngineSettings() const override; void allowCertificateError(const QSharedPointer &errorController) override; void selectClientCert(const QSharedPointer &selectController) override; - void runGeolocationPermissionRequest(QUrl const&) override; - void runUserNotificationPermissionRequest(QUrl const&) override; + void runFeaturePermissionRequest(QtWebEngineCore::ProfileAdapter::PermissionType permission, const QUrl &securityOrigin) override; void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, int exitCode) override; void requestGeometryChange(const QRect &geometry, const QRect &frameGeometry) override; void updateScrollPosition(const QPointF &position) override; diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index 55fa6a078..0d2988421 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -537,10 +537,24 @@ void QWebEnginePagePrivate::runMediaAccessPermissionRequest(const QUrl &security Q_EMIT q->featurePermissionRequested(securityOrigin, feature); } -void QWebEnginePagePrivate::runGeolocationPermissionRequest(const QUrl &securityOrigin) +static QWebEnginePage::Feature toFeature(QtWebEngineCore::ProfileAdapter::PermissionType type) +{ + switch (type) { + case QtWebEngineCore::ProfileAdapter::NotificationPermission: + return QWebEnginePage::Notifications; + case QtWebEngineCore::ProfileAdapter::GeolocationPermission: + return QWebEnginePage::Geolocation; + default: + break; + } + Q_UNREACHABLE(); + return QWebEnginePage::Feature(-1); +} + +void QWebEnginePagePrivate::runFeaturePermissionRequest(QtWebEngineCore::ProfileAdapter::PermissionType permission, const QUrl &securityOrigin) { Q_Q(QWebEnginePage); - Q_EMIT q->featurePermissionRequested(securityOrigin, QWebEnginePage::Geolocation); + Q_EMIT q->featurePermissionRequested(securityOrigin, toFeature(permission)); } void QWebEnginePagePrivate::runMouseLockPermissionRequest(const QUrl &securityOrigin) @@ -561,12 +575,6 @@ void QWebEnginePagePrivate::runRegisterProtocolHandlerRequest(QWebEngineRegister Q_EMIT q->registerProtocolHandlerRequested(request); } -void QWebEnginePagePrivate::runUserNotificationPermissionRequest(const QUrl &securityOrigin) -{ - Q_Q(QWebEnginePage); - Q_EMIT q->featurePermissionRequested(securityOrigin, QWebEnginePage::Notifications); -} - QObject *QWebEnginePagePrivate::accessibilityParentObject() { return view; @@ -1976,13 +1984,13 @@ void QWebEnginePage::setFeaturePermission(const QUrl &securityOrigin, QWebEngine d->adapter->grantMediaAccessPermission(securityOrigin, WebContentsAdapterClient::MediaDesktopVideoCapture); break; case Geolocation: - d->adapter->runGeolocationRequestCallback(securityOrigin, true); + d->adapter->runFeatureRequestCallback(securityOrigin, ProfileAdapter::GeolocationPermission, true); break; case MouseLock: d->adapter->grantMouseLockPermission(true); break; case Notifications: - d->adapter->runUserNotificationRequestCallback(securityOrigin, true); + d->adapter->runFeatureRequestCallback(securityOrigin, ProfileAdapter::NotificationPermission, true); break; } } else { // if (policy == PermissionDeniedByUser) @@ -1995,13 +2003,13 @@ void QWebEnginePage::setFeaturePermission(const QUrl &securityOrigin, QWebEngine d->adapter->grantMediaAccessPermission(securityOrigin, WebContentsAdapterClient::MediaNone); break; case Geolocation: - d->adapter->runGeolocationRequestCallback(securityOrigin, false); + d->adapter->runFeatureRequestCallback(securityOrigin, ProfileAdapter::GeolocationPermission, false); break; case MouseLock: d->adapter->grantMouseLockPermission(false); break; case Notifications: - d->adapter->runUserNotificationRequestCallback(securityOrigin, false); + d->adapter->runFeatureRequestCallback(securityOrigin, ProfileAdapter::NotificationPermission, false); break; } } diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h index 7fdc811e2..4f33e26f3 100644 --- a/src/webenginewidgets/api/qwebenginepage_p.h +++ b/src/webenginewidgets/api/qwebenginepage_p.h @@ -136,8 +136,7 @@ public: void authenticationRequired(QSharedPointer) override; void releaseProfile() override; void runMediaAccessPermissionRequest(const QUrl &securityOrigin, MediaRequestFlags requestFlags) override; - void runGeolocationPermissionRequest(const QUrl &securityOrigin) override; - void runUserNotificationPermissionRequest(const QUrl &securityOrigin) override; + void runFeaturePermissionRequest(QtWebEngineCore::ProfileAdapter::PermissionType permission, const QUrl &securityOrigin) override; void runMouseLockPermissionRequest(const QUrl &securityOrigin) override; void runQuotaRequest(QWebEngineQuotaRequest) override; void runRegisterProtocolHandlerRequest(QWebEngineRegisterProtocolHandlerRequest) override; -- cgit v1.2.3 From 270ecb76d378b1cf8a5db63b100f6ddafdd796ef Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 16 Apr 2020 13:06:58 +0200 Subject: Replace deprecated call to TouchPoint::rect() with ellipseDiameters() GetTouchMajor/Minor sound like they are intended to return ellipse diameters, so it was clearly the right thing to do already, any time after 5.6 when rect() was deprecated. Change-Id: I3cbb1e9f38206626fdd9fe2eb3d799662751c475 Reviewed-by: Allan Sandfeld Jensen --- src/core/render_widget_host_view_qt.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index 813ce4be9..5887b356e 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -1,3 +1,4 @@ + /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. @@ -216,13 +217,13 @@ public: float GetRawY(size_t pointer_index) const override { return touchPoints.at(pointer_index).screenPos().y(); } float GetTouchMajor(size_t pointer_index) const override { - QRectF touchRect = touchPoints.at(pointer_index).rect(); - return std::max(touchRect.height(), touchRect.width()); + QSizeF diams = touchPoints.at(pointer_index).ellipseDiameters(); + return std::max(diams.height(), diams.width()); } float GetTouchMinor(size_t pointer_index) const override { - QRectF touchRect = touchPoints.at(pointer_index).rect(); - return std::min(touchRect.height(), touchRect.width()); + QSizeF diams = touchPoints.at(pointer_index).ellipseDiameters(); + return std::min(diams.height(), diams.width()); } float GetOrientation(size_t pointer_index) const override { -- cgit v1.2.3 From 707b66cbf7da4e31bfd897e5c4bc6889bc09ef9a Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 8 Apr 2020 09:20:18 +0000 Subject: PdfLinkModel: support the remaining link action types In practice, some PDFs contain links for which FPDFAction_GetType() reports PDFACTION_UNSUPPORTED and yet we can successfully get the same information as if it were PDFACTION_GOTO. For example https://www.openexr.com/documentation/TechnicalIntroduction.pdf contains some of these. PDFACTION_URI is another web link representation: for example in https://www.w3.org/WAI/WCAG21/working-examples/pdf-links/links.pdf PDFACTION_LAUNCH and PDFACTION_REMOTEGOTO will be trickier to support in actual viewer applications, but at least we should provide the file path to open, as a URL. Log similar warnings each time an invalid aspect of a link is encountered, into the qt.pdf.links logging category. Change-Id: I7ca24baa10524611e0705e89a07906ab7b74dadb Reviewed-by: Shawn Rutledge --- src/pdf/qpdflinkmodel.cpp | 83 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 62 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/pdf/qpdflinkmodel.cpp b/src/pdf/qpdflinkmodel.cpp index 96e6ddd5c..4020f036e 100644 --- a/src/pdf/qpdflinkmodel.cpp +++ b/src/pdf/qpdflinkmodel.cpp @@ -144,7 +144,7 @@ void QPdfLinkModelPrivate::update() const QPdfMutexLocker lock; FPDF_PAGE pdfPage = FPDF_LoadPage(doc, page); if (!pdfPage) { - qWarning() << "failed to load page" << page; + qCWarning(qLcLink) << "failed to load page" << page; return; } double pageHeight = FPDF_GetPageHeight(pdfPage); @@ -153,35 +153,76 @@ void QPdfLinkModelPrivate::update() // Iterate the ordinary links int linkStart = 0; - bool ok = true; - while (ok) { + bool hasNext = true; + while (hasNext) { FPDF_LINK linkAnnot; - ok = FPDFLink_Enumerate(pdfPage, &linkStart, &linkAnnot); - if (!ok) + hasNext = FPDFLink_Enumerate(pdfPage, &linkStart, &linkAnnot); + if (!hasNext) break; FS_RECTF rect; - ok = FPDFLink_GetAnnotRect(linkAnnot, &rect); - if (!ok) - break; + bool ok = FPDFLink_GetAnnotRect(linkAnnot, &rect); + if (!ok) { + qCWarning(qLcLink) << "skipping link with invalid bounding box"; + continue; // while enumerating links + } Link linkData; linkData.rect = QRectF(rect.left, pageHeight - rect.top, rect.right - rect.left, rect.top - rect.bottom); FPDF_DEST dest = FPDFLink_GetDest(doc, linkAnnot); FPDF_ACTION action = FPDFLink_GetAction(linkAnnot); - if (FPDFAction_GetType(action) != PDFACTION_GOTO) { - qWarning() << "link action type" << FPDFAction_GetType(action) << "is not yet supported"; - continue; + switch (FPDFAction_GetType(action)) { + case PDFACTION_UNSUPPORTED: // this happens with valid links in some PDFs + case PDFACTION_GOTO: { + linkData.page = FPDFDest_GetDestPageIndex(doc, dest); + if (linkData.page < 0) { + qCWarning(qLcLink) << "skipping link with invalid page number"; + continue; // while enumerating links + } + FPDF_BOOL hasX, hasY, hasZoom; + FS_FLOAT x, y, zoom; + ok = FPDFDest_GetLocationInPage(dest, &hasX, &hasY, &hasZoom, &x, &y, &zoom); + if (!ok) { + qCWarning(qLcLink) << "link with invalid location and/or zoom @" << linkData.rect; + break; // at least we got a page number, so the link will jump there + } + if (hasX && hasY) + linkData.location = QPointF(x, pageHeight - y); + if (hasZoom) + linkData.zoom = zoom; + break; + } + case PDFACTION_URI: { + unsigned long len = FPDFAction_GetURIPath(doc, action, nullptr, 0); + if (len < 1) { + qCWarning(qLcLink) << "skipping link with empty URI @" << linkData.rect; + continue; // while enumerating links + } else { + QByteArray buf(len, 0); + unsigned long got = FPDFAction_GetURIPath(doc, action, buf.data(), len); + Q_ASSERT(got == len); + linkData.url = QString::fromLatin1(buf.data(), got - 1); + } + break; } - linkData.page = FPDFDest_GetDestPageIndex(doc, dest); - FPDF_BOOL hasX, hasY, hasZoom; - FS_FLOAT x, y, zoom; - ok = FPDFDest_GetLocationInPage(dest, &hasX, &hasY, &hasZoom, &x, &y, &zoom); - if (!ok) + case PDFACTION_LAUNCH: + case PDFACTION_REMOTEGOTO: { + unsigned long len = FPDFAction_GetFilePath(action, nullptr, 0); + if (len < 1) { + qCWarning(qLcLink) << "skipping link with empty file path @" << linkData.rect; + continue; // while enumerating links + } else { + QByteArray buf(len, 0); + unsigned long got = FPDFAction_GetFilePath(action, buf.data(), len); + Q_ASSERT(got == len); + linkData.url = QUrl::fromLocalFile(QString::fromLatin1(buf.data(), got - 1)).toString(); + + // Unfortunately, according to comments in fpdf_doc.h, if it's PDFACTION_REMOTEGOTO, + // we can't get the page and location without first opening the linked document + // and then calling FPDFAction_GetDest() again. + } break; - if (hasX && hasY) - linkData.location = QPointF(x, pageHeight - y); - if (hasZoom) - linkData.zoom = zoom; + } + } links << linkData; } @@ -195,7 +236,7 @@ void QPdfLinkModelPrivate::update() Link linkData; int len = FPDFLink_GetURL(webLinks, i, nullptr, 0); if (len < 1) { - qWarning() << "URL" << i << "has length" << len; + qCWarning(qLcLink) << "skipping link" << i << "with empty URL"; } else { QVector buf(len); int got = FPDFLink_GetURL(webLinks, i, buf.data(), len); -- cgit v1.2.3 From a05bb73747620dd8f0294a57ff690a4f4202884e Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Thu, 16 Apr 2020 13:20:04 +0200 Subject: Move request interceptor to ui thread We use now network service avoid io-ui-io-ui hops, pipe proxying url loader factory directly to ui thread. This solves thread safty issues. Add deprecated request interceptor test cases. Task-number: QTBUG-83082 Task-number: QTBUG-82999 Change-Id: I38778cf1a70789c5e92e04c93d1c93e2cc4c765a Reviewed-by: Allan Sandfeld Jensen --- src/core/api/qwebengineurlrequestinfo.cpp | 5 +- src/core/api/qwebengineurlrequestinfo_p.h | 2 +- src/core/content_browser_client_qt.cpp | 35 ++-- src/core/net/proxying_url_loader_factory_qt.cpp | 226 +++++++++--------------- src/core/net/proxying_url_loader_factory_qt.h | 21 ++- src/core/web_contents_adapter.cpp | 10 ++ src/core/web_contents_adapter.h | 5 + src/core/web_contents_adapter_client.h | 3 +- src/webenginewidgets/api/qwebenginepage.cpp | 18 +- src/webenginewidgets/api/qwebenginepage_p.h | 2 - src/webenginewidgets/api/qwebengineprofile.cpp | 1 + 11 files changed, 145 insertions(+), 183 deletions(-) (limited to 'src') diff --git a/src/core/api/qwebengineurlrequestinfo.cpp b/src/core/api/qwebengineurlrequestinfo.cpp index 3816f08ca..5ed729f5e 100644 --- a/src/core/api/qwebengineurlrequestinfo.cpp +++ b/src/core/api/qwebengineurlrequestinfo.cpp @@ -131,10 +131,12 @@ ASSERT_ENUMS_MATCH(QtWebEngineCore::WebContentsAdapterClient::RedirectNavigation QWebEngineUrlRequestInfoPrivate::QWebEngineUrlRequestInfoPrivate(QWebEngineUrlRequestInfo::ResourceType resource, QWebEngineUrlRequestInfo::NavigationType navigation, - const QUrl &u, const QUrl &fpu, const QUrl &i, const QByteArray &m) + const QUrl &u, const QUrl &fpu, const QUrl &i, + const QByteArray &m) : resourceType(resource) , navigationType(navigation) , shouldBlockRequest(false) + , shouldRedirectRequest(false) , url(u) , firstPartyUrl(fpu) , initiator(i) @@ -310,6 +312,7 @@ void QWebEngineUrlRequestInfo::redirect(const QUrl &url) { d_ptr->changed = true; d_ptr->url = url; + d_ptr->shouldRedirectRequest = true; } /*! diff --git a/src/core/api/qwebengineurlrequestinfo_p.h b/src/core/api/qwebengineurlrequestinfo_p.h index 35b5610be..206104ec9 100644 --- a/src/core/api/qwebengineurlrequestinfo_p.h +++ b/src/core/api/qwebengineurlrequestinfo_p.h @@ -75,7 +75,7 @@ public: QWebEngineUrlRequestInfo::ResourceType resourceType; QWebEngineUrlRequestInfo::NavigationType navigationType; bool shouldBlockRequest; - + bool shouldRedirectRequest; QUrl url; QUrl firstPartyUrl; QUrl initiator; diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index 22dbc173b..cac392182 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -57,6 +57,7 @@ #include "components/network_hints/browser/simple_network_hints_handler_impl.h" #include "components/spellcheck/spellcheck_buildflags.h" #include "content/browser/renderer_host/render_view_host_delegate.h" +#include "content/browser/web_contents/web_contents_impl.h" #include "content/common/url_schemes.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" @@ -136,8 +137,10 @@ #include "renderer_host/user_resource_controller_host.h" #include "type_conversion.h" #include "web_contents_adapter_client.h" +#include "web_contents_adapter.h" #include "web_contents_delegate_qt.h" #include "web_engine_context.h" +#include "web_contents_view_qt.h" #include "web_engine_library_info.h" #include "api/qwebenginecookiestore.h" #include "api/qwebenginecookiestore_p.h" @@ -1205,17 +1208,29 @@ bool ContentBrowserClientQt::WillCreateURLLoaderFactory( bool *bypass_redirect_checks, network::mojom::URLLoaderFactoryOverridePtr *factory_override) { - auto proxied_receiver = std::move(*factory_receiver); - network::mojom::URLLoaderFactoryPtrInfo target_factory_info; - *factory_receiver = mojo::MakeRequest(&target_factory_info); - int process_id = (type == URLLoaderFactoryType::kNavigation) ? 0 : render_process_id; + auto *web_contents = content::WebContents::FromRenderFrameHost(frame); + ProfileQt *profile = static_cast(browser_context); - base::PostTask(FROM_HERE, { content::BrowserThread::IO }, - base::BindOnce(&ProxyingURLLoaderFactoryQt::CreateProxy, process_id, - browser_context->GetResourceContext(), - std::move(proxied_receiver), - std::move(target_factory_info))); - return true; + QWebEngineUrlRequestInterceptor *profile_interceptor = profile->profileAdapter()->requestInterceptor(); + QWebEngineUrlRequestInterceptor *page_interceptor = nullptr; + + if (web_contents) { + WebContentsAdapterClient *client = + WebContentsViewQt::from(static_cast(web_contents)->GetView())->client(); + page_interceptor = client->webContentsAdapter()->requestInterceptor(); + } + + if (profile_interceptor || page_interceptor) { + int process_id = type == URLLoaderFactoryType::kNavigation ? 0 : render_process_id; + auto proxied_receiver = std::move(*factory_receiver); + mojo::PendingRemote pending_url_loader_factory; + *factory_receiver = pending_url_loader_factory.InitWithNewPipeAndPassReceiver(); + // Will manage its own lifetime + new ProxyingURLLoaderFactoryQt(process_id, profile_interceptor, page_interceptor, std::move(proxied_receiver), + std::move(pending_url_loader_factory)); + return true; + } + return false; } } // namespace QtWebEngineCore diff --git a/src/core/net/proxying_url_loader_factory_qt.cpp b/src/core/net/proxying_url_loader_factory_qt.cpp index a7dc8a48c..b42aa64bb 100644 --- a/src/core/net/proxying_url_loader_factory_qt.cpp +++ b/src/core/net/proxying_url_loader_factory_qt.cpp @@ -59,7 +59,7 @@ #include "net/http/http_util.h" #include "api/qwebengineurlrequestinfo_p.h" -#include "profile_io_data_qt.h" +#include "profile_qt.h" #include "type_conversion.h" #include "web_contents_adapter_client.h" #include "web_contents_view_qt.h" @@ -96,15 +96,14 @@ public: InterceptedRequest(int process_id, uint64_t request_id, int32_t routing_id, uint32_t options, const network::ResourceRequest &request, const net::MutableNetworkTrafficAnnotationTag &traffic_annotation, - ProfileIODataQt *profileData, + QWebEngineUrlRequestInterceptor *profile_request_interceptor, + QWebEngineUrlRequestInterceptor *page_request_interceptor, mojo::PendingReceiver loader, mojo::PendingRemote client, mojo::PendingRemote target_factory); ~InterceptedRequest() override; - void Start(); void Restart(); - void InterceptOnUIThread(); // network::mojom::URLLoaderClient void OnReceiveResponse(network::mojom::URLResponseHeadPtr head) override; @@ -122,9 +121,11 @@ public: void PauseReadingBodyFromNet() override; void ResumeReadingBodyFromNet() override; +private: + void InterceptOnUIThread(); + void InterceptOnIOThread(base::WaitableEvent *event); void ContinueAfterIntercept(); -private: // This is called when the original URLLoaderClient has a connection error. void OnURLLoaderClientError(); @@ -149,32 +150,29 @@ private: // That way the destructor can send it to OnReceivedError if safe browsing // error didn't occur. int error_status_ = net::OK; - QUrl m_originalUrl; - GURL m_topDocumentUrl; - network::ResourceRequest request_; network::ResourceResponseHead current_response_; const net::MutableNetworkTrafficAnnotationTag traffic_annotation_; - QWebEngineUrlRequestInfo m_requestInfo; - ProfileIODataQt *m_profileData; + QWebEngineUrlRequestInfo request_info_; + QPointer profile_request_interceptor_; + QPointer page_request_interceptor_; mojo::Receiver proxied_loader_receiver_; mojo::Remote target_client_; - mojo::Receiver proxied_client_receiver_{this}; mojo::Remote target_loader_; mojo::Remote target_factory_; - base::WeakPtrFactory m_weakFactory; - base::WeakPtr m_weakPtr; + base::WeakPtrFactory weak_factory_; DISALLOW_COPY_AND_ASSIGN(InterceptedRequest); }; InterceptedRequest::InterceptedRequest(int process_id, uint64_t request_id, int32_t routing_id, uint32_t options, const network::ResourceRequest &request, const net::MutableNetworkTrafficAnnotationTag &traffic_annotation, - ProfileIODataQt *profileData, + QWebEngineUrlRequestInterceptor *profile_request_interceptor, + QWebEngineUrlRequestInterceptor *page_request_interceptor, mojo::PendingReceiver loader_receiver, mojo::PendingRemote client, mojo::PendingRemote target_factory) @@ -184,128 +182,105 @@ InterceptedRequest::InterceptedRequest(int process_id, uint64_t request_id, int3 , options_(options) , request_(request) , traffic_annotation_(traffic_annotation) - , m_profileData(profileData) + , profile_request_interceptor_(profile_request_interceptor) + , page_request_interceptor_(page_request_interceptor) , proxied_loader_receiver_(this, std::move(loader_receiver)) , target_client_(std::move(client)) , target_factory_(std::move(target_factory)) - , m_weakFactory(this) - , m_weakPtr(m_weakFactory.GetWeakPtr()) + , weak_factory_(this) { // If there is a client error, clean up the request. target_client_.set_disconnect_handler( - base::BindOnce(&InterceptedRequest::OnURLLoaderClientError, m_weakFactory.GetWeakPtr())); + base::BindOnce(&InterceptedRequest::OnURLLoaderClientError, weak_factory_.GetWeakPtr())); proxied_loader_receiver_.set_disconnect_with_reason_handler( - base::BindOnce(&InterceptedRequest::OnURLLoaderError, m_weakFactory.GetWeakPtr())); + base::BindOnce(&InterceptedRequest::OnURLLoaderError, weak_factory_.GetWeakPtr())); } InterceptedRequest::~InterceptedRequest() { - m_weakFactory.InvalidateWeakPtrs(); + weak_factory_.InvalidateWeakPtrs(); } -void InterceptedRequest::Start() +void InterceptedRequest::Restart() { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + content::ResourceType resourceType = content::ResourceType(request_.resource_type); + WebContentsAdapterClient::NavigationType navigationType = + pageTransitionToNavigationType(ui::PageTransition(request_.transition_type)); + + const QUrl originalUrl = toQt(request_.url); + const QUrl initiator = request_.request_initiator.has_value() ? toQt(request_.request_initiator->GetURL()) : QUrl(); content::WebContents *webContents = nullptr; if (process_id_) { content::RenderFrameHost *frameHost = content::RenderFrameHost::FromID(process_id_, request_.render_frame_id); webContents = content::WebContents::FromRenderFrameHost(frameHost); - } else + } else { webContents = content::WebContents::FromFrameTreeNodeId(request_.render_frame_id); + } - if (webContents) - m_topDocumentUrl = static_cast(webContents)->GetLastCommittedURL(); - - base::PostTask(FROM_HERE, {content::BrowserThread::IO}, - base::BindOnce(&InterceptedRequest::Restart, m_weakPtr)); -} - -void InterceptedRequest::Restart() -{ - DCHECK_CURRENTLY_ON(content::BrowserThread::IO); - - content::ResourceType resourceType = content::ResourceType(request_.resource_type); - WebContentsAdapterClient::NavigationType navigationType = - pageTransitionToNavigationType(ui::PageTransition(request_.transition_type)); - - m_originalUrl = toQt(request_.url); - - const QUrl initiator = request_.request_initiator.has_value() ? toQt(request_.request_initiator->GetURL()) : QUrl(); - + GURL top_document_url = webContents ? webContents->GetLastCommittedURL() : GURL(); QUrl firstPartyUrl; - if (!m_topDocumentUrl.is_empty()) - firstPartyUrl = toQt(m_topDocumentUrl); + if (!top_document_url.is_empty()) + firstPartyUrl = toQt(top_document_url); else firstPartyUrl = toQt(request_.site_for_cookies); // m_topDocumentUrl can be empty for the main-frame. QWebEngineUrlRequestInfoPrivate *infoPrivate = - new QWebEngineUrlRequestInfoPrivate(toQt(resourceType), toQt(navigationType), - m_originalUrl, firstPartyUrl, initiator, - QByteArray::fromStdString(request_.method)); - m_requestInfo = QWebEngineUrlRequestInfo(infoPrivate); - - if (m_profileData && m_profileData->isInterceptorDeprecated()) { - QWebEngineUrlRequestInterceptor *interceptor = m_profileData->acquireInterceptor(); - if (interceptor && m_profileData->isInterceptorDeprecated()) - interceptor->interceptRequest(m_requestInfo); - m_profileData->releaseInterceptor(); + new QWebEngineUrlRequestInfoPrivate(toQt(resourceType), toQt(navigationType), originalUrl, firstPartyUrl, + initiator, QByteArray::fromStdString(request_.method)); + request_info_ = QWebEngineUrlRequestInfo(infoPrivate); + + // TODO: remove for Qt6 + if (profile_request_interceptor_ && profile_request_interceptor_->property("deprecated").toBool()) { + // sync call supports depracated call of an interceptor on io thread + base::WaitableEvent event; + base::PostTask(FROM_HERE, { content::BrowserThread::IO }, + base::BindOnce(&InterceptedRequest::InterceptOnIOThread, base::Unretained(this), &event)); + event.Wait(); + if (request_info_.changed()) { + ContinueAfterIntercept(); + return; + } } + InterceptOnUIThread(); + ContinueAfterIntercept(); +} - if (m_requestInfo.changed()) { - ContinueAfterIntercept(); - } else { - // FIXME: unretained post? - base::PostTask(FROM_HERE, {content::BrowserThread::UI}, - base::BindOnce(&InterceptedRequest::InterceptOnUIThread, base::Unretained(this))); - } +void InterceptedRequest::InterceptOnIOThread(base::WaitableEvent *event) +{ + DCHECK_CURRENTLY_ON(content::BrowserThread::IO); + if (profile_request_interceptor_) + profile_request_interceptor_->interceptRequest(request_info_); + event->Signal(); } void InterceptedRequest::InterceptOnUIThread() { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + if (profile_request_interceptor_) + profile_request_interceptor_->interceptRequest(request_info_); - content::WebContents *webContents = nullptr; - if (process_id_) { - content::RenderFrameHost *frameHost = content::RenderFrameHost::FromID(process_id_, request_.render_frame_id); - webContents = content::WebContents::FromRenderFrameHost(frameHost); - } else - webContents = content::WebContents::FromFrameTreeNodeId(request_.render_frame_id); - - if (webContents) { - if (m_profileData) { - QWebEngineUrlRequestInterceptor *interceptor = m_profileData->requestInterceptor(); - if (interceptor && !interceptor->property("deprecated").toBool()) - interceptor->interceptRequest(m_requestInfo); - } - - WebContentsAdapterClient *client = - WebContentsViewQt::from(static_cast(webContents)->GetView())->client(); - - if (!m_requestInfo.changed()) - client->interceptRequest(m_requestInfo); - } - base::PostTask(FROM_HERE, {content::BrowserThread::IO}, - base::BindOnce(&InterceptedRequest::ContinueAfterIntercept, m_weakPtr)); + if (!request_info_.changed() && page_request_interceptor_) + page_request_interceptor_->interceptRequest(request_info_); } void InterceptedRequest::ContinueAfterIntercept() { - DCHECK_CURRENTLY_ON(content::BrowserThread::IO); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); - if (m_requestInfo.changed()) { - if (m_requestInfo.d_ptr->shouldBlockRequest) + if (request_info_.changed()) { + if (request_info_.d_ptr->shouldBlockRequest) return SendErrorAndCompleteImmediately(net::ERR_BLOCKED_BY_CLIENT); - if (m_requestInfo.requestUrl() != m_originalUrl) { + if (request_info_.d_ptr->shouldRedirectRequest) { net::URLRequest::FirstPartyURLPolicy first_party_url_policy = request_.update_first_party_url_on_redirect ? net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT : net::URLRequest::NEVER_CHANGE_FIRST_PARTY_URL; - net::RedirectInfo redirectInfo = net::RedirectInfo::ComputeRedirectInfo(request_.method, request_.url, - request_.site_for_cookies, - first_party_url_policy, request_.referrer_policy, - request_.referrer.spec(), net::HTTP_TEMPORARY_REDIRECT, - toGurl(m_requestInfo.requestUrl()), base::nullopt, - false /*insecure_scheme_was_upgraded*/); + net::RedirectInfo redirectInfo = net::RedirectInfo::ComputeRedirectInfo( + request_.method, request_.url, request_.site_for_cookies, + first_party_url_policy, request_.referrer_policy, request_.referrer.spec(), + net::HTTP_TEMPORARY_REDIRECT, toGurl(request_info_.requestUrl()), base::nullopt, + false /*insecure_scheme_was_upgraded*/); // FIXME: Should probably create a new header. current_response_.encoded_data_length = 0; @@ -320,9 +295,9 @@ void InterceptedRequest::ContinueAfterIntercept() return; } - if (!m_requestInfo.d_ptr->extraHeaders.isEmpty()) { - auto end = m_requestInfo.d_ptr->extraHeaders.constEnd(); - for (auto header = m_requestInfo.d_ptr->extraHeaders.constBegin(); header != end; ++header) { + if (!request_info_.d_ptr->extraHeaders.isEmpty()) { + auto end = request_info_.d_ptr->extraHeaders.constEnd(); + for (auto header = request_info_.d_ptr->extraHeaders.constBegin(); header != end; ++header) { std::string h = header.key().toStdString(); if (base::LowerCaseEqualsASCII(h, "referer")) { request_.referrer = GURL(header.value().toStdString()); @@ -443,7 +418,7 @@ void InterceptedRequest::OnURLLoaderError(uint32_t custom_reason, const std::str void InterceptedRequest::CallOnComplete(const network::URLLoaderCompletionStatus &status, bool wait_for_loader_error) { - DCHECK_CURRENTLY_ON(content::BrowserThread::IO); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); // Save an error status so that we call onReceiveError at destruction if there // was no safe browsing error. if (status.error_code != net::OK) @@ -467,7 +442,7 @@ void InterceptedRequest::CallOnComplete(const network::URLLoaderCompletionStatus // In case there are pending checks as to whether this request should be // intercepted, we don't want that causing |target_client_| to be used // later. - m_weakFactory.InvalidateWeakPtrs(); + weak_factory_.InvalidateWeakPtrs(); } else { delete this; } @@ -475,22 +450,21 @@ void InterceptedRequest::CallOnComplete(const network::URLLoaderCompletionStatus void InterceptedRequest::SendErrorAndCompleteImmediately(int error_code) { - DCHECK_CURRENTLY_ON(content::BrowserThread::IO); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); auto status = network::URLLoaderCompletionStatus(error_code); target_client_->OnComplete(status); delete this; } -ProxyingURLLoaderFactoryQt::ProxyingURLLoaderFactoryQt(int process_id, - content::ResourceContext *resourceContext, +ProxyingURLLoaderFactoryQt::ProxyingURLLoaderFactoryQt(int process_id, QWebEngineUrlRequestInterceptor *profile, QWebEngineUrlRequestInterceptor *page, mojo::PendingReceiver loader_receiver, - network::mojom::URLLoaderFactoryPtrInfo target_factory_info) - : m_processId(process_id), m_resourceContext(resourceContext), m_weakFactory(this) + mojo::PendingRemote target_factory_info) + : m_processId(process_id), m_profileRequestInterceptor(profile), m_pageRequestInterceptor(page), m_weakFactory(this) { - DCHECK_CURRENTLY_ON(content::BrowserThread::IO); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); if (target_factory_info) { m_targetFactory.Bind(std::move(target_factory_info)); - m_targetFactory.set_connection_error_handler( + m_targetFactory.set_disconnect_handler( base::BindOnce(&ProxyingURLLoaderFactoryQt::OnTargetFactoryError, m_weakFactory.GetWeakPtr())); } m_proxyReceivers.Add(this, std::move(loader_receiver)); @@ -503,47 +477,21 @@ ProxyingURLLoaderFactoryQt::~ProxyingURLLoaderFactoryQt() m_weakFactory.InvalidateWeakPtrs(); } -// static -void ProxyingURLLoaderFactoryQt::CreateProxy(int process_id, - content::ResourceContext *resourceContext, - mojo::PendingReceiver loader_receiver, - network::mojom::URLLoaderFactoryPtrInfo target_factory_info) -{ - DCHECK_CURRENTLY_ON(content::BrowserThread::IO); - - // Will manage its own lifetime - new ProxyingURLLoaderFactoryQt(process_id, resourceContext, std::move(loader_receiver), std::move(target_factory_info)); -} - -void ProxyingURLLoaderFactoryQt::CreateLoaderAndStart(mojo::PendingReceiver loader, - int32_t routing_id, int32_t request_id, uint32_t options, - const network::ResourceRequest &request, - mojo::PendingRemote client, +void ProxyingURLLoaderFactoryQt::CreateLoaderAndStart(mojo::PendingReceiver loader, int32_t routing_id, + int32_t request_id, uint32_t options, const network::ResourceRequest &request, + mojo::PendingRemote url_loader_client, const net::MutableNetworkTrafficAnnotationTag &traffic_annotation) { - DCHECK_CURRENTLY_ON(content::BrowserThread::IO); - - ProfileIODataQt *profileIOData = ProfileIODataQt::FromResourceContext(m_resourceContext); - - QWebEngineUrlRequestInterceptor *profileInterceptor = profileIOData ? profileIOData->requestInterceptor() : nullptr; - if (!profileIOData || !(profileInterceptor || profileIOData->hasPageInterceptors())) { - m_targetFactory->CreateLoaderAndStart( - std::move(loader), routing_id, request_id, options, request, - std::move(client), traffic_annotation); - return; - } - + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); mojo::PendingRemote target_factory_clone; if (m_targetFactory) m_targetFactory->Clone(target_factory_clone.InitWithNewPipeAndPassReceiver()); // Will manage its own lifetime - InterceptedRequest *req = new InterceptedRequest(m_processId, request_id, routing_id, options, request, - traffic_annotation, profileIOData, - std::move(loader), std::move(client), - std::move(target_factory_clone)); - base::PostTask(FROM_HERE, {content::BrowserThread::UI}, - base::BindOnce(&InterceptedRequest::Start, base::Unretained(req))); + InterceptedRequest *req = new InterceptedRequest(m_processId, request_id, routing_id, options, request, traffic_annotation, + m_profileRequestInterceptor, m_pageRequestInterceptor, std::move(loader), + std::move(url_loader_client), std::move(target_factory_clone)); + req->Restart(); } void ProxyingURLLoaderFactoryQt::OnTargetFactoryError() @@ -559,7 +507,7 @@ void ProxyingURLLoaderFactoryQt::OnProxyBindingError() void ProxyingURLLoaderFactoryQt::Clone(mojo::PendingReceiver receiver) { - DCHECK_CURRENTLY_ON(content::BrowserThread::IO); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); m_proxyReceivers.Add(this, std::move(receiver)); } diff --git a/src/core/net/proxying_url_loader_factory_qt.h b/src/core/net/proxying_url_loader_factory_qt.h index ba19bab97..3d77856cc 100644 --- a/src/core/net/proxying_url_loader_factory_qt.h +++ b/src/core/net/proxying_url_loader_factory_qt.h @@ -54,11 +54,14 @@ #include "services/network/public/mojom/url_loader_factory.mojom.h" #include "url/gurl.h" +#include // based on aw_proxying_url_loader_factory.h: // Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +QT_FORWARD_DECLARE_CLASS(QWebEngineUrlRequestInterceptor) + namespace content { class ResourceContext; } @@ -68,16 +71,13 @@ namespace QtWebEngineCore { class ProxyingURLLoaderFactoryQt : public network::mojom::URLLoaderFactory { public: - ProxyingURLLoaderFactoryQt(int process_id, content::ResourceContext *resourceContext, + ProxyingURLLoaderFactoryQt(int processId, QWebEngineUrlRequestInterceptor *profile, + QWebEngineUrlRequestInterceptor *page, mojo::PendingReceiver loader_receiver, - network::mojom::URLLoaderFactoryPtrInfo target_factory_info); + mojo::PendingRemote pending_target_factory_remote); ~ProxyingURLLoaderFactoryQt() override; - static void CreateProxy(int process_id, content::ResourceContext *resourceContext, - mojo::PendingReceiver loader_receiver, - network::mojom::URLLoaderFactoryPtrInfo target_factory_info); - void CreateLoaderAndStart(mojo::PendingReceiver loader, int32_t routing_id, int32_t request_id, uint32_t options, const network::ResourceRequest &request, @@ -90,12 +90,11 @@ private: void OnTargetFactoryError(); void OnProxyBindingError(); - const int m_processId; + int m_processId; mojo::ReceiverSet m_proxyReceivers; - network::mojom::URLLoaderFactoryPtr m_targetFactory; - - content::ResourceContext *m_resourceContext; - + mojo::Remote m_targetFactory; + QPointer m_profileRequestInterceptor; + QPointer m_pageRequestInterceptor; base::WeakPtrFactory m_weakFactory; DISALLOW_COPY_AND_ASSIGN(ProxyingURLLoaderFactoryQt); diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index a97db169b..2d559bb38 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -1014,6 +1014,16 @@ ProfileAdapter* WebContentsAdapter::profileAdapter() static_cast(m_webContents->GetBrowserContext())->profileAdapter() : nullptr; } +void WebContentsAdapter::setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor) +{ + m_requestInterceptor = interceptor; +} + +QWebEngineUrlRequestInterceptor* WebContentsAdapter::requestInterceptor() const +{ + return m_requestInterceptor; +} + #ifndef QT_NO_ACCESSIBILITY QAccessibleInterface *WebContentsAdapter::browserAccessible() { diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h index 1a76cd3c1..cc041ed55 100644 --- a/src/core/web_contents_adapter.h +++ b/src/core/web_contents_adapter.h @@ -61,6 +61,7 @@ #include #include #include +#include namespace content { class WebContents; @@ -79,6 +80,7 @@ class QPageLayout; class QString; class QTemporaryDir; class QWebChannel; +class QWebEngineUrlRequestInterceptor; QT_END_NAMESPACE namespace QtWebEngineCore { @@ -235,6 +237,8 @@ public: void initialize(content::SiteInstance *site); content::WebContents *webContents() const; void updateRecommendedState(); + void setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor); + QWebEngineUrlRequestInterceptor* requestInterceptor() const; private: Q_DISABLE_COPY(WebContentsAdapter) @@ -274,6 +278,7 @@ private: LifecycleState m_lifecycleState = LifecycleState::Active; LifecycleState m_recommendedState = LifecycleState::Active; bool m_inspector = false; + QPointer m_requestInterceptor; }; } // namespace QtWebEngineCore diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h index 04df0450c..250801f51 100644 --- a/src/core/web_contents_adapter_client.h +++ b/src/core/web_contents_adapter_client.h @@ -70,6 +70,7 @@ QT_FORWARD_DECLARE_CLASS(QWebEngineFindTextResult) QT_FORWARD_DECLARE_CLASS(QWebEngineQuotaRequest) QT_FORWARD_DECLARE_CLASS(QWebEngineRegisterProtocolHandlerRequest) QT_FORWARD_DECLARE_CLASS(QWebEngineUrlRequestInfo) +QT_FORWARD_DECLARE_CLASS(QWebEngineUrlRequestInterceptor) namespace content { struct DropData; @@ -514,7 +515,6 @@ public: virtual ClientType clientType() = 0; virtual void printRequested() = 0; virtual void widgetChanged(RenderWidgetHostViewQtDelegate *newWidget) = 0; - virtual void interceptRequest(QWebEngineUrlRequestInfo &) { } virtual TouchHandleDrawableClient *createTouchHandle(const QMap &images) = 0; virtual void showTouchSelectionMenu(TouchSelectionMenuController *menuController, const QRect &bounds, const QSize &handleSize) = 0; virtual void hideTouchSelectionMenu() = 0; @@ -523,7 +523,6 @@ public: virtual ProfileAdapter *profileAdapter() = 0; virtual WebContentsAdapter* webContentsAdapter() = 0; virtual void releaseProfile() = 0; - }; } // namespace QtWebEngineCore diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index 0d2988421..b267c5dd1 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -163,7 +163,6 @@ QWebEnginePagePrivate::QWebEnginePagePrivate(QWebEngineProfile *_profile) , webChannelWorldId(QWebEngineScript::MainWorld) , defaultAudioMuted(false) , defaultZoomFactor(1.0) - , requestInterceptor(nullptr) #if QT_CONFIG(webengine_printing_and_pdf) , currentPrinter(nullptr) #endif @@ -185,8 +184,6 @@ QWebEnginePagePrivate::QWebEnginePagePrivate(QWebEngineProfile *_profile) QWebEnginePagePrivate::~QWebEnginePagePrivate() { - if (requestInterceptor) - profile->d_ptr->profileAdapter()->removePageRequestInterceptor(); delete history; delete settings; profile->d_ptr->removeWebContentsAdapterClient(this); @@ -1916,20 +1913,7 @@ void QWebEnginePagePrivate::visibleChanged(bool visible) void QWebEnginePage::setUrlRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor) { Q_D(QWebEnginePage); - bool hadInterceptorChanged = bool(d->requestInterceptor) != bool(interceptor); - d->requestInterceptor = interceptor; - if (hadInterceptorChanged) { - if (interceptor) - d->profile->d_ptr->profileAdapter()->addPageRequestInterceptor(); - else - d->profile->d_ptr->profileAdapter()->removePageRequestInterceptor(); - } -} - -void QWebEnginePagePrivate::interceptRequest(QWebEngineUrlRequestInfo &info) -{ - if (requestInterceptor) - requestInterceptor->interceptRequest(info); + d->adapter->setRequestInterceptor(interceptor); } #if QT_CONFIG(menu) diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h index 4f33e26f3..f37413b8e 100644 --- a/src/webenginewidgets/api/qwebenginepage_p.h +++ b/src/webenginewidgets/api/qwebenginepage_p.h @@ -161,7 +161,6 @@ public: void hideTouchSelectionMenu() override { } const QObject *holdingQObject() const override; ClientType clientType() override { return QtWebEngineCore::WebContentsAdapterClient::WidgetsClient; } - void interceptRequest(QWebEngineUrlRequestInfo &) override; void widgetChanged(QtWebEngineCore::RenderWidgetHostViewQtDelegate *newWidget) override; void findTextFinished(const QWebEngineFindTextResult &result) override; @@ -202,7 +201,6 @@ public: bool defaultAudioMuted; qreal defaultZoomFactor; QTimer wasShownTimer; - QWebEngineUrlRequestInterceptor *requestInterceptor; QtWebEngineCore::RenderWidgetHostViewQtDelegateWidget *widget = nullptr; mutable QtWebEngineCore::CallbackDirectory m_callbacks; diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp index 470babf8f..4c49be709 100644 --- a/src/webenginewidgets/api/qwebengineprofile.cpp +++ b/src/webenginewidgets/api/qwebengineprofile.cpp @@ -596,6 +596,7 @@ QWebEngineCookieStore* QWebEngineProfile::cookieStore() Interceptors installed with this method will call QWebEngineUrlRequestInterceptor::interceptRequest on the I/O thread. Therefore the user has to provide thread-safe interaction with the other user classes. + For a duration of this call ui thread is blocked. Use setUrlRequestInterceptor instead. \since 5.6 -- cgit v1.2.3 From 9e56f570e31a0ef18e544bb21dfddebfe43ec2d0 Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Thu, 16 Apr 2020 15:41:42 +0200 Subject: Cleanup interceptors in profile Change-Id: Ibc6d63845601b8189ac38bacc77885327284c81f Reviewed-by: Allan Sandfeld Jensen --- src/core/profile_adapter.cpp | 28 --------------------------- src/core/profile_adapter.h | 5 ----- src/core/profile_io_data_qt.cpp | 43 ----------------------------------------- src/core/profile_io_data_qt.h | 10 ---------- 4 files changed, 86 deletions(-) (limited to 'src') diff --git a/src/core/profile_adapter.cpp b/src/core/profile_adapter.cpp index c27883b65..d2c4ab1d8 100644 --- a/src/core/profile_adapter.cpp +++ b/src/core/profile_adapter.cpp @@ -95,7 +95,6 @@ ProfileAdapter::ProfileAdapter(const QString &storageName): , m_persistentCookiesPolicy(AllowPersistentCookies) , m_visitedLinksPolicy(TrackVisitedLinksOnDisk) , m_httpCacheMaxSize(0) - , m_pageRequestInterceptors(0) { WebEngineContext::current()->addProfileAdapter(this); // creation of profile requires webengine context @@ -134,7 +133,6 @@ ProfileAdapter::~ProfileAdapter() #if QT_CONFIG(ssl) delete m_clientCertificateStore; #endif - Q_ASSERT(m_pageRequestInterceptors == 0); } void ProfileAdapter::setStorageName(const QString &storageName) @@ -194,19 +192,7 @@ QWebEngineUrlRequestInterceptor *ProfileAdapter::requestInterceptor() void ProfileAdapter::setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor) { - if (m_requestInterceptor == interceptor) - return; - - if (m_requestInterceptor) - disconnect(m_requestInterceptor, &QObject::destroyed, this, nullptr); m_requestInterceptor = interceptor; - if (m_requestInterceptor) - connect(m_requestInterceptor, &QObject::destroyed, this, [this] () { - m_profile->m_profileIOData->updateRequestInterceptor(); - Q_ASSERT(!m_profile->m_profileIOData->requestInterceptor()); - }); - - m_profile->m_profileIOData->updateRequestInterceptor(); } void ProfileAdapter::addClient(ProfileAdapterClient *adapterClient) @@ -219,20 +205,6 @@ void ProfileAdapter::removeClient(ProfileAdapterClient *adapterClient) m_clients.removeOne(adapterClient); } -void ProfileAdapter::addPageRequestInterceptor() -{ - ++m_pageRequestInterceptors; - m_profile->m_profileIOData->updateRequestInterceptor(); -} - -void ProfileAdapter::removePageRequestInterceptor() -{ - Q_ASSERT(m_pageRequestInterceptors > 0); - --m_pageRequestInterceptors; - m_profile->m_profileIOData->updateRequestInterceptor(); -} - - void ProfileAdapter::cancelDownload(quint32 downloadId) { downloadManagerDelegate()->cancelDownload(downloadId); diff --git a/src/core/profile_adapter.h b/src/core/profile_adapter.h index 60d04273b..1e5a3e21f 100644 --- a/src/core/profile_adapter.h +++ b/src/core/profile_adapter.h @@ -199,10 +199,6 @@ public: void setUseForGlobalCertificateVerification(bool enable = true); bool isUsedForGlobalCertificateVerification() const; - void addPageRequestInterceptor(); - void removePageRequestInterceptor(); - bool hasPageRequestInterceptor() const { return m_pageRequestInterceptors > 0; } - #if QT_CONFIG(ssl) QWebEngineClientCertificateStore *clientCertificateStore(); #endif @@ -247,7 +243,6 @@ private: QList m_clients; QVector m_webContentsAdapterClients; int m_httpCacheMaxSize; - int m_pageRequestInterceptors; QrcUrlSchemeHandler m_qrcHandler; Q_DISABLE_COPY(ProfileAdapter) diff --git a/src/core/profile_io_data_qt.cpp b/src/core/profile_io_data_qt.cpp index fd073f208..64ad096a6 100644 --- a/src/core/profile_io_data_qt.cpp +++ b/src/core/profile_io_data_qt.cpp @@ -155,49 +155,6 @@ void ProfileIODataQt::resetNetworkContext() })); } -void ProfileIODataQt::updateRequestInterceptor() -{ - Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); - const std::lock_guard lock(m_mutex); - m_requestInterceptor = m_profileAdapter->requestInterceptor(); - m_hasPageInterceptors = m_profileAdapter->hasPageRequestInterceptor(); - if (m_requestInterceptor) - m_isInterceptorDeprecated = m_requestInterceptor->property("deprecated").toBool(); - else - m_isInterceptorDeprecated = false; - // We in this case do not need to regenerate any Chromium classes. -} - -bool ProfileIODataQt::isInterceptorDeprecated() const -{ - return m_isInterceptorDeprecated; -} - -QWebEngineUrlRequestInterceptor *ProfileIODataQt::acquireInterceptor() -{ - Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); - m_mutex.lock(); - return m_requestInterceptor; -} - -QWebEngineUrlRequestInterceptor *ProfileIODataQt::requestInterceptor() -{ - return m_requestInterceptor; -} - -bool ProfileIODataQt::hasPageInterceptors() -{ - // used in NetworkDelegateQt::OnBeforeURLRequest - Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); - return m_hasPageInterceptors; -} - -void ProfileIODataQt::releaseInterceptor() -{ - Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); - m_mutex.unlock(); -} - bool ProfileIODataQt::canGetCookies(const QUrl &firstPartyUrl, const QUrl &url) const { return m_cookieDelegate->canGetCookies(firstPartyUrl, url); diff --git a/src/core/profile_io_data_qt.h b/src/core/profile_io_data_qt.h index 6d9dd1a45..26ae1bcb2 100644 --- a/src/core/profile_io_data_qt.h +++ b/src/core/profile_io_data_qt.h @@ -87,15 +87,8 @@ public: bool canGetCookies(const QUrl &firstPartyUrl, const QUrl &url) const; // Used in NetworkDelegateQt::OnBeforeURLRequest. - bool isInterceptorDeprecated() const; // Remove for Qt6 - QWebEngineUrlRequestInterceptor *acquireInterceptor(); // Remove for Qt6 - void releaseInterceptor(); - QWebEngineUrlRequestInterceptor *requestInterceptor(); - void setFullConfiguration(); // runs on ui thread void resetNetworkContext(); // runs on ui thread - void updateRequestInterceptor(); // runs on ui thread - bool hasPageInterceptors(); network::mojom::NetworkContextParamsPtr CreateNetworkContextParams(); @@ -125,7 +118,6 @@ private: QString m_httpUserAgent; ProfileAdapter::HttpCacheType m_httpCacheType; QString m_httpCachePath; - QWebEngineUrlRequestInterceptor* m_requestInterceptor = nullptr; #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) QMutex m_mutex{QMutex::Recursive}; using QRecursiveMutex = QMutex; @@ -134,10 +126,8 @@ private: #endif int m_httpCacheMaxSize = 0; bool m_useForGlobalCertificateVerification = false; - bool m_hasPageInterceptors = false; base::WeakPtrFactory m_weakPtrFactory; // this should be always the last member QString m_dataPath; - volatile bool m_isInterceptorDeprecated = false; // Remove for Qt6 DISALLOW_COPY_AND_ASSIGN(ProfileIODataQt); }; } // namespace QtWebEngineCore -- cgit v1.2.3 From ab179f60844f5b0cd6ef863b753566a3588e9d5d Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 21 Apr 2020 19:01:43 +0200 Subject: Fix warning about unexpected null disconnect in QPdfLinkModel QObject::disconnect: Unexpected nullptr parameter was caused by disconnecting from the previous document's statusChanged signal even when there was no previous document. Change-Id: I740f0e569f445660494011d788c0e917e787ac80 Reviewed-by: Shawn Rutledge --- src/pdf/qpdflinkmodel.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/pdf/qpdflinkmodel.cpp b/src/pdf/qpdflinkmodel.cpp index 4020f036e..900d3cd9e 100644 --- a/src/pdf/qpdflinkmodel.cpp +++ b/src/pdf/qpdflinkmodel.cpp @@ -104,7 +104,8 @@ void QPdfLinkModel::setDocument(QPdfDocument *document) Q_D(QPdfLinkModel); if (d->document == document) return; - disconnect(d->document, &QPdfDocument::statusChanged, this, &QPdfLinkModel::onStatusChanged); + if (d->document) + disconnect(d->document, &QPdfDocument::statusChanged, this, &QPdfLinkModel::onStatusChanged); connect(document, &QPdfDocument::statusChanged, this, &QPdfLinkModel::onStatusChanged); d->document = document; emit documentChanged(); -- cgit v1.2.3 From 75412200db05ddc5ee2b9aea367b580d8b0c438e Mon Sep 17 00:00:00 2001 From: Tamas Zakor Date: Mon, 20 Apr 2020 11:41:29 +0200 Subject: Avoid the network context reset during http cache clear Reinstate BrowsingDataRemoverObserverQt() to check if http cache clearing is in-progress or done. ProfileIODataQt::resetNetworkContext() should not be called during http cache clearing because it causes an assert. Call it after the clearing is done. Change-Id: I6750341ff23f704ba547c913f40b0cec92b1cc43 Reviewed-by: Allan Sandfeld Jensen --- src/core/profile_adapter.cpp | 28 +++++++++++++++------------- src/core/profile_io_data_qt.cpp | 38 ++++++++++++++++++++++++++++++++++++++ src/core/profile_io_data_qt.h | 21 ++++++++++++++++++++- 3 files changed, 73 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/core/profile_adapter.cpp b/src/core/profile_adapter.cpp index d2c4ab1d8..b87591c97 100644 --- a/src/core/profile_adapter.cpp +++ b/src/core/profile_adapter.cpp @@ -142,7 +142,8 @@ void ProfileAdapter::setStorageName(const QString &storageName) m_name = storageName; if (!m_offTheRecord) { m_profile->setupPrefService(); - m_profile->m_profileIOData->resetNetworkContext(); + if (!m_profile->m_profileIOData->isClearHttpCacheInProgress()) + m_profile->m_profileIOData->resetNetworkContext(); if (m_visitedLinksManager) resetVisitedLinksManager(); } @@ -154,7 +155,8 @@ void ProfileAdapter::setOffTheRecord(bool offTheRecord) return; m_offTheRecord = offTheRecord; m_profile->setupPrefService(); - m_profile->m_profileIOData->resetNetworkContext(); + if (!m_profile->m_profileIOData->isClearHttpCacheInProgress()) + m_profile->m_profileIOData->resetNetworkContext(); if (m_visitedLinksManager) resetVisitedLinksManager(); } @@ -259,7 +261,8 @@ void ProfileAdapter::setDataPath(const QString &path) m_dataPath = path; if (!m_offTheRecord) { m_profile->setupPrefService(); - m_profile->m_profileIOData->resetNetworkContext(); + if (!m_profile->m_profileIOData->isClearHttpCacheInProgress()) + m_profile->m_profileIOData->resetNetworkContext(); if (m_visitedLinksManager) resetVisitedLinksManager(); } @@ -286,7 +289,7 @@ void ProfileAdapter::setCachePath(const QString &path) if (m_cachePath == path) return; m_cachePath = path; - if (!m_offTheRecord) + if (!m_offTheRecord && !m_profile->m_profileIOData->isClearHttpCacheInProgress()) m_profile->m_profileIOData->resetNetworkContext(); } @@ -341,7 +344,7 @@ void ProfileAdapter::setHttpCacheType(ProfileAdapter::HttpCacheType newhttpCache m_httpCacheType = newhttpCacheType; if (oldCacheType == httpCacheType()) return; - if (!m_offTheRecord) { + if (!m_offTheRecord && !m_profile->m_profileIOData->isClearHttpCacheInProgress()) { m_profile->m_profileIOData->resetNetworkContext(); if (m_httpCacheType == NoCache) clearHttpCache(); @@ -361,7 +364,7 @@ void ProfileAdapter::setPersistentCookiesPolicy(ProfileAdapter::PersistentCookie m_persistentCookiesPolicy = newPersistentCookiesPolicy; if (oldPolicy == persistentCookiesPolicy()) return; - if (!m_offTheRecord) + if (!m_offTheRecord && !m_profile->m_profileIOData->isClearHttpCacheInProgress()) m_profile->m_profileIOData->resetNetworkContext(); } @@ -416,7 +419,7 @@ void ProfileAdapter::setHttpCacheMaxSize(int maxSize) if (m_httpCacheMaxSize == maxSize) return; m_httpCacheMaxSize = maxSize; - if (!m_offTheRecord) + if (!m_offTheRecord && !m_profile->m_profileIOData->isClearHttpCacheInProgress()) m_profile->m_profileIOData->resetNetworkContext(); } @@ -592,10 +595,7 @@ void ProfileAdapter::setHttpAcceptLanguage(const QString &httpAcceptLanguage) void ProfileAdapter::clearHttpCache() { - content::BrowsingDataRemover *remover = content::BrowserContext::GetBrowsingDataRemover(m_profile.data()); - remover->Remove(base::Time(), base::Time::Max(), - content::BrowsingDataRemover::DATA_TYPE_CACHE, - content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB | content::BrowsingDataRemover::ORIGIN_TYPE_PROTECTED_WEB); + m_profile->m_profileIOData->clearHttpCache(); } void ProfileAdapter::setSpellCheckLanguages(const QStringList &languages) @@ -656,7 +656,8 @@ void ProfileAdapter::setUseForGlobalCertificateVerification(bool enable) if (enable) { if (profileForglobalCertificateVerification) { profileForglobalCertificateVerification->m_usedForGlobalCertificateVerification = false; - profileForglobalCertificateVerification->m_profile->m_profileIOData->resetNetworkContext(); + if (!m_profile->m_profileIOData->isClearHttpCacheInProgress()) + profileForglobalCertificateVerification->m_profile->m_profileIOData->resetNetworkContext(); for (auto *client : qAsConst(profileForglobalCertificateVerification->m_clients)) client->useForGlobalCertificateVerificationChanged(); } @@ -667,7 +668,8 @@ void ProfileAdapter::setUseForGlobalCertificateVerification(bool enable) profileForglobalCertificateVerification = nullptr; } - m_profile->m_profileIOData->resetNetworkContext(); + if (!m_profile->m_profileIOData->isClearHttpCacheInProgress()) + m_profile->m_profileIOData->resetNetworkContext(); } bool ProfileAdapter::isUsedForGlobalCertificateVerification() const diff --git a/src/core/profile_io_data_qt.cpp b/src/core/profile_io_data_qt.cpp index 64ad096a6..ecebbdaa7 100644 --- a/src/core/profile_io_data_qt.cpp +++ b/src/core/profile_io_data_qt.cpp @@ -43,6 +43,7 @@ #include "content/browser/storage_partition_impl.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" +#include "content/public/browser/browsing_data_remover.h" #include "content/public/browser/shared_cors_origin_access_list.h" #include "content/public/common/content_features.h" #include "net/ssl/ssl_config_service_defaults.h" @@ -66,6 +67,7 @@ ProfileIODataQt::ProfileIODataQt(ProfileQt *profile) #if QT_CONFIG(ssl) m_clientCertificateStoreData(new ClientCertificateStoreData), #endif + m_removerObserver(this), m_weakPtrFactory(this) { if (content::BrowserThread::IsThreadInitialized(content::BrowserThread::UI)) @@ -130,6 +132,42 @@ void ProfileIODataQt::initializeOnUIThread() m_proxyConfigMonitor.reset(new ProxyConfigMonitor(m_profile->GetPrefs())); } +void ProfileIODataQt::clearHttpCache() +{ + Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + if (!m_clearHttpCacheInProgress) { + m_clearHttpCacheInProgress = true; + content::BrowsingDataRemover *remover = + content::BrowserContext::GetBrowsingDataRemover(m_profileAdapter->profile()); + remover->AddObserver(&m_removerObserver); + remover->RemoveAndReply(base::Time(), base::Time::Max(), + content::BrowsingDataRemover::DATA_TYPE_CACHE, + content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB | + content::BrowsingDataRemover::ORIGIN_TYPE_PROTECTED_WEB, + &m_removerObserver); + } +} + +void ProfileIODataQt::removeBrowsingDataRemoverObserver() +{ + content::BrowsingDataRemover *remover = + content::BrowserContext::GetBrowsingDataRemover(m_profileAdapter->profile()); + remover->RemoveObserver(&m_removerObserver); +} + +BrowsingDataRemoverObserverQt::BrowsingDataRemoverObserverQt(ProfileIODataQt *profileIOData) + : m_profileIOData(profileIOData) +{ +} + +void BrowsingDataRemoverObserverQt::OnBrowsingDataRemoverDone() +{ + Q_ASSERT(m_profileIOData->m_clearHttpCacheInProgress); + m_profileIOData->removeBrowsingDataRemoverObserver(); + m_profileIOData->m_clearHttpCacheInProgress = false; + m_profileIOData->resetNetworkContext(); +} + void ProfileIODataQt::setFullConfiguration() { Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); diff --git a/src/core/profile_io_data_qt.h b/src/core/profile_io_data_qt.h index 26ae1bcb2..b0567dead 100644 --- a/src/core/profile_io_data_qt.h +++ b/src/core/profile_io_data_qt.h @@ -40,6 +40,7 @@ #ifndef PROFILE_IO_DATA_QT_H #define PROFILE_IO_DATA_QT_H +#include "content/public/browser/browsing_data_remover.h" #include "chrome/browser/profiles/profile.h" #include "extensions/buildflags/buildflags.h" @@ -65,6 +66,16 @@ struct ClientCertificateStoreData; class ProfileIODataQt; class ProfileQt; +class BrowsingDataRemoverObserverQt : public content::BrowsingDataRemover::Observer { +public: + BrowsingDataRemoverObserverQt(ProfileIODataQt *profileIOData); + + void OnBrowsingDataRemoverDone() override; + +private: + ProfileIODataQt *m_profileIOData; +}; + // ProfileIOData contains data that lives on the IOthread // we still use shared memebers and use mutex which breaks // idea for this object, but this is wip. @@ -89,6 +100,8 @@ public: // Used in NetworkDelegateQt::OnBeforeURLRequest. void setFullConfiguration(); // runs on ui thread void resetNetworkContext(); // runs on ui thread + void clearHttpCache(); // runs on ui thread + bool isClearHttpCacheInProgress() { return m_clearHttpCacheInProgress; } network::mojom::NetworkContextParamsPtr CreateNetworkContextParams(); @@ -104,6 +117,8 @@ public: CookieMonsterDelegateQt *cookieDelegate() const { return m_cookieDelegate.get(); } private: + void removeBrowsingDataRemoverObserver(); + ProfileQt *m_profile; std::unique_ptr m_resourceContext; scoped_refptr m_cookieDelegate; @@ -126,9 +141,13 @@ private: #endif int m_httpCacheMaxSize = 0; bool m_useForGlobalCertificateVerification = false; - base::WeakPtrFactory m_weakPtrFactory; // this should be always the last member + BrowsingDataRemoverObserverQt m_removerObserver; QString m_dataPath; + bool m_clearHttpCacheInProgress = false; + base::WeakPtrFactory m_weakPtrFactory; // this should be always the last member DISALLOW_COPY_AND_ASSIGN(ProfileIODataQt); + + friend class BrowsingDataRemoverObserverQt; }; } // namespace QtWebEngineCore -- cgit v1.2.3