summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2018-02-10 10:46:49 -0500
committerMatt A. Tobin <email@mattatobin.com>2018-02-10 10:46:49 -0500
commitceb5709ba1666a4f4200314e495d1260591d4e5c (patch)
tree589c55286185116d68f6a9b86e41c11f19d37ab5
parent05909d49b86e40faf18060fa513e9788c4fa99c1 (diff)
downloaduxp-ceb5709ba1666a4f4200314e495d1260591d4e5c.tar.gz
Make the Add-on Manager's binary components build
-rw-r--r--toolkit/components/build/nsToolkitCompsModule.cpp12
-rw-r--r--toolkit/mozapps/extensions/AddonPathService.cpp22
2 files changed, 28 insertions, 6 deletions
diff --git a/toolkit/components/build/nsToolkitCompsModule.cpp b/toolkit/components/build/nsToolkitCompsModule.cpp
index 675c8c92b0..22bb434a0a 100644
--- a/toolkit/components/build/nsToolkitCompsModule.cpp
+++ b/toolkit/components/build/nsToolkitCompsModule.cpp
@@ -35,7 +35,9 @@
#include "nsBrowserStatusFilter.h"
#include "mozilla/FinalizationWitnessService.h"
#include "mozilla/NativeOSFileInternals.h"
+#ifdef MOZ_WEBEXTENSIONS
#include "mozilla/AddonContentPolicy.h"
+#endif
#include "mozilla/AddonPathService.h"
#if defined(XP_WIN)
@@ -122,7 +124,9 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(FinalizationWitnessService, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(NativeOSFileInternalsService)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(NativeFileWatcherService, Init)
+#ifdef MOZ_WEBEXTENSIONS
NS_GENERIC_FACTORY_CONSTRUCTOR(AddonContentPolicy)
+#endif
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(AddonPathService, AddonPathService::GetInstance)
NS_DEFINE_NAMED_CID(NS_TOOLKIT_APPSTARTUP_CID);
@@ -155,7 +159,9 @@ NS_DEFINE_NAMED_CID(NS_UPDATEPROCESSOR_CID);
#endif
NS_DEFINE_NAMED_CID(FINALIZATIONWITNESSSERVICE_CID);
NS_DEFINE_NAMED_CID(NATIVE_OSFILE_INTERNALS_SERVICE_CID);
+#ifdef MOZ_WEBEXTENSIONS
NS_DEFINE_NAMED_CID(NS_ADDONCONTENTPOLICY_CID);
+#endif
NS_DEFINE_NAMED_CID(NS_ADDON_PATH_SERVICE_CID);
NS_DEFINE_NAMED_CID(NATIVE_FILEWATCHER_SERVICE_CID);
@@ -189,7 +195,9 @@ static const Module::CIDEntry kToolkitCIDs[] = {
#endif
{ &kFINALIZATIONWITNESSSERVICE_CID, false, nullptr, FinalizationWitnessServiceConstructor },
{ &kNATIVE_OSFILE_INTERNALS_SERVICE_CID, false, nullptr, NativeOSFileInternalsServiceConstructor },
+#ifdef MOZ_WEBEXTENSIONS
{ &kNS_ADDONCONTENTPOLICY_CID, false, nullptr, AddonContentPolicyConstructor },
+#endif
{ &kNS_ADDON_PATH_SERVICE_CID, false, nullptr, AddonPathServiceConstructor },
{ &kNATIVE_FILEWATCHER_SERVICE_CID, false, nullptr, NativeFileWatcherServiceConstructor },
{ nullptr }
@@ -225,14 +233,18 @@ static const Module::ContractIDEntry kToolkitContracts[] = {
#endif
{ FINALIZATIONWITNESSSERVICE_CONTRACTID, &kFINALIZATIONWITNESSSERVICE_CID },
{ NATIVE_OSFILE_INTERNALS_SERVICE_CONTRACTID, &kNATIVE_OSFILE_INTERNALS_SERVICE_CID },
+#ifdef MOZ_WEBEXTENSIONS
{ NS_ADDONCONTENTPOLICY_CONTRACTID, &kNS_ADDONCONTENTPOLICY_CID },
+#endif
{ NS_ADDONPATHSERVICE_CONTRACTID, &kNS_ADDON_PATH_SERVICE_CID },
{ NATIVE_FILEWATCHER_SERVICE_CONTRACTID, &kNATIVE_FILEWATCHER_SERVICE_CID },
{ nullptr }
};
static const mozilla::Module::CategoryEntry kToolkitCategories[] = {
+#ifdef MOZ_WEBEXTENSIONS
{ "content-policy", NS_ADDONCONTENTPOLICY_CONTRACTID, NS_ADDONCONTENTPOLICY_CONTRACTID },
+#endif
{ nullptr }
};
diff --git a/toolkit/mozapps/extensions/AddonPathService.cpp b/toolkit/mozapps/extensions/AddonPathService.cpp
index e384926fdb..0061491005 100644
--- a/toolkit/mozapps/extensions/AddonPathService.cpp
+++ b/toolkit/mozapps/extensions/AddonPathService.cpp
@@ -14,11 +14,13 @@
#include "nsThreadUtils.h"
#include "nsIIOService.h"
#include "nsNetUtil.h"
+#include "nsIFileURL.h"
#include "nsIResProtocolHandler.h"
#include "nsIChromeRegistry.h"
#include "nsIJARURI.h"
#include "nsJSUtils.h"
#include "mozilla/dom/ScriptSettings.h"
+#include "mozilla/dom/ToJSValue.h"
#include "mozilla/AddonPathService.h"
#include "mozilla/Omnijar.h"
@@ -64,6 +66,18 @@ AddonPathService::GetInstance()
return sInstance;
}
+static JSAddonId*
+ConvertAddonId(const nsAString& addonIdString)
+{
+ AutoSafeJSContext cx;
+ JS::RootedValue strv(cx);
+ if (!mozilla::dom::ToJSValue(cx, addonIdString, &strv)) {
+ return nullptr;
+ }
+ JS::RootedString str(cx, strv.toString());
+ return JS::NewAddonId(cx, str);
+}
+
JSAddonId*
AddonPathService::Find(const nsAString& path)
{
@@ -106,11 +120,7 @@ AddonPathService::FindAddonId(const nsAString& path)
NS_IMETHODIMP
AddonPathService::InsertPath(const nsAString& path, const nsAString& addonIdString)
{
- AutoSafeJSContext cx;
- JS::RootedString str(cx, JS_NewUCStringCopyN(cx,
- addonIdString.BeginReading(),
- addonIdString.Length()));
- JSAddonId* addonId = JS::NewAddonId(cx, str);
+ JSAddonId* addonId = ConvertAddonId(addonIdString);
// Add the new path in sorted order.
PathEntryComparator comparator;
@@ -193,7 +203,7 @@ ResolveURI(nsIURI* aURI, nsAString& out)
JSAddonId*
MapURIToAddonID(nsIURI* aURI)
{
- if (!NS_IsMainThread() || XRE_GetProcessType() != GoannaProcessType_Default) {
+ if (!NS_IsMainThread() || !XRE_IsParentProcess()) {
return nullptr;
}