From a04efdc0be368848798aacc2681f00d79db94f97 Mon Sep 17 00:00:00 2001 From: David Rosca Date: Mon, 31 Aug 2015 13:17:14 +0200 Subject: [PATCH] window.external: Only export speedDial on qupzilla:speeddial --- src/lib/webengine/javascript/externaljsobject.cpp | 11 ++++++++--- src/lib/webengine/javascript/externaljsobject.h | 8 ++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/lib/webengine/javascript/externaljsobject.cpp b/src/lib/webengine/javascript/externaljsobject.cpp index ad7dedd94..c8e160acb 100644 --- a/src/lib/webengine/javascript/externaljsobject.cpp +++ b/src/lib/webengine/javascript/externaljsobject.cpp @@ -19,10 +19,12 @@ #include "mainapplication.h" #include "pluginproxy.h" #include "speeddial.h" +#include "webpage.h" #include "searchenginesmanager.h" -ExternalJsObject::ExternalJsObject(QObject* parent) - : QObject(parent) +ExternalJsObject::ExternalJsObject(WebPage *page) + : QObject(page) + , m_page(page) { } @@ -37,7 +39,10 @@ int ExternalJsObject::IsSearchProviderInstalled(const QString &engineURL) return 0; } -QObject* ExternalJsObject::speedDial() const +QObject *ExternalJsObject::speedDial() const { + if (m_page->url().toString() != QL1S("qupzilla:speeddial")) + return Q_NULLPTR; + return mApp->plugins()->speedDial(); } diff --git a/src/lib/webengine/javascript/externaljsobject.h b/src/lib/webengine/javascript/externaljsobject.h index 3c2db0a46..1d1bad29b 100644 --- a/src/lib/webengine/javascript/externaljsobject.h +++ b/src/lib/webengine/javascript/externaljsobject.h @@ -20,20 +20,24 @@ #include +class WebPage; + class ExternalJsObject : public QObject { Q_OBJECT Q_PROPERTY(QObject* speedDial READ speedDial CONSTANT) public: - explicit ExternalJsObject(QObject* parent = 0); + explicit ExternalJsObject(WebPage *page); public slots: void AddSearchProvider(const QString &engineUrl); int IsSearchProviderInstalled(const QString &engineURL); private: - QObject* speedDial() const; + QObject *speedDial() const; + + WebPage *m_page; };