summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2022-02-09 01:08:38 -0600
committerMatt A. Tobin <email@mattatobin.com>2022-02-09 01:08:38 -0600
commit6231b9e2ed5cc27fbbc5854c32c7af7f3ec1b279 (patch)
tree6be724e6209558dc22727f41fab884f003406a88
parenta2c6d634e83d1138c39ba2a93b21c37c3cd1a3c4 (diff)
downloadaura-central-6231b9e2ed5cc27fbbc5854c32c7af7f3ec1b279.tar.gz
[fxguid] Part 3 - Add reverse-dual-guid hack for Pale Moon
-rw-r--r--components/addons/moz.build5
-rw-r--r--components/addons/src/AddonRepository.jsm9
-rw-r--r--components/addons/src/AddonUpdateChecker.jsm12
-rw-r--r--components/addons/src/XPIProvider.jsm40
4 files changed, 60 insertions, 6 deletions
diff --git a/components/addons/moz.build b/components/addons/moz.build
index 22193c1e7..151008dff 100644
--- a/components/addons/moz.build
+++ b/components/addons/moz.build
@@ -7,6 +7,9 @@
# out of sync.
DEFINES['MOZ_EXTENSIONS_DB_SCHEMA'] = 16
+if CONFIG['MC_APP_ID']:
+ DEFINES['MC_APP_ID'] = CONFIG['MC_APP_ID']
+
# Additional debugging info is exposed in debug builds
if CONFIG['MOZ_EM_DEBUG']:
DEFINES['MOZ_EM_DEBUG'] = 1
@@ -43,7 +46,6 @@ EXTRA_PP_JS_MODULES += [
EXTRA_JS_MODULES.addons += [
'src/AddonLogging.jsm',
- 'src/AddonRepository.jsm',
'src/AddonRepository_SQLiteMigrator.jsm',
'src/Content.js',
'src/LightweightThemeImageOptimizer.jsm',
@@ -52,6 +54,7 @@ EXTRA_JS_MODULES.addons += [
]
EXTRA_PP_JS_MODULES.addons += [
+ 'src/AddonRepository.jsm',
'src/AddonUpdateChecker.jsm',
'src/XPIProvider.jsm',
'src/XPIProviderUtils.js',
diff --git a/components/addons/src/AddonRepository.jsm b/components/addons/src/AddonRepository.jsm
index 8432886b6..4569abdd1 100644
--- a/components/addons/src/AddonRepository.jsm
+++ b/components/addons/src/AddonRepository.jsm
@@ -64,6 +64,11 @@ const BLANK_DB = function() {
}
const TOOLKIT_ID = "toolkit@mozilla.org";
+
+#ifdef MC_APP_ID
+#expand const ALT_APP_ID = "__MC_APP_ID__";
+#endif
+
Cu.import("resource://gre/modules/Log.jsm");
const LOGGER_ID = "addons.repository";
@@ -1251,7 +1256,11 @@ this.AddonRepository = {
let results = [];
function isSameApplication(aAppNode) {
+#ifdef MC_APP_ID
+ if (self._getTextContent(aAppNode) == ALT_APP_ID || self._getTextContent(aAppNode) == Services.appinfo.ID) {
+#else
if (self._getTextContent(aAppNode) == Services.appinfo.ID) {
+#endif
return true;
}
return false;
diff --git a/components/addons/src/AddonUpdateChecker.jsm b/components/addons/src/AddonUpdateChecker.jsm
index b09c221a8..e2f0c2c56 100644
--- a/components/addons/src/AddonUpdateChecker.jsm
+++ b/components/addons/src/AddonUpdateChecker.jsm
@@ -26,6 +26,10 @@ const XMLURI_PARSE_ERROR = "http://www.mozilla.org/newlayout/xml/pa
const TOOLKIT_ID = "toolkit@mozilla.org";
const FIREFOX_ID = "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}";
+#ifdef MC_APP_ID
+#expand const ALT_APP_ID = "__MC_APP_ID__";
+#endif
+
const PREF_UPDATE_REQUIREBUILTINCERTS = "extensions.update.requireBuiltInCerts";
const PREF_EM_MIN_COMPAT_APP_VERSION = "extensions.minCompatibleAppVersion";
@@ -804,7 +808,11 @@ function matchesVersions(aUpdate, aAppVersion, aPlatformVersion,
let result = false;
for (let app of aUpdate.targetApplications) {
+#ifdef MC_APP_ID
+ if (ALT_APP_ID == Services.appinfo.ID || app.id == Services.appinfo.ID) {
+#else
if (app.id == Services.appinfo.ID) {
+#endif
return (Services.vc.compare(aAppVersion, app.minVersion) >= 0) &&
(aIgnoreMaxVersion || (Services.vc.compare(aAppVersion, app.maxVersion) <= 0));
}
@@ -865,7 +873,11 @@ this.AddonUpdateChecker = {
if (aIgnoreCompatibility) {
for (let targetApp of update.targetApplications) {
let id = targetApp.id;
+#ifdef MC_APP_ID
+ if (id == ALT_APP_ID || id == Services.appinfo.ID || id == TOOLKIT_ID)
+#else
if (id == Services.appinfo.ID || id == TOOLKIT_ID)
+#endif
return update;
}
}
diff --git a/components/addons/src/XPIProvider.jsm b/components/addons/src/XPIProvider.jsm
index d3948e8aa..b97edfcdb 100644
--- a/components/addons/src/XPIProvider.jsm
+++ b/components/addons/src/XPIProvider.jsm
@@ -135,6 +135,10 @@ const PREFIX_NS_EM = "http://www.mozilla.org/2004/em-rdf#";
const TOOLKIT_ID = "toolkit@mozilla.org";
+#ifdef MC_APP_ID
+#expand const ALT_APP_ID = "__MC_APP_ID__";
+#endif
+
// The value for this is in Makefile.in
#expand const DB_SCHEMA = __MOZ_EXTENSIONS_DB_SCHEMA__;
XPCOMUtils.defineConstant(this, "DB_SCHEMA", DB_SCHEMA);
@@ -6403,7 +6407,11 @@ AddonInternal.prototype = {
aPlatformVersion = Services.appinfo.greVersion;
let version;
+#ifdef MC_APP_ID
+ if (app.id == ALT_APP_ID || app.id == Services.appinfo.ID) {
+#else
if (app.id == Services.appinfo.ID) {
+#endif
version = aAppVersion;
}
else if (app.id == TOOLKIT_ID) {
@@ -6429,7 +6437,11 @@ AddonInternal.prototype = {
// Extremely old extensions should not be compatible by default.
let minCompatVersion;
- if (app.id == Services.appinfo.ID)
+#ifdef MC_APP_ID
+ if (app.id == ALT_APP_ID || app.id == Services.appinfo.ID)
+#else
+ if (app.id == Services.appinfo.ID)
+#endif
minCompatVersion = XPIProvider.minCompatibleAppVersion;
else if (app.id == TOOLKIT_ID)
minCompatVersion = XPIProvider.minCompatiblePlatformVersion;
@@ -6445,15 +6457,33 @@ AddonInternal.prototype = {
(Services.vc.compare(version, app.maxVersion) <= 0)
},
- get matchingTargetApplication() {
+ get matchingTargetApplication() {
let app = null;
+
+#ifdef MC_APP_ID
+ // We want to prefer the Pale Moon application ID
+ // over any other for the duration of this hack.
+ for (let targetApp of this.targetApplications) {
+ if (targetApp.id == ALT_APP_ID) {
+ logger.warn("getMatchingTargetApplication: Add-on " + this.defaultLocale.name +
+ " matches because Alternate Application ID " + ALT_APP_ID +
+ " is currently preferred over the Application or Toolkit's ID.");
+
+ return targetApp;
+ }
+ }
+#endif
+
for (let targetApp of this.targetApplications) {
- if (targetApp.id == Services.appinfo.ID)
+ if (targetApp.id == Services.appinfo.ID) {
return targetApp;
- if (targetApp.id == TOOLKIT_ID)
+ }
+
+ if (targetApp.id == TOOLKIT_ID) {
app = targetApp;
+ }
}
- // Return toolkit ID if toolkit.
+
return app;
},