summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/core/web_contents_adapter_client.h2
-rw-r--r--src/core/web_contents_delegate_qt.cpp2
-rw-r--r--src/webengine/api/qquickwebengineloadrequest.cpp113
-rw-r--r--src/webengine/api/qquickwebengineloadrequest_p.h96
-rw-r--r--src/webengine/api/qquickwebengineview.cpp40
-rw-r--r--src/webengine/api/qquickwebengineview_p.h22
-rw-r--r--src/webengine/api/qquickwebengineview_p_p.h3
-rw-r--r--src/webengine/plugin/plugin.cpp2
-rw-r--r--src/webengine/webengine.pro2
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp4
-rw-r--r--src/webenginewidgets/api/qwebenginepage_p.h2
11 files changed, 277 insertions, 11 deletions
diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h
index dad77cf57..72754e9dc 100644
--- a/src/core/web_contents_adapter_client.h
+++ b/src/core/web_contents_adapter_client.h
@@ -109,7 +109,7 @@ public:
virtual void loadProgressChanged(int progress) = 0;
virtual QRectF viewportRect() const = 0;
virtual qreal dpiScale() const = 0;
- virtual void loadFinished(bool success) = 0;
+ virtual void loadFinished(bool success, int error_code = 0, const QString &error_description = QString()) = 0;
virtual void focusContainer() = 0;
virtual void adoptNewWindow(WebContentsAdapter *newWebContents, WindowOpenDisposition disposition, const QRect & initialGeometry) = 0;
virtual void close() = 0;
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index 27d1c3e9a..5c5026f78 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -100,7 +100,7 @@ void WebContentsDelegateQt::LoadProgressChanged(content::WebContents* source, do
void WebContentsDelegateQt::DidFailLoad(int64 frame_id, const GURL &validated_url, bool is_main_frame, int error_code, const string16 &error_description, content::RenderViewHost *render_view_host)
{
if (is_main_frame)
- m_viewClient->loadFinished(false);
+ m_viewClient->loadFinished(false, error_code, toQt(error_description));
}
void WebContentsDelegateQt::DidFinishLoad(int64 frame_id, const GURL &validated_url, bool is_main_frame, content::RenderViewHost *render_view_host)
diff --git a/src/webengine/api/qquickwebengineloadrequest.cpp b/src/webengine/api/qquickwebengineloadrequest.cpp
new file mode 100644
index 000000000..e9e6fab14
--- /dev/null
+++ b/src/webengine/api/qquickwebengineloadrequest.cpp
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qquickwebengineloadrequest_p.h>
+
+/*!
+ \qmltype WebEngineLoadRequest
+ \instantiates QQuickWebEngineLoadRequest
+ \inqmlmodule QtWebEngine 1.0
+
+ \brief A utility class for the WebEngineView::loadingStateChanged signal.
+
+ This class contains information about a requested load of a web page, like the URL and
+ current loading status (started, finished, failed).
+
+ \sa WebEngineView::onLoadingStateChanged
+*/
+QQuickWebEngineLoadRequest::QQuickWebEngineLoadRequest(const QUrl& url, QQuickWebEngineView::LoadStatus status, const QString& errorString, int errorCode, QQuickWebEngineView::ErrorDomain errorDomain, QObject* parent)
+ : QObject(parent)
+ , d(new QQuickWebEngineLoadRequestPrivate(url, status, errorString, errorCode, errorDomain))
+{
+}
+
+QQuickWebEngineLoadRequest::~QQuickWebEngineLoadRequest()
+{
+}
+
+/*!
+ \qmlproperty url WebEngineLoadRequest::url
+ \brief The URL of the load request.
+ */
+QUrl QQuickWebEngineLoadRequest::url() const
+{
+ return d->url;
+}
+
+/*!
+ \qmlproperty enumeration WebEngineLoadRequest::status
+
+ The load status of a web page load request.
+
+ \list
+ \li WebEngineView::LoadStartedStatus - the page is currently loading.
+ \li WebEngineView::LoadSucceededStatus - the page has been loaded with success.
+ \li WebEngineView::LoadFailedStatus - the page has failed loading.
+ \endlist
+
+ \sa WebEngineLoadRequest
+ \sa WebEngineView::onLoadingStateChanged
+*/
+QQuickWebEngineView::LoadStatus QQuickWebEngineLoadRequest::status() const
+{
+ return d->status;
+}
+
+/*!
+ \qmlproperty string WebEngineLoadRequest::errorString
+*/
+QString QQuickWebEngineLoadRequest::errorString() const
+{
+ return d->errorString;
+}
+
+QQuickWebEngineView::ErrorDomain QQuickWebEngineLoadRequest::errorDomain() const
+{
+ return d->errorDomain;
+}
+
+/*!
+ \qmlproperty int WebEngineLoadRequest::errorCode
+*/
+int QQuickWebEngineLoadRequest::errorCode() const
+{
+ return d->errorCode;
+}
diff --git a/src/webengine/api/qquickwebengineloadrequest_p.h b/src/webengine/api/qquickwebengineloadrequest_p.h
new file mode 100644
index 000000000..6f627acb0
--- /dev/null
+++ b/src/webengine/api/qquickwebengineloadrequest_p.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKWEBENGINELOADREQUEST_P_H
+#define QQUICKWEBENGINELOADREQUEST_P_H
+
+#include "qtwebengineglobal_p.h"
+#include "qquickwebengineview_p.h"
+#include "web_engine_error.h"
+
+QT_BEGIN_NAMESPACE
+
+class QQuickWebEngineLoadRequestPrivate;
+
+class Q_WEBENGINE_EXPORT QQuickWebEngineLoadRequest : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QUrl url READ url)
+ Q_PROPERTY(QQuickWebEngineView::LoadStatus status READ status)
+ Q_PROPERTY(QString errorString READ errorString)
+ Q_PROPERTY(QQuickWebEngineView::ErrorDomain errorDomain READ errorDomain)
+ Q_PROPERTY(int errorCode READ errorCode)
+
+public:
+ QQuickWebEngineLoadRequest(const QUrl& url, QQuickWebEngineView::LoadStatus status, const QString& errorString = QString(), int errorCode = 0, QQuickWebEngineView::ErrorDomain errorDomain = QQuickWebEngineView::NoErrorDomain, QObject* parent = 0);
+ ~QQuickWebEngineLoadRequest();
+ QUrl url() const;
+ QQuickWebEngineView::LoadStatus status() const;
+ QString errorString() const;
+ QQuickWebEngineView::ErrorDomain errorDomain() const;
+ int errorCode() const;
+
+private:
+ QScopedPointer<QQuickWebEngineLoadRequestPrivate> d;
+};
+
+class QQuickWebEngineLoadRequestPrivate {
+public:
+ QQuickWebEngineLoadRequestPrivate(const QUrl& url, QQuickWebEngineView::LoadStatus status, const QString& errorString, int errorCode, QQuickWebEngineView::ErrorDomain errorDomain)
+ : url(url)
+ , status(status)
+ , errorString(errorString)
+ , errorCode(errorCode)
+ , errorDomain(errorDomain)
+ {
+ }
+
+ QUrl url;
+ QQuickWebEngineView::LoadStatus status;
+ QString errorString;
+ int errorCode;
+ QQuickWebEngineView::ErrorDomain errorDomain;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickWebEngineLoadRequest)
+
+#endif // QQUICKWEBENGINELOADREQUEST_P_H
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index d159ed8fc..ac2dc681e 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -42,7 +42,10 @@
#include "qquickwebengineview_p.h"
#include "qquickwebengineview_p_p.h"
+#include "net/base/net_errors.h"
+#include "qquickwebengineloadrequest_p.h"
#include "web_contents_adapter.h"
+#include "web_engine_error.h"
#include "render_widget_host_view_qt_delegate_quick.h"
#include <QScreen>
@@ -57,6 +60,7 @@ QQuickWebEngineViewPrivate::QQuickWebEngineViewPrivate()
, v(new QQuickWebEngineViewport(this))
, loadProgress(0)
, inspectable(false)
+ , m_isLoading(false)
, devicePixelRatio(QGuiApplication::primaryScreen()->devicePixelRatio())
, m_dpiScale(1.0)
{
@@ -123,7 +127,12 @@ void QQuickWebEngineViewPrivate::iconChanged(const QUrl &url)
void QQuickWebEngineViewPrivate::loadingStateChanged()
{
Q_Q(QQuickWebEngineView);
- Q_EMIT q->loadingStateChanged();
+ const bool wasLoading = m_isLoading;
+ m_isLoading = adapter->isLoading();
+ if (m_isLoading && !wasLoading) {
+ QQuickWebEngineLoadRequest loadRequest(q->url(), QQuickWebEngineView::LoadStartedStatus);
+ Q_EMIT q->loadingStateChanged(&loadRequest);
+ }
}
void QQuickWebEngineViewPrivate::loadProgressChanged(int progress)
@@ -144,11 +153,29 @@ qreal QQuickWebEngineViewPrivate::dpiScale() const
return m_dpiScale;
}
-void QQuickWebEngineViewPrivate::loadFinished(bool success)
+void QQuickWebEngineViewPrivate::loadFinished(bool success, int error_code, const QString &error_description)
{
Q_Q(QQuickWebEngineView);
- Q_UNUSED(success);
- Q_EMIT q->loadingStateChanged();
+ if (error_code == net::ERR_ABORTED) {
+ QQuickWebEngineLoadRequest loadRequest(q->url(), QQuickWebEngineView::LoadStoppedStatus);
+ Q_EMIT q->loadingStateChanged(&loadRequest);
+ return;
+ }
+ if (success) {
+ QQuickWebEngineLoadRequest loadRequest(q->url(), QQuickWebEngineView::LoadSucceededStatus);
+ Q_EMIT q->loadingStateChanged(&loadRequest);
+ return;
+ }
+
+ Q_ASSERT(error_code);
+ QQuickWebEngineLoadRequest loadRequest(
+ q->url(),
+ QQuickWebEngineView::LoadFailedStatus,
+ error_description,
+ error_code,
+ static_cast<QQuickWebEngineView::ErrorDomain>(WebEngineError::toQtErrorDomain(error_code)));
+ Q_EMIT q->loadingStateChanged(&loadRequest);
+ return;
}
void QQuickWebEngineViewPrivate::focusContainer()
@@ -391,7 +418,10 @@ void QQuickWebEngineViewExperimental::adoptHandle(QQuickWebEngineViewHandle *vie
emit q->titleChanged();
emit q->urlChanged();
emit q->iconChanged();
- emit q->loadingStateChanged();
+ // FIXME: The current loading state should be stored in the WebContentAdapter
+ // and it should be checked here if the signal emission is really necessary.
+ QQuickWebEngineLoadRequest loadRequest(viewHandle->adapter->activeUrl(), QQuickWebEngineView::LoadSucceededStatus);
+ emit q->loadingStateChanged(&loadRequest);
emit q->loadProgressChanged();
}
diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h
index 943ce0804..76fbc7853 100644
--- a/src/webengine/api/qquickwebengineview_p.h
+++ b/src/webengine/api/qquickwebengineview_p.h
@@ -48,6 +48,7 @@
QT_BEGIN_NAMESPACE
class QQuickWebEngineViewPrivate;
+class QQuickWebEngineLoadRequest;
class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem {
Q_OBJECT
@@ -59,6 +60,8 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem {
Q_PROPERTY(bool canGoBack READ canGoBack NOTIFY loadingStateChanged)
Q_PROPERTY(bool canGoForward READ canGoForward NOTIFY loadingStateChanged)
Q_PROPERTY(bool inspectable READ inspectable WRITE setInspectable)
+ Q_ENUMS(LoadStatus);
+ Q_ENUMS(ErrorDomain);
public:
QQuickWebEngineView(QQuickItem *parent = 0);
@@ -75,6 +78,23 @@ public:
bool inspectable() const;
void setInspectable(bool);
+ enum LoadStatus {
+ LoadStartedStatus,
+ LoadStoppedStatus,
+ LoadSucceededStatus,
+ LoadFailedStatus
+ };
+
+ enum ErrorDomain {
+ NoErrorDomain,
+ InternalErrorDomain,
+ ConnectionErrorDomain,
+ CertificateErrorDomain,
+ HttpErrorDomain,
+ FtpErrorDomain,
+ DnsErrorDomain
+ };
+
public Q_SLOTS:
void goBack();
void goForward();
@@ -85,7 +105,7 @@ Q_SIGNALS:
void titleChanged();
void urlChanged();
void iconChanged();
- void loadingStateChanged();
+ void loadingStateChanged(QQuickWebEngineLoadRequest *loadRequest);
void loadProgressChanged();
protected:
diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h
index 0af1dcb45..f43bb17fa 100644
--- a/src/webengine/api/qquickwebengineview_p_p.h
+++ b/src/webengine/api/qquickwebengineview_p_p.h
@@ -119,7 +119,7 @@ public:
virtual void loadProgressChanged(int progress) Q_DECL_OVERRIDE;
virtual QRectF viewportRect() const Q_DECL_OVERRIDE;
virtual qreal dpiScale() const Q_DECL_OVERRIDE;
- virtual void loadFinished(bool success) Q_DECL_OVERRIDE;
+ virtual void loadFinished(bool success, int error_code = 0, const QString &error_description = QString()) Q_DECL_OVERRIDE;
virtual void focusContainer() Q_DECL_OVERRIDE;
virtual void adoptNewWindow(WebContentsAdapter *newWebContents, WindowOpenDisposition disposition, const QRect &) Q_DECL_OVERRIDE;
virtual void close() Q_DECL_OVERRIDE;
@@ -134,6 +134,7 @@ public:
QUrl icon;
int loadProgress;
bool inspectable;
+ bool m_isLoading;
qreal devicePixelRatio;
private:
diff --git a/src/webengine/plugin/plugin.cpp b/src/webengine/plugin/plugin.cpp
index 751916364..dd36bc6b7 100644
--- a/src/webengine/plugin/plugin.cpp
+++ b/src/webengine/plugin/plugin.cpp
@@ -42,6 +42,7 @@
#include <QtQml/qqmlextensionplugin.h>
#include "qquickwebengineview_p.h"
+#include "qquickwebengineloadrequest_p.h"
QT_BEGIN_NAMESPACE
@@ -55,6 +56,7 @@ public:
Q_ASSERT(QLatin1String(uri) == QLatin1String("QtWebEngine"));
qmlRegisterType<QQuickWebEngineView>(uri, 1, 0, "WebEngineView");
+ qmlRegisterUncreatableType<QQuickWebEngineLoadRequest>(uri, 1, 0, "WebEngineLoadRequest", QObject::tr("Cannot create separate instance of WebEngineLoadRequest"));
}
};
diff --git a/src/webengine/webengine.pro b/src/webengine/webengine.pro
index ccf874358..96724d465 100644
--- a/src/webengine/webengine.pro
+++ b/src/webengine/webengine.pro
@@ -20,12 +20,14 @@ QMAKE_RPATHDIR += $$LIBPATH
#DESTDIR = $$LIBPATH
SOURCES = \
+ api/qquickwebengineloadrequest.cpp \
api/qquickwebengineview.cpp \
render_widget_host_view_qt_delegate_quick.cpp
HEADERS = \
api/qtwebengineglobal.h \
api/qtwebengineglobal_p.h \
+ api/qquickwebengineloadrequest_p.h \
api/qquickwebengineview_p.h \
api/qquickwebengineview_p_p.h \
render_widget_host_view_qt_delegate_quick.h
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index be1cdc9f7..6214c0f78 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -109,9 +109,11 @@ qreal QWebEnginePagePrivate::dpiScale() const
return 1.0;
}
-void QWebEnginePagePrivate::loadFinished(bool success)
+void QWebEnginePagePrivate::loadFinished(bool success, int error_code, const QString &error_description)
{
Q_Q(QWebEnginePage);
+ Q_UNUSED(error_code);
+ Q_UNUSED(error_description);
m_isLoading = adapter->isLoading();
Q_EMIT q->loadFinished(success);
}
diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h
index 43f24b813..a8df3ba6a 100644
--- a/src/webenginewidgets/api/qwebenginepage_p.h
+++ b/src/webenginewidgets/api/qwebenginepage_p.h
@@ -72,7 +72,7 @@ public:
virtual void loadProgressChanged(int progress) Q_DECL_OVERRIDE;
virtual QRectF viewportRect() const Q_DECL_OVERRIDE;
virtual qreal dpiScale() const Q_DECL_OVERRIDE;
- virtual void loadFinished(bool success) Q_DECL_OVERRIDE;
+ virtual void loadFinished(bool success, int error_code, const QString &error_description = QString()) Q_DECL_OVERRIDE;
virtual void focusContainer() Q_DECL_OVERRIDE;
virtual void adoptNewWindow(WebContentsAdapter *newWebContents, WindowOpenDisposition disposition, const QRect &initialGeometry) Q_DECL_OVERRIDE;
virtual void close() Q_DECL_OVERRIDE;