Bug 1372694: Part 2 - Remove support for registering non-bootstrapped extension chrome. r=aswan
authorKris Maglione <maglione.k@gmail.com>
Fri, 20 Apr 2018 17:00:29 -0700
changeset 468739 6bb7337970f19723f9ba34a682b4682c53863e5a
parent 468738 0819fc14fc57f1a10a9aaf179882a532ac2f6835
child 468740 1fa2a1d2d41e69c953e0b307e46b885271cd6091
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan
bugs1372694
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1372694: Part 2 - Remove support for registering non-bootstrapped extension chrome. r=aswan MozReview-Commit-ID: FpTfAHWpTnt
toolkit/mozapps/extensions/AddonManagerStartup.cpp
toolkit/mozapps/extensions/AddonManagerStartup.h
toolkit/mozapps/extensions/amIAddonManagerStartup.idl
toolkit/mozapps/extensions/internal/AddonTestUtils.jsm
toolkit/xre/nsXREDirProvider.cpp
--- a/toolkit/mozapps/extensions/AddonManagerStartup.cpp
+++ b/toolkit/mozapps/extensions/AddonManagerStartup.cpp
@@ -59,17 +59,16 @@ AddonManagerStartup::GetSingleton()
   if (!singleton) {
     singleton = new AddonManagerStartup();
     ClearOnShutdown(&singleton);
   }
   return *singleton;
 }
 
 AddonManagerStartup::AddonManagerStartup()
-  : mInitialized(false)
 {}
 
 
 nsIFile*
 AddonManagerStartup::ProfileDir()
 {
   if (!mProfileDir) {
     nsresult rv;
@@ -408,18 +407,16 @@ public:
 
   bool Enabled() { return GetBool("enabled"); }
 
   double LastModifiedTime() { return GetNumber("lastModifiedTime"); }
 
 
   Result<nsCOMPtr<nsIFile>, nsresult> FullPath();
 
-  NSLocationType LocationType();
-
   Result<bool, nsresult> UpdateLastModifiedTime();
 
 
 private:
   nsString mId;
   InstallLocation& mLocation;
 };
 
@@ -436,26 +433,16 @@ Addon::FullPath()
 
   // If not an absolute path, fall back to a relative path from the location.
   MOZ_TRY(NS_NewLocalFile(mLocation.Path(), false, getter_AddRefs(file)));
 
   MOZ_TRY(file->AppendRelativePath(path));
   return Move(file);
 }
 
-NSLocationType
-Addon::LocationType()
-{
-  nsString type = GetString("type", "extension");
-  if (type.LowerCaseEqualsLiteral("theme")) {
-    return NS_SKIN_LOCATION;
-  }
-  return NS_EXTENSION_LOCATION;
-}
-
 Result<bool, nsresult>
 Addon::UpdateLastModifiedTime()
 {
   nsCOMPtr<nsIFile> file;
   MOZ_TRY_VAR(file, FullPath());
 
   bool result;
   if (NS_FAILED(file->Exists(&result)) || !result) {
@@ -503,42 +490,16 @@ InstallLocation::InstallLocation(JSConte
   mAddonsIter.emplace(cx, mAddonsObj, this);
 }
 
 
 /*****************************************************************************
  * XPC interfacing
  *****************************************************************************/
 
-Result<Ok, nsresult>
-AddonManagerStartup::AddInstallLocation(Addon& addon)
-{
-  nsCOMPtr<nsIFile> file;
-  MOZ_TRY_VAR(file, addon.FullPath());
-
-  nsString path;
-  MOZ_TRY(file->GetPath(path));
-
-  auto type = addon.LocationType();
-
-  if (type == NS_SKIN_LOCATION) {
-    mThemePaths.AppendElement(file);
-  } else {
-    return Ok();
-  }
-
-  if (StringTail(path, 4).LowerCaseEqualsLiteral(".xpi")) {
-    XRE_AddJarManifestLocation(type, file);
-  } else {
-    nsCOMPtr<nsIFile> manifest = CloneAndAppend(file, "chrome.manifest");
-    XRE_AddManifestLocation(type, manifest);
-  }
-  return Ok();
-}
-
 nsresult
 AddonManagerStartup::ReadStartupData(JSContext* cx, JS::MutableHandleValue locations)
 {
   locations.set(JS::UndefinedValue());
 
   nsCOMPtr<nsIFile> file = CloneAndAppend(ProfileDir(), "addonStartup.json.lz4");
 
   nsCString data;
@@ -577,44 +538,16 @@ AddonManagerStartup::ReadStartupData(JSC
       }
     }
   }
 
   return NS_OK;
 }
 
 nsresult
-AddonManagerStartup::InitializeExtensions(JS::HandleValue locations, JSContext* cx)
-{
-  NS_ENSURE_FALSE(mInitialized, NS_ERROR_UNEXPECTED);
-  NS_ENSURE_TRUE(locations.isObject(), NS_ERROR_INVALID_ARG);
-
-  mInitialized = true;
-
-  if (!Preferences::GetBool("extensions.defaultProviders.enabled", true)) {
-    return NS_OK;
-  }
-
-  JS::RootedObject locs(cx, &locations.toObject());
-  for (auto e1 : PropertyIter(cx, locs)) {
-    InstallLocation loc(e1);
-
-    for (auto e2 : loc.Addons()) {
-      Addon addon(e2);
-
-      if (addon.Enabled() && !addon.Bootstrapped()) {
-        Unused << AddInstallLocation(addon);
-      }
-    }
-  }
-
-  return NS_OK;
-}
-
-nsresult
 AddonManagerStartup::EncodeBlob(JS::HandleValue value, JSContext* cx, JS::MutableHandleValue result)
 {
   StructuredCloneData holder;
 
   ErrorResult rv;
   holder.Write(cx, value, rv);
   if (rv.Failed()) {
     return rv.StealNSResult();
@@ -702,29 +635,16 @@ AddonManagerStartup::EnumerateZipFile(ns
 
   *countOut = results.Length();
   *entriesOut = strResults.release();
 
   return NS_OK;
 }
 
 nsresult
-AddonManagerStartup::Reset()
-{
-  MOZ_RELEASE_ASSERT(xpc::IsInAutomation());
-
-  mInitialized = false;
-
-  mExtensionPaths.Clear();
-  mThemePaths.Clear();
-
-  return NS_OK;
-}
-
-nsresult
 AddonManagerStartup::InitializeURLPreloader()
 {
   MOZ_RELEASE_ASSERT(xpc::IsInAutomation());
 
   URLPreloader::ReInitialize();
 
   return NS_OK;
 }
--- a/toolkit/mozapps/extensions/AddonManagerStartup.h
+++ b/toolkit/mozapps/extensions/AddonManagerStartup.h
@@ -33,38 +33,21 @@ public:
   static AddonManagerStartup& GetSingleton();
 
   static already_AddRefed<AddonManagerStartup> GetInstance()
   {
     RefPtr<AddonManagerStartup> inst = &GetSingleton();
     return inst.forget();
   }
 
-  const nsCOMArray<nsIFile>& ExtensionPaths()
-  {
-    return mExtensionPaths;
-  }
-
-  const nsCOMArray<nsIFile>& ThemePaths()
-  {
-    return mExtensionPaths;
-  }
-
 private:
-  Result<Ok, nsresult> AddInstallLocation(Addon& addon);
-
   nsIFile* ProfileDir();
 
   nsCOMPtr<nsIFile> mProfileDir;
 
-  nsCOMArray<nsIFile> mExtensionPaths;
-  nsCOMArray<nsIFile> mThemePaths;
-
-  bool mInitialized;
-
 protected:
   virtual ~AddonManagerStartup() = default;
 };
 
 } // namespace mozilla
 
 #define NS_ADDONMANAGERSTARTUP_CONTRACTID \
   "@mozilla.org/addons/addon-manager-startup;1"
--- a/toolkit/mozapps/extensions/amIAddonManagerStartup.idl
+++ b/toolkit/mozapps/extensions/amIAddonManagerStartup.idl
@@ -17,23 +17,16 @@ interface amIAddonManagerStartup : nsISu
    *
    * Returns null for an empty or nonexistent state file, but throws for an
    * invalid one.
    */
   [implicit_jscontext]
   jsval readStartupData();
 
   /**
-   * Initializes the chrome registry for the enabled, non-restartless add-on
-   * in the given state data.
-   */
-  [implicit_jscontext]
-  void initializeExtensions(in jsval locations);
-
-  /**
    * Registers a set of dynamic chrome registry entries, and returns an object
    * with a `destruct()` method which must be called in order to unregister
    * the entries.
    *
    * @param manifestURI The base manifest URI for the entries. URL values are
    *        resolved relative to this URI.
    * @param entries An array of arrays, each containing a registry entry as it
    *        would appar in a chrome.manifest file. Only the following entry
@@ -63,25 +56,16 @@ interface amIAddonManagerStartup : nsISu
    * @param file The zip file to enumerate.
    * @param pattern The pattern to match, as passed to nsIZipReader.findEntries.
    */
   void enumerateZipFile(in nsIFile file, in AUTF8String pattern,
                         [optional] out unsigned long count,
                         [retval, array, size_is(count)] out wstring entries);
 
   /**
-   * Resets the internal state of the startup service, and allows
-   * initializeExtensions() to be called again. Does *not* fully unregister
-   * chrome registry locations for previously registered add-ons.
-   *
-   * NOT FOR USE OUTSIDE OF UNIT TESTS.
-   */
-  void reset();
-
-  /**
    * Initializes the URL Preloader.
    *
    * NOT FOR USE OUTSIDE OF UNIT TESTS.
    */
   void initializeURLPreloader();
 
 };
 
--- a/toolkit/mozapps/extensions/internal/AddonTestUtils.jsm
+++ b/toolkit/mozapps/extensions/internal/AddonTestUtils.jsm
@@ -784,22 +784,16 @@ var AddonTestUtils = {
         // This would be cleaner if I could get it as the rejection reason from
         // the AddonManagerInternal.shutdown() promise
         let shutdownError = XPIscope.XPIDatabase._saveError;
 
         AddonManagerPrivate.unregisterProvider(XPIscope.XPIProvider);
         Cu.unload("resource://gre/modules/addons/XPIProvider.jsm");
         Cu.unload("resource://gre/modules/addons/XPIInstall.jsm");
 
-        // We need to set this in order reset the startup service, which
-        // is only possible when running in automation.
-        Services.prefs.setBoolPref(PREF_DISABLE_SECURITY, true);
-
-        aomStartup.reset();
-
         if (shutdownError)
           throw shutdownError;
 
         return true;
       });
   },
 
   promiseRestartManager(newVersion) {
--- a/toolkit/xre/nsXREDirProvider.cpp
+++ b/toolkit/xre/nsXREDirProvider.cpp
@@ -1,17 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsAppRunner.h"
 #include "nsToolkitCompsCID.h"
 #include "nsXREDirProvider.h"
-#include "mozilla/AddonManagerStartup.h"
 
 #include "jsapi.h"
 #include "xpcpublic.h"
 
 #include "nsIAppStartup.h"
 #include "nsIDirectoryEnumerator.h"
 #include "nsIFile.h"
 #include "nsIObserver.h"
@@ -862,18 +861,16 @@ nsXREDirProvider::GetFilesInternal(const
 
   if (!strcmp(aProperty, XRE_EXTENSIONS_DIR_LIST)) {
     nsCOMArray<nsIFile> directories;
 
     static const char *const kAppendNothing[] = { nullptr };
 
     LoadDirsIntoArray(mAppBundleDirectories,
                       kAppendNothing, directories);
-    LoadDirsIntoArray(AddonManagerStartup::GetSingleton().ExtensionPaths(),
-                      kAppendNothing, directories);
 
     rv = NS_NewArrayEnumerator(aResult, directories);
   }
   else if (!strcmp(aProperty, NS_APP_PREFS_DEFAULTS_DIR_LIST)) {
     nsCOMArray<nsIFile> directories;
 
     LoadDirIntoArray(mXULAppDir, kAppendPrefDir, directories);
     LoadDirsIntoArray(mAppBundleDirectories,
@@ -888,19 +885,16 @@ nsXREDirProvider::GetFilesInternal(const
     static const char *const kAppendChromeDir[] = { "chrome", nullptr };
     nsCOMArray<nsIFile> directories;
     LoadDirIntoArray(mXULAppDir,
                      kAppendChromeDir,
                      directories);
     LoadDirsIntoArray(mAppBundleDirectories,
                       kAppendChromeDir,
                       directories);
-    LoadDirsIntoArray(AddonManagerStartup::GetSingleton().ExtensionPaths(),
-                      kAppendChromeDir,
-                      directories);
 
     rv = NS_NewArrayEnumerator(aResult, directories);
   }
   else if (!strcmp(aProperty, NS_APP_PLUGINS_DIR_LIST)) {
     nsCOMArray<nsIFile> directories;
 
     if (mozilla::Preferences::GetBool("plugins.load_appdir_plugins", false)) {
       nsCOMPtr<nsIFile> appdir;
@@ -913,19 +907,16 @@ nsXREDirProvider::GetFilesInternal(const
 
     static const char *const kAppendPlugins[] = { "plugins", nullptr };
 
     // The root dirserviceprovider does quite a bit for us: we're mainly
     // interested in xulapp and extension-provided plugins.
     LoadDirsIntoArray(mAppBundleDirectories,
                       kAppendPlugins,
                       directories);
-    LoadDirsIntoArray(AddonManagerStartup::GetSingleton().ExtensionPaths(),
-                      kAppendPlugins,
-                      directories);
 
     if (mProfileDir) {
       nsCOMArray<nsIFile> profileDir;
       profileDir.AppendObject(mProfileDir);
       LoadDirsIntoArray(profileDir,
                         kAppendPlugins,
                         directories);
     }