diff options
author | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2014-01-15 19:00:59 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-22 08:45:02 +0100 |
commit | e6b846f3800eed35d31a45122f7f8c3215dc38ef (patch) | |
tree | d8a167d8671fde146d3e0fafab3cb98e1a21fb56 /src/core/web_contents_adapter.cpp | |
parent | 0d85992198886cfb2b55087bcf9fe2acb9da84de (diff) |
Implement QWebEnginePage::setHtml and setContent
Load a generated data: URL to carry the data.
This is not as efficient as it could be but the behavior matches and
this should be fine for now.
Change-Id: I26ad2e5976025a3044fb03f066074ce6dd34e575
Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
Diffstat (limited to 'src/core/web_contents_adapter.cpp')
-rw-r--r-- | src/core/web_contents_adapter.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index ce9dccd90..108506b06 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -271,6 +271,22 @@ void WebContentsAdapter::load(const QUrl &url) d->webContents->GetView()->Focus(); } +void WebContentsAdapter::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl) +{ + Q_D(WebContentsAdapter); + QByteArray encodedData = data.toPercentEncoding(); + std::string urlString("data:"); + urlString.append(mimeType.toStdString()); + urlString.append(","); + urlString.append(encodedData.constData(), encodedData.length()); + + content::NavigationController::LoadURLParams params((GURL(urlString))); + params.load_type = content::NavigationController::LOAD_TYPE_DATA; + params.base_url_for_data_url = toGurl(baseUrl); + params.can_load_local_resources = true; + d->webContents->GetController().LoadURLWithParams(params); +} + QUrl WebContentsAdapter::activeUrl() const { Q_D(const WebContentsAdapter); |