summaryrefslogtreecommitdiffstats
path: root/src/core/web_contents_delegate_qt.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2021-06-06 18:30:13 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2021-06-06 21:33:49 +0200
commit5dd4dd1d1f83157339bac1600228895cc0c86088 (patch)
tree15f04a636c1a2dfbc3b58a71772e0d872af5e90b /src/core/web_contents_delegate_qt.cpp
parent163e262888f8d44d1c4405b420a6a58cb622aca8 (diff)
Replace testsupport's QQuickWebEngineErrorPage with isErrorPage
Merge and unify handling of loading started/finished for quick and widgets by removing separate quick's type for monitoring error page load and replace it with an isErrorPage method in WebEngineLoadRequest to indicate, that load ended with an error page being displayed. Effectively this only slightly changes when loading finished gets emitted: now the signal is just postponed until error page is finished loading after initial failure. [ChangeLog][QWebEngineQuick][WebEngineLoadingInfo] New property 'isErrorPage' which indicates that the load resulted in an error page Change-Id: I3e59dc488429d776f7c8e083b6d0489fb30a65fc Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core/web_contents_delegate_qt.cpp')
-rw-r--r--src/core/web_contents_delegate_qt.cpp33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index 34e1f7ad1..a04ef700b 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -49,6 +49,7 @@
#include "file_picker_controller.h"
#include "media_capture_devices_dispatcher.h"
#include "profile_qt.h"
+#include "qwebengineloadinginfo.h"
#include "qwebengineregisterprotocolhandlerrequest.h"
#include "register_protocol_handler_request_controller_impl.h"
#include "render_widget_host_view_qt.h"
@@ -58,6 +59,7 @@
#include "web_contents_adapter.h"
#include "web_contents_view_qt.h"
#include "web_engine_context.h"
+#include "web_engine_error.h"
#include "web_engine_settings.h"
#include "certificate_error_controller.h"
#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
@@ -344,11 +346,9 @@ void WebContentsDelegateQt::emitLoadStarted(bool isErrorPage)
m_isDocumentEmpty = true; // reset to default which may only be overridden on actual resource load complete
if (!isErrorPage) {
m_loadingInfo.progress = 0;
- m_viewClient->loadStarted(m_loadingInfo.url, false);
+ m_viewClient->loadStarted(QWebEngineLoadingInfo(m_loadingInfo.url, QWebEngineLoadingInfo::LoadStartedStatus));
m_viewClient->updateNavigationActions();
m_viewClient->loadProgressChanged(0);
- } else {
- m_viewClient->loadStarted(toQt(GURL(content::kUnreachableWebDataURL)), true);
}
}
@@ -374,17 +374,25 @@ void WebContentsDelegateQt::emitLoadFinished(bool isErrorPage)
Q_ASSERT(!isErrorPage || webEngineSettings()->testAttribute(QWebEngineSettings::ErrorPageEnabled));
Q_ASSERT((m_loadingInfo.triggersErrorPage && webEngineSettings()->testAttribute(QWebEngineSettings::ErrorPageEnabled)) || !m_loadingInfo.triggersErrorPage);
- if (!isErrorPage) {
- if (m_loadingInfo.progress < 100) {
- m_loadingInfo.progress = 100;
- m_viewClient->loadProgressChanged(100);
- }
+ if (isErrorPage) {
+ m_loadingInfo.isErrorPage = isErrorPage;
+ return;
+ }
- m_viewClient->loadFinished(m_loadingInfo.success, m_loadingInfo.url, false, m_loadingInfo.errorCode, m_loadingInfo.errorDescription);
- m_viewClient->updateNavigationActions();
- } else {
- m_viewClient->loadFinished(false, toQt(GURL(content::kUnreachableWebDataURL)), true, 0, QString());
+ if (m_loadingInfo.progress < 100) {
+ m_loadingInfo.progress = 100;
+ m_viewClient->loadProgressChanged(100);
}
+
+ auto loadStatus = m_loadingInfo.success
+ ? QWebEngineLoadingInfo::LoadSucceededStatus
+ : (m_loadingInfo.errorCode == WebEngineError::UserAbortedError
+ ? QWebEngineLoadingInfo::LoadStoppedStatus : QWebEngineLoadingInfo::LoadFailedStatus);
+ auto errorDomain = static_cast<QWebEngineLoadingInfo::ErrorDomain>(WebEngineError::toQtErrorDomain(m_loadingInfo.errorCode));
+ QWebEngineLoadingInfo info(m_loadingInfo.url, loadStatus, m_loadingInfo.isErrorPage,
+ m_loadingInfo.errorDescription, m_loadingInfo.errorCode, errorDomain);
+ m_viewClient->loadFinished(std::move(info));
+ m_viewClient->updateNavigationActions();
}
void WebContentsDelegateQt::emitLoadCommitted()
@@ -422,7 +430,6 @@ void WebContentsDelegateQt::DidFinishNavigation(content::NavigationHandle *navig
// The load will succede as an error-page load later, and we reported the original error above
if (navigation_handle->IsErrorPage()) {
// Now report we are starting to load an error-page.
- emitLoadStarted(true);
// If it is already committed we will not see another DidFinishNavigation call or a DidFinishLoad call.
if (navigation_handle->HasCommitted())