From e8796ab87c9b094265fc613e11ad9e275aaf8c90 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Fri, 8 Jan 2010 00:55:46 +0000 Subject: [PATCH] make it possible to turn off all eternal extensions svn path=/trunk/KDE/kdebase/runtime/; revision=1071432 --- scriptengines/javascript/appletauthorization.cpp | 7 +++++++ scriptengines/javascript/appletauthorization.h | 1 + scriptengines/javascript/authorization.h | 3 +++ scriptengines/javascript/scriptenv.cpp | 8 ++++++-- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/scriptengines/javascript/appletauthorization.cpp b/scriptengines/javascript/appletauthorization.cpp index 8499ec77c..6156f34c4 100644 --- a/scriptengines/javascript/appletauthorization.cpp +++ b/scriptengines/javascript/appletauthorization.cpp @@ -16,6 +16,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include + #include "appletauthorization.h" #include "simplejavascriptapplet.h" @@ -43,3 +45,8 @@ bool AppletAuthorization::authorizeOptionalExtension(const QString &extension) return m_scriptEngine->applet()->hasAuthorization(extension); } +bool AppletAuthorization::authorizeExternalExtensions() +{ +} + + diff --git a/scriptengines/javascript/appletauthorization.h b/scriptengines/javascript/appletauthorization.h index 6501b53b7..3b83ac5e6 100644 --- a/scriptengines/javascript/appletauthorization.h +++ b/scriptengines/javascript/appletauthorization.h @@ -30,6 +30,7 @@ public: bool authorizeRequiredExtension(const QString &extension); bool authorizeOptionalExtension(const QString &extension); + bool authorizeExternalExtensions(); private: SimpleJavaScriptApplet *m_scriptEngine; diff --git a/scriptengines/javascript/authorization.h b/scriptengines/javascript/authorization.h index 4df9766d1..08eb10594 100644 --- a/scriptengines/javascript/authorization.h +++ b/scriptengines/javascript/authorization.h @@ -21,6 +21,8 @@ #include +#include + class Authorization { public: @@ -29,6 +31,7 @@ public: virtual bool authorizeRequiredExtension(const QString &) { return true; } virtual bool authorizeOptionalExtension(const QString &) { return true; } + virtual bool authorizeExternalExtensions() { return KAuthorized::authorize("plasma/external_script_extensions"); } }; #endif diff --git a/scriptengines/javascript/scriptenv.cpp b/scriptengines/javascript/scriptenv.cpp index 770cb3d5c..8915f49a9 100644 --- a/scriptengines/javascript/scriptenv.cpp +++ b/scriptengines/javascript/scriptenv.cpp @@ -228,7 +228,9 @@ bool ScriptEnv::importExtensions(const KPluginInfo &info, QScriptValue &obj, Aut } if (!importBuiltinExtension(extension, obj)) { - importExtension(extension); + if (auth.authorizeExternalExtensions()) { + importExtension(extension); + } } if (hasUncaughtException()) { @@ -253,7 +255,9 @@ bool ScriptEnv::importExtensions(const KPluginInfo &info, QScriptValue &obj, Aut } if (!importBuiltinExtension(extension, obj)) { - importExtension(extension); + if (auth.authorizeExternalExtensions()) { + importExtension(extension); + } } if (hasUncaughtException()) {