Bug 396510: Remove EM command line global installation capability (e.g. -install-global-extension and -install-global-theme). r=robstrong
authorDave Townsend <dtownsend@oxymoronical.com>
Tue, 12 May 2009 09:22:39 +0100
changeset 28225 c61c8e18dba6153105959c17a1f766675acd1ce4
parent 28224 8fc05484508051a86afdc3bcbb1935a0aa0c59c8
child 28226 ee88749b4b6edd6c9b74087717a1fe1f7a76bf8f
push id6954
push userdtownsend@mozilla.com
push dateTue, 12 May 2009 08:23:10 +0000
treeherdermozilla-central@c61c8e18dba6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrobstrong
bugs396510
milestone1.9.2a1pre
Bug 396510: Remove EM command line global installation capability (e.g. -install-global-extension and -install-global-theme). r=robstrong
toolkit/mozapps/extensions/public/nsIExtensionManager.idl
toolkit/mozapps/extensions/src/nsExtensionManager.js.in
toolkit/mozapps/extensions/test/unit/head_extensionmanager.js
toolkit/xre/nsAppRunner.cpp
--- a/toolkit/mozapps/extensions/public/nsIExtensionManager.idl
+++ b/toolkit/mozapps/extensions/public/nsIExtensionManager.idl
@@ -40,17 +40,16 @@
 
 #include "nsISupports.idl"
 
 interface nsIFile;
 interface nsIRDFDataSource;
 interface nsIUpdateItem;
 interface nsIAddonInstallListener;
 interface nsIAddonUpdateCheckListener;
-interface nsICommandLine;
 interface nsISimpleEnumerator;
 interface nsIDirectoryEnumerator;
 interface nsIObserver;
 
 /**
  * Interface representing a location where extensions, themes etc are
  * installed.
  */
@@ -194,58 +193,46 @@ interface nsIInstallLocation : nsISuppor
 
 /**
  * Interface representing a system for the installation and management of
  * Extensions, Themes etc.
  *
  * XXXben - Some of this stuff should go into a management-ey interface,
  *          some into an app-startup-ey interface.
  */
-[scriptable, uuid(7fbb049a-00e6-4ce2-82fc-854c52788df9)]
+[scriptable, uuid(c6838785-ddb5-4886-8c05-4dd6424a01ac)]
 interface nsIExtensionManager : nsISupports
 {
   /**
    * Constants representing types of update checks.
    */
   const unsigned long UPDATE_CHECK_NEWVERSION    = 0;
   const unsigned long UPDATE_CHECK_COMPATIBILITY = 1;
   const unsigned long UPDATE_SYNC_COMPATIBILITY  = 2;
   const unsigned long UPDATE_NOTIFY_NEWVERSION   = 3;
 
   /**
    * Starts the Extension Manager, checking for item changes, additions and
    * removals, and finishing pending operations.
-   * @param   commandLine
-   *          The command line the application was started with.
    * @returns true if the application has rewritten the extensions.ini file
    *          and needs to restart to register components/chrome etc,
    *          false otherwise
    */
-  boolean start(in nsICommandLine commandLine);
+  boolean start();
 
   /**
    * Determines if there are incompatible items installed (and offers to
    * upgrade them to newer versions if available, via a UI).
    * @returns true if there were incompatible items that were disabled
    *          and the application needs to restart to re-register components,
    *          chrome etc, false otherwise.
    */
   boolean checkForMismatches();
 
   /**
-   * Handle command line flags, e.g. -install-global-[extension|theme]
-   * @param   cmdLine
-   *          the command line the application was started with
-   * XXXben - move this off this API - currently it is only used for
-   *          global installation, and the apprunner can do this directly
-   *          with |installItemFromFile|
-   */
-  void handleCommandLineArgs(in nsICommandLine cmdline);
-
-  /**
    * Gets the Install Location for an item
    * @param   id
    *          The GUID of the item
    * @returns The Install Location where the item is installed or null if the
    *          location cannot be obtained (e.g. an invalid id).
    */
   nsIInstallLocation getInstallLocation(in AString id);
 
--- a/toolkit/mozapps/extensions/src/nsExtensionManager.js.in
+++ b/toolkit/mozapps/extensions/src/nsExtensionManager.js.in
@@ -2743,17 +2743,17 @@ ExtensionManager.prototype = {
       extensionsCache.remove(false);
 
     return [true, !iniExists];
   },
 
   /**
    * See nsIExtensionManager.idl
    */
-  start: function EM_start(commandLine) {
+  start: function EM_start() {
     var isDirty, forceAutoReg;
 
     // Check for missing manifests - e.g. missing extensions.ini, missing
     // extensions.cache, extensions.rdf etc. If any of these files
     // is missing then we are in some kind of weird or initial state and need
     // to force a regeneration.
     [isDirty, forceAutoReg] = this._ensureDatasetIntegrity();
 
@@ -2830,69 +2830,16 @@ ExtensionManager.prototype = {
     var updater = new ExtensionItemUpdater(this);
     updater.checkForUpdates(items, items.length,
                             Ci.nsIExtensionManager.UPDATE_CHECK_NEWVERSION,
                             new BackgroundUpdateCheckListener(this.datasource),
                             null, null);
   },
 
   /**
-   * See nsIExtensionManager.idl
-   */
-  handleCommandLineArgs: function EM_handleCommandLineArgs(commandLine) {
-    try {
-      var globalExtension = commandLine.handleFlagWithParam("install-global-extension", false);
-      if (globalExtension) {
-        var file = commandLine.resolveFile(globalExtension);
-        this._installGlobalItem(file);
-      }
-      var globalTheme = commandLine.handleFlagWithParam("install-global-theme", false);
-      if (globalTheme) {
-        file = commandLine.resolveFile(globalTheme);
-        this._installGlobalItem(file);
-      }
-    }
-    catch (e) {
-      ERROR("ExtensionManager:handleCommandLineArgs - failure, catching exception - lineno: " +
-            e.lineNumber + " - file: " + e.fileName + " - " + e);
-    }
-    commandLine.preventDefault = true;
-  },
-
-  /**
-   * Installs an XPI/JAR file into the KEY_APP_GLOBAL install location.
-   * @param   file
-   *          The XPI/JAR file to extract
-   */
-  _installGlobalItem: function EM__installGlobalItem(file) {
-    if (!file || !file.exists())
-      throw new Error("Unable to find the file specified on the command line!");
-#ifdef XP_WIN
-    // make sure the file is local on Windows
-    file.normalize();
-    if (file.path[1] != ':')
-      throw new Error("Can't install global chrome from non-local file "+file.path);
-#endif
-    var installManifestFile = extractRDFFileToTempDir(file, FILE_INSTALL_MANIFEST, true);
-    if (!installManifestFile.exists())
-      throw new Error("The package is missing an install manifest!");
-    var installManifest = getInstallManifest(installManifestFile);
-    installManifestFile.remove(false);
-    var installData = this._getInstallData(installManifest);
-    var installer = new Installer(installManifest, installData.id,
-                                  InstallLocations.get(KEY_APP_GLOBAL),
-                                  installData.type);
-    installer._installExtensionFiles(file);
-    if (installData.type == Ci.nsIUpdateItem.TYPE_THEME)
-      installer.upgradeThemeChrome();
-    else
-      installer.upgradeExtensionChrome();
-  },
-
-  /**
    * Check to see if a file is a XPI/JAR file that the user dropped into this
    * Install Location. (i.e. a XPI that is not a staged XPI from an install
    * transaction that is currently in operation).
    * @param   file
    *          The XPI/JAR file to configure
    * @param   location
    *          The Install Location where this file was found.
    * @returns A nsIUpdateItem representing the dropped XPI if this file was a
--- a/toolkit/mozapps/extensions/test/unit/head_extensionmanager.js
+++ b/toolkit/mozapps/extensions/test/unit/head_extensionmanager.js
@@ -220,17 +220,17 @@ function startupEM()
   }
   catch (e) {
     dump("checkForMismatches threw an exception: " + e + "\n");
     needsRestart = false;
     upgraded = false;
   }
 
   if (!upgraded || !needsRestart)
-    needsRestart = gEM.start(null);
+    needsRestart = gEM.start();
 }
 
 /**
  * Simple function to simulate the termination of an app to the EM.
  * This harness does not support creating a new EM after calling this.
  */
 function shutdownEM()
 {
@@ -240,19 +240,19 @@ function shutdownEM()
 }
 
 /**
  * Many operations require restarts to take effect. This function should
  * perform all that is necessary for this to happen.
  */
 function restartEM()
 {
-  var needsRestart = gEM.start(null);
+  var needsRestart = gEM.start();
   if (needsRestart)
-    gEM.start(null);
+    gEM.start();
 }
 
 var gDirSvc = Components.classes["@mozilla.org/file/directory_service;1"]
                         .getService(Components.interfaces.nsIProperties);
 
 // Need to create and register a profile folder.
 var gProfD = do_get_cwd();
 gProfD.append("profile");
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -3243,46 +3243,26 @@ XRE_main(int argc, char* argv[], const n
           NS_TIMELINE_LEAVE("appStartup->CreateHiddenWindow");
           NS_ENSURE_SUCCESS(rv, 1);
 
           // Extension Compatibility Checking and Startup
           if (gAppData->flags & NS_XRE_ENABLE_EXTENSION_MANAGER) {
             nsCOMPtr<nsIExtensionManager> em(do_GetService("@mozilla.org/extensions/manager;1"));
             NS_ENSURE_TRUE(em, 1);
 
-            ar = CheckArg("install-global-extension", PR_TRUE);
-            if (ar == ARG_BAD) {
-              PR_fprintf(PR_STDERR, "Error: argument -install-global-extension is invalid when argument -osint is specified\n");
-              return 1;
-            } else if (ar == ARG_FOUND) {
-              // Do the required processing and then shut down.
-              em->HandleCommandLineArgs(cmdLine);
-              return 0;
-            }
-
-            ar = CheckArg("install-global-theme", PR_TRUE);
-            if (ar == ARG_BAD) {
-              PR_fprintf(PR_STDERR, "Error: argument -install-global-theme is invalid when argument -osint is specified\n");
-              return 1;
-            } else if (ar == ARG_FOUND) {
-              // Do the required processing and then shut down.
-              em->HandleCommandLineArgs(cmdLine);
-              return 0;
-            }
-
             if (upgraded) {
               rv = em->CheckForMismatches(&needsRestart);
               if (NS_FAILED(rv)) {
                 needsRestart = PR_FALSE;
                 upgraded = PR_FALSE;
               }
             }
             
             if (!upgraded || !needsRestart)
-              em->Start(cmdLine, &needsRestart);
+              em->Start(&needsRestart);
           }
 
           // We want to restart no more than 2 times. The first restart,
           // NO_EM_RESTART == "0" , and the second time, "1".
           char* noEMRestart = PR_GetEnv("NO_EM_RESTART");
           if (noEMRestart && *noEMRestart && *noEMRestart == '1') {
             if (upgraded || needsRestart) {
               NS_WARNING("EM tried to force us to restart twice! Forcefully preventing that.");