summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSzabolcs David <davidsz@inf.u-szeged.hu>2014-02-05 08:40:38 -0800
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-11 19:31:25 +0100
commitf2cd2e0a32e8da3a0fbff6271dd9c257d8e8867f (patch)
tree191ffa3d55e4edbd7a1dce46a17328b4997830a0 /src
parent45e3f34fba7f499d58352951d8e8777c47c229d2 (diff)
Implement loadHtml function for QQuickWebEngineView
Implement unreachableUrl support for WebContentsAdapter::setContent and add loadProgressAfterLoadHtml QML test case. Change-Id: I2d0d7834cbbf8f508de4fa9cb72240f2ac6ebf83 Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/web_contents_adapter.cpp4
-rw-r--r--src/core/web_contents_adapter.h2
-rw-r--r--src/webengine/api/qquickwebengineview.cpp6
-rw-r--r--src/webengine/api/qquickwebengineview_p.h1
4 files changed, 11 insertions, 2 deletions
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 9f4768e1..6325a380 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -57,6 +57,7 @@
#include "content/public/browser/render_view_host.h"
#include "content/public/common/page_zoom.h"
#include "content/public/common/renderer_preferences.h"
+#include "content/public/common/url_constants.h"
#include "ui/shell_dialogs/selected_file_info.h"
#include <QDir>
@@ -283,7 +284,7 @@ void WebContentsAdapter::load(const QUrl &url)
d->webContents->GetView()->Focus();
}
-void WebContentsAdapter::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl)
+void WebContentsAdapter::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl, const QUrl &unreachableUrl)
{
Q_D(WebContentsAdapter);
QByteArray encodedData = data.toPercentEncoding();
@@ -295,6 +296,7 @@ void WebContentsAdapter::setContent(const QByteArray &data, const QString &mimeT
content::NavigationController::LoadURLParams params((GURL(urlString)));
params.load_type = content::NavigationController::LOAD_TYPE_DATA;
params.base_url_for_data_url = toGurl(baseUrl);
+ params.virtual_url_for_data_url = unreachableUrl.isEmpty() ? GURL(content::kAboutBlankURL) : toGurl(unreachableUrl);
params.can_load_local_resources = true;
d->webContents->GetController().LoadURLWithParams(params);
}
diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h
index f39599d9..0e8eb1b2 100644
--- a/src/core/web_contents_adapter.h
+++ b/src/core/web_contents_adapter.h
@@ -68,7 +68,7 @@ public:
void stop();
void reload();
void load(const QUrl&);
- void setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl);
+ void setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl, const QUrl &unreachableUrl = QUrl());
QUrl activeUrl() const;
QString pageTitle() const;
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index 043a7f84..1d289c78 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -386,6 +386,12 @@ QUrl QQuickWebEngineView::icon() const
return d->icon;
}
+void QQuickWebEngineView::loadHtml(const QString &html, const QUrl &baseUrl, const QUrl &unreachableUrl)
+{
+ Q_D(QQuickWebEngineView);
+ d->adapter->setContent(html.toUtf8(), QStringLiteral("text/html;charset=UTF-8"), baseUrl, unreachableUrl);
+}
+
void QQuickWebEngineView::goBack()
{
Q_D(QQuickWebEngineView);
diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h
index abc46d55..77d5b982 100644
--- a/src/webengine/api/qquickwebengineview_p.h
+++ b/src/webengine/api/qquickwebengineview_p.h
@@ -96,6 +96,7 @@ public:
};
public Q_SLOTS:
+ void loadHtml(const QString &html, const QUrl &baseUrl = QUrl(), const QUrl &unreachableUrl = QUrl());
void goBack();
void goForward();
void reload();