зеркало из https://github.com/mozilla/pjs.git
Bug 230778 Convert pref window from nsIPref to nsIPrefBranch r=caillon sr=jag
This commit is contained in:
Родитель
8a2fa7ea41
Коммит
4e628233ac
|
@ -79,7 +79,7 @@ nsPrefWindow.prototype =
|
|||
{
|
||||
try
|
||||
{
|
||||
this.pref = Components.classes["@mozilla.org/preferences;1"].getService(Components.interfaces.nsIPref);
|
||||
this.pref = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch(null);
|
||||
this.chromeRegistry = Components.classes["@mozilla.org/chrome/chrome-registry;1"].getService(Components.interfaces.nsIXULChromeRegistry);
|
||||
this.observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
|
||||
}
|
||||
|
@ -145,26 +145,25 @@ nsPrefWindow.prototype =
|
|||
getPrefIsLocked:
|
||||
function ( aPrefString )
|
||||
{
|
||||
return hPrefWindow.pref.PrefIsLocked(aPrefString);
|
||||
return this.pref.prefIsLocked(aPrefString);
|
||||
},
|
||||
getPref:
|
||||
function ( aPrefType, aPrefString, aDefaultFlag )
|
||||
function ( aPrefType, aPrefString )
|
||||
{
|
||||
var pref = hPrefWindow.pref;
|
||||
try
|
||||
{
|
||||
switch ( aPrefType )
|
||||
{
|
||||
case "bool":
|
||||
return !aDefaultFlag ? pref.GetBoolPref( aPrefString ) : pref.GetDefaultBoolPref( aPrefString );
|
||||
return this.pref.getBoolPref( aPrefString );
|
||||
case "int":
|
||||
return !aDefaultFlag ? pref.GetIntPref( aPrefString ) : pref.GetDefaultIntPref( aPrefString );
|
||||
return this.pref.getIntPref( aPrefString );
|
||||
case "localizedstring":
|
||||
return pref.getLocalizedUnicharPref( aPrefString );
|
||||
return this.pref.getComplexValue( aPrefString, Components.interfaces.nsIPrefLocalizedString ).data;
|
||||
case "color":
|
||||
case "string":
|
||||
default:
|
||||
return !aDefaultFlag ? pref.CopyUnicharPref( aPrefString ) : pref.CopyDefaultUnicharPref( aPrefString );
|
||||
return this.pref.getComplexValue( aPrefString, Components.interfaces.nsISupportsString ).data;
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
|
@ -186,16 +185,18 @@ nsPrefWindow.prototype =
|
|||
switch ( aPrefType )
|
||||
{
|
||||
case "bool":
|
||||
hPrefWindow.pref.SetBoolPref( aPrefString, aValue );
|
||||
this.pref.setBoolPref( aPrefString, aValue );
|
||||
break;
|
||||
case "int":
|
||||
hPrefWindow.pref.SetIntPref( aPrefString, aValue );
|
||||
this.pref.setIntPref( aPrefString, aValue );
|
||||
break;
|
||||
case "color":
|
||||
case "string":
|
||||
case "localizedstring":
|
||||
default:
|
||||
hPrefWindow.pref.SetUnicharPref( aPrefString, aValue );
|
||||
var supportsString = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
|
||||
supportsString.data = aValue;
|
||||
this.pref.setComplexValue( aPrefString, Components.interfaces.nsISupportsString, supportsString );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -279,7 +280,9 @@ nsPrefWindow.prototype =
|
|||
}
|
||||
try
|
||||
{
|
||||
this.pref.savePrefFile(null);
|
||||
Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefService)
|
||||
.savePrefFile(null);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
|
|
|
@ -149,7 +149,7 @@
|
|||
function sysPrefUpdate() {
|
||||
var checkObj = document.getElementById("systemPrefCheck");
|
||||
var prefstring = checkObj.getAttribute( "prefstring" );
|
||||
parent.hPrefWindow.pref.SetBoolPref(prefstring, checkObj.checked);
|
||||
parent.hPrefWindow.setPref("bool", prefstring, checkObj.checked);
|
||||
parent.hPrefWindow.pagePrefChanged = true;
|
||||
parent.hPrefWindow.pagePrefUpdated = [];
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@
|
|||
// Default to true in case the preference cannot be retrieved
|
||||
var forceAlwaysAsk = true;
|
||||
try {
|
||||
var prefService = Components.classes["@mozilla.org/preferences;1"].getService(Components.interfaces.nsIPrefService);
|
||||
var prefService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
|
||||
var prefBranch = prefService.getBranch("browser.helperApps.alwaysAsk.");
|
||||
forceAlwaysAsk = prefBranch.getBoolPref("force");
|
||||
} catch(e) {
|
||||
|
|
|
@ -89,7 +89,7 @@ const xmlSinkObserver = {
|
|||
|
||||
// Convert old "don't ask" pref info to helper app pref entries
|
||||
try {
|
||||
var prefService = Components.classes["@mozilla.org/preferences;1"].getService(Components.interfaces.nsIPrefService);
|
||||
var prefService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
|
||||
var prefBranch = prefService.getBranch("browser.helperApps.neverAsk.");
|
||||
if (!prefBranch) return;
|
||||
} catch(e) { return; }
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
//get prefInt services
|
||||
|
||||
var availCharsetDict = [];
|
||||
var prefInt = null; //Preferences Interface
|
||||
var prefBranch = null; //Preferences Interface
|
||||
var pref_string_title = "";
|
||||
var pref_string_object = null;
|
||||
var pref_string_content = "";
|
||||
|
||||
function Init()
|
||||
|
@ -12,11 +13,11 @@ function Init()
|
|||
if ("arguments" in window && window.arguments[0])
|
||||
applicationArea = window.arguments[0];
|
||||
|
||||
prefInt = Components.classes["@mozilla.org/preferences;1"];
|
||||
|
||||
if (prefInt) {
|
||||
prefInt = prefInt.getService(Components.interfaces.nsIPref);
|
||||
try {
|
||||
prefBranch = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch(null);
|
||||
} catch (e) {}
|
||||
|
||||
if (prefBranch) {
|
||||
if (applicationArea == "mailedit") {
|
||||
pref_string_title = "intl.charsetmenu.mailedit";
|
||||
} else {
|
||||
|
@ -24,7 +25,8 @@ function Init()
|
|||
pref_string_title = "intl.charsetmenu.browser.static";
|
||||
}
|
||||
|
||||
pref_string_content = prefInt.getLocalizedUnicharPref(pref_string_title);
|
||||
pref_string_object = prefBranch.getComplexValue(pref_string_title, Components.interfaces.nsIPrefLocalizedString);
|
||||
pref_string_content = pref_string_object.data;
|
||||
|
||||
AddRemoveLatin1('add');
|
||||
}
|
||||
|
@ -286,9 +288,9 @@ function Save()
|
|||
|
||||
try
|
||||
{
|
||||
if (prefInt) {
|
||||
prefInt.SetCharPref(pref_string_title, pref_string_content);
|
||||
window.close();
|
||||
if (prefBranch) {
|
||||
pref_string_object.data = pref_string_content;
|
||||
prefBranch.setComplexValue(pref_string_title, Components.interfaces.nsIPrefLocalizedString, pref_string_object);
|
||||
}
|
||||
}
|
||||
catch(ex) {
|
||||
|
|
|
@ -37,15 +37,6 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
try
|
||||
{
|
||||
var pref = Components.classes["@mozilla.org/preferences;1"].getService( Components.interfaces.nsIPref );
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
dump("failed to get font list or pref object: "+e+" in pref-fonts.js\n");
|
||||
}
|
||||
|
||||
var fontEnumerator = null;
|
||||
var globalFonts = null;
|
||||
var fontTypes = ["serif", "sans-serif", "cursive", "fantasy", "monospace"];
|
||||
|
@ -378,13 +369,13 @@ function lazyAppendFontNames( i )
|
|||
try
|
||||
{
|
||||
var fontPrefString = "font.name." + fontTypes[i] + "." + languageList.value;
|
||||
var selectVal = parent.hPrefWindow.pref.CopyUnicharPref( fontPrefString );
|
||||
var selectVal = parent.hPrefWindow.pref.getComplexValue( fontPrefString, Components.interfaces.nsISupportsString ).data;
|
||||
var dataEls = selectElement.listElement.getElementsByAttribute( "value", selectVal );
|
||||
|
||||
// we need to honor name-list in case name is unavailable
|
||||
if (!dataEls.length) {
|
||||
var fontListPrefString = "font.name-list." + fontTypes[i] + "." + languageList.value;
|
||||
var nameList = parent.hPrefWindow.pref.CopyUnicharPref( fontListPrefString );
|
||||
var nameList = parent.hPrefWindow.pref.getComplexValue( fontListPrefString, Components.interfaces.nsISupportsString ).data;
|
||||
var fontNames = nameList.split(",");
|
||||
var stripWhitespace = /^\s*(.*)\s*$/;
|
||||
|
||||
|
@ -419,7 +410,7 @@ function saveFontPrefs()
|
|||
var currValue = "";
|
||||
try
|
||||
{
|
||||
currValue = pref.CopyUnicharPref( fontPrefString );
|
||||
currValue = pref.getComplexValue( fontPrefString, Components.interfaces.nsISupportsString ).data;
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
|
@ -430,7 +421,7 @@ function saveFontPrefs()
|
|||
{
|
||||
if (dataValue)
|
||||
{
|
||||
pref.SetUnicharPref( fontPrefString, dataValue );
|
||||
parent.hPrefWindow.setPref( "string", fontPrefString, dataValue );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -441,7 +432,7 @@ function saveFontPrefs()
|
|||
try
|
||||
{
|
||||
// ClearUserPref throws an exception...
|
||||
pref.ClearUserPref( fontPrefString );
|
||||
pref.clearUserPref( fontPrefString );
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
|
@ -455,19 +446,19 @@ function saveFontPrefs()
|
|||
var currVariableSize = 12, currFixedSize = 12, minSizeVal = 0;
|
||||
try
|
||||
{
|
||||
currVariableSize = pref.GetIntPref( variableSizePref );
|
||||
currFixedSize = pref.GetIntPref( fixedSizePref );
|
||||
minSizeVal = pref.GetIntPref( minSizePref );
|
||||
currVariableSize = pref.getIntPref( variableSizePref );
|
||||
currFixedSize = pref.getIntPref( fixedSizePref );
|
||||
minSizeVal = pref.getIntPref( minSizePref );
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
}
|
||||
if( currVariableSize != dataObject.languageData[language].variableSize )
|
||||
pref.SetIntPref( variableSizePref, dataObject.languageData[language].variableSize );
|
||||
pref.setIntPref( variableSizePref, dataObject.languageData[language].variableSize );
|
||||
if( currFixedSize != dataObject.languageData[language].fixedSize )
|
||||
pref.SetIntPref( fixedSizePref, dataObject.languageData[language].fixedSize );
|
||||
pref.setIntPref( fixedSizePref, dataObject.languageData[language].fixedSize );
|
||||
if ( minSizeVal != dataObject.languageData[language].minSize ) {
|
||||
pref.SetIntPref ( minSizePref, dataObject.languageData[language].minSize );
|
||||
pref.setIntPref ( minSizePref, dataObject.languageData[language].minSize );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -478,20 +469,20 @@ function saveFontPrefs()
|
|||
|
||||
try
|
||||
{
|
||||
var currDPI = pref.GetIntPref( "browser.display.screen_resolution" );
|
||||
var currFonts = pref.GetIntPref( "browser.display.use_document_fonts" );
|
||||
var currDefault = pref.CopyUnicharPref( "font.default" );
|
||||
var currDPI = pref.getIntPref( "browser.display.screen_resolution" );
|
||||
var currFonts = pref.getIntPref( "browser.display.use_document_fonts" );
|
||||
var currDefault = pref.getComplexValue( "font.default", Components.interfaces.nsISupportsString ).data;
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
}
|
||||
if( currDPI != fontDPI )
|
||||
pref.SetIntPref( "browser.display.screen_resolution", fontDPI );
|
||||
pref.setIntPref( "browser.display.screen_resolution", fontDPI );
|
||||
if( currFonts != documentFonts )
|
||||
pref.SetIntPref( "browser.display.use_document_fonts", documentFonts );
|
||||
pref.setIntPref( "browser.display.use_document_fonts", documentFonts );
|
||||
if( currDefault != defaultFont )
|
||||
{
|
||||
pref.SetUnicharPref( "font.default", defaultFont );
|
||||
parent.hPrefWindow.setPref( "string", "font.default", defaultFont );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -562,11 +553,11 @@ function selectLanguage()
|
|||
try
|
||||
{
|
||||
var variableSizePref = "font.size.variable." + languageList.value;
|
||||
var sizeVarVal = parent.hPrefWindow.pref.GetIntPref( variableSizePref );
|
||||
var sizeVarVal = parent.hPrefWindow.pref.getIntPref( variableSizePref );
|
||||
variableSize.selectedItem = variableSize.getElementsByAttribute( "value", sizeVarVal )[0];
|
||||
|
||||
var fixedSizePref = "font.size.fixed." + languageList.value;
|
||||
var sizeFixedVal = parent.hPrefWindow.pref.GetIntPref( fixedSizePref );
|
||||
var sizeFixedVal = parent.hPrefWindow.pref.getIntPref( fixedSizePref );
|
||||
fixedSize.selectedItem = fixedSize.getElementsByAttribute( "value", sizeFixedVal )[0];
|
||||
}
|
||||
catch(e) { } // font size lists can simply default to the first entry
|
||||
|
@ -575,7 +566,7 @@ function selectLanguage()
|
|||
try
|
||||
{
|
||||
var minSizePref = "font.minimum-size." + languageList.value;
|
||||
minSizeVal = pref.GetIntPref( minSizePref );
|
||||
minSizeVal = parent.hPrefWindow.pref.getIntPref( minSizePref );
|
||||
}
|
||||
catch(e) { }
|
||||
minSizeSelect( minSizeVal );
|
||||
|
|
|
@ -34,15 +34,7 @@ function checkEngine()
|
|||
|
||||
try
|
||||
{
|
||||
var prefInt = null; //Preferences Interface
|
||||
var strDefaultSearchEngineName;
|
||||
|
||||
prefInt = Components.classes["@mozilla.org/preferences;1"];
|
||||
if (prefInt)
|
||||
{
|
||||
prefInt = prefInt.getService(Components.interfaces.nsIPref);
|
||||
strDefaultSearchEngineName = prefInt.getLocalizedUnicharPref("browser.search.defaultenginename");
|
||||
}
|
||||
var strDefaultSearchEngineName = parent.hPrefWindow.getPref("localizedstring", "browser.search.defaultenginename");
|
||||
|
||||
var engineListSelection = engineList.getElementsByAttribute( "label", strDefaultSearchEngineName );
|
||||
var selectedItem = engineListSelection.length ? engineListSelection[0] : null;
|
||||
|
|
|
@ -28,17 +28,7 @@ function moreInfo()
|
|||
var smartBrowsingURL = regionBundle.getString("smartBrowsingURL");
|
||||
if (smartBrowsingURL) {
|
||||
try {
|
||||
var prefs = Components.classes["@mozilla.org/preferences;1"];
|
||||
if (prefs) {
|
||||
prefs = prefs.getService();
|
||||
if (prefs)
|
||||
prefs = prefs.QueryInterface(Components.interfaces.nsIPref);
|
||||
}
|
||||
if (prefs) {
|
||||
var url = prefs.CopyCharPref("browser.chromeURL");
|
||||
if (url)
|
||||
browserURL = url;
|
||||
}
|
||||
browserURL = parent.hPrefWindow.getPref("string", "browser.chromeURL");
|
||||
} catch(e) {
|
||||
}
|
||||
if (browserURL == null)
|
||||
|
|
|
@ -58,14 +58,9 @@ function Startup()
|
|||
gData.loaded = true;
|
||||
parent.hPrefWindow.registerOKCallbackFunc( applySkin );
|
||||
|
||||
const kPrefSvcContractID = "@mozilla.org/preferences;1";
|
||||
const kPrefSvcIID = Components.interfaces.nsIPref;
|
||||
const kPrefSvc = Components.classes[kPrefSvcContractID].getService(kPrefSvcIID);
|
||||
|
||||
var theme = null;
|
||||
try {
|
||||
theme = kPrefSvc.getComplexValue("general.skins.selectedSkin",
|
||||
Components.interfaces.nsISupportsString).data;
|
||||
theme = parent.hPrefWindow.pref.getComplexValue("general.skins.selectedSkin", Components.interfaces.nsISupportsString).data;
|
||||
} catch (e) {
|
||||
}
|
||||
var matches;
|
||||
|
@ -101,14 +96,9 @@ function applySkin()
|
|||
if (data.name == null)
|
||||
return;
|
||||
|
||||
const kPrefSvcContractID = "@mozilla.org/preferences;1";
|
||||
const kPrefSvcIID = Components.interfaces.nsIPref;
|
||||
const kPrefSvc = Components.classes[kPrefSvcContractID].getService(kPrefSvcIID);
|
||||
|
||||
var theme = null;
|
||||
try {
|
||||
theme = kPrefSvc.getComplexValue("general.skins.selectedSkin",
|
||||
Components.interfaces.nsISupportsString).data;
|
||||
theme = parent.hPrefWindow.pref.getComplexValue("general.skins.selectedSkin", Components.interfaces.nsISupportsString).data;
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
|
@ -124,11 +114,7 @@ function applySkin()
|
|||
var inUse = reg.isSkinSelected(data.name, true);
|
||||
if (!theme && inUse == Components.interfaces.nsIChromeRegistry.FULL) return;
|
||||
|
||||
var str = Components.classes["@mozilla.org/supports-string;1"]
|
||||
.createInstance(Components.interfaces.nsISupportsString);
|
||||
str.data = data.name;
|
||||
|
||||
kPrefSvc.setComplexValue("general.skins.selectedSkin", Components.interfaces.nsISupportsString, str);
|
||||
parent.hPrefWindow.setPref("string", "general.skins.selectedSkin", data.name);
|
||||
|
||||
// shut down quicklaunch so the next launch will have the new skin
|
||||
var appShell = Components.classes['@mozilla.org/appshell/appShellService;1'].getService();
|
||||
|
@ -208,10 +194,7 @@ function themeSelect()
|
|||
// XXX - this sucks and should only be temporary.
|
||||
var selectedSkin = "";
|
||||
try {
|
||||
const kPrefSvcContractID = "@mozilla.org/preferences;1";
|
||||
const kPrefSvcIID = Components.interfaces.nsIPref;
|
||||
const kPrefSvc = Components.classes[kPrefSvcContractID].getService(kPrefSvcIID);
|
||||
selectedSkin = kPrefSvc.CopyCharPref("general.skins.selectedSkin");
|
||||
selectedSkin = parent.hPrefWindow.pref.getComplexValue("general.skins.selectedSkin", Components.interfaces.nsISupportsString).data;
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче