summaryrefslogtreecommitdiffstats
path: root/src/core/web_contents_adapter.cpp
diff options
context:
space:
mode:
authorSzabolcs David <davidsz@inf.u-szeged.hu>2021-02-04 14:48:52 +0100
committerSzabolcs David <davidsz@inf.u-szeged.hu>2021-03-06 08:28:04 +0100
commit8f56ea6806d9a72d4b705da5f6f90fa5a6873567 (patch)
treed4f5d01cde73e34973990ae5a5f3cb271516db15 /src/core/web_contents_adapter.cpp
parent84104b7d100553c1550c525759ef6fb4446c31be (diff)
Show PDF viewer in a guest view
This is the basic support of guest views, implemented based on Chrome. - Embed PDF as a child frame instead of navigating to its extension WebUI. Keep the original URL (pointing to the file) to extend functionality of PDF viewer with URL parameters. - Make RenderWidgetHostInputEventRouter to work and modify most of the event forwarding logic to use that. This way WebEngine supports pages with multiple RenderWidgetHost and guest views can be interactive with user input. [ChangeLog] PDF files are opened as embedded objects, WebEngine will not navigate the content away from the requested file to present it. PDF viewer can accept URL parameters (e.g. to control zooming or fitting to view). Also, PDF viewer is interactive when displayed in a subframe. Task-number: QTBUG-80463 Task-number: QTBUG-86152 Task-number: QTBUG-90712 Change-Id: Ib1591fbd9a594891cdeace8e9dae0d3cc21a9f8e Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core/web_contents_adapter.cpp')
-rw-r--r--src/core/web_contents_adapter.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index ee0c1fb3c..bfeab41a2 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -1547,7 +1547,15 @@ void WebContentsAdapter::startDragging(QObject *dragSource, const content::DropD
QObject::disconnect(onDestroyed);
if (dValid) {
if (m_webContents) {
- content::RenderViewHost *rvh = m_webContents->GetRenderViewHost();
+ // This is the quickest and (at the moment) the most safe solution to not break guest views when
+ // dropping data into them. We don't even try to support dropping into PDF input fields,
+ // since it's not working in Chrome right now.
+ content::WebContents *targetWebContents = m_webContents.get();
+ std::vector<content::WebContents *> innerWebContents = m_webContents->GetInnerWebContents();
+ if (!innerWebContents.empty())
+ targetWebContents = innerWebContents[0];
+
+ content::RenderViewHost *rvh = targetWebContents->GetRenderViewHost();
if (rvh) {
rvh->GetWidget()->DragSourceEndedAt(gfx::PointF(m_lastDragClientPos.x(), m_lastDragClientPos.y()),
gfx::PointF(m_lastDragScreenPos.x(), m_lastDragScreenPos.y()),