Bug 560451 - Fennec allows uninstall attempt of add-ons in readonly directories. r=mfinkle
authorWolfgang Rosenauer <wr@rosenauer.org>
Thu, 20 May 2010 07:16:50 +0200
changeset 66236 56ae6a09a05b3cce5f87121ef4bd33ade1004b1e
parent 66235 1e697b88f098af8bfabc2b80137e21371d398c15
child 66237 b753e8ac13fd5d9cb7cc81fe56ea3de25f9ae8c7
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs560451
Bug 560451 - Fennec allows uninstall attempt of add-ons in readonly directories. r=mfinkle
mobile/chrome/content/bindings/extensions.xml
mobile/chrome/content/extensions.js
--- a/mobile/chrome/content/bindings/extensions.xml
+++ b/mobile/chrome/content/bindings/extensions.xml
@@ -33,17 +33,17 @@
       <xul:hbox class="show-on-select buttons-box">
         <xul:button anonid="options-button" type="checkbox" class="addon-options" label="&addonOptions.label;"
                     oncommand="document.getBindingParent(this).toggleOptions();"/>
         <xul:spacer flex="1"/>
         <xul:button anonid="enable-button" class="show-on-disable hide-on-enable hide-on-uninstall addon-enable" label="&addonEnable.label;"
                     oncommand="ExtensionsView.enable(document.getBindingParent(this));"/>
         <xul:button class="show-on-enable hide-on-disable hide-on-uninstall addon-disable" label="&addonDisable.label;"
                     oncommand="ExtensionsView.disable(document.getBindingParent(this));"/>
-        <xul:button class="hide-on-uninstall addon-uninstall" label="&addonUninstall.label;"
+        <xul:button anonid="uninstall-button" class="hide-on-uninstall addon-uninstall" label="&addonUninstall.label;"
                     oncommand="ExtensionsView.uninstall(document.getBindingParent(this));"/>
         <xul:button class="show-on-uninstall addon-cancel" label="&addonCancel.label;"
                     oncommand="ExtensionsView.cancelUninstall(document.getBindingParent(this));"/>
       </xul:hbox>
       <!-- options are generated dynamically from the optionsURL -->
       <xul:vbox class="options-box" anonid="options-box" collapsed="true" flex="1" />
     </content>
 
@@ -53,16 +53,20 @@
           let isDisabled = this.getAttribute("isDisabled");
           let optionsURL = this.getAttribute("optionsURL");
           if (optionsURL == "" || isDisabled == "true")
             document.getAnonymousElementByAttribute(this, "anonid", "options-button").setAttribute("disabled", "true");
 
           let appDisabled = this.getAttribute("appDisabled");
           if (appDisabled == "true")
             document.getAnonymousElementByAttribute(this, "anonid", "enable-button").setAttribute("disabled", "true");
+
+          let isReadOnly = this.getAttribute("isReadonly");
+          if (isReadOnly == "true")
+            document.getAnonymousElementByAttribute(this, "anonid", "uninstall-button").setAttribute("disabled", "true");
         ]]>
       </constructor>
 
       <method name="hideOptions">
         <body>
           <![CDATA[
             let box = document.getAnonymousElementByAttribute(this, "anonid", "options-box");
             if (!box.collapsed)
--- a/mobile/chrome/content/extensions.js
+++ b/mobile/chrome/content/extensions.js
@@ -289,25 +289,27 @@ var ExtensionsView = {
 
     let self = this;
     AddonManager.getAddonsByTypes(["extension", "theme", "locale"], function(items) {
       for (let i = 0; i < items.length; i++) {
         let addon = items[i];
         let appManaged = (addon.scope == AddonManager.SCOPE_APPLICATION);
         let opType = self._getOpTypeForOperations(addon.pendingOperations);
         let updateable = (addon.permissions & AddonManager.PERM_CAN_UPDATE) > 0;
+        let uninstallable = (addon.permissions & AddonManager.PERM_CAN_UNINSTALL) > 0;
 
         let listitem = self._createItem(addon, "local");
         listitem.setAttribute("isDisabled", !addon.isActive);
         listitem.setAttribute("appDisabled", addon.appDisabled);
         listitem.setAttribute("appManaged", appManaged);
         listitem.setAttribute("description", addon.description);
         listitem.setAttribute("optionsURL", addon.optionsURL);
         listitem.setAttribute("opType", opType);
         listitem.setAttribute("updateable", updateable);
+        listitem.setAttribute("isReadonly", !uninstallable);
         listitem.addon = addon;
         self._list.insertBefore(listitem, self._repoItem);
       }
 
       // Load the search engines
       let defaults = self._search.getDefaultEngines({ }).map(function (e) e.name);
       function isDefault(aEngine)
         defaults.indexOf(aEngine.name) != -1