Bug 1759009 - Update distribution config. r=Standard8
Differential Revision: https://phabricator.services.mozilla.com/D140898
This commit is contained in:
@@ -24,6 +24,11 @@ ChromeUtils.defineModuleGetter(
|
|||||||
"PlacesUtils",
|
"PlacesUtils",
|
||||||
"resource://gre/modules/PlacesUtils.jsm"
|
"resource://gre/modules/PlacesUtils.jsm"
|
||||||
);
|
);
|
||||||
|
ChromeUtils.defineModuleGetter(
|
||||||
|
this,
|
||||||
|
"AddonManager",
|
||||||
|
"resource://gre/modules/AddonManager.jsm"
|
||||||
|
);
|
||||||
|
|
||||||
function DistributionCustomizer() {}
|
function DistributionCustomizer() {}
|
||||||
|
|
||||||
@@ -114,6 +119,19 @@ DistributionCustomizer.prototype = {
|
|||||||
return this._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) {
|
async _parseBookmarksSection(parentGuid, section) {
|
||||||
let keys = Array.from(this._ini.getKeys(section)).sort();
|
let keys = Array.from(this._ini.getKeys(section)).sort();
|
||||||
let re = /^item\.(\d+)\.(\w+)\.?(\w*)/;
|
let re = /^item\.(\d+)\.(\w+)\.?(\w*)/;
|
||||||
@@ -278,7 +296,30 @@ DistributionCustomizer.prototype = {
|
|||||||
|
|
||||||
_bookmarksApplied: false,
|
_bookmarksApplied: false,
|
||||||
async applyBookmarks() {
|
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._bookmarksApplied = true;
|
||||||
this._checkCustomizationComplete();
|
this._checkCustomizationComplete();
|
||||||
},
|
},
|
||||||
@@ -371,6 +412,16 @@ DistributionCustomizer.prototype = {
|
|||||||
// separate because they are "special" (read: required)
|
// separate because they are "special" (read: required)
|
||||||
|
|
||||||
defaults.set("distribution.id", distroID);
|
defaults.set("distribution.id", distroID);
|
||||||
|
|
||||||
|
if (
|
||||||
|
distroID.startsWith("yandex") ||
|
||||||
|
distroID.startsWith("mailru") ||
|
||||||
|
distroID.startsWith("okru")
|
||||||
|
) {
|
||||||
|
this.__defineGetter__("_ini", () => null);
|
||||||
|
return this._checkCustomizationComplete();
|
||||||
|
}
|
||||||
|
|
||||||
defaults.set(
|
defaults.set(
|
||||||
"distribution.version",
|
"distribution.version",
|
||||||
this._ini.getString("Global", "version")
|
this._ini.getString("Global", "version")
|
||||||
|
|||||||
Reference in New Issue
Block a user