Bug 1252831 - remove 30boxes webcal handler as both possible and default handler, r=paolo,Dolske

Differential Revision: https://phabricator.services.mozilla.com/D18073

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Gijs Kruitbosch 2019-02-08 19:04:53 +00:00
parent 52c26fbf83
commit dcea4f2a22
5 changed files with 75 additions and 10 deletions

View File

@ -2219,7 +2219,7 @@ BrowserGlue.prototype = {
_migrateUI: function BG__migrateUI() {
// Use an increasing number to keep track of the current migration state.
// Completely unrelated to the current Firefox release number.
const UI_VERSION = 78;
const UI_VERSION = 79;
const BROWSER_DOCURL = AppConstants.BROWSER_CHROME_URL;
let currentUIVersion;
@ -2588,6 +2588,12 @@ BrowserGlue.prototype = {
Services.prefs.clearUserPref("browser.search.region");
}
if (currentUIVersion < 79) {
// The handler app service will read this. We need to wait with migrating
// until the handler service has started up, so just set a pref here.
Services.prefs.setCharPref("browser.handlers.migrations", "30boxes");
}
// Update the migration version.
Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
},

View File

@ -9,10 +9,6 @@
# don't make any spelling errors here.
gecko.handlerService.defaultHandlersVersion=4
# The default set of protocol handlers for webcal:
gecko.handlerService.schemes.webcal.0.name=30 Boxes
gecko.handlerService.schemes.webcal.0.uriTemplate=https://30boxes.com/external/widget?refer=ff&url=%s
# The default set of protocol handlers for mailto:
gecko.handlerService.schemes.mailto.0.name=Yahoo! Mail
gecko.handlerService.schemes.mailto.0.uriTemplate=https://compose.mail.yahoo.com/?To=%s

View File

@ -986,7 +986,7 @@ var BrowserApp = {
},
_migrateUI: function() {
const UI_VERSION = 3;
const UI_VERSION = 4;
let currentUIVersion = Services.prefs.getIntPref("browser.migration.version", 0);
if (currentUIVersion >= UI_VERSION) {
return;
@ -1055,6 +1055,12 @@ var BrowserApp = {
}
}
if (currentUIVersion < 4) {
// The handler app service will read this. We need to wait with migrating
// until the handler service has started up, so just set a pref here.
Services.prefs.setCharPref("browser.handlers.migrations", "30boxes");
}
// Update the migration version.
Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
},

View File

@ -9,10 +9,6 @@
# don't make any spelling errors here.
gecko.handlerService.defaultHandlersVersion=3
# The default set of protocol handlers for webcal:
gecko.handlerService.schemes.webcal.0.name=30 Boxes
gecko.handlerService.schemes.webcal.0.uriTemplate=https://30boxes.com/external/widget?refer=ff&url=%s
# The default set of protocol handlers for mailto:
gecko.handlerService.schemes.mailto.0.name=Yahoo! Mail
gecko.handlerService.schemes.mailto.0.uriTemplate=https://compose.mail.yahoo.com/?To=%s

View File

@ -54,6 +54,7 @@ HandlerService.prototype = {
this.__store.ensureDataReady();
this._injectDefaultProtocolHandlersIfNeeded();
this._migrateProtocolHandlersIfNeeded();
Services.obs.notifyObservers(null, "handlersvc-store-initialized");
}
@ -146,6 +147,66 @@ HandlerService.prototype = {
}
},
/**
* Execute any migrations. Migrations are defined here for any changes or removals for
* existing handlers. Additions are still handled via the localized prefs infrastructure.
*
* This depends on the browser.handlers.migrations pref being set by migrateUI in
* nsBrowserGlue (for Fx Desktop) or similar mechanisms for other products.
* This is a comma-separated list of identifiers of migrations that need running.
* This avoids both re-running older migrations and keeping an additional
* pref around permanently.
*/
_migrateProtocolHandlersIfNeeded() {
const kMigrations = {
"30boxes": () => {
const k30BoxesRegex = /^https?:\/\/(?:www\.)?30boxes.com\/external\/widget/i;
let webcalHandler = gExternalProtocolService.getProtocolHandlerInfo("webcal");
if (this.exists(webcalHandler)) {
this.fillHandlerInfo(webcalHandler, "");
let shouldStore = false;
// First remove 30boxes from possible handlers.
let handlers = webcalHandler.possibleApplicationHandlers;
for (let i = handlers.length - 1; i >= 0; i--) {
let app = handlers.queryElementAt(i, Ci.nsIHandlerApp);
if (app instanceof Ci.nsIWebHandlerApp &&
k30BoxesRegex.test(app.uriTemplate)) {
shouldStore = true;
handlers.removeElementAt(i);
}
}
// Then remove as a preferred handler.
if (webcalHandler.preferredApplicationHandler) {
let app = webcalHandler.preferredApplicationHandler;
if (app instanceof Ci.nsIWebHandlerApp &&
k30BoxesRegex.test(app.uriTemplate)) {
webcalHandler.preferredApplicationHandler = null;
shouldStore = true;
}
}
// Then store, if we changed anything.
if (shouldStore) {
this.store(webcalHandler);
}
}
},
};
let migrationsToRun = Services.prefs.getCharPref("browser.handlers.migrations", "");
migrationsToRun = migrationsToRun ? migrationsToRun.split(",") : [];
for (let migration of migrationsToRun) {
migration.trim();
try {
kMigrations[migration]();
} catch (ex) {
Cu.reportError(ex);
}
}
if (migrationsToRun.length) {
Services.prefs.clearUserPref("browser.handlers.migrations");
}
},
_onDBChange() {
return (async () => {
if (this.__store) {