From 158c45e59e6f3911f56fdc4e337128314db1f8f8 Mon Sep 17 00:00:00 2001 From: Mike Perry Date: Tue, 24 Mar 2015 11:02:32 +0000 Subject: [PATCH] Bug 10280: Don't load any plugins into the address space. --- dom/plugins/base/nsPluginHost.cpp | 12 ++++ toolkit/mozapps/extensions/AddonManager.jsm | 5 ++ .../mozapps/extensions/content/extensions.js | 68 +++++++++++++++++++ .../mozapps/extensions/content/extensions.xul | 20 ++++++ .../extensions/internal/PluginProvider.jsm | 8 +++ 5 files changed, 113 insertions(+) diff --git a/dom/plugins/base/nsPluginHost.cpp b/dom/plugins/base/nsPluginHost.cpp index d373a05754cf4..a63a8561a51d3 100644 --- a/dom/plugins/base/nsPluginHost.cpp +++ b/dom/plugins/base/nsPluginHost.cpp @@ -3320,6 +3320,7 @@ NS_IMETHODIMP nsPluginHost::Observe(nsISupports* aSubject, const char* aTopic, UnloadPlugins(); } if (!strcmp(NS_PREFBRANCH_PREFCHANGE_TOPIC_ID, aTopic)) { + NS_ConvertUTF16toUTF8 prefName(someData); mPluginsDisabled = Preferences::GetBool("plugin.disable", false); // Unload or load plugins as needed if (mPluginsDisabled) { @@ -3327,6 +3328,17 @@ NS_IMETHODIMP nsPluginHost::Observe(nsISupports* aSubject, const char* aTopic, } else { LoadPlugins(); } + if (prefName.Equals("plugin.disable")) { + nsCOMPtr obsService = + mozilla::services::GetObserverService(); + if (obsService) { + nsAutoString pluginPolicy; + pluginPolicy = mPluginsDisabled ? NS_LITERAL_STRING("disabled") + : NS_LITERAL_STRING("enabled"); + obsService->NotifyObservers(nullptr, "plugin-policy-changed", + pluginPolicy.get()); + } + } } if (XRE_IsParentProcess() && !strcmp("plugin-blocklist-updated", aTopic)) { // The blocklist has updated. Asynchronously get blocklist state for all diff --git a/toolkit/mozapps/extensions/AddonManager.jsm b/toolkit/mozapps/extensions/AddonManager.jsm index 0686ecb5bfbf7..ba345e97672cb 100644 --- a/toolkit/mozapps/extensions/AddonManager.jsm +++ b/toolkit/mozapps/extensions/AddonManager.jsm @@ -3544,6 +3544,11 @@ var AddonManagerPrivate = { AddonManagerInternal.callAddonListeners.apply(AddonManagerInternal, aArgs); }, + callManagerListeners: function AMP_callManagerListeners(...aArgs) { + AddonManagerInternal.callManagerListeners.apply(AddonManagerInternal, + aArgs); + }, + AddonAuthor, AddonScreenshot, diff --git a/toolkit/mozapps/extensions/content/extensions.js b/toolkit/mozapps/extensions/content/extensions.js index 3b97377f9cec1..4e2ddf4f70f8c 100644 --- a/toolkit/mozapps/extensions/content/extensions.js +++ b/toolkit/mozapps/extensions/content/extensions.js @@ -1130,6 +1130,20 @@ var gViewController = { }, }, + cmd_pluginEnable: { + isEnabled: function cmd_pluginEnable_isEnabled() { return true; }, + doCommand: function cmd_pluginEnable_doCommand() { + Services.prefs.setBoolPref("plugin.disable", false); + } + }, + + cmd_pluginDisable: { + isEnabled: function cmd_pluginDisable_isEnabled() { return true; }, + doCommand: function cmd_pluginDisable_doCommand() { + Services.prefs.setBoolPref("plugin.disable", true); + } + }, + cmd_toggleAutoUpdateDefault: { isEnabled() { return true; @@ -2788,6 +2802,8 @@ var gListView = { node: null, _listBox: null, _emptyNotice: null, + _pluginEnableButton: null, + _pluginHeader: null, _type: null, isRoot: true, @@ -2795,6 +2811,8 @@ var gListView = { this.node = document.getElementById("list-view"); this._listBox = document.getElementById("addon-list"); this._emptyNotice = document.getElementById("addon-list-empty"); + this._pluginEnableButton = document.getElementById("plugin-enable-button"); + this._pluginHeader = document.getElementsByClassName("plugin-info-container")[0]; this._listBox.addEventListener("keydown", aEvent => { if (aEvent.keyCode == aEvent.DOM_VK_RETURN) { @@ -2864,6 +2882,11 @@ var gListView = { } }, + shutdown: function gListView_shutdown() { + AddonManager.removeAddonListener(this); + AddonManager.removeManagerListener(this); + }, + show(aType, aRequest) { let showOnlyDisabledUnsigned = false; if (aType.endsWith("?unsigned=true")) { @@ -2881,6 +2904,8 @@ var gListView = { this._type = aType; this.node.setAttribute("type", aType); this.showEmptyNotice(false); + this.showPluginHeader(false); + this.showPluginEnableButton(false); this._listBox.textContent = ""; @@ -2931,6 +2956,7 @@ var gListView = { this._listBox.appendChild(element); } } + this.showPluginButton(); this.filterDisabledUnsigned(showOnlyDisabledUnsigned); let legacyNotice = document.getElementById("legacy-extensions-notice"); @@ -2959,10 +2985,14 @@ var gListView = { gEventManager.registerInstallListener(this); gViewController.updateCommands(); gViewController.notifyViewChanged(); + AddonManager.addAddonListener(this); /* for onUninstalled */ + AddonManager.addManagerListener(this); /* for onPluginPolicyChanged */ }); }, hide() { + AddonManager.removeAddonListener(this); + AddonManager.removeManagerListener(this); gEventManager.unregisterInstallListener(this); doPendingUninstalls(this._listBox); }, @@ -3031,6 +3061,44 @@ var gListView = { } }, + onUninstalled: function gListView_onUninstalled() { + this.showEmptyNotice(this._listBox.itemCount == 0); + }, + + showPluginEnableButton: function gListView_showPluginEnableButton(aShow) { + if (this._pluginEnableButton) + this._pluginEnableButton.hidden = !aShow; + }, + + showPluginHeader: function gListView_showPluginHeader(aShow) { + if (this._pluginHeader) + this._pluginHeader.hidden = !aShow; + }, + + showPluginButton: function gListView_showPluginButton() { + if (this._type == "plugin") { + var plugin_disable = false; + + try { + plugin_disable = Services.prefs.getBoolPref("plugin.disable") + } catch (e) {} + + if (plugin_disable == true) { + this.showPluginHeader(false); + this.showEmptyNotice(false); + this.showPluginEnableButton(true); + } else { + this.showPluginHeader(true); + this.showEmptyNotice(this._listBox.itemCount == 0); + this.showPluginEnableButton(false); + } + } + }, + + onPluginPolicyChanged: function gListView_onPluginPolicyChanged() { + this.showPluginButton(); + }, + addItem(aObj, aIsInstall) { if (aObj.type != this._type) { return; diff --git a/toolkit/mozapps/extensions/content/extensions.xul b/toolkit/mozapps/extensions/content/extensions.xul index 97d44129b1e08..04163274ddbe3 100644 --- a/toolkit/mozapps/extensions/content/extensions.xul +++ b/toolkit/mozapps/extensions/content/extensions.xul @@ -106,6 +106,8 @@ + + @@ -366,6 +368,13 @@ command="cmd_enableUpdateSecurity"/> + +