Skip to content
Commit c217801a authored by Stefano Crocco's avatar Stefano Crocco
Browse files

Fix download behavior when using webengine part

With KHTML and KWebKitPart, clicking on a download link would make
konqueror embed the downloaded file in the current view or in another
tab or window according to the user settings.

To have the same happen with WebEnginePart, the openUrlRequest signal
must be emitted by the part in response to
QWebEngineProfile::downloadRequested
signal.

To achieve this, a new class, WebEnginePartDownloadManager, is
introduced. This class connects to QWebProfile::downloadRequested signal
and to a new signal, navigationRequested, from each existing
WebEnginePage.

The navigationRequested signal (emitted by a web page's
acceptNavigationRequest method) allows the download manager to associate
each download request with a navigation request, and, consequently, with
the WebEnginePage which requested the download (this is necessary
because there's no way to associate the download request with a
QWebEnginePage automatically). At this point, the openUrlRequest is
emitted from the part corresponding to the page. Note that the download
is not performed using QWebEngineDownloadItem (that is,
QWebEngineDownloadItem::accept is not called).

Sometimes, a download is requested without a corresponding call to
acceptNavigationRequest: in this case, the signal is emitted from an
arbitrary part, specifying to open the file in a new window.

This process doesn't always work, expecially when downloads are started
from javascript or by clicking on links forcing a download or specifying
a _blank target. These issues need to be investigated further

Differential Revision: https://phabricator.kde.org/D6781
parent 43ebc7d8
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment