mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-14 05:45:37 +00:00
backout 110452fddc2a (bug 738568) since it broke viewsource
This commit is contained in:
parent
20faec3a29
commit
6bae99c0d1
@ -36,8 +36,6 @@
|
||||
#
|
||||
# ***** 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;
|
||||
@ -95,11 +93,14 @@ function prefillAlertInfo()
|
||||
|
||||
function onAlertLoad()
|
||||
{
|
||||
gSlideIncrement = Services.prefs.getIntPref("alerts.slideIncrement");
|
||||
gSlideTime = Services.prefs.getIntPref("alerts.slideIncrementTime");
|
||||
gOpenTime = Services.prefs.getIntPref("alerts.totalOpenTime");
|
||||
gDisableSlideEffect = Services.prefs.getBoolPref("alerts.disableSlidingEffect");
|
||||
|
||||
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");
|
||||
|
||||
// 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
|
||||
// like "unfolding". The default packing of "start" only works for
|
||||
|
@ -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;
|
||||
const gPrefBranch = Services.prefs.getBranch(null);
|
||||
const gClipboardHelper = Components.classes[nsClipboardHelper_CONTRACTID].getService(nsIClipboardHelper);
|
||||
const gAtomService = Components.classes[nsAtomService_CONTRACTID].getService(nsIAtomService);
|
||||
|
||||
|
@ -38,10 +38,9 @@
|
||||
#
|
||||
# ***** 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;
|
||||
@ -73,6 +72,13 @@ __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,
|
||||
@ -213,14 +219,22 @@ function viewSource(url)
|
||||
|
||||
// Check the view_source.wrap_long_lines pref and set the menuitem's checked
|
||||
// attribute accordingly.
|
||||
var wraplonglinesPrefValue = Services.prefs
|
||||
.getBoolPref("view_source.wrap_long_lines");
|
||||
if (gPrefs) {
|
||||
try {
|
||||
var wraplonglinesPrefValue = gPrefs.getBoolPref("view_source.wrap_long_lines");
|
||||
|
||||
if (wraplonglinesPrefValue)
|
||||
document.getElementById("menu_wrapLongLines").setAttribute("checked", "true");
|
||||
|
||||
document.getElementById("menu_highlightSyntax").setAttribute("checked",
|
||||
Services.prefs.getBoolPref("view_source.syntax_highlight"));
|
||||
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");
|
||||
}
|
||||
|
||||
window.addEventListener("AppCommand", HandleAppCommandEvent, true);
|
||||
window.addEventListener("MozSwipeGesture", HandleSwipeGesture, true);
|
||||
@ -272,13 +286,16 @@ 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
|
||||
// use the right strings/links
|
||||
var isMalware = /e=malwareBlocked/.test(errorDoc.documentURI);
|
||||
|
||||
|
||||
if (target == errorDoc.getElementById('getMeOutButton')) {
|
||||
// Instead of loading some safe page, just close the window
|
||||
window.close();
|
||||
@ -291,7 +308,7 @@ function onClickContent(event) {
|
||||
// Get the stop badware "why is this blocked" report url,
|
||||
// append the current url, and go there.
|
||||
try {
|
||||
let reportURL = Services.urlFormatter.formatURLPref("browser.safebrowsing.malware.reportURL", true);
|
||||
let reportURL = formatter.formatURLPref("browser.safebrowsing.malware.reportURL", true);
|
||||
reportURL += errorDoc.location.href.slice(12);
|
||||
openURL(reportURL);
|
||||
} catch (e) {
|
||||
@ -299,7 +316,7 @@ function onClickContent(event) {
|
||||
}
|
||||
} else { // It's a phishing site, not malware
|
||||
try {
|
||||
var infoURL = Services.urlFormatter.formatURLPref("browser.safebrowsing.warning.infoURL", true);
|
||||
var infoURL = formatter.formatURLPref("browser.safebrowsing.warning.infoURL", true);
|
||||
openURL(infoURL);
|
||||
} catch (e) {
|
||||
Components.utils.reportError("Couldn't get phishing info URL: " + e);
|
||||
@ -405,9 +422,12 @@ function getWebNavigation()
|
||||
|
||||
function ViewSourceGoToLine()
|
||||
{
|
||||
var promptService = Cc["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(Ci.nsIPromptService);
|
||||
|
||||
var input = {value:gLastLineFound};
|
||||
for (;;) {
|
||||
var ok = Services.prompt.prompt(
|
||||
var ok = promptService.prompt(
|
||||
window,
|
||||
gViewSourceBundle.getString("goToLineTitle"),
|
||||
gViewSourceBundle.getString("goToLineText"),
|
||||
@ -421,9 +441,9 @@ function ViewSourceGoToLine()
|
||||
var line = parseInt(input.value, 10);
|
||||
|
||||
if (!(line > 0)) {
|
||||
Services.prompt.alert(window,
|
||||
gViewSourceBundle.getString("invalidInputTitle"),
|
||||
gViewSourceBundle.getString("invalidInputText"));
|
||||
promptService.alert(window,
|
||||
gViewSourceBundle.getString("invalidInputTitle"),
|
||||
gViewSourceBundle.getString("invalidInputText"));
|
||||
|
||||
continue;
|
||||
}
|
||||
@ -433,9 +453,9 @@ function ViewSourceGoToLine()
|
||||
if (found)
|
||||
break;
|
||||
|
||||
Services.prompt.alert(window,
|
||||
gViewSourceBundle.getString("outOfRangeTitle"),
|
||||
gViewSourceBundle.getString("outOfRangeText"));
|
||||
promptService.alert(window,
|
||||
gViewSourceBundle.getString("outOfRangeTitle"),
|
||||
gViewSourceBundle.getString("outOfRangeText"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -663,13 +683,22 @@ 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.
|
||||
Services.prefs.setBoolPref("view_source.wrap_long_lines", 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) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Toggles syntax highlighting and sets the view_source.syntax_highlight
|
||||
@ -678,7 +707,7 @@ function highlightSyntax()
|
||||
{
|
||||
var highlightSyntaxMenu = document.getElementById("menu_highlightSyntax");
|
||||
var highlightSyntax = (highlightSyntaxMenu.getAttribute("checked") == "true");
|
||||
Services.prefs.setBoolPref("view_source.syntax_highlight", highlightSyntax);
|
||||
gPrefs.setBoolPref("view_source.syntax_highlight", highlightSyntax);
|
||||
|
||||
gPageLoader.loadPage(gPageLoader.currentDescriptor, gPageLoader.DISPLAY_NORMAL);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user