mobile-config-autoconfig: restart Firefox on update

With the current implementation, `userChrome.css` and `userContent.css`
are effectively replaced on a package update, but the session still uses
the previous version.

Triggering a restart as soone as those files are updated ensures the
latest version will be used immediately.
This commit is contained in:
Arnaud Ferraris 2022-02-17 17:17:13 +01:00 committed by Oliver Smith
parent d661fc1666
commit fbc916b447
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB

View file

@ -9,6 +9,8 @@ const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/FileUtils.jsm");
var updated = false;
// Create <profile>/chrome/ directory if not already present
var chromeDir = Services.dirsvc.get("ProfD", Ci.nsIFile);
chromeDir.append("chrome");
@ -30,6 +32,7 @@ if (chromeFile.exists() && defaultChrome.exists() &&
// Copy userChrome.css to <profile>/chrome/
if (!chromeFile.exists()) {
defaultChrome.copyTo(chromeDir, "userChrome.css");
updated = true;
}
// Create nsIFile objects for userContent.css in <profile>/chrome/ and in /etc/
@ -46,6 +49,13 @@ if (contentFile.exists() && defaultContent.exists() &&
// Copy userContent.css to <profile>/chrome/
if (!contentFile.exists()) {
defaultContent.copyTo(chromeDir, "userContent.css");
updated = true;
}
// Restart Firefox immediately if one of the files got updated
if (updated == true) {
var appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci.nsIAppStartup);
appStartup.quit(Ci.nsIAppStartup.eForceQuit | Ci.nsIAppStartup.eRestart);
}
// Select a mobile user agent for firefox (same as tor browser on android)