зеркало из https://github.com/mozilla/gecko-dev.git
Bug 738568 - remove Services.prefs.getBranch(null) occurences. r=gavin
This commit is contained in:
Родитель
bf6be5e14a
Коммит
d2a90f50d5
|
@ -36,6 +36,8 @@
|
|||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
// Copied from nsILookAndFeel.h, see comments on eMetric_AlertNotificationOrigin
|
||||
const NS_ALERT_HORIZONTAL = 1;
|
||||
const NS_ALERT_LEFT = 2;
|
||||
|
@ -93,13 +95,10 @@ function prefillAlertInfo()
|
|||
|
||||
function onAlertLoad()
|
||||
{
|
||||
var prefService = Components.classes["@mozilla.org/preferences-service;1"].getService();
|
||||
prefService = prefService.QueryInterface(Components.interfaces.nsIPrefService);
|
||||
var prefBranch = prefService.getBranch(null);
|
||||
gSlideIncrement = prefBranch.getIntPref("alerts.slideIncrement");
|
||||
gSlideTime = prefBranch.getIntPref("alerts.slideIncrementTime");
|
||||
gOpenTime = prefBranch.getIntPref("alerts.totalOpenTime");
|
||||
gDisableSlideEffect = prefBranch.getBoolPref("alerts.disableSlidingEffect");
|
||||
gSlideIncrement = Services.prefs.getIntPref("alerts.slideIncrement");
|
||||
gSlideTime = Services.prefs.getIntPref("alerts.slideIncrementTime");
|
||||
gOpenTime = Services.prefs.getIntPref("alerts.totalOpenTime");
|
||||
gDisableSlideEffect = Services.prefs.getBoolPref("alerts.disableSlidingEffect");
|
||||
|
||||
// Make sure that the contents are fixed at the window edge facing the
|
||||
// screen's center so that the window looks like "sliding in" and not
|
||||
|
|
|
@ -52,7 +52,7 @@ const nsPrefService_CONTRACTID = "@mozilla.org/preferences-service;1";
|
|||
const nsClipboardHelper_CONTRACTID = "@mozilla.org/widget/clipboardhelper;1";
|
||||
const nsAtomService_CONTRACTID = "@mozilla.org/atom-service;1";
|
||||
|
||||
const gPrefBranch = Services.prefs.getBranch(null);
|
||||
const gPrefBranch = Services.prefs;
|
||||
const gClipboardHelper = Components.classes[nsClipboardHelper_CONTRACTID].getService(nsIClipboardHelper);
|
||||
const gAtomService = Components.classes[nsAtomService_CONTRACTID].getService(nsIAtomService);
|
||||
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var gDebug = 0;
|
||||
var gLineCount = 0;
|
||||
var gStartTargetLine = 0;
|
||||
|
@ -59,22 +61,13 @@ const MARK_SELECTION_END = '\u200B\u200B\u200B\u200B\u200B';
|
|||
|
||||
function onLoadViewPartialSource()
|
||||
{
|
||||
// check the view_source.wrap_long_lines pref and set the menuitem's checked attribute accordingly
|
||||
if (gPrefs) {
|
||||
try {
|
||||
var wraplonglinesPrefValue = gPrefs.getBoolPref('view_source.wrap_long_lines');
|
||||
if (wraplonglinesPrefValue) {
|
||||
document.getElementById('menu_wrapLongLines').setAttribute('checked', 'true');
|
||||
gWrapLongLines = true;
|
||||
}
|
||||
} catch (e) { }
|
||||
try {
|
||||
document.getElementById("menu_highlightSyntax").setAttribute("checked", gPrefs.getBoolPref("view_source.syntax_highlight"));
|
||||
} catch (e) {
|
||||
}
|
||||
} else {
|
||||
document.getElementById("menu_highlightSyntax").setAttribute("hidden", "true");
|
||||
}
|
||||
// check the view_source.wrap_long_lines pref
|
||||
// and set the menuitem's checked attribute accordingly
|
||||
gWrapLongLines = Services.prefs.getBoolPref("view_source.wrap_long_lines");
|
||||
document.getElementById("menu_wrapLongLines").setAttribute("checked", gWrapLongLines);
|
||||
document.getElementById("menu_highlightSyntax")
|
||||
.setAttribute("checked",
|
||||
Services.prefs.getBoolPref("view_source.syntax_highlight"));
|
||||
|
||||
if (window.arguments[3] == 'selection')
|
||||
viewPartialSourceForSelection(window.arguments[2]);
|
||||
|
|
|
@ -38,9 +38,10 @@
|
|||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
var gPrefs = null;
|
||||
|
||||
var gLastLineFound = '';
|
||||
var gGoToLine = 0;
|
||||
|
@ -72,13 +73,6 @@ __defineGetter__("gPageLoader", function () {
|
|||
return this.gPageLoader = webnav.QueryInterface(Ci.nsIWebPageDescriptor);
|
||||
});
|
||||
|
||||
try {
|
||||
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefService);
|
||||
gPrefs = prefService.getBranch(null);
|
||||
} catch (ex) {
|
||||
}
|
||||
|
||||
var gSelectionListener = {
|
||||
timeout: 0,
|
||||
attached: false,
|
||||
|
@ -219,22 +213,14 @@ function viewSource(url)
|
|||
|
||||
// Check the view_source.wrap_long_lines pref and set the menuitem's checked
|
||||
// attribute accordingly.
|
||||
if (gPrefs) {
|
||||
try {
|
||||
var wraplonglinesPrefValue = gPrefs.getBoolPref("view_source.wrap_long_lines");
|
||||
var wraplonglinesPrefValue = Services.prefs.getBoolPref("view_source.wrap_long_lines");
|
||||
|
||||
if (wraplonglinesPrefValue)
|
||||
document.getElementById("menu_wrapLongLines").setAttribute("checked", "true");
|
||||
} catch (ex) {
|
||||
}
|
||||
try {
|
||||
document.getElementById("menu_highlightSyntax").setAttribute("checked",
|
||||
gPrefs.getBoolPref("view_source.syntax_highlight"));
|
||||
} catch (ex) {
|
||||
}
|
||||
} else {
|
||||
document.getElementById("menu_highlightSyntax").setAttribute("hidden", "true");
|
||||
}
|
||||
|
||||
document.getElementById("menu_highlightSyntax")
|
||||
.setAttribute("checked",
|
||||
Services.prefs.getBoolPref("view_source.syntax_highlight"));
|
||||
|
||||
window.addEventListener("AppCommand", HandleAppCommandEvent, true);
|
||||
window.addEventListener("MozSwipeGesture", HandleSwipeGesture, true);
|
||||
|
@ -287,9 +273,6 @@ function onClickContent(event) {
|
|||
var target = event.originalTarget;
|
||||
var errorDoc = target.ownerDocument;
|
||||
|
||||
var formatter = Cc["@mozilla.org/toolkit/URLFormatterService;1"]
|
||||
.getService(Ci.nsIURLFormatter);
|
||||
|
||||
if (/^about:blocked/.test(errorDoc.documentURI)) {
|
||||
// The event came from a button on a malware/phishing block page
|
||||
// First check whether it's malware or phishing, so that we can
|
||||
|
@ -308,7 +291,7 @@ function onClickContent(event) {
|
|||
// Get the stop badware "why is this blocked" report url,
|
||||
// append the current url, and go there.
|
||||
try {
|
||||
let reportURL = formatter.formatURLPref("browser.safebrowsing.malware.reportURL", true);
|
||||
let reportURL = Services.urlFormatter.formatURLPref("browser.safebrowsing.malware.reportURL", true);
|
||||
reportURL += errorDoc.location.href.slice(12);
|
||||
openURL(reportURL);
|
||||
} catch (e) {
|
||||
|
@ -316,7 +299,7 @@ function onClickContent(event) {
|
|||
}
|
||||
} else { // It's a phishing site, not malware
|
||||
try {
|
||||
var infoURL = formatter.formatURLPref("browser.safebrowsing.warning.infoURL", true);
|
||||
var infoURL = Services.urlFormatter.formatURLPref("browser.safebrowsing.warning.infoURL", true);
|
||||
openURL(infoURL);
|
||||
} catch (e) {
|
||||
Components.utils.reportError("Couldn't get phishing info URL: " + e);
|
||||
|
@ -422,12 +405,9 @@ function getWebNavigation()
|
|||
|
||||
function ViewSourceGoToLine()
|
||||
{
|
||||
var promptService = Cc["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(Ci.nsIPromptService);
|
||||
|
||||
var input = {value:gLastLineFound};
|
||||
for (;;) {
|
||||
var ok = promptService.prompt(
|
||||
var ok = Services.prompt.prompt(
|
||||
window,
|
||||
gViewSourceBundle.getString("goToLineTitle"),
|
||||
gViewSourceBundle.getString("goToLineText"),
|
||||
|
@ -441,7 +421,7 @@ function ViewSourceGoToLine()
|
|||
var line = parseInt(input.value, 10);
|
||||
|
||||
if (!(line > 0)) {
|
||||
promptService.alert(window,
|
||||
Services.prompt.alert(window,
|
||||
gViewSourceBundle.getString("invalidInputTitle"),
|
||||
gViewSourceBundle.getString("invalidInputText"));
|
||||
|
||||
|
@ -453,7 +433,7 @@ function ViewSourceGoToLine()
|
|||
if (found)
|
||||
break;
|
||||
|
||||
promptService.alert(window,
|
||||
Services.prompt.alert(window,
|
||||
gViewSourceBundle.getString("outOfRangeTitle"),
|
||||
gViewSourceBundle.getString("outOfRangeText"));
|
||||
}
|
||||
|
@ -683,22 +663,13 @@ function wrapLongLines()
|
|||
|
||||
if (myWrap.className == '')
|
||||
myWrap.className = 'wrap';
|
||||
else myWrap.className = '';
|
||||
else
|
||||
myWrap.className = '';
|
||||
|
||||
// Since multiple viewsource windows are possible, another window could have
|
||||
// affected the pref, so instead of determining the new pref value via the current
|
||||
// pref value, we use myWrap.className.
|
||||
if (gPrefs) {
|
||||
try {
|
||||
if (myWrap.className == '') {
|
||||
gPrefs.setBoolPref("view_source.wrap_long_lines", false);
|
||||
}
|
||||
else {
|
||||
gPrefs.setBoolPref("view_source.wrap_long_lines", true);
|
||||
}
|
||||
} catch (ex) {
|
||||
}
|
||||
}
|
||||
Services.prefs.setBoolPref("view_source.wrap_long_lines", myWrap.className != '');
|
||||
}
|
||||
|
||||
// Toggles syntax highlighting and sets the view_source.syntax_highlight
|
||||
|
@ -707,7 +678,7 @@ function highlightSyntax()
|
|||
{
|
||||
var highlightSyntaxMenu = document.getElementById("menu_highlightSyntax");
|
||||
var highlightSyntax = (highlightSyntaxMenu.getAttribute("checked") == "true");
|
||||
gPrefs.setBoolPref("view_source.syntax_highlight", highlightSyntax);
|
||||
Services.prefs.setBoolPref("view_source.syntax_highlight", highlightSyntax);
|
||||
|
||||
gPageLoader.loadPage(gPageLoader.currentDescriptor, gPageLoader.DISPLAY_NORMAL);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче