diff --git a/suite/browser/viewSource.xul b/suite/browser/viewSource.xul
index ff1488b52ee..68857a7db16 100644
--- a/suite/browser/viewSource.xul
+++ b/suite/browser/viewSource.xul
@@ -64,6 +64,9 @@
+
@@ -144,6 +147,7 @@
+
diff --git a/suite/browser/viewsource.js b/suite/browser/viewsource.js
index fe929e9245f..ebbffcb32ac 100644
--- a/suite/browser/viewsource.js
+++ b/suite/browser/viewsource.js
@@ -22,6 +22,16 @@
var gBrowser = null;
var appCore = null;
+var gPrefs = null;
+
+try {
+ var prefsService = Components.classes["@mozilla.org/preferences;1"];
+ if (prefsService)
+ prefsService = prefsService.getService();
+ if (prefsService)
+ var gPrefs = prefsService.QueryInterface(Components.interfaces.nsIPref);
+} catch (ex) {
+}
function onLoadViewSource()
{
@@ -68,6 +78,18 @@ function viewSource(url)
var loadFlags = Components.interfaces.nsIWebNavigation.LOAD_FLAGS_NONE;
var viewSrcUrl = "view-source:" + url;
getBrowser().webNavigation.loadURI(viewSrcUrl, loadFlags);
+
+ //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");
+ } catch (ex) {
+ }
+ }
+
window._content.focus();
return true;
}
@@ -84,3 +106,30 @@ function ViewSourceEditPage()
url = url.substring(12,url.length);
editPage(url,window, false);
}
+
+//function to toggle long-line wrapping and set the view_source.wrap_long_lines
+//pref to persist the last state
+function wrapLongLines()
+{
+ //get the first pre tag which surrounds the entire viewsource content
+ var myWrap = window._content.document.getElementById('viewsource');
+
+ if (myWrap.className == '')
+ myWrap.className = 'wrap';
+ 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) {
+ }
+ }
+}
diff --git a/suite/locales/en-US/chrome/browser/viewSource.dtd b/suite/locales/en-US/chrome/browser/viewSource.dtd
index 56991c2bbcd..acb4e22457b 100644
--- a/suite/locales/en-US/chrome/browser/viewSource.dtd
+++ b/suite/locales/en-US/chrome/browser/viewSource.dtd
@@ -7,3 +7,5 @@
+
+