Bug 698374 - Port bug 476430 - Make third-party add-ons disabled on startup, and allow users to activate them. r=mconley,a=Standard8
authorMark Banner <bugzilla@standard8.plus.com>
Mon, 31 Oct 2011 16:17:48 +0000
changeset 8967 2d6c6de72c8bfa771b449e9b1891b17fe89095cd
parent 8966 2deefa1ecd9aeef2eaedd8cbd628b8b409258e17
child 8968 9777fae9034060f3571623f47cfc8c28e32db65b
child 8971 686a094bd8adf92f815f781f49090d28914d3051
push idunknown
push userunknown
push dateunknown
reviewersmconley, Standard8
bugs698374, 476430
Bug 698374 - Port bug 476430 - Make third-party add-ons disabled on startup, and allow users to activate them. r=mconley,a=Standard8
mail/app/profile/all-thunderbird.js
mail/components/mailGlue.js
mail/test/mozmill/migration-from-tb2/prefs.js
mail/test/mozmill/runtest.py
mailnews/test/performance/bloat/mailnewsTestPrefs.js
--- a/mail/app/profile/all-thunderbird.js
+++ b/mail/app/profile/all-thunderbird.js
@@ -130,16 +130,21 @@ pref("app.releaseNotesURL", "http://live
 // Base URL for web-based support pages.
 pref("app.support.baseURL", "http://support.live.mozillamessaging.com/%LOCALE%/%APP%/%APPBUILDID%/");
 
 // Controls enabling of the extension system logging (can reduce performance)
 pref("extensions.logging.enabled", false);
 
 pref("extensions.update.autoUpdateDefault", true);
 
+// Disable add-ons installed into the shared user and shared system areas by
+// default. This does not include the application directory. See the SCOPE
+// constants in AddonManager.jsm for values to use here
+pref("extensions.autoDisableScopes", 15);
+
 // Preferences for AMO integration
 pref("extensions.getAddons.cache.enabled", true);
 pref("extensions.getAddons.maxResults", 15);
 pref("extensions.getAddons.get.url", "https://services.addons.mozilla.org/%LOCALE%/%APP%/api/%API_VERSION%/search/guid:%IDS%?src=thunderbird&appOS=%OS%&appVersion=%VERSION%&tMain=%TIME_MAIN%&tFirstPaint=%TIME_FIRST_PAINT%&tSessionRestored=%TIME_SESSION_RESTORED%");
 pref("extensions.getAddons.search.browseURL", "https://addons.mozilla.org/%LOCALE%/%APP%/search?q=%TERMS%");
 pref("extensions.getAddons.search.url", "https://services.addons.mozilla.org/%LOCALE%/%APP%/api/%API_VERSION%/search/%TERMS%/all/%MAX_RESULTS%/%OS%/%VERSION%?src=thunderbird");
 pref("extensions.webservice.discoverURL", "https://services.addons.mozilla.org/%LOCALE%/%APP%/discovery/pane/%VERSION%/%OS%");
 
--- a/mail/components/mailGlue.js
+++ b/mail/components/mailGlue.js
@@ -37,16 +37,17 @@
  * ***** END LICENSE BLOCK ***** */
 
 const Ci = Components.interfaces;
 const Cc = Components.classes;
 const Cu = Components.utils;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
+Cu.import("resource://gre/modules/AddonManager.jsm");
 
 /**
  * Glue code that should be executed before any windows are opened. Any
  * window-independent helper methods (a la nsBrowserGlue.js) should go in
  * MailUtils.js instead.
  */
 
 function MailGlue() {
@@ -94,16 +95,33 @@ MailGlue.prototype = {
   _onMailStartupDone: function MailGlue__onMailStartupDone() {
     // On Windows 7 and above, initialize the jump list module.
     const WINTASKBAR_CONTRACTID = "@mozilla.org/windows-taskbar;1";
     if (WINTASKBAR_CONTRACTID in Cc &&
         Cc[WINTASKBAR_CONTRACTID].getService(Ci.nsIWinTaskbar).available) {
       Cu.import("resource:///modules/windowsJumpLists.js");
       WinTaskbarJumpList.startup();
     }
+
+    // For any add-ons that were installed disabled and can be enabled, offer
+    // them to the user.
+    var win = Services.wm.getMostRecentWindow("mail:3pane");
+    var tabmail = win.document.getElementById("tabmail");
+    var changedIDs = AddonManager.getStartupChanges(AddonManager.STARTUP_CHANGE_INSTALLED);
+    AddonManager.getAddonsByIDs(changedIDs, function (aAddons) {
+      aAddons.forEach(function(aAddon) {
+        // If the add-on isn't user disabled or can't be enabled then skip it.
+        if (!aAddon.userDisabled || !(aAddon.permissions & AddonManager.PERM_CAN_ENABLE))
+          return;
+
+        tabmail.openTab("contentTab",
+                        { contentPage: "about:newaddon?id=" + aAddon.id,
+                          clickHandler: null });
+      });
+    });
   },
 
   // for XPCOM
   classID: Components.ID("{eb239c82-fac9-431e-98d7-11cacd0f71b8}"),
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
 };
 
 var components = [MailGlue];
--- a/mail/test/mozmill/migration-from-tb2/prefs.js
+++ b/mail/test/mozmill/migration-from-tb2/prefs.js
@@ -9,16 +9,17 @@
  * For more information, see http://www.mozilla.org/unix/customizing.html#prefs
  */
 
 user_pref("app.update.lastUpdateTime.addon-background-update-timer", 1273257684);
 user_pref("app.update.lastUpdateTime.background-update-timer", 1273257684);
 user_pref("app.update.lastUpdateTime.blocklist-background-update-timer", 1273257684);
 user_pref("extensions.checkCompatibility.8.0a", false);
 user_pref("extensions.checkCompatibility.8.0", false);
+user_pref("extensions.autoDisableScopes", 10);
 user_pref("intl.charsetmenu.mailview.cache", "windows-1252, ISO-8859-1, UTF-8");
 user_pref("ldap_2.prefs_migrated", true);
 user_pref("ldap_2.servers.default.filename", "default.mab");
 user_pref("ldap_2.servers.default.replication.lastChangeNumber", 0);
 user_pref("ldap_2.servers.default.uri", "moz-abldapdirectory://default.mab");
 user_pref("ldap_2.servers.history.replication.lastChangeNumber", 0);
 user_pref("ldap_2.servers.pab.replication.lastChangeNumber", 0);
 user_pref("mail.account.account1.server", "server1");
--- a/mail/test/mozmill/runtest.py
+++ b/mail/test/mozmill/runtest.py
@@ -109,16 +109,18 @@ class ThunderTestProfile(mozrunner.Thund
         # say yes to debug output via dump
         'browser.dom.window.dump.enabled': True,
         # say no to slow script warnings
         'dom.max_chrome_script_run_time': 0,
         'dom.max_script_run_time': 0,
         # disable extension stuffs
         'extensions.update.enabled'    : False,
         'extensions.update.notifyUser' : False,
+        # don't warn about third party extensions in profile or elsewhere.
+        'extensions.autoDisableScopes': 10,
         # do not ask about being the default mail client
         'mail.shell.checkDefaultClient': False,
         # do not tell us about the greatness that is mozilla (about:rights)
         'mail.rights.override': True,
         # disable non-gloda indexing daemons
         'mail.winsearch.enable': False,
         'mail.winsearch.firstRunDone': True,
         'mail.spotlight.enable': False,
--- a/mailnews/test/performance/bloat/mailnewsTestPrefs.js
+++ b/mailnews/test/performance/bloat/mailnewsTestPrefs.js
@@ -1,14 +1,15 @@
 // This set of prefs is copyied over the defaults that build-seamonkey-util.pl
 // sets up.
 user_pref("browser.dom.window.dump.enabled", true);
 // no slow script dialogs
 user_pref("dom.max_chrome_script_run_time", 0);
 user_pref("dom.max_script_run_time", 0);
+user_pref("extensions.autoDisableScopes", 10);
 user_pref("mail.account.account1.server", "server1");
 user_pref("mail.account.account2.identities", "id1");
 user_pref("mail.account.account2.server", "server2");
 user_pref("mail.accountmanager.accounts", "account1,account2");
 user_pref("mail.accountmanager.defaultaccount", "account2");
 user_pref("mail.accountmanager.localfoldersserver", "server1");
 user_pref("mail.identity.id1.fullName", "Tinderbox");
 user_pref("mail.identity.id1.smtpServer", "smtp1");