summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErwin Kandler <e.kandler@gmail.com>2018-08-21 10:46:31 +0200
committerKai Koehne <kai.koehne@qt.io>2018-08-29 13:06:36 +0000
commit0c97d942b0d723f7efbb31f651d2bd75f5537da9 (patch)
treebe62256087de8e0ed36e3397639169a2e6556377
parent33d4b696eba33804da06ae9dda7997feb8b1c50e (diff)
Return http status code for successfully loaded pages
WebEngineView supports getting the http status code (error code) for failed loading requests only. This patch lets the user access the status code for successfully loaded pages as well. Change-Id: Ib8dbdfe94eed4d62e731c736c13f60ebd62a23fa Reviewed-by: Kai Koehne <kai.koehne@qt.io>
-rw-r--r--src/core/web_contents_delegate_qt.cpp6
-rw-r--r--src/webengine/api/qquickwebengineview.cpp4
2 files changed, 7 insertions, 3 deletions
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index 7f1604162..36703c225 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -376,7 +376,11 @@ void WebContentsDelegateQt::DidFinishLoad(content::RenderFrameHost* render_frame
if (!m_faviconManager->hasCandidate())
m_viewClient->iconChanged(QUrl());
- EmitLoadFinished(true, toQt(validated_url));
+ content::NavigationEntry *entry = web_contents()->GetController().GetActiveEntry();
+ int http_statuscode = 0;
+ if (entry)
+ http_statuscode = entry->GetHttpStatusCode();
+ EmitLoadFinished(true /* success */ , toQt(validated_url), false /* isErrorPage */, http_statuscode);
}
void WebContentsDelegateQt::DidUpdateFaviconURL(const std::vector<content::FaviconURL> &candidates)
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index a840e3cb0..bdd3bfe26 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -474,8 +474,8 @@ void QQuickWebEngineViewPrivate::loadFinished(bool success, const QUrl &url, boo
}
if (success) {
explicitUrl = QUrl();
- QTimer::singleShot(0, q, [q, url]() {
- QQuickWebEngineLoadRequest loadRequest(url, QQuickWebEngineView::LoadSucceededStatus);
+ QTimer::singleShot(0, q, [q, url, errorDescription, errorCode]() {
+ QQuickWebEngineLoadRequest loadRequest(url, QQuickWebEngineView::LoadSucceededStatus, errorDescription, errorCode);
emit q->loadingChanged(&loadRequest);
});
return;