summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Dywan <christian@twotoasts.de>2019-02-24 20:38:40 +0100
committerGitHub <noreply@github.com>2019-02-24 20:38:40 +0100
commit4e979c8d6ed1a27ba070c7ec40b4511a2dbcb436 (patch)
treebe68271a5045701196b715f5774ffad157a88074
parent7d66c70d6d9b8b570dc17b81ff9b08fbee08888a (diff)
downloadmidori-git-4e979c8d6ed1a27ba070c7ec40b4511a2dbcb436.tar.gz
Only load web extensions which are enabled (#270)
-rw-r--r--core/app.vala4
-rw-r--r--core/plugins.vala2
-rw-r--r--core/settings.vala4
-rw-r--r--extensions/web-extensions.vala12
4 files changed, 13 insertions, 9 deletions
diff --git a/core/app.vala b/core/app.vala
index d4b25c40..8b5a4b38 100644
--- a/core/app.vala
+++ b/core/app.vala
@@ -167,10 +167,10 @@ namespace Midori {
var plugins = Plugins.get_default (builtin_path.get_path ());
// Save/ load state of plugins
plugins.load_plugin.connect ((info) => {
- settings.set_plugin_enabled (info.get_module_name (), true);
+ settings.set_plugin_enabled ("lib%s.so".printf (info.get_module_name ()), true);
});
plugins.unload_plugin.connect ((info) => {
- settings.set_plugin_enabled (info.get_module_name (), false);
+ settings.set_plugin_enabled ("lib%s.so".printf (info.get_module_name ()), false);
});
var extensions = Plugins.get_default ().plug<AppActivatable> ("app", this);
diff --git a/core/plugins.vala b/core/plugins.vala
index 80d4739d..515d7de0 100644
--- a/core/plugins.vala
+++ b/core/plugins.vala
@@ -40,7 +40,7 @@ namespace Midori {
foreach (var plugin in get_plugin_list ()) {
debug ("Found plugin %s", plugin.get_name ());
if (plugin.is_builtin ()
- || settings.get_plugin_enabled (plugin.get_module_name ())) {
+ || settings.get_plugin_enabled ("lib%s.so".printf (plugin.get_module_name ()))) {
if (!try_load_plugin (plugin)) {
critical ("Failed to load plugin %s", plugin.get_module_name ());
}
diff --git a/core/settings.vala b/core/settings.vala
index 7d7173f8..48ed377c 100644
--- a/core/settings.vala
+++ b/core/settings.vala
@@ -42,11 +42,11 @@ namespace Midori {
}
public bool get_plugin_enabled (string plugin) {
- return get_boolean ("extensions", "lib%s.so".printf (plugin));
+ return get_boolean ("extensions", plugin);
}
public void set_plugin_enabled (string plugin, bool enabled) {
- set_boolean ("extensions", "lib%s.so".printf (plugin), enabled);
+ set_boolean ("extensions", plugin, enabled);
}
public int last_window_width { get {
diff --git a/extensions/web-extensions.vala b/extensions/web-extensions.vala
index 6a472733..4ea734b4 100644
--- a/extensions/web-extensions.vala
+++ b/extensions/web-extensions.vala
@@ -108,7 +108,11 @@ namespace WebExtension {
FileInfo info;
while ((info = enumerator.next_file ()) != null) {
var file = folder.get_child (info.get_name ());
- string id = Checksum.compute_for_string (ChecksumType.MD5, file.get_path ());
+ string id = file.get_basename ();
+ if (!Midori.CoreSettings.get_default ().get_plugin_enabled (id)) {
+ continue;
+ }
+
var extension = extensions.lookup (id);
if (extension == null) {
InputStream? stream = null;
@@ -155,6 +159,7 @@ namespace WebExtension {
var json = new Json.Parser ();
yield json.load_from_stream_async (stream);
+ debug ("Loading web extension %s from %s", id, file.get_path ());
var manifest = json.get_root ().get_object ();
if (manifest.has_member ("name")) {
extension.name = manifest.get_string_member ("name");
@@ -202,7 +207,6 @@ namespace WebExtension {
}
}
- debug ("Loaded %s from %s", extension.name, file.get_path ());
extensions.insert (id, extension);
extension_added (extension);
} catch (Error error) {
@@ -281,7 +285,7 @@ namespace WebExtension {
}
public void install_api (WebKit.WebView web_view) {
- web_view.get_settings ().enable_write_console_messages_to_stdout = true; // XXX
+ web_view.get_settings ().enable_write_console_messages_to_stdout = true;
var content = web_view.get_user_content_manager ();
if (content.register_script_message_handler ("midori")) {
@@ -314,7 +318,7 @@ namespace WebExtension {
manager.install_api (this);
if (uri != null) {
- string id = Checksum.compute_for_string (ChecksumType.MD5, extension.file.get_path ());
+ string id = extension.file.get_basename ();
load_uri ("extension:///%s/%s".printf (id, uri));
} else {
load_html ("<body></body>", extension.file.get_uri ());