From 81d1b13588ed89309a4ef036d828a5892f0d7543 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Sat, 10 Feb 2018 10:46:49 -0500 Subject: Make the Add-on Manager's binary components build --- toolkit/mozapps/extensions/AddonPathService.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'toolkit/mozapps') 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; } -- cgit v1.2.3