| author | Mike Kaply <mozilla@kaply.com> |
| Mon, 14 Mar 2022 10:52:39 +0000 | |
| changeset 610511 | a03a9c72d1db3716adffc6968cfb6eb43c6fcd74 |
| parent 610510 | bca5d94b7a90612a71eb8f06ee94ce1301cfacf3 |
| child 610512 | ee9b7007dd66e70cf8ae9b6ab7e48fa8a80dee2b |
| push id | 39417 |
| push user | imoraru@mozilla.com |
| push date | Mon, 14 Mar 2022 21:49:02 +0000 |
| treeherder | mozilla-central@b38ec693c713 [default view] [failures only] |
| perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
| reviewers | Standard8 |
| bugs | 1759009 |
| milestone | 100.0a1 |
| first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
| last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/browser/components/distribution.js +++ b/browser/components/distribution.js @@ -19,16 +19,21 @@ ChromeUtils.defineModuleGetter( "Preferences", "resource://gre/modules/Preferences.jsm" ); ChromeUtils.defineModuleGetter( this, "PlacesUtils", "resource://gre/modules/PlacesUtils.jsm" ); +ChromeUtils.defineModuleGetter( + this, + "AddonManager", + "resource://gre/modules/AddonManager.jsm" +); function DistributionCustomizer() {} DistributionCustomizer.prototype = { // These prefixes must only contain characters // allowed by PlacesUtils.isValidGuid BOOKMARK_GUID_PREFIX: "DstB-", FOLDER_GUID_PREFIX: "DstF-", @@ -109,16 +114,29 @@ DistributionCustomizer.prototype = { }, get _language() { let language = this._locale.split("-")[0]; this.__defineGetter__("_language", () => language); return this._language; }, + async _removeDistributionBookmarks() { + await PlacesUtils.bookmarks.fetch( + { guidPrefix: this.BOOKMARK_GUID_PREFIX }, + bookmark => PlacesUtils.bookmarks.remove(bookmark).catch() + ); + await PlacesUtils.bookmarks.fetch( + { guidPrefix: this.FOLDER_GUID_PREFIX }, + folder => { + PlacesUtils.bookmarks.remove(folder).catch(); + } + ); + }, + async _parseBookmarksSection(parentGuid, section) { let keys = Array.from(this._ini.getKeys(section)).sort(); let re = /^item\.(\d+)\.(\w+)\.?(\w*)/; let items = {}; let defaultIndex = -1; let maxIndex = -1; for (let key of keys) { @@ -273,17 +291,40 @@ DistributionCustomizer.prototype = { if (!this._prefDefaultsApplied) { this.applyPrefDefaults(); } }, _bookmarksApplied: false, async applyBookmarks() { - await this._doApplyBookmarks(); + let prefs = Services.prefs + .getChildList("distribution.yandex") + .concat(Services.prefs.getChildList("distribution.mailru")) + .concat(Services.prefs.getChildList("distribution.okru")); + if (prefs.length) { + let extensionIDs = [ + "sovetnik-yandex@yandex.ru", + "vb@yandex.ru", + "ntp-mail@corp.mail.ru", + "ntp-okru@corp.mail.ru", + ]; + for (let extensionID of extensionIDs) { + let addon = await AddonManager.getAddonByID(extensionID); + if (addon) { + await addon.disable(); + } + } + for (let pref of prefs) { + Services.prefs.clearUserPref(pref); + } + await this._removeDistributionBookmarks(); + } else { + await this._doApplyBookmarks(); + } this._bookmarksApplied = true; this._checkCustomizationComplete(); }, async _doApplyBookmarks() { if (!this._ini) { return; } @@ -366,16 +407,26 @@ DistributionCustomizer.prototype = { } let defaults = new Preferences({ defaultBranch: true }); // Global really contains info we set as prefs. They're only // separate because they are "special" (read: required) defaults.set("distribution.id", distroID); + + if ( + distroID.startsWith("yandex") || + distroID.startsWith("mailru") || + distroID.startsWith("okru") + ) { + this.__defineGetter__("_ini", () => null); + return this._checkCustomizationComplete(); + } + defaults.set( "distribution.version", this._ini.getString("Global", "version") ); let partnerAbout; try { if (globalPrefs["about." + this._locale]) {