Skip to content

Commit

Permalink
Bug 1773762 - Add ifdefs to allow Thunderbird builds to use mozAddonM…
Browse files Browse the repository at this point in the history
…anager. r=mixedpuppy

Differential Revision: https://phabricator.services.mozilla.com/D149340
  • Loading branch information
jfx2006 committed Jun 17, 2022
1 parent 231612f commit 8100334
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions toolkit/mozapps/extensions/AddonManagerWebAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@
namespace mozilla {
using namespace mozilla::dom;

#ifndef MOZ_THUNDERBIRD
# define MOZ_AMO_HOSTNAME "addons.mozilla.org"
# define MOZ_AMO_STAGE_HOSTNAME "addons.allizom.org"
# define MOZ_AMO_DEV_HOSTNAME "addons-dev.allizom.org"
#else
# define MOZ_AMO_HOSTNAME "addons.thunderbird.net"
# define MOZ_AMO_STAGE_HOSTNAME "addons-stage.thunderbird.net"
# undef MOZ_AMO_DEV_HOSTNAME
#endif

static bool IsValidHost(const nsACString& host) {
// This hidden pref allows users to disable mozAddonManager entirely if they
// want for fingerprinting resistance. Someone like Tor browser will use this
Expand All @@ -29,14 +39,16 @@ static bool IsValidHost(const nsACString& host) {
return false;
}

if (host.EqualsLiteral("addons.mozilla.org")) {
if (host.EqualsLiteral(MOZ_AMO_HOSTNAME)) {
return true;
}

// When testing allow access to the developer sites.
if (Preferences::GetBool("extensions.webapi.testing", false)) {
if (host.LowerCaseEqualsLiteral("addons.allizom.org") ||
host.LowerCaseEqualsLiteral("addons-dev.allizom.org") ||
if (host.LowerCaseEqualsLiteral(MOZ_AMO_STAGE_HOSTNAME) ||
#ifdef MOZ_AMO_DEV_HOSTNAME
host.LowerCaseEqualsLiteral(MOZ_AMO_DEV_HOSTNAME) ||
#endif
host.LowerCaseEqualsLiteral("example.com")) {
return true;
}
Expand Down

0 comments on commit 8100334

Please sign in to comment.