summaryrefslogtreecommitdiffstats
path: root/src/webenginewidgets/api
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@digia.com>2014-11-18 16:08:20 +0100
committerAndras Becsi <andras.becsi@theqtcompany.com>2015-02-21 21:38:57 +0000
commit4ed187a54e6d2a06bbe272e1429757b6572dc6b6 (patch)
tree2b1d0485a780904f544623dff96be9dd270988bc /src/webenginewidgets/api
parent88ca68c1b3ceff005f6a3a33fc8fc0d551c53a70 (diff)
Introduce a user scripts mechanism
Allowing programmatic injection of JavaScript to accomplish all sorts of tasks on the render process side. This API gives control over the point during the loading phase at which the script is run, whether it is run on sub-frames or not, as well as the JavaScript world it is run in (either the page's main world, or an arbitrary isolated world). This only has the Widgets API. The Quick API, tests and docs are coming in separate patches Change-Id: Ia1c79f68f8dfd4d964281d9723d09062ed7abe46 Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
Diffstat (limited to 'src/webenginewidgets/api')
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp13
-rw-r--r--src/webenginewidgets/api/qwebenginepage.h3
-rw-r--r--src/webenginewidgets/api/qwebenginepage_p.h2
-rw-r--r--src/webenginewidgets/api/qwebengineprofile.cpp14
-rw-r--r--src/webenginewidgets/api/qwebengineprofile.h2
-rw-r--r--src/webenginewidgets/api/qwebengineprofile_p.h2
-rw-r--r--src/webenginewidgets/api/qwebenginescript.cpp163
-rw-r--r--src/webenginewidgets/api/qwebenginescript.h106
-rw-r--r--src/webenginewidgets/api/qwebenginescriptcollection.cpp154
-rw-r--r--src/webenginewidgets/api/qwebenginescriptcollection.h78
-rw-r--r--src/webenginewidgets/api/qwebenginescriptcollection_p.h71
11 files changed, 606 insertions, 2 deletions
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index f2cc7e304..bdce04978 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -30,6 +30,7 @@
#include "qwebenginehistory_p.h"
#include "qwebengineprofile.h"
#include "qwebengineprofile_p.h"
+#include "qwebenginescriptcollection_p.h"
#include "qwebenginesettings.h"
#include "qwebengineview.h"
#include "qwebengineview_p.h"
@@ -175,6 +176,7 @@ QWebEnginePagePrivate::QWebEnginePagePrivate(QWebEngineProfile *_profile)
, settings(new QWebEngineSettings(profile->settings()))
, view(0)
, isLoading(false)
+ , scriptCollection(new QWebEngineScriptCollectionPrivate(browserContextAdapter()->userScriptController(), adapter.data()))
{
memset(actions, 0, sizeof(actions));
}
@@ -977,6 +979,17 @@ void QWebEnginePage::runJavaScript(const QString& scriptSource, const QWebEngine
d->m_callbacks.registerCallback(requestId, resultCallback.d);
}
+/*!
+ Returns the script collection used by this page.
+ \sa QWebEngineScriptCollection
+*/
+
+QWebEngineScriptCollection &QWebEnginePage::scripts()
+{
+ Q_D(QWebEnginePage);
+ return d->scriptCollection;
+}
+
QWebEnginePage *QWebEnginePage::createWindow(WebWindowType type)
{
Q_D(QWebEnginePage);
diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h
index 7fcf000d9..f2067c6aa 100644
--- a/src/webenginewidgets/api/qwebenginepage.h
+++ b/src/webenginewidgets/api/qwebenginepage.h
@@ -53,6 +53,7 @@ class QWebEngineHistory;
class QWebEnginePage;
class QWebEnginePagePrivate;
class QWebEngineProfile;
+class QWebEngineScriptCollection;
class QWebEngineSettings;
namespace QtWebEnginePrivate {
@@ -230,7 +231,7 @@ public:
#else
void runJavaScript(const QString& scriptSource, const QWebEngineCallback<const QVariant &> &resultCallback);
#endif
-
+ QWebEngineScriptCollection &scripts();
QWebEngineSettings *settings() const;
QWebChannel *webChannel() const;
diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h
index e7bcedfc1..dc07ce2c6 100644
--- a/src/webenginewidgets/api/qwebenginepage_p.h
+++ b/src/webenginewidgets/api/qwebenginepage_p.h
@@ -39,6 +39,7 @@
#include "qwebenginepage.h"
+#include "qwebenginescriptcollection.h"
#include "web_contents_adapter_client.h"
#include <QtCore/qcompilerdetection.h>
#include <QSharedData>
@@ -163,6 +164,7 @@ public:
QUrl explicitUrl;
WebEngineContextMenuData m_menuData;
bool isLoading;
+ QWebEngineScriptCollection scriptCollection;
mutable CallbackDirectory m_callbacks;
mutable QAction *actions[QWebEnginePage::WebActionCount];
diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp
index 3de2fe521..e2441ca54 100644
--- a/src/webenginewidgets/api/qwebengineprofile.cpp
+++ b/src/webenginewidgets/api/qwebengineprofile.cpp
@@ -42,6 +42,7 @@
#include "qwebengineprofile_p.h"
#include "qwebenginesettings.h"
#include "qwebengineurlschemehandler_p_p.h"
+#include "qwebenginescriptcollection_p.h"
#include "browser_context_adapter.h"
#include "web_engine_visited_links_manager.h"
@@ -100,7 +101,8 @@ QT_BEGIN_NAMESPACE
*/
QWebEngineProfilePrivate::QWebEngineProfilePrivate(BrowserContextAdapter* browserContext, bool ownsContext)
- : m_settings(new QWebEngineSettings())
+ : scriptCollection(new QWebEngineScriptCollectionPrivate(browserContext->userScriptController()))
+ , m_settings(new QWebEngineSettings())
, m_browserContext(browserContext)
{
if (ownsContext)
@@ -433,6 +435,16 @@ bool QWebEngineProfile::visitedLinksContainsUrl(const QUrl &url) const
}
/*!
+ Returns the script collection used by this profile.
+ \sa QWebEngineScriptCollection
+*/
+QWebEngineScriptCollection &QWebEngineProfile::scripts()
+{
+ Q_D(QWebEngineProfile);
+ return d->scriptCollection;
+}
+
+/*!
Returns the default profile.
The default profile uses the storage name "Default".
diff --git a/src/webenginewidgets/api/qwebengineprofile.h b/src/webenginewidgets/api/qwebengineprofile.h
index a2523edad..a25cbcccd 100644
--- a/src/webenginewidgets/api/qwebengineprofile.h
+++ b/src/webenginewidgets/api/qwebengineprofile.h
@@ -52,6 +52,7 @@ class QWebEnginePage;
class QWebEnginePagePrivate;
class QWebEngineProfilePrivate;
class QWebEngineSettings;
+class QWebEngineScriptCollection;
class QWEBENGINEWIDGETS_EXPORT QWebEngineProfile : public QObject {
Q_OBJECT
@@ -97,6 +98,7 @@ public:
bool visitedLinksContainsUrl(const QUrl &url) const;
QWebEngineSettings *settings() const;
+ QWebEngineScriptCollection &scripts();
static QWebEngineProfile *defaultProfile();
diff --git a/src/webenginewidgets/api/qwebengineprofile_p.h b/src/webenginewidgets/api/qwebengineprofile_p.h
index 1fc2297c7..6f2d53a81 100644
--- a/src/webenginewidgets/api/qwebengineprofile_p.h
+++ b/src/webenginewidgets/api/qwebengineprofile_p.h
@@ -40,6 +40,7 @@
#include "browser_context_adapter_client.h"
#include "qwebengineprofile.h"
#include "qwebengineurlschemehandler_p.h"
+#include "qwebenginescriptcollection.h"
#include <QMap>
#include <QPointer>
@@ -69,6 +70,7 @@ public:
void removeUrlSchemeHandler(QWebEngineUrlSchemeHandler *);
void clearUrlSchemeHandlers();
+ QWebEngineScriptCollection scriptCollection;
private:
QWebEngineProfile *q_ptr;
QWebEngineSettings *m_settings;
diff --git a/src/webenginewidgets/api/qwebenginescript.cpp b/src/webenginewidgets/api/qwebenginescript.cpp
new file mode 100644
index 000000000..63459992b
--- /dev/null
+++ b/src/webenginewidgets/api/qwebenginescript.cpp
@@ -0,0 +1,163 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/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 "qwebenginescript.h"
+
+#include "user_script.h"
+#include <QtCore/QDebug>
+
+QWebEngineScript::QWebEngineScript()
+ : d(new UserScript)
+{
+}
+
+QWebEngineScript::QWebEngineScript(const QWebEngineScript &other)
+ : d(other.d)
+{
+}
+
+QWebEngineScript::~QWebEngineScript()
+{
+}
+
+QWebEngineScript &QWebEngineScript::operator=(const QWebEngineScript &other)
+{
+ d = other.d;
+ return *this;
+}
+
+bool QWebEngineScript::isNull() const
+{
+ return d->isNull();
+}
+
+QString QWebEngineScript::name() const
+{
+ return d->name();
+}
+
+void QWebEngineScript::setName(const QString &scriptName)
+{
+ if (scriptName == name())
+ return;
+ d->setName(scriptName);
+}
+
+QString QWebEngineScript::source() const
+{
+ return d->source();
+}
+
+void QWebEngineScript::setSource(const QString &scriptSource)
+{
+ if (scriptSource == source())
+ return;
+ d->setSource(scriptSource);
+}
+
+ASSERT_ENUMS_MATCH(QWebEngineScript::Deferred, UserScript::AfterLoad)
+ASSERT_ENUMS_MATCH(QWebEngineScript::DocumentReady, UserScript::DocumentLoadFinished)
+ASSERT_ENUMS_MATCH(QWebEngineScript::DocumentCreation, UserScript::DocumentElementCreation)
+
+QWebEngineScript::InjectionPoint QWebEngineScript::injectionPoint() const
+{
+ return static_cast<QWebEngineScript::InjectionPoint>(d->injectionPoint());
+}
+
+void QWebEngineScript::setInjectionPoint(QWebEngineScript::InjectionPoint p)
+{
+ if (p == injectionPoint())
+ return;
+ d->setInjectionPoint(static_cast<UserScript::InjectionPoint>(p));
+}
+
+quint32 QWebEngineScript::worldId() const
+{
+ return d->worldId();
+}
+
+void QWebEngineScript::setWorldId(quint32 id)
+{
+ if (id == d->worldId())
+ return;
+ d->setWorldId(id);
+}
+
+bool QWebEngineScript::runsOnSubFrames() const
+{
+ return d->runsOnSubFrames();
+}
+
+void QWebEngineScript::setRunsOnSubFrames(bool on)
+{
+ if (runsOnSubFrames() == on)
+ return;
+ d->setRunsOnSubFrames(on);
+}
+
+bool QWebEngineScript::operator==(const QWebEngineScript &other) const
+{
+ return d == other.d || *d == *(other.d);
+}
+
+QWebEngineScript::QWebEngineScript(const UserScript &coreScript)
+ : d(new UserScript(coreScript))
+{
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const QWebEngineScript &script)
+{
+ if (script.isNull())
+ return d.maybeSpace() << "QWebEngineScript()";
+
+ d.nospace() << "QWebEngineScript(" << script.name() << ", ";
+ switch (script.injectionPoint()) {
+ case QWebEngineScript::DocumentCreation:
+ d << "QWebEngineScript::DocumentCreation" << ", ";
+ break;
+ case QWebEngineScript::DocumentReady:
+ d << "QWebEngineScript::DocumentReady" << ", ";
+ break;
+ case QWebEngineScript::Deferred:
+ d << "QWebEngineScript::Deferred" << ", ";
+ break;
+ }
+ d << script.worldId() << ", "
+ << script.runsOnSubFrames() << ", " << script.source() << ")";
+ return d.space();
+}
+#endif
diff --git a/src/webenginewidgets/api/qwebenginescript.h b/src/webenginewidgets/api/qwebenginescript.h
new file mode 100644
index 000000000..735ee92e0
--- /dev/null
+++ b/src/webenginewidgets/api/qwebenginescript.h
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/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 QWEBENGINESCRIPT_H
+#define QWEBENGINESCRIPT_H
+#include "qtwebenginewidgetsglobal.h"
+
+#include <QtCore/QSharedDataPointer>
+#include <QtCore/QString>
+
+class UserScript;
+QT_BEGIN_NAMESPACE
+
+class QWEBENGINEWIDGETS_EXPORT QWebEngineScript {
+public:
+ enum InjectionPoint {
+ Deferred,
+ DocumentReady,
+ DocumentCreation
+ };
+
+ enum ScriptWorldId {
+ MainWorld = 0,
+ ApplicationWorld,
+ UserWorld
+ };
+
+ QWebEngineScript();
+ QWebEngineScript(const QWebEngineScript &other);
+ ~QWebEngineScript();
+
+ QWebEngineScript &operator=(const QWebEngineScript &other);
+
+ bool isNull() const;
+
+ QString name() const;
+ void setName(const QString &);
+
+ QString source() const;
+ void setSource(const QString &);
+
+ InjectionPoint injectionPoint() const;
+ void setInjectionPoint(InjectionPoint);
+
+ quint32 worldId() const;
+ void setWorldId(quint32);
+
+ bool runsOnSubFrames() const;
+ void setRunsOnSubFrames(bool on);
+
+ bool operator==(const QWebEngineScript &other) const;
+ inline bool operator!=(const QWebEngineScript &other) const
+ { return !operator==(other); }
+ void swap(QWebEngineScript &other) { qSwap(d, other.d); }
+
+
+private:
+ friend class QWebEngineScriptCollectionPrivate;
+ friend class QWebEngineScriptCollection;
+ QWebEngineScript(const UserScript &);
+
+ QSharedDataPointer<UserScript> d;
+};
+
+Q_DECLARE_SHARED(QWebEngineScript)
+
+#ifndef QT_NO_DEBUG_STREAM
+QWEBENGINEWIDGETS_EXPORT QDebug operator<<(QDebug, const QWebEngineScript &);
+#endif
+
+QT_END_NAMESPACE
+
+#endif // QWEBENGINESCRIPT_H
diff --git a/src/webenginewidgets/api/qwebenginescriptcollection.cpp b/src/webenginewidgets/api/qwebenginescriptcollection.cpp
new file mode 100644
index 000000000..ffbb9052e
--- /dev/null
+++ b/src/webenginewidgets/api/qwebenginescriptcollection.cpp
@@ -0,0 +1,154 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/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 "qwebenginescriptcollection.h"
+#include "qwebenginescriptcollection_p.h"
+
+#include "user_script_controller_host.h"
+
+QWebEngineScriptCollection::QWebEngineScriptCollection(QWebEngineScriptCollectionPrivate *collectionPrivate)
+ :d(collectionPrivate)
+{
+}
+
+QWebEngineScriptCollection::~QWebEngineScriptCollection()
+{
+}
+
+int QWebEngineScriptCollection::count() const
+{
+ return d->count();
+}
+
+bool QWebEngineScriptCollection::contains(const QWebEngineScript &value) const
+{
+ return d->contains(value);
+}
+
+QWebEngineScript QWebEngineScriptCollection::findScript(const QString &name) const
+{
+ return d->find(name);
+}
+
+QList<QWebEngineScript> QWebEngineScriptCollection::findScripts(const QString &name) const
+{
+ return d->toList(name);
+}
+
+void QWebEngineScriptCollection::insert(const QWebEngineScript &s)
+{
+ d->insert(s);
+}
+
+void QWebEngineScriptCollection::insert(const QList<QWebEngineScript> &list)
+{
+ d->reserve(list.size());
+ Q_FOREACH (const QWebEngineScript &s, list)
+ d->insert(s);
+}
+
+bool QWebEngineScriptCollection::remove(const QWebEngineScript &script)
+{
+ return d->remove(script);
+}
+
+void QWebEngineScriptCollection::clear()
+{
+ d->clear();
+}
+
+QList<QWebEngineScript> QWebEngineScriptCollection::toList() const
+{
+ return d->toList();
+}
+
+
+QWebEngineScriptCollectionPrivate::QWebEngineScriptCollectionPrivate(UserScriptControllerHost *controller, WebContentsAdapter *webContents)
+ : m_scriptController(controller)
+ , m_contents(webContents)
+{
+}
+
+int QWebEngineScriptCollectionPrivate::count() const
+{
+ return m_scriptController->registeredScripts(m_contents).count();
+}
+
+bool QWebEngineScriptCollectionPrivate::contains(const QWebEngineScript &s) const
+{
+ return m_scriptController->containsUserScript(*s.d, m_contents);
+}
+
+void QWebEngineScriptCollectionPrivate::insert(const QWebEngineScript &script)
+{
+ if (!script.d)
+ return;
+ m_scriptController->addUserScript(*script.d, m_contents);
+}
+
+bool QWebEngineScriptCollectionPrivate::remove(const QWebEngineScript &script)
+{
+ if (!script.d)
+ return false;
+ return m_scriptController->removeUserScript(*script.d, m_contents);
+}
+
+QList<QWebEngineScript> QWebEngineScriptCollectionPrivate::toList(const QString &scriptName) const
+{
+ QList<QWebEngineScript> ret;
+ Q_FOREACH (const UserScript &script, m_scriptController->registeredScripts(m_contents))
+ if (scriptName.isNull() || scriptName == script.name())
+ ret.append(QWebEngineScript(script));
+ return ret;
+}
+
+QWebEngineScript QWebEngineScriptCollectionPrivate::find(const QString &name) const
+{
+ Q_FOREACH (const UserScript &script, m_scriptController->registeredScripts(m_contents))
+ if (name == script.name())
+ return QWebEngineScript(script);
+ return QWebEngineScript();
+}
+
+void QWebEngineScriptCollectionPrivate::clear()
+{
+ m_scriptController->clearAllScripts(m_contents);
+}
+
+void QWebEngineScriptCollectionPrivate::reserve(int capacity)
+{
+ m_scriptController->reserve(m_contents, capacity);
+}
diff --git a/src/webenginewidgets/api/qwebenginescriptcollection.h b/src/webenginewidgets/api/qwebenginescriptcollection.h
new file mode 100644
index 000000000..c8e40c5da
--- /dev/null
+++ b/src/webenginewidgets/api/qwebenginescriptcollection.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/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 QWEBENGINESCRIPTCOLLECTION_H
+#define QWEBENGINESCRIPTCOLLECTION_H
+
+#include "qtwebengineglobal.h"
+
+#include "qwebenginescript.h"
+#include <QtCore/QScopedPointer>
+#include <QtCore/QList>
+#include <QtCore/QSet>
+
+QT_BEGIN_NAMESPACE
+class QWebEngineScriptCollectionPrivate;
+
+class Q_WEBENGINE_EXPORT QWebEngineScriptCollection {
+public:
+ ~QWebEngineScriptCollection();
+ bool isEmpty() const { return !count(); }
+ int count() const;
+ inline int size() const { return count(); }
+ bool contains(const QWebEngineScript &value) const;
+
+ QWebEngineScript findScript(const QString &name) const;
+ QList<QWebEngineScript> findScripts(const QString &name) const;
+
+ void insert(const QWebEngineScript &);
+ void insert(const QList<QWebEngineScript> &list);
+
+ bool remove(const QWebEngineScript &);
+ void clear();
+
+ QList<QWebEngineScript> toList() const;
+
+private:
+ friend class QWebEnginePagePrivate;
+ friend class QWebEngineProfilePrivate;
+ QWebEngineScriptCollection(QWebEngineScriptCollectionPrivate *);
+
+ QScopedPointer<QWebEngineScriptCollectionPrivate> d;
+};
+
+QT_END_NAMESPACE
+#endif // QWEBENGINESCRIPTCOLLECTION_H
diff --git a/src/webenginewidgets/api/qwebenginescriptcollection_p.h b/src/webenginewidgets/api/qwebenginescriptcollection_p.h
new file mode 100644
index 000000000..baf09dbb4
--- /dev/null
+++ b/src/webenginewidgets/api/qwebenginescriptcollection_p.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/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 QWEBENGINESCRIPTCOLLECTION_P_H
+#define QWEBENGINESCRIPTCOLLECTION_P_H
+
+#include "qtwebengineglobal.h"
+
+#include "qwebenginescript.h"
+
+#include <QtCore/QSet>
+
+class UserScriptControllerHost;
+class WebContentsAdapter;
+
+QT_BEGIN_NAMESPACE
+class QWebEngineScriptCollectionPrivate {
+public:
+ QWebEngineScriptCollectionPrivate(UserScriptControllerHost *, WebContentsAdapter * = 0);
+
+ int count() const;
+ bool contains(const QWebEngineScript &) const;
+ QList<QWebEngineScript> toList(const QString &scriptName = QString()) const;
+ QWebEngineScript find(const QString & name) const;
+
+ void insert(const QWebEngineScript &);
+ bool remove(const QWebEngineScript &);
+ void clear();
+ void reserve(int);
+
+private:
+ UserScriptControllerHost *m_scriptController;
+ WebContentsAdapter *m_contents;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWEBENGINESCRIPTCOLLECTION__PH