Browse Source

[Pale-Moon] Copy default userChrome and userContent examples to profile

* [profile] Copy default userChrome and userContent examples to profile
* [profile] Don't package example files inside omnijar
pull/24/head
Moonchild 2 years ago committed by Roy Tam
parent
commit
6ff23f2f28
  1. 70
      application/palemoon/components/nsBrowserGlue.js
  2. 5
      application/palemoon/installer/Makefile.in

70
application/palemoon/components/nsBrowserGlue.js

@ -287,6 +287,9 @@ BrowserGlue.prototype = {
case "profile-before-change":
this._onProfileShutdown();
break;
case "profile-after-change":
this._onProfileAfterChange();
break;
case "browser-search-engine-modified":
if (data != "engine-default" && data != "engine-current") {
break;
@ -357,6 +360,7 @@ BrowserGlue.prototype = {
this._isPlacesShutdownObserver = true;
os.addObserver(this, "handle-xul-text-link", false);
os.addObserver(this, "profile-before-change", false);
os.addObserver(this, "profile-after-change", false);
os.addObserver(this, "browser-search-engine-modified", false);
os.addObserver(this, "browser-search-service", false);
},
@ -394,6 +398,7 @@ BrowserGlue.prototype = {
}
os.removeObserver(this, "handle-xul-text-link");
os.removeObserver(this, "profile-before-change");
os.removeObserver(this, "profile-after-change");
os.removeObserver(this, "browser-search-engine-modified");
try {
os.removeObserver(this, "browser-search-service");
@ -402,6 +407,12 @@ BrowserGlue.prototype = {
}
},
// profile is available
_onProfileAfterChange: function()
{
this._copyDefaultProfileFiles();
},
_onAppDefaults: function() {
// apply distribution customizations (prefs)
// other customizations are applied in _finalUIStartup()
@ -444,6 +455,65 @@ BrowserGlue.prototype = {
Services.obs.notifyObservers(null, "browser-ui-startup-complete", "");
},
// Copies additional profile files from the default profile tho the current profile.
// Only files not covered by the regular profile creation process.
// Currently only the userchrome examples.
_copyDefaultProfileFiles: function()
{
// Copy default chrome example files if they do not exist in the current profile.
var profileDir = Services.dirsvc.get("ProfD", Components.interfaces.nsILocalFile);
profileDir.append("chrome");
// The chrome directory in the current/new profile already exists so no copying.
if (profileDir.exists())
return;
let defaultProfileDir = Services.dirsvc.get("DefRt",
Components.interfaces.nsIFile);
defaultProfileDir.append("profile");
defaultProfileDir.append("chrome");
if (defaultProfileDir.exists() && defaultProfileDir.isDirectory()) {
try {
this._copyDir(defaultProfileDir, profileDir);
} catch (e) {
Components.utils.reportError(e);
}
}
},
// Simple copy function for copying complete aSource Directory to aDestiniation.
_copyDir: function(aSource, aDestination)
{
let enumerator = aSource.directoryEntries;
while (enumerator.hasMoreElements()) {
let file = enumerator.getNext().QueryInterface(Components.interfaces.nsIFile);
if (file.isDirectory()) {
let subdir = aDestination.clone();
subdir.append(file.leafName);
// Create the target directory. If it already exists continue copying files.
try {
subdir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE,
FileUtils.PERMS_DIRECTORY);
} catch (ex) {
if (ex.result != Components.results.NS_ERROR_FILE_ALREADY_EXISTS)
throw ex;
}
// Directory created. Now copy the files.
this._copyDir(file, subdir);
} else {
try {
file.copyTo(aDestination, null);
} catch (e) {
Components.utils.reportError(e);
}
}
}
},
_setUpUserAgentOverrides: function() {
UserAgentOverrides.init();

5
application/palemoon/installer/Makefile.in

@ -104,6 +104,11 @@ MOZ_PKG_MAC_ICON=branding/disk.icns
MOZ_PKG_MAC_EXTRA=--symlink '/Applications:/ '
endif
NON_OMNIJAR_FILES = \
defaults/profile/chrome/userChrome-example.css \
defaults/profile/chrome/userContent-example.css \
$(NULL)
ifndef LIBXUL_SDK
INSTALL_SDK = 1
endif

Loading…
Cancel
Save