mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-22 23:27:30 +09:00
[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
This commit is contained in:
parent
207b454aed
commit
6ff23f2f28
2 changed files with 75 additions and 0 deletions
|
|
@ -287,6 +287,9 @@ BrowserGlue.prototype = {
|
||||||
case "profile-before-change":
|
case "profile-before-change":
|
||||||
this._onProfileShutdown();
|
this._onProfileShutdown();
|
||||||
break;
|
break;
|
||||||
|
case "profile-after-change":
|
||||||
|
this._onProfileAfterChange();
|
||||||
|
break;
|
||||||
case "browser-search-engine-modified":
|
case "browser-search-engine-modified":
|
||||||
if (data != "engine-default" && data != "engine-current") {
|
if (data != "engine-default" && data != "engine-current") {
|
||||||
break;
|
break;
|
||||||
|
|
@ -357,6 +360,7 @@ BrowserGlue.prototype = {
|
||||||
this._isPlacesShutdownObserver = true;
|
this._isPlacesShutdownObserver = true;
|
||||||
os.addObserver(this, "handle-xul-text-link", false);
|
os.addObserver(this, "handle-xul-text-link", false);
|
||||||
os.addObserver(this, "profile-before-change", 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-engine-modified", false);
|
||||||
os.addObserver(this, "browser-search-service", false);
|
os.addObserver(this, "browser-search-service", false);
|
||||||
},
|
},
|
||||||
|
|
@ -394,6 +398,7 @@ BrowserGlue.prototype = {
|
||||||
}
|
}
|
||||||
os.removeObserver(this, "handle-xul-text-link");
|
os.removeObserver(this, "handle-xul-text-link");
|
||||||
os.removeObserver(this, "profile-before-change");
|
os.removeObserver(this, "profile-before-change");
|
||||||
|
os.removeObserver(this, "profile-after-change");
|
||||||
os.removeObserver(this, "browser-search-engine-modified");
|
os.removeObserver(this, "browser-search-engine-modified");
|
||||||
try {
|
try {
|
||||||
os.removeObserver(this, "browser-search-service");
|
os.removeObserver(this, "browser-search-service");
|
||||||
|
|
@ -402,6 +407,12 @@ BrowserGlue.prototype = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// profile is available
|
||||||
|
_onProfileAfterChange: function()
|
||||||
|
{
|
||||||
|
this._copyDefaultProfileFiles();
|
||||||
|
},
|
||||||
|
|
||||||
_onAppDefaults: function() {
|
_onAppDefaults: function() {
|
||||||
// apply distribution customizations (prefs)
|
// apply distribution customizations (prefs)
|
||||||
// other customizations are applied in _finalUIStartup()
|
// other customizations are applied in _finalUIStartup()
|
||||||
|
|
@ -444,6 +455,65 @@ BrowserGlue.prototype = {
|
||||||
Services.obs.notifyObservers(null, "browser-ui-startup-complete", "");
|
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() {
|
_setUpUserAgentOverrides: function() {
|
||||||
UserAgentOverrides.init();
|
UserAgentOverrides.init();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,11 @@ MOZ_PKG_MAC_ICON=branding/disk.icns
|
||||||
MOZ_PKG_MAC_EXTRA=--symlink '/Applications:/ '
|
MOZ_PKG_MAC_EXTRA=--symlink '/Applications:/ '
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
NON_OMNIJAR_FILES = \
|
||||||
|
defaults/profile/chrome/userChrome-example.css \
|
||||||
|
defaults/profile/chrome/userContent-example.css \
|
||||||
|
$(NULL)
|
||||||
|
|
||||||
ifndef LIBXUL_SDK
|
ifndef LIBXUL_SDK
|
||||||
INSTALL_SDK = 1
|
INSTALL_SDK = 1
|
||||||
endif
|
endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue