|
|
|
|
@ -1,6 +1,6 @@ |
|
|
|
|
/* ============================================================
|
|
|
|
|
* Falkon - Qt web browser |
|
|
|
|
* Copyright (C) 2014 David Rosca <nowrep@gmail.com> |
|
|
|
|
* Copyright (C) 2014-2018 David Rosca <nowrep@gmail.com> |
|
|
|
|
* |
|
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
|
|
|
* it under the terms of the GNU General Public License as published by |
|
|
|
|
@ -24,6 +24,10 @@ |
|
|
|
|
#include "autofilljsobject.h" |
|
|
|
|
#include "restoremanager.h" |
|
|
|
|
|
|
|
|
|
#include <QWebChannel> |
|
|
|
|
|
|
|
|
|
static QHash<QString, QObject*> s_extraObjects; |
|
|
|
|
|
|
|
|
|
ExternalJsObject::ExternalJsObject(WebPage *page) |
|
|
|
|
: QObject(page) |
|
|
|
|
, m_page(page) |
|
|
|
|
@ -36,6 +40,28 @@ WebPage *ExternalJsObject::page() const |
|
|
|
|
return m_page; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// static
|
|
|
|
|
void ExternalJsObject::setupWebChannel(QWebChannel *webChannel, WebPage *page) |
|
|
|
|
{ |
|
|
|
|
webChannel->registerObject(QSL("qz_object"), new ExternalJsObject(page)); |
|
|
|
|
|
|
|
|
|
for (auto it = s_extraObjects.constBegin(); it != s_extraObjects.constEnd(); ++it) { |
|
|
|
|
webChannel->registerObject(QSL("qz_") + it.key(), it.value()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// static
|
|
|
|
|
void ExternalJsObject::registerExtraObject(const QString &id, QObject *object) |
|
|
|
|
{ |
|
|
|
|
s_extraObjects[id] = object; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// static
|
|
|
|
|
void ExternalJsObject::unregisterExtraObject(const QString &id) |
|
|
|
|
{ |
|
|
|
|
s_extraObjects.remove(id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void ExternalJsObject::AddSearchProvider(const QString &engineUrl) |
|
|
|
|
{ |
|
|
|
|
mApp->searchEnginesManager()->addEngine(QUrl(engineUrl)); |
|
|
|
|
|