fix for #16231, r=mscott. use the file locator (which caches the profile directory) instead of going through the profile service.

This commit is contained in:
sspitzer%netscape.com 1999-10-29 04:02:20 +00:00
Родитель 7a72b30bde
Коммит f1a3d41f84
2 изменённых файлов: 56 добавлений и 38 удалений

Просмотреть файл

@ -24,6 +24,9 @@ var rdf_uri = 'component://netscape/rdf/rdf-service'
var RDF = Components.classes[rdf_uri].getService()
RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService)
// the magic number to find panels.rdf
var PANELS_RDF_FILE = 66626;
// the default sidebar:
var sidebar = new Object;
@ -35,26 +38,32 @@ function debug(msg)
function sidebarOverlayInit()
{
// Look in the profile directory to find 'panels.rdf', which is the
try {
var fileLocatorInterface = Components.interfaces.nsIFileLocator;
var fileLocatorProgID = 'component://netscape/filelocator';
var fileLocatorService = Components.classes[fileLocatorProgID].getService();
// use the fileLocator to look in the profile directory
// to find 'panels.rdf', which is the
// database of the user's currently selected panels.
var profileInterface = Components.interfaces.nsIProfile;
var profileURI = 'component://netscape/profile/manager';
var profileService = Components.classes[profileURI].getService();
profileService = profileService.QueryInterface(profileInterface);
var sidebar_url = profileService.getCurrentProfileDirFromJS();
sidebar_url.URLString += "panels.rdf";
fileLocatorService = fileLocatorService.QueryInterface(fileLocatorInterface);
if (sidebar_url.exists()) {
debug("sidebar url is " + sidebar_url.URLString + "\n");
sidebar.db = sidebar_url.URLString;
// if <profile>/panels.rdf doesn't exist, GetFileLocation() will copy
// bin/defaults/profile/panels.rdf to <profile>/panels.rdf
var sidebar_file = fileLocatorService.GetFileLocation(PANELS_RDF_FILE);
var sidebar_url = sidebar_file.URLString;
if (!sidebar_file.exists()) {
// this should not happen, as GetFileLocation() should copy
// defaults/panels.rdf to the users profile directory
return;
}
else {
// XXX What we should _really_ do here is copy the default panels
// into the profile directory and then try again.
sidebar.db = 'chrome://sidebar/content/default-panels.rdf'
debug("using " + sidebar.db + " because " + sidebar_url.URLString + " does not exist\n");
debug("sidebar url is " + sidebar_url.URLString + "\n");
sidebar.db = sidebar_file.URLString;
}
catch (ex) {
// this should not happen
return;
}
sidebar.resource = 'urn:sidebar:current-panel-list';

Просмотреть файл

@ -24,6 +24,9 @@ var rdf_uri = 'component://netscape/rdf/rdf-service'
var RDF = Components.classes[rdf_uri].getService()
RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService)
// the magic number to find panels.rdf
var PANELS_RDF_FILE = 66626;
// the default sidebar:
var sidebar = new Object;
@ -35,26 +38,32 @@ function debug(msg)
function sidebarOverlayInit()
{
// Look in the profile directory to find 'panels.rdf', which is the
try {
var fileLocatorInterface = Components.interfaces.nsIFileLocator;
var fileLocatorProgID = 'component://netscape/filelocator';
var fileLocatorService = Components.classes[fileLocatorProgID].getService();
// use the fileLocator to look in the profile directory
// to find 'panels.rdf', which is the
// database of the user's currently selected panels.
var profileInterface = Components.interfaces.nsIProfile;
var profileURI = 'component://netscape/profile/manager';
var profileService = Components.classes[profileURI].getService();
profileService = profileService.QueryInterface(profileInterface);
var sidebar_url = profileService.getCurrentProfileDirFromJS();
sidebar_url.URLString += "panels.rdf";
fileLocatorService = fileLocatorService.QueryInterface(fileLocatorInterface);
if (sidebar_url.exists()) {
debug("sidebar url is " + sidebar_url.URLString + "\n");
sidebar.db = sidebar_url.URLString;
// if <profile>/panels.rdf doesn't exist, GetFileLocation() will copy
// bin/defaults/profile/panels.rdf to <profile>/panels.rdf
var sidebar_file = fileLocatorService.GetFileLocation(PANELS_RDF_FILE);
var sidebar_url = sidebar_file.URLString;
if (!sidebar_file.exists()) {
// this should not happen, as GetFileLocation() should copy
// defaults/panels.rdf to the users profile directory
return;
}
else {
// XXX What we should _really_ do here is copy the default panels
// into the profile directory and then try again.
sidebar.db = 'chrome://sidebar/content/default-panels.rdf'
debug("using " + sidebar.db + " because " + sidebar_url.URLString + " does not exist\n");
debug("sidebar url is " + sidebar_url.URLString + "\n");
sidebar.db = sidebar_file.URLString;
}
catch (ex) {
// this should not happen
return;
}
sidebar.resource = 'urn:sidebar:current-panel-list';