summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@digia.com>2014-03-06 20:46:19 +0100
committerPierre Rossi <pierre.rossi@gmail.com>2014-09-02 10:02:07 +0200
commit33a0ed37321edf6f1d9e89fa55e820800cec031c (patch)
tree52cede0b50f2f854b9f4543ec14e9b5cc82addb1
parentc6c1da2f4c71e523213aa8ee961d8fec779f62e2 (diff)
Settings for Qt quick
Expose settings in experimental for now. Simply use the global/per-view mechanism as a group level in between seems like overkill. Change-Id: I7610e9c7765ccb41674702acdd24a52b87716da8 Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
-rw-r--r--src/core/web_engine_settings.cpp2
-rw-r--r--src/webengine/api/qquickwebenginesettings.cpp256
-rw-r--r--src/webengine/api/qquickwebenginesettings_p.h115
-rw-r--r--src/webengine/api/qquickwebenginesettings_p_p.h57
-rw-r--r--src/webengine/api/qquickwebenginesingleton.cpp48
-rw-r--r--src/webengine/api/qquickwebenginesingleton_p.h56
-rw-r--r--src/webengine/api/qquickwebengineview.cpp29
-rw-r--r--src/webengine/api/qquickwebengineview_p_p.h4
-rw-r--r--src/webengine/plugin/experimental/plugin.cpp10
-rw-r--r--src/webengine/plugin/plugin.cpp4
-rw-r--r--src/webengine/webengine.pro5
11 files changed, 562 insertions, 24 deletions
diff --git a/src/core/web_engine_settings.cpp b/src/core/web_engine_settings.cpp
index fdbc65ed..76eb7f25 100644
--- a/src/core/web_engine_settings.cpp
+++ b/src/core/web_engine_settings.cpp
@@ -185,7 +185,6 @@ QString WebEngineSettings::defaultTextEncoding() const
void WebEngineSettings::initDefaults()
{
// Initialize the default settings.
-
m_attributes.insert(AutoLoadImages, true);
m_attributes.insert(JavascriptEnabled, true);
m_attributes.insert(JavascriptCanOpenWindows, false);
@@ -236,7 +235,6 @@ void WebEngineSettings::doApply()
if (webPreferences.isNull())
return;
// Override with our settings when applicable
- // FIXME: batch sequential calls to apply?
applySettingsToWebPreferences(webPreferences.data());
Q_ASSERT(m_adapter);
diff --git a/src/webengine/api/qquickwebenginesettings.cpp b/src/webengine/api/qquickwebenginesettings.cpp
new file mode 100644
index 00000000..aa6290aa
--- /dev/null
+++ b/src/webengine/api/qquickwebenginesettings.cpp
@@ -0,0 +1,256 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickwebenginesettings_p.h"
+#include "qquickwebenginesettings_p_p.h"
+
+#include <QtCore/QList>
+
+QT_BEGIN_NAMESPACE
+
+Q_GLOBAL_STATIC(QList<QQuickWebEngineSettingsPrivate*>, allSettings)
+
+QQuickWebEngineSettingsPrivate::QQuickWebEngineSettingsPrivate()
+ : coreSettings(new WebEngineSettings(this))
+{
+ allSettings->append(this);
+}
+
+void QQuickWebEngineSettingsPrivate::apply()
+{
+ coreSettings->scheduleApply();
+ QQuickWebEngineSettingsPrivate *globals = QQuickWebEngineSettings::globalSettings()->d_func();
+ Q_ASSERT((this == globals) != (allSettings->contains(this)));
+ if (this == globals)
+ Q_FOREACH (QQuickWebEngineSettingsPrivate *settings, *allSettings)
+ settings->coreSettings->scheduleApply();
+}
+
+WebEngineSettings *QQuickWebEngineSettingsPrivate::fallbackSettings() const
+{
+ return QQuickWebEngineSettings::globalSettings()->d_func()->coreSettings.data();
+}
+
+
+QQuickWebEngineSettings *QQuickWebEngineSettings::globalSettings()
+{
+ static QQuickWebEngineSettings *globals = 0;
+ if (!globals) {
+ globals = new QQuickWebEngineSettings;
+ allSettings->removeAll(globals->d_func());
+ globals->d_func()->coreSettings->initDefaults();
+ }
+ return globals;
+}
+
+QQuickWebEngineSettings::~QQuickWebEngineSettings()
+{
+}
+
+bool QQuickWebEngineSettings::autoLoadImages() const
+{
+ Q_D(const QQuickWebEngineSettings);
+ return d->coreSettings->testAttribute(WebEngineSettings::AutoLoadImages);
+}
+
+bool QQuickWebEngineSettings::javascriptEnabled() const
+{
+ Q_D(const QQuickWebEngineSettings);
+ return d->coreSettings->testAttribute(WebEngineSettings::JavascriptEnabled);
+}
+
+bool QQuickWebEngineSettings::javascriptCanOpenWindows() const
+{
+ Q_D(const QQuickWebEngineSettings);
+ return d->coreSettings->testAttribute(WebEngineSettings::JavascriptCanOpenWindows);
+}
+
+bool QQuickWebEngineSettings::javascriptCanAccessClipboard() const
+{
+ Q_D(const QQuickWebEngineSettings);
+ return d->coreSettings->testAttribute(WebEngineSettings::JavascriptCanAccessClipboard);
+}
+
+bool QQuickWebEngineSettings::linksIncludedInFocusChain() const
+{
+ Q_D(const QQuickWebEngineSettings);
+ return d->coreSettings->testAttribute(WebEngineSettings::LinksIncludedInFocusChain);
+}
+
+bool QQuickWebEngineSettings::localStorageEnabled() const
+{
+ Q_D(const QQuickWebEngineSettings);
+ return d->coreSettings->testAttribute(WebEngineSettings::LocalStorageEnabled);
+}
+
+bool QQuickWebEngineSettings::localContentCanAccessRemoteUrls() const
+{
+ Q_D(const QQuickWebEngineSettings);
+ return d->coreSettings->testAttribute(WebEngineSettings::LocalContentCanAccessRemoteUrls);
+}
+
+bool QQuickWebEngineSettings::spatialNavigationEnabled() const
+{
+ Q_D(const QQuickWebEngineSettings);
+ return d->coreSettings->testAttribute(WebEngineSettings::SpatialNavigationEnabled);
+}
+
+bool QQuickWebEngineSettings::localContentCanAccessFileUrls() const
+{
+ Q_D(const QQuickWebEngineSettings);
+ return d->coreSettings->testAttribute(WebEngineSettings::LocalContentCanAccessFileUrls);
+}
+
+bool QQuickWebEngineSettings::hyperlinkAuditingEnabled() const
+{
+ Q_D(const QQuickWebEngineSettings);
+ return d->coreSettings->testAttribute(WebEngineSettings::HyperlinkAuditingEnabled);
+}
+
+QString QQuickWebEngineSettings::defaultTextEncoding() const
+{
+ Q_D(const QQuickWebEngineSettings);
+ return d->coreSettings->defaultTextEncoding();
+}
+
+void QQuickWebEngineSettings::setAutoLoadImages(bool on)
+{
+ Q_D(QQuickWebEngineSettings);
+ bool wasOn = d->coreSettings->testAttribute(WebEngineSettings::AutoLoadImages);
+ // Set unconditionally as it sets the override for the current settings while the current setting
+ // could be from the fallback and is prone to changing later on.
+ d->coreSettings->setAttribute(WebEngineSettings::AutoLoadImages, on);
+ if (wasOn ^ on)
+ Q_EMIT autoLoadImagesChanged(on);
+}
+
+void QQuickWebEngineSettings::setJavascriptEnabled(bool on)
+{
+ Q_D(QQuickWebEngineSettings);
+ bool wasOn = d->coreSettings->testAttribute(WebEngineSettings::JavascriptEnabled);
+ d->coreSettings->setAttribute(WebEngineSettings::JavascriptEnabled, on);
+ if (wasOn ^ on)
+ Q_EMIT javascriptEnabledChanged(on);
+}
+
+void QQuickWebEngineSettings::setJavascriptCanOpenWindows(bool on)
+{
+ Q_D(QQuickWebEngineSettings);
+ bool wasOn = d->coreSettings->testAttribute(WebEngineSettings::JavascriptCanOpenWindows);
+ d->coreSettings->setAttribute(WebEngineSettings::JavascriptCanOpenWindows, on);
+ if (wasOn ^ on)
+ Q_EMIT javascriptCanOpenWindowsChanged(on);
+}
+
+void QQuickWebEngineSettings::setJavascriptCanAccessClipboard(bool on)
+{
+ Q_D(QQuickWebEngineSettings);
+ bool wasOn = d->coreSettings->testAttribute(WebEngineSettings::JavascriptCanAccessClipboard);
+ d->coreSettings->setAttribute(WebEngineSettings::JavascriptCanAccessClipboard, on);
+ if (wasOn ^ on)
+ Q_EMIT javascriptCanAccessClipboardChanged(on);
+}
+
+void QQuickWebEngineSettings::setLinksIncludedInFocusChain(bool on)
+{
+ Q_D(QQuickWebEngineSettings);
+ bool wasOn = d->coreSettings->testAttribute(WebEngineSettings::LinksIncludedInFocusChain);
+ d->coreSettings->setAttribute(WebEngineSettings::LinksIncludedInFocusChain, on);
+ if (wasOn ^ on)
+ Q_EMIT linksIncludedInFocusChainChanged(on);
+}
+
+void QQuickWebEngineSettings::setLocalStorageEnabled(bool on)
+{
+ Q_D(QQuickWebEngineSettings);
+ bool wasOn = d->coreSettings->testAttribute(WebEngineSettings::LocalStorageEnabled);
+ d->coreSettings->setAttribute(WebEngineSettings::LocalStorageEnabled, on);
+ if (wasOn ^ on)
+ Q_EMIT localStorageEnabledChanged(on);
+}
+
+void QQuickWebEngineSettings::setLocalContentCanAccessRemoteUrls(bool on)
+{
+ Q_D(QQuickWebEngineSettings);
+ bool wasOn = d->coreSettings->testAttribute(WebEngineSettings::LocalContentCanAccessRemoteUrls);
+ d->coreSettings->setAttribute(WebEngineSettings::LocalContentCanAccessRemoteUrls, on);
+ if (wasOn ^ on)
+ Q_EMIT localContentCanAccessRemoteUrlsChanged(on);
+}
+
+
+void QQuickWebEngineSettings::setSpatialNavigationEnabled(bool on)
+{
+ Q_D(QQuickWebEngineSettings);
+ bool wasOn = d->coreSettings->testAttribute(WebEngineSettings::SpatialNavigationEnabled);
+ d->coreSettings->setAttribute(WebEngineSettings::SpatialNavigationEnabled, on);
+ if (wasOn ^ on)
+ Q_EMIT spatialNavigationEnabledChanged(on);
+}
+
+void QQuickWebEngineSettings::setLocalContentCanAccessFileUrls(bool on)
+{
+ Q_D(QQuickWebEngineSettings);
+ bool wasOn = d->coreSettings->testAttribute(WebEngineSettings::LocalContentCanAccessFileUrls);
+ d->coreSettings->setAttribute(WebEngineSettings::LocalContentCanAccessFileUrls, on);
+ if (wasOn ^ on)
+ Q_EMIT localContentCanAccessFileUrlsChanged(on);
+}
+
+void QQuickWebEngineSettings::setHyperlinkAuditingEnabled(bool on)
+{
+ Q_D(QQuickWebEngineSettings);
+ bool wasOn = d->coreSettings->testAttribute(WebEngineSettings::HyperlinkAuditingEnabled);
+ d->coreSettings->setAttribute(WebEngineSettings::HyperlinkAuditingEnabled, on);
+ if (wasOn ^ on)
+ Q_EMIT hyperlinkAuditingEnabledChanged(on);
+}
+
+void QQuickWebEngineSettings::setDefaultTextEncoding(QString encoding)
+{
+ Q_D(QQuickWebEngineSettings);
+ const QString oldDefaultTextEncoding = d->coreSettings->defaultTextEncoding();
+ d->coreSettings->setDefaultTextEncoding(encoding);
+ if (oldDefaultTextEncoding.compare(encoding))
+ Q_EMIT defaultTextEncodingChanged(encoding);
+}
+
+QQuickWebEngineSettings::QQuickWebEngineSettings()
+ : d_ptr(new QQuickWebEngineSettingsPrivate)
+{
+}
+
+QT_END_NAMESPACE
diff --git a/src/webengine/api/qquickwebenginesettings_p.h b/src/webengine/api/qquickwebenginesettings_p.h
new file mode 100644
index 00000000..0fa44ef4
--- /dev/null
+++ b/src/webengine/api/qquickwebenginesettings_p.h
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKWEBENGINESETTINGS_P_H
+#define QQUICKWEBENGINESETTINGS_P_H
+
+#include <private/qtwebengineglobal_p.h>
+#include <QObject>
+#include <QScopedPointer>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickWebEngineSettingsPrivate;
+
+class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineSettings : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(bool autoLoadImages READ autoLoadImages WRITE setAutoLoadImages NOTIFY autoLoadImagesChanged)
+ Q_PROPERTY(bool javascriptEnabled READ javascriptEnabled WRITE setJavascriptEnabled NOTIFY javascriptEnabledChanged)
+ Q_PROPERTY(bool javascriptCanOpenWindows READ javascriptCanOpenWindows WRITE setJavascriptCanOpenWindows NOTIFY javascriptCanOpenWindowsChanged)
+ Q_PROPERTY(bool javascriptCanAccessClipboard READ javascriptCanAccessClipboard WRITE setJavascriptCanAccessClipboard NOTIFY javascriptCanAccessClipboardChanged)
+ Q_PROPERTY(bool linksIncludedInFocusChain READ linksIncludedInFocusChain WRITE setLinksIncludedInFocusChain NOTIFY linksIncludedInFocusChainChanged)
+ Q_PROPERTY(bool localStorageEnabled READ localStorageEnabled WRITE setLocalStorageEnabled NOTIFY localStorageEnabledChanged)
+ Q_PROPERTY(bool localContentCanAccessRemoteUrls READ localContentCanAccessRemoteUrls WRITE setLocalContentCanAccessRemoteUrls NOTIFY localContentCanAccessRemoteUrlsChanged)
+ Q_PROPERTY(bool spatialNavigationEnabled READ spatialNavigationEnabled WRITE setSpatialNavigationEnabled NOTIFY spatialNavigationEnabledChanged)
+ Q_PROPERTY(bool localContentCanAccessFileUrls READ localContentCanAccessFileUrls WRITE setLocalContentCanAccessFileUrls NOTIFY localContentCanAccessFileUrlsChanged)
+ Q_PROPERTY(bool hyperlinkAuditingEnabled READ hyperlinkAuditingEnabled WRITE setHyperlinkAuditingEnabled NOTIFY hyperlinkAuditingEnabledChanged)
+ Q_PROPERTY(QString defaultTextEncoding READ defaultTextEncoding WRITE setDefaultTextEncoding NOTIFY defaultTextEncodingChanged)
+
+public:
+ static QQuickWebEngineSettings *globalSettings();
+
+ ~QQuickWebEngineSettings();
+
+ bool autoLoadImages() const;
+ bool javascriptEnabled() const;
+ bool javascriptCanOpenWindows() const;
+ bool javascriptCanAccessClipboard() const;
+ bool linksIncludedInFocusChain() const;
+ bool localStorageEnabled() const;
+ bool localContentCanAccessRemoteUrls() const;
+ bool spatialNavigationEnabled() const;
+ bool localContentCanAccessFileUrls() const;
+ bool hyperlinkAuditingEnabled() const;
+ QString defaultTextEncoding() const;
+
+ void setAutoLoadImages(bool on);
+ void setJavascriptEnabled(bool on);
+ void setJavascriptCanOpenWindows(bool on);
+ void setJavascriptCanAccessClipboard(bool on);
+ void setLinksIncludedInFocusChain(bool on);
+ void setLocalStorageEnabled(bool on);
+ void setLocalContentCanAccessRemoteUrls(bool on);
+ void setSpatialNavigationEnabled(bool on);
+ void setLocalContentCanAccessFileUrls(bool on);
+ void setHyperlinkAuditingEnabled(bool on);
+ void setDefaultTextEncoding(QString encoding);
+
+signals:
+ void autoLoadImagesChanged(bool on);
+ void javascriptEnabledChanged(bool on);
+ void javascriptCanOpenWindowsChanged(bool on);
+ void javascriptCanAccessClipboardChanged(bool on);
+ void linksIncludedInFocusChainChanged(bool on);
+ void localStorageEnabledChanged(bool on);
+ void localContentCanAccessRemoteUrlsChanged(bool on);
+ void spatialNavigationEnabledChanged(bool on);
+ void localContentCanAccessFileUrlsChanged(bool on);
+ void hyperlinkAuditingEnabledChanged(bool on);
+ void defaultTextEncodingChanged(QString encoding);
+
+private:
+ QQuickWebEngineSettings();
+ Q_DISABLE_COPY(QQuickWebEngineSettings)
+ Q_DECLARE_PRIVATE(QQuickWebEngineSettings)
+ friend class QQuickWebEngineViewPrivate;
+
+ QScopedPointer<QQuickWebEngineSettingsPrivate> d_ptr;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKWEBENGINESETTINGS_P_H
diff --git a/src/webengine/api/qquickwebenginesettings_p_p.h b/src/webengine/api/qquickwebenginesettings_p_p.h
new file mode 100644
index 00000000..8f3e95ee
--- /dev/null
+++ b/src/webengine/api/qquickwebenginesettings_p_p.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKWEBENGINESETTINGS_P_P_H
+#define QQUICKWEBENGINESETTINGS_P_P_H
+
+#include "web_engine_settings.h"
+
+QT_BEGIN_NAMESPACE
+
+class QQuickWebEngineSettingsPrivate : public WebEngineSettingsDelegate {
+public:
+ QQuickWebEngineSettingsPrivate();
+ QQuickWebEngineSettingsPrivate(WebContentsAdapter *adapter);
+
+ void apply() Q_DECL_OVERRIDE;
+ WebEngineSettings *fallbackSettings() const Q_DECL_OVERRIDE;
+
+ QScopedPointer<WebEngineSettings> coreSettings;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKWEBENGINESETTINGS_P_P_H
diff --git a/src/webengine/api/qquickwebenginesingleton.cpp b/src/webengine/api/qquickwebenginesingleton.cpp
new file mode 100644
index 00000000..bf4951f3
--- /dev/null
+++ b/src/webengine/api/qquickwebenginesingleton.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickwebenginesingleton_p.h"
+
+#include "qquickwebenginesettings_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QQuickWebEngineSettings *QQuickWebEngineSingleton::settings() const
+{
+ return QQuickWebEngineSettings::globalSettings();
+}
+
+QT_END_NAMESPACE
diff --git a/src/webengine/api/qquickwebenginesingleton_p.h b/src/webengine/api/qquickwebenginesingleton_p.h
new file mode 100644
index 00000000..23205e2d
--- /dev/null
+++ b/src/webengine/api/qquickwebenginesingleton_p.h
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKWEBENGINESINGLETON_P_H
+#define QQUICKWEBENGINESINGLETON_P_H
+
+#include <QObject>
+#include <qtwebengineglobal_p.h>
+
+QT_BEGIN_NAMESPACE
+class QQuickWebEngineSettings;
+
+class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineSingleton : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QQuickWebEngineSettings* settings READ settings CONSTANT FINAL)
+
+public:
+ QQuickWebEngineSettings *settings() const;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKWEBENGINESINGLETON_P_H
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index e08232e7..c9faa1a7 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -43,6 +43,8 @@
#include "qquickwebengineloadrequest_p.h"
#include "qquickwebenginenavigationrequest_p.h"
#include "qquickwebenginenewviewrequest_p.h"
+#include "qquickwebenginesettings_p.h"
+#include "qquickwebenginesettings_p_p.h"
#include "render_widget_host_view_qt_delegate_quick.h"
#include "render_widget_host_view_qt_delegate_quickwindow.h"
#include "ui_delegates_manager.h"
@@ -75,6 +77,7 @@ QQuickWebEngineViewPrivate::QQuickWebEngineViewPrivate()
, e(new QQuickWebEngineViewExperimental(this))
, v(new QQuickWebEngineViewport(this))
, m_history(new QQuickWebEngineHistory(this))
+ , m_settings(new QQuickWebEngineSettings)
, contextMenuExtraItems(0)
, loadProgress(0)
, inspectable(false)
@@ -393,28 +396,9 @@ QObject *QQuickWebEngineViewPrivate::accessibilityParentObject()
return q;
}
-namespace {
-class DummySettingsDelegate : public WebEngineSettingsDelegate {
-public:
- DummySettingsDelegate()
- : settings(0) {}
- void apply() { }
- WebEngineSettings* fallbackSettings() const { return settings; }
- WebEngineSettings *settings;
-};
-
-}// anonymous namespace
-
WebEngineSettings *QQuickWebEngineViewPrivate::webEngineSettings() const
{
- static WebEngineSettings *dummySettings = 0;
- if (!dummySettings) {
- DummySettingsDelegate *dummyDelegate = new DummySettingsDelegate;
- dummySettings = new WebEngineSettings(dummyDelegate);
- dummyDelegate->settings = dummySettings;
- dummySettings->initDefaults();
- }
- return dummySettings;
+ return m_settings->d_func()->coreSettings.data();
}
void QQuickWebEngineViewPrivate::setDevicePixelRatio(qreal devicePixelRatio)
@@ -667,6 +651,11 @@ QQmlComponent *QQuickWebEngineViewExperimental::extraContextMenuEntriesComponent
return d_ptr->contextMenuExtraItems;
}
+QQuickWebEngineSettings *QQuickWebEngineViewExperimental::settings() const
+{
+ return d_ptr->m_settings.data();
+}
+
void QQuickWebEngineViewExperimental::findText(const QString &subString, FindFlags options, const QJSValue &callback)
{
if (subString.isEmpty()) {
diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h
index e2625553..dc47d63b 100644
--- a/src/webengine/api/qquickwebengineview_p_p.h
+++ b/src/webengine/api/qquickwebengineview_p_p.h
@@ -55,6 +55,7 @@ class QQuickWebEngineNewViewRequest;
class QQuickWebEngineView;
class QQmlComponent;
class QQmlContext;
+class QQuickWebEngineSettings;
class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineViewport : public QObject {
Q_OBJECT
@@ -81,6 +82,7 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineViewExperimental : public QObjec
Q_PROPERTY(bool inspectable READ inspectable WRITE setInspectable)
Q_PROPERTY(bool isFullScreen READ isFullScreen WRITE setIsFullScreen NOTIFY isFullScreenChanged)
Q_PROPERTY(QQuickWebEngineHistory *navigationHistory READ navigationHistory CONSTANT FINAL)
+ Q_PROPERTY(QQuickWebEngineSettings *settings READ settings)
Q_ENUMS(Feature)
Q_FLAGS(FindFlags)
@@ -105,6 +107,7 @@ public:
void setExtraContextMenuEntriesComponent(QQmlComponent *);
QQmlComponent *extraContextMenuEntriesComponent() const;
QQuickWebEngineHistory *navigationHistory() const;
+ QQuickWebEngineSettings *settings() const;
public Q_SLOTS:
void goBackTo(int index);
@@ -183,6 +186,7 @@ public:
QScopedPointer<QQuickWebEngineViewExperimental> e;
QScopedPointer<QQuickWebEngineViewport> v;
QScopedPointer<QQuickWebEngineHistory> m_history;
+ QScopedPointer<QQuickWebEngineSettings> m_settings;
QQmlComponent *contextMenuExtraItems;
QUrl icon;
int loadProgress;
diff --git a/src/webengine/plugin/experimental/plugin.cpp b/src/webengine/plugin/experimental/plugin.cpp
index f517a28c..883ebc59 100644
--- a/src/webengine/plugin/experimental/plugin.cpp
+++ b/src/webengine/plugin/experimental/plugin.cpp
@@ -37,11 +37,18 @@
#include <QtQml/qqmlextensionplugin.h>
#include "qquickwebenginehistory_p.h"
+#include "qquickwebenginesettings_p.h"
+#include "qquickwebenginesingleton_p.h"
#include "qquickwebengineview_p.h"
#include "qquickwebengineview_p_p.h"
QT_BEGIN_NAMESPACE
+static QObject *webEngineSingletonProvider(QQmlEngine *, QJSEngine *)
+{
+ return new QQuickWebEngineSingleton;
+}
+
class QQuickWebEngineViewExperimentalExtension : public QObject {
Q_OBJECT
Q_PROPERTY(QQuickWebEngineViewExperimental* experimental READ experimental CONSTANT FINAL)
@@ -71,6 +78,9 @@ public:
QObject::tr("Cannot create a separate instance of NavigationHistory"));
qmlRegisterUncreatableType<QQuickWebEngineHistoryListModel>(uri, 1, 0, "NavigationHistoryListModel",
QObject::tr("Cannot create a separate instance of NavigationHistory"));
+ qmlRegisterUncreatableType<QQuickWebEngineSettings>(uri, 1, 0, "WebEngineSettings",
+ QObject::tr("Cannot create a separate instance of WebEngineSettings"));
+ qmlRegisterSingletonType<QQuickWebEngineSingleton>(uri, 1, 0, "WebEngine", webEngineSingletonProvider);
}
};
diff --git a/src/webengine/plugin/plugin.cpp b/src/webengine/plugin/plugin.cpp
index 689eca99..7a759fcd 100644
--- a/src/webengine/plugin/plugin.cpp
+++ b/src/webengine/plugin/plugin.cpp
@@ -36,11 +36,11 @@
#include <QtQml/qqmlextensionplugin.h>
-#include "qtwebengineversion.h"
-#include "qquickwebengineview_p.h"
#include "qquickwebengineloadrequest_p.h"
#include "qquickwebenginenavigationrequest_p.h"
#include "qquickwebenginenewviewrequest_p.h"
+#include "qquickwebengineview_p.h"
+#include "qtwebengineversion.h"
QT_BEGIN_NAMESPACE
diff --git a/src/webengine/webengine.pro b/src/webengine/webengine.pro
index 6f243470..1278fdf1 100644
--- a/src/webengine/webengine.pro
+++ b/src/webengine/webengine.pro
@@ -17,6 +17,8 @@ SOURCES = \
api/qquickwebengineloadrequest.cpp \
api/qquickwebenginenavigationrequest.cpp \
api/qquickwebenginenewviewrequest.cpp \
+ api/qquickwebenginesettings.cpp \
+ api/qquickwebenginesingleton.cpp \
api/qquickwebengineview.cpp \
api/qtwebengineglobal.cpp \
render_widget_host_view_qt_delegate_quick.cpp \
@@ -30,6 +32,9 @@ HEADERS = \
api/qquickwebengineloadrequest_p.h \
api/qquickwebenginenavigationrequest_p.h \
api/qquickwebenginenewviewrequest_p.h \
+ api/qquickwebenginesettings_p.h \
+ api/qquickwebenginesettings_p_p.h \
+ api/qquickwebenginesingleton_p.h \
api/qquickwebengineview_p.h \
api/qquickwebengineview_p_p.h \
render_widget_host_view_qt_delegate_quick.h \