summaryrefslogtreecommitdiffstats
path: root/src/webengine/api
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-11-20 16:01:37 +0100
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-11-20 16:04:42 +0100
commit1f474fcc4cd47a85ce8d99f07d18b46ef2af5898 (patch)
treed4e52b5ac98343b4c2417d622164bf320d781a59 /src/webengine/api
parent4cc28c7c89f794d469f5e8f778ff05effe8c646f (diff)
parent1173d48149a8133b607894b67e1ec32de68e21e8 (diff)
Merge branch '5.6' into dev
Diffstat (limited to 'src/webengine/api')
-rw-r--r--src/webengine/api/qquickwebenginecertificateerror_p.h2
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem_p.h2
-rw-r--r--src/webengine/api/qquickwebenginenewviewrequest.cpp2
-rw-r--r--src/webengine/api/qquickwebengineprofile_p.h4
-rw-r--r--src/webengine/api/qquickwebenginescript_p.h4
-rw-r--r--src/webengine/api/qquickwebenginesettings_p.h6
-rw-r--r--src/webengine/api/qquickwebengineview.cpp41
-rw-r--r--src/webengine/api/qquickwebengineview_p.h18
8 files changed, 58 insertions, 21 deletions
diff --git a/src/webengine/api/qquickwebenginecertificateerror_p.h b/src/webengine/api/qquickwebenginecertificateerror_p.h
index 6f54528d4..7deeac932 100644
--- a/src/webengine/api/qquickwebenginecertificateerror_p.h
+++ b/src/webengine/api/qquickwebenginecertificateerror_p.h
@@ -62,7 +62,6 @@ class Q_WEBENGINE_EXPORT QQuickWebEngineCertificateError : public QObject {
Q_PROPERTY(Error error READ error)
Q_PROPERTY(QString description READ description)
Q_PROPERTY(bool overridable READ overridable)
- Q_ENUMS(Error)
public:
@@ -82,6 +81,7 @@ public:
CertificateWeakKey = -211,
CertificateNameConstraintViolation = -212,
};
+ Q_ENUM(Error)
QQuickWebEngineCertificateError(const QSharedPointer<CertificateErrorController> &controller, QObject *parent = 0);
~QQuickWebEngineCertificateError();
diff --git a/src/webengine/api/qquickwebenginedownloaditem_p.h b/src/webengine/api/qquickwebenginedownloaditem_p.h
index 9a30eb4ca..d0be2f99a 100644
--- a/src/webengine/api/qquickwebenginedownloaditem_p.h
+++ b/src/webengine/api/qquickwebenginedownloaditem_p.h
@@ -69,7 +69,7 @@ public:
DownloadCancelled,
DownloadInterrupted
};
- Q_ENUMS(DownloadState)
+ Q_ENUM(DownloadState)
Q_PROPERTY(quint32 id READ id CONSTANT FINAL)
Q_PROPERTY(DownloadState state READ state NOTIFY stateChanged)
diff --git a/src/webengine/api/qquickwebenginenewviewrequest.cpp b/src/webengine/api/qquickwebenginenewviewrequest.cpp
index 893df7f46..6e20c0a46 100644
--- a/src/webengine/api/qquickwebenginenewviewrequest.cpp
+++ b/src/webengine/api/qquickwebenginenewviewrequest.cpp
@@ -69,7 +69,7 @@ QQuickWebEngineView::NewViewDestination QQuickWebEngineNewViewRequest::destinati
}
/*!
- \qmlproperty bool WebEngineNewViewRequest::isUserInitiated
+ \qmlproperty bool WebEngineNewViewRequest::userInitiated
Whether this window request was directly triggered as the result of a keyboard or mouse event.
Use this property to block possibly unwanted \e popups.
diff --git a/src/webengine/api/qquickwebengineprofile_p.h b/src/webengine/api/qquickwebengineprofile_p.h
index b4e0d173c..1ed15aec2 100644
--- a/src/webengine/api/qquickwebengineprofile_p.h
+++ b/src/webengine/api/qquickwebengineprofile_p.h
@@ -67,8 +67,6 @@ class QWebEngineCookieStoreClient;
class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineProfile : public QObject {
Q_OBJECT
- Q_ENUMS(HttpCacheType);
- Q_ENUMS(PersistentCookiesPolicy);
Q_PROPERTY(QString storageName READ storageName WRITE setStorageName NOTIFY storageNameChanged FINAL)
Q_PROPERTY(bool offTheRecord READ isOffTheRecord WRITE setOffTheRecord NOTIFY offTheRecordChanged FINAL)
Q_PROPERTY(QString persistentStoragePath READ persistentStoragePath WRITE setPersistentStoragePath NOTIFY persistentStoragePathChanged FINAL)
@@ -86,12 +84,14 @@ public:
MemoryHttpCache,
DiskHttpCache
};
+ Q_ENUM(HttpCacheType)
enum PersistentCookiesPolicy {
NoPersistentCookies,
AllowPersistentCookies,
ForcePersistentCookies
};
+ Q_ENUM(PersistentCookiesPolicy)
QString storageName() const;
void setStorageName(const QString &name);
diff --git a/src/webengine/api/qquickwebenginescript_p.h b/src/webengine/api/qquickwebenginescript_p.h
index de91134ef..c9d6f5d26 100644
--- a/src/webengine/api/qquickwebenginescript_p.h
+++ b/src/webengine/api/qquickwebenginescript_p.h
@@ -59,8 +59,6 @@ class QQuickWebEngineView;
class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineScript : public QObject
{
Q_OBJECT
- Q_ENUMS(InjectionPoint)
- Q_ENUMS(ScriptWorldId)
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY(QUrl sourceUrl READ sourceUrl WRITE setSourceUrl NOTIFY sourceUrlChanged)
Q_PROPERTY(QString sourceCode READ sourceCode WRITE setSourceCode NOTIFY sourceCodeChanged)
@@ -75,12 +73,14 @@ public:
DocumentReady,
DocumentCreation
};
+ Q_ENUM(InjectionPoint)
enum ScriptWorldId {
MainWorld = 0,
ApplicationWorld,
UserWorld
};
+ Q_ENUM(ScriptWorldId)
QQuickWebEngineScript();
~QQuickWebEngineScript();
diff --git a/src/webengine/api/qquickwebenginesettings_p.h b/src/webengine/api/qquickwebenginesettings_p.h
index e82ec6d48..c08a5d897 100644
--- a/src/webengine/api/qquickwebenginesettings_p.h
+++ b/src/webengine/api/qquickwebenginesettings_p.h
@@ -72,7 +72,8 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineSettings : public QObject {
Q_PROPERTY(bool hyperlinkAuditingEnabled READ hyperlinkAuditingEnabled WRITE setHyperlinkAuditingEnabled NOTIFY hyperlinkAuditingEnabledChanged)
Q_PROPERTY(bool errorPageEnabled READ errorPageEnabled WRITE setErrorPageEnabled NOTIFY errorPageEnabledChanged)
Q_PROPERTY(bool pluginsEnabled READ pluginsEnabled WRITE setPluginsEnabled NOTIFY pluginsEnabledChanged)
- Q_PROPERTY(bool fullScreenSupportEnabled READ fullScreenSupportEnabled WRITE setFullScreenSupportEnabled NOTIFY fullScreenSupportEnabledChanged REVISION 1)
+ // FIXME(QTBUG-40043): Mark fullScreenSupportEnabled with REVISION 1
+ Q_PROPERTY(bool fullScreenSupportEnabled READ fullScreenSupportEnabled WRITE setFullScreenSupportEnabled NOTIFY fullScreenSupportEnabledChanged)
// FIXME: add back REVISION when QTBUG-40043 has been fixed.
Q_PROPERTY(bool screenCaptureEnabled READ screenCaptureEnabled WRITE setScreenCaptureEnabled NOTIFY screenCaptureEnabledChanged /* REVISION 2 */)
Q_PROPERTY(QString defaultTextEncoding READ defaultTextEncoding WRITE setDefaultTextEncoding NOTIFY defaultTextEncodingChanged)
@@ -125,7 +126,8 @@ signals:
void hyperlinkAuditingEnabledChanged();
void errorPageEnabledChanged();
void pluginsEnabledChanged();
- Q_REVISION(1) void fullScreenSupportEnabledChanged();
+ // FIXME(QTBUG-40043): Mark fullScreenSupportEnabledChanged with Q_REVISION(1)
+ void fullScreenSupportEnabledChanged();
// FIXME: add back Q_REVISION when QTBUG-40043 has been fixed.
void screenCaptureEnabledChanged();
void defaultTextEncodingChanged();
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index aa450003c..f266fdce6 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -67,6 +67,7 @@
#include <QClipboard>
#include <QGuiApplication>
+#include <QLoggingCategory>
#include <QMimeData>
#include <QQmlComponent>
#include <QQmlContext>
@@ -534,7 +535,29 @@ bool QQuickWebEngineViewPrivate::isFullScreenMode() const
void QQuickWebEngineViewPrivate::javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID)
{
Q_Q(QQuickWebEngineView);
- Q_EMIT q->javaScriptConsoleMessage(static_cast<QQuickWebEngineView::JavaScriptConsoleMessageLevel>(level), message, lineNumber, sourceID);
+ if (q->receivers(SIGNAL(javaScriptConsoleMessage(JavaScriptConsoleMessageLevel,QString,int,QString))) > 0) {
+ Q_EMIT q->javaScriptConsoleMessage(static_cast<QQuickWebEngineView::JavaScriptConsoleMessageLevel>(level), message, lineNumber, sourceID);
+ return;
+ }
+
+ static QLoggingCategory loggingCategory("js", QtWarningMsg);
+ const QByteArray file = sourceID.toUtf8();
+ QMessageLogger logger(file.constData(), lineNumber, nullptr, loggingCategory.categoryName());
+
+ switch (level) {
+ case JavaScriptConsoleMessageLevel::Info:
+ if (loggingCategory.isInfoEnabled())
+ logger.info().noquote() << message;
+ break;
+ case JavaScriptConsoleMessageLevel::Warning:
+ if (loggingCategory.isWarningEnabled())
+ logger.warning().noquote() << message;
+ break;
+ case JavaScriptConsoleMessageLevel::Error:
+ if (loggingCategory.isCriticalEnabled())
+ logger.critical().noquote() << message;
+ break;
+ }
}
void QQuickWebEngineViewPrivate::authenticationRequired(QSharedPointer<AuthenticationDialogController> controller)
@@ -656,11 +679,25 @@ void QQuickWebEngineViewPrivate::adoptWebContents(WebContentsAdapter *webContent
}
Q_Q(QQuickWebEngineView);
+
+ // memorize what webChannel we had for the previous adapter
+ QQmlWebChannel *qmlWebChannel = NULL;
+ if (adapter)
+ qmlWebChannel = qobject_cast<QQmlWebChannel *>(adapter->webChannel());
+
// This throws away the WebContentsAdapter that has been used until now.
// All its states, particularly the loading URL, are replaced by the adopted WebContentsAdapter.
adapter = webContents;
adapter->initialize(this);
+ // associate the webChannel with the new adapter
+ if (qmlWebChannel)
+ adapter->setWebChannel(qmlWebChannel);
+
+ // re-bind the userscrips to the new adapter
+ Q_FOREACH (QQuickWebEngineScript *script, m_userScripts)
+ script->d_func()->bind(browserContextAdapter()->userScriptController(), adapter.data());
+
// Emit signals for values that might be different from the previous WebContentsAdapter.
emit q->titleChanged();
emit q->urlChanged();
@@ -1454,5 +1491,3 @@ void QQuickWebEngineViewport::setDevicePixelRatio(qreal devicePixelRatio)
QT_END_NAMESPACE
-#include "moc_qquickwebengineview_p.cpp"
-#include "moc_qquickwebengineview_p_p.cpp"
diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h
index a17c7bd43..4c4192b4c 100644
--- a/src/webengine/api/qquickwebengineview_p.h
+++ b/src/webengine/api/qquickwebengineview_p.h
@@ -115,16 +115,7 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem {
Q_PROPERTY(QQuickWebEngineTestSupport *testSupport READ testSupport WRITE setTestSupport FINAL)
#endif
- Q_ENUMS(NavigationRequestAction);
- Q_ENUMS(NavigationType);
- Q_ENUMS(LoadStatus);
- Q_ENUMS(ErrorDomain);
- Q_ENUMS(NewViewDestination);
- Q_ENUMS(Feature);
- Q_ENUMS(JavaScriptConsoleMessageLevel);
- Q_ENUMS(RenderProcessTerminationStatus);
Q_FLAGS(FindFlags);
- Q_ENUMS(WebAction);
public:
QQuickWebEngineView(QQuickItem *parent = 0);
@@ -155,6 +146,7 @@ public:
// we can expose extra actions in experimental.
IgnoreRequest = 0xFF
};
+ Q_ENUM(NavigationRequestAction)
// must match WebContentsAdapterClient::NavigationType
enum NavigationType {
@@ -165,6 +157,7 @@ public:
ReloadNavigation,
OtherNavigation
};
+ Q_ENUM(NavigationType)
enum LoadStatus {
LoadStartedStatus,
@@ -172,6 +165,7 @@ public:
LoadSucceededStatus,
LoadFailedStatus
};
+ Q_ENUM(LoadStatus)
enum ErrorDomain {
NoErrorDomain,
@@ -182,6 +176,7 @@ public:
FtpErrorDomain,
DnsErrorDomain
};
+ Q_ENUM(ErrorDomain)
enum NewViewDestination {
NewViewInWindow,
@@ -189,6 +184,7 @@ public:
NewViewInDialog,
NewViewInBackgroundTab
};
+ Q_ENUM(NewViewDestination)
enum Feature {
MediaAudioCapture,
@@ -196,6 +192,7 @@ public:
MediaAudioVideoCapture,
Geolocation
};
+ Q_ENUM(Feature)
enum WebAction {
NoWebAction = - 1,
@@ -239,6 +236,7 @@ public:
WebActionCount
};
+ Q_ENUM(WebAction)
// must match WebContentsAdapterClient::JavaScriptConsoleMessageLevel
enum JavaScriptConsoleMessageLevel {
@@ -246,6 +244,7 @@ public:
WarningMessageLevel,
ErrorMessageLevel
};
+ Q_ENUM(JavaScriptConsoleMessageLevel)
// must match WebContentsAdapterClient::RenderProcessTerminationStatus
enum RenderProcessTerminationStatus {
@@ -254,6 +253,7 @@ public:
CrashedTerminationStatus,
KilledTerminationStatus
};
+ Q_ENUM(RenderProcessTerminationStatus)
enum FindFlag {
FindBackward = 1,