From b8145b3d592cf0290cc17a6223816b817e3e3b77 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Sat, 28 Apr 2018 12:46:29 +0200 Subject: Bug 1263935 - Expose native version of mapURIToAddonId via amIAddonPathService Issue #102 --- toolkit/mozapps/extensions/AddonPathService.cpp | 10 ++++++++++ toolkit/mozapps/extensions/amIAddonPathService.idl | 8 ++++++++ 2 files changed, 18 insertions(+) (limited to 'toolkit/mozapps/extensions') diff --git a/toolkit/mozapps/extensions/AddonPathService.cpp b/toolkit/mozapps/extensions/AddonPathService.cpp index 006149100..ddfdbe817 100644 --- a/toolkit/mozapps/extensions/AddonPathService.cpp +++ b/toolkit/mozapps/extensions/AddonPathService.cpp @@ -128,6 +128,16 @@ AddonPathService::InsertPath(const nsAString& path, const nsAString& addonIdStri return NS_OK; } +NS_IMETHODIMP +AddonPathService::MapURIToAddonId(nsIURI* aURI, nsAString& addonIdString) +{ + if (JSAddonId* id = MapURIToAddonID(aURI)) { + JSFlatString* flat = JS_ASSERT_STRING_IS_FLAT(JS::StringOfAddonId(id)); + AssignJSFlatString(addonIdString, flat); + } + return NS_OK; +} + static nsresult ResolveURI(nsIURI* aURI, nsAString& out) { diff --git a/toolkit/mozapps/extensions/amIAddonPathService.idl b/toolkit/mozapps/extensions/amIAddonPathService.idl index 863689858..9c9197a61 100644 --- a/toolkit/mozapps/extensions/amIAddonPathService.idl +++ b/toolkit/mozapps/extensions/amIAddonPathService.idl @@ -5,6 +5,8 @@ #include "nsISupports.idl" +interface nsIURI; + /** * This service maps file system paths where add-ons reside to the ID * of the add-on. Paths are added by the add-on manager. They can @@ -26,4 +28,10 @@ interface amIAddonPathService : nsISupports * associated with the given add-on ID. */ void insertPath(in AString path, in AString addonId); + + /** + * Given a URI to a file, return the ID of the add-on that the file belongs + * to. Returns an empty string if there is no add-on there. + */ + AString mapURIToAddonId(in nsIURI aURI); }; -- cgit v1.2.3 From 77e7fcac500629602059ad573c4ff6a9ff4d93b7 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Sat, 28 Apr 2018 12:47:07 +0200 Subject: Bug 1263935 - Forward AddonManager.mapURIToAddonId to AddonPathService.mapURIToAddonId Issue #102 --- toolkit/mozapps/extensions/internal/XPIProvider.jsm | 19 +++++++------------ .../extensions/test/xpcshell/test_mapURIToAddonID.js | 4 +++- 2 files changed, 10 insertions(+), 13 deletions(-) (limited to 'toolkit/mozapps/extensions') diff --git a/toolkit/mozapps/extensions/internal/XPIProvider.jsm b/toolkit/mozapps/extensions/internal/XPIProvider.jsm index c43811ba8..8b49c6600 100644 --- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm +++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm @@ -52,6 +52,10 @@ XPCOMUtils.defineLazyServiceGetter(this, "ResProtocolHandler", "@mozilla.org/network/protocol;1?name=resource", "nsIResProtocolHandler"); +XPCOMUtils.defineLazyServiceGetter(this, + "AddonPathService", + "@mozilla.org/addon-path-service;1", + "amIAddonPathService"); const nsIFile = Components.Constructor("@mozilla.org/file/local;1", "nsIFile", "initWithPath"); @@ -1887,8 +1891,7 @@ this.XPIProvider = { logger.info("Mapping " + aID + " to " + aFile.path); this._addonFileMap.set(aID, aFile.path); - let service = Cc["@mozilla.org/addon-path-service;1"].getService(Ci.amIAddonPathService); - service.insertPath(aFile.path, aID); + AddonPathService.insertPath(aFile.path, aID); }, /** @@ -3916,16 +3919,8 @@ this.XPIProvider = { * @see amIAddonManager.mapURIToAddonID */ mapURIToAddonID: function XPI_mapURIToAddonID(aURI) { - let resolved = this._resolveURIToFile(aURI); - if (!resolved || !(resolved instanceof Ci.nsIFileURL)) - return null; - - for (let [id, path] of this._addonFileMap) { - if (resolved.file.path.startsWith(path)) - return id; - } - - return null; + // Returns `null` instead of empty string if the URI can't be mapped. + return AddonPathService.mapURIToAddonId(aURI) || null; }, /** diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_mapURIToAddonID.js b/toolkit/mozapps/extensions/test/xpcshell/test_mapURIToAddonID.js index a6f9c8052..a153256dc 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_mapURIToAddonID.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_mapURIToAddonID.js @@ -95,8 +95,10 @@ function run_test_early() { "resource://gre/modules/addons/XPIProvider.jsm", {}); // Make the early API call. - do_check_null(s.XPIProvider.mapURIToAddonID(uri)); + // AddonManager still misses its provider and so doesn't work yet. do_check_null(AddonManager.mapURIToAddonID(uri)); + // But calling XPIProvider directly works immediately + do_check_eq(s.XPIProvider.mapURIToAddonID(uri), id); // Actually start up the manager. startupManager(false); -- cgit v1.2.3 From 11caf6ecb3cb8c84d2355a6c6e9580a290147e92 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Sat, 28 Apr 2018 18:19:42 -0400 Subject: [TychoAM] Fix gCertBlocklistService.addRevokedCert is not a function Mozilla renamed it to revokeCertByIssuerAndSerial --- toolkit/mozapps/extensions/nsBlocklistService.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'toolkit/mozapps/extensions') diff --git a/toolkit/mozapps/extensions/nsBlocklistService.js b/toolkit/mozapps/extensions/nsBlocklistService.js index 936c9d1b5..487dae8e5 100644 --- a/toolkit/mozapps/extensions/nsBlocklistService.js +++ b/toolkit/mozapps/extensions/nsBlocklistService.js @@ -910,7 +910,7 @@ Blocklist.prototype = { let issuer = blocklistElement.getAttribute("issuerName"); for (let snElement of blocklistElement.children) { try { - gCertBlocklistService.addRevokedCert(issuer, snElement.textContent); + gCertBlocklistService.revokeCertByIssuerAndSerial(issuer, snElement.textContent); } catch (e) { // we want to keep trying other elements since missing all items // is worse than missing one -- cgit v1.2.3 From d2bf1f169db9ba341636808b9902aee652727499 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Sun, 29 Apr 2018 22:35:29 -0400 Subject: [*AM] Expand the list for excluding internally used IDs from being sent to AUS --- toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'toolkit/mozapps/extensions') diff --git a/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm b/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm index 939e2e269..8d742ea42 100644 --- a/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm +++ b/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm @@ -766,8 +766,17 @@ this.AddonUpdateChecker = { * down in-progress update requests */ checkForUpdates: function AUC_checkForUpdates(aId, aUpdateKey, aUrl, aObserver) { - // Exclude default theme - if (aId != "{972ce4c6-7e08-4474-a285-3208198ce6fd}") + // Define an array of internally used IDs to NOT send to AUS such as the + // Default Theme. Please keep this list in sync with: + // toolkit/mozapps/webextensions/AddonUpdateChecker.jsm + let internalIDS = [ + '{972ce4c6-7e08-4474-a285-3208198ce6fd}', + 'modern@themes.mozilla.org' + ]; + + // If the ID is not in the array then go ahead and query AUS + if (internalIDS.indexOf(aId) == -1) { return new UpdateParser(aId, aUpdateKey, aUrl, aObserver); + } } }; -- cgit v1.2.3 From 61de1c80cdc6c04e71fde07cc5028af503438134 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Tue, 1 May 2018 12:26:01 -0400 Subject: Only set and show the dual-guid indicators when dual-guid has been built --- toolkit/mozapps/extensions/content/extensions.xml | 6 ++++++ toolkit/mozapps/extensions/internal/XPIProvider.jsm | 8 +++++--- toolkit/mozapps/extensions/internal/XPIProviderUtils.js | 6 +++++- 3 files changed, 16 insertions(+), 4 deletions(-) (limited to 'toolkit/mozapps/extensions') diff --git a/toolkit/mozapps/extensions/content/extensions.xml b/toolkit/mozapps/extensions/content/extensions.xml index fab340540..7fe17be2a 100644 --- a/toolkit/mozapps/extensions/content/extensions.xml +++ b/toolkit/mozapps/extensions/content/extensions.xml @@ -9,6 +9,8 @@ %extensionsDTD; %aboutDTD; + +%brandDTD; ]> +#ifdef MOZ_PHOENIX_EXTENSIONS +#endif @@ -1362,8 +1366,10 @@ [this.mAddon.name], 1); } else { this.removeAttribute("notification"); +#ifdef MOZ_PHOENIX_EXTENSIONS if (this.mAddon.type == "extension") this.setAttribute("native", this.mAddon.native); +#endif } } diff --git a/toolkit/mozapps/extensions/internal/XPIProvider.jsm b/toolkit/mozapps/extensions/internal/XPIProvider.jsm index 8b49c6600..e1883fb6a 100644 --- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm +++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm @@ -6442,21 +6442,23 @@ AddonInternal.prototype = { if (!aPlatformVersion) aPlatformVersion = Services.appinfo.platformVersion; +#ifdef MOZ_PHOENIX_EXTENSIONS this.native = false; - +#endif + let version; if (app.id == Services.appinfo.ID) { version = aAppVersion; +#ifdef MOZ_PHOENIX_EXTENSIONS this.native = true; } -#ifdef MOZ_PHOENIX_EXTENSIONS else if (app.id == FIREFOX_ID) { version = FIREFOX_APPCOMPATVERSION; if (this.type == "locale") //Never allow language packs in Firefox compatibility mode return false; - } #endif + } else if (app.id == TOOLKIT_ID) version = aPlatformVersion diff --git a/toolkit/mozapps/extensions/internal/XPIProviderUtils.js b/toolkit/mozapps/extensions/internal/XPIProviderUtils.js index d26029455..6b37ed640 100644 --- a/toolkit/mozapps/extensions/internal/XPIProviderUtils.js +++ b/toolkit/mozapps/extensions/internal/XPIProviderUtils.js @@ -70,7 +70,11 @@ const PROP_JSON_FIELDS = ["id", "syncGUID", "location", "version", "type", "skinnable", "size", "sourceURI", "releaseNotesURI", "softDisabled", "foreignInstall", "hasBinaryComponents", "strictCompatibility", "locales", "targetApplications", - "targetPlatforms", "multiprocessCompatible", "native"]; + "targetPlatforms", "multiprocessCompatible", +#ifdef MOZ_PHOENIX_EXTENSIONS + "native" +#endif + ]; // Time to wait before async save of XPI JSON database, in milliseconds const ASYNC_SAVE_DELAY_MS = 20; -- cgit v1.2.3 From ec1df1e8a21d83e393dbfb6f5cc03657b11af0fc Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Tue, 1 May 2018 16:14:17 -0400 Subject: [TychoAM] Make the Add-ons Manager conditionally devtools free --- toolkit/mozapps/extensions/content/extensions.js | 4 ++++ toolkit/mozapps/extensions/content/extensions.xml | 2 ++ toolkit/mozapps/extensions/content/extensions.xul | 6 ++++++ toolkit/mozapps/extensions/internal/XPIProvider.jsm | 15 +++++++++++++++ 4 files changed, 27 insertions(+) (limited to 'toolkit/mozapps/extensions') diff --git a/toolkit/mozapps/extensions/content/extensions.js b/toolkit/mozapps/extensions/content/extensions.js index 8d9c132e6..fc4392231 100644 --- a/toolkit/mozapps/extensions/content/extensions.js +++ b/toolkit/mozapps/extensions/content/extensions.js @@ -18,10 +18,12 @@ Cu.import("resource://gre/modules/addons/AddonRepository.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "PluralForm", "resource://gre/modules/PluralForm.jsm"); +#ifdef MOZ_DEVTOOLS XPCOMUtils.defineLazyGetter(this, "BrowserToolboxProcess", function () { return Cu.import("resource://devtools/client/framework/ToolboxProcess.jsm", {}). BrowserToolboxProcess; }); +#endif const PREF_DISCOVERURL = "extensions.webservice.discoverURL"; const PREF_DISCOVER_ENABLED = "extensions.getAddons.showPane"; @@ -1002,6 +1004,7 @@ var gViewController = { } }, +#ifdef MOZ_DEVTOOLS cmd_debugItem: { doCommand: function cmd_debugItem_doCommand(aAddon) { BrowserToolboxProcess.init({ addonID: aAddon.id }); @@ -1015,6 +1018,7 @@ var gViewController = { return aAddon && aAddon.isDebuggable && debuggerEnabled && remoteEnabled; } }, +#endif cmd_showItemPreferences: { isEnabled: function cmd_showItemPreferences_isEnabled(aAddon) { diff --git a/toolkit/mozapps/extensions/content/extensions.xml b/toolkit/mozapps/extensions/content/extensions.xml index 7fe17be2a..cbd05bfa9 100644 --- a/toolkit/mozapps/extensions/content/extensions.xml +++ b/toolkit/mozapps/extensions/content/extensions.xml @@ -1628,11 +1628,13 @@ ]]> +#ifdef MOZ_DEVTOOLS +#endif +#ifdef MOZ_DEVTOOLS +#endif +#ifdef MOZ_DEVTOOLS +#endif @@ -631,9 +635,11 @@ #endif command="cmd_showItemPreferences"/> +#ifdef MOZ_DEVTOOLS