Skip to content

Commit

Permalink
Bug 1833209 - Propagate recommendationState from AddonDB into activeA…
Browse files Browse the repository at this point in the history
…ddons details stored into the XPIStates. r=robwu,willdurand

Differential Revision: https://phabricator.services.mozilla.com/D179373
  • Loading branch information
rpl committed May 30, 2023
1 parent 3398162 commit de83812
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
14 changes: 6 additions & 8 deletions toolkit/components/extensions/Extension.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,12 @@ function dirname(path) {
// Returns true if the extension is owned by Mozilla (is either privileged,
// using one of the @mozilla.com/@mozilla.org protected addon id suffixes).
//
// This method throws if the extension's startupReason is not one of the expected
// ones (either ADDON_INSTALL, ADDON_UPGRADE or ADDON_DOWNGRADE).
// This method throws if the extension's startupReason is not one of the
// expected ones (either ADDON_INSTALL, ADDON_UPGRADE or ADDON_DOWNGRADE).
//
// NOTE: This methos is internally referring to "addonData.recommendationState" to
// identify a Mozilla line extension. That property is part of the addonData only when
// the extension is installed or updated, and so we enforce the expected
// startup reason values to prevent it from silently returning different results
// if called with an unexpected startupReason.
// TODO(Bug 1835787): Consider to remove the restriction based on the
// startupReason now that the recommendationState property is always
// included in the addonData with any of the startupReason.
function isMozillaExtension(extension) {
const { addonData, id, isPrivileged, startupReason } = extension;

Expand All @@ -344,7 +342,7 @@ function isMozillaExtension(extension) {

// This check is a subset of what is being checked in AddonWrapper's
// recommendationStates (states expire dates for line extensions are
// not consideredcimportant in determining that the extension is
// not considered important in determining that the extension is
// provided by mozilla, and so they are omitted here on purpose).
const isMozillaLineExtension =
addonData.recommendationState?.states?.includes("line");
Expand Down
3 changes: 3 additions & 0 deletions toolkit/mozapps/extensions/internal/XPIProvider.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ const JSON_FIELDS = Object.freeze([
"loader",
"lastModifiedTime",
"path",
"recommendationState",
"rootURI",
"runInSafeMode",
"signedState",
Expand Down Expand Up @@ -553,6 +554,7 @@ class XPIState {
lastModifiedTime: this.lastModifiedTime,
loader: this.loader,
path: this.relativePath,
recommendationState: this.recommendationState,
rootURI: this.rootURI,
runInSafeMode: this.runInSafeMode,
signedState: this.signedState,
Expand Down Expand Up @@ -656,6 +658,7 @@ class XPIState {
this.signedDate = aDBAddon.signedDate;
this.file = aDBAddon._sourceBundle;
this.rootURI = aDBAddon.rootURI;
this.recommendationState = aDBAddon.recommendationState;

if ((aUpdated || mustGetMod) && this.file) {
this.getModTime(this.file);
Expand Down

0 comments on commit de83812

Please sign in to comment.