From 08b1dd80f9511c84b5b72dbaac9321f152a27c47 Mon Sep 17 00:00:00 2001 From: "gavin%gavinsharp.com" Date: Tue, 22 Nov 2005 05:36:48 +0000 Subject: [PATCH] Bug 172817: Allow external source viewer/editor, patch by Jason Barnabe (np) , r=mconnor git-svn-id: svn://10.0.0.236/trunk@185124 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/browser/app/profile/firefox.js | 3 + mozilla/browser/base/content/browser.js | 18 +- .../browser/base/content/global-scripts.inc | 1 + .../viewsource/content/viewSourceUtils.js | 259 ++++++++++++++++++ mozilla/toolkit/components/viewsource/jar.mn | 1 + 5 files changed, 273 insertions(+), 9 deletions(-) create mode 100644 mozilla/toolkit/components/viewsource/content/viewSourceUtils.js diff --git a/mozilla/browser/app/profile/firefox.js b/mozilla/browser/app/profile/firefox.js index b0950354b1d..bdc4317735c 100644 --- a/mozilla/browser/app/profile/firefox.js +++ b/mozilla/browser/app/profile/firefox.js @@ -434,3 +434,6 @@ pref("bidi.browser.ui", false); // 1 act like PgUp/PgDown // 2 and other values, nothing pref("browser.backspace_action", 0); + +pref("view_source.editor.path", ""); +pref("view_source.editor.external", false); diff --git a/mozilla/browser/base/content/browser.js b/mozilla/browser/base/content/browser.js index 166aa94192f..6f6e966c311 100644 --- a/mozilla/browser/base/content/browser.js +++ b/mozilla/browser/base/content/browser.js @@ -1932,12 +1932,11 @@ function readFromClipboard() function BrowserViewSourceOfDocument(aDocument) { - var docCharset; var pageCookie; var webNav; // Get the document charset - docCharset = "charset=" + aDocument.characterSet; + var docCharset = "charset=" + aDocument.characterSet; // Get the nsIWebNavigation associated with the document try { @@ -1973,16 +1972,17 @@ function BrowserViewSourceOfDocument(aDocument) // If no page descriptor is available, just use the view-source URL... } - BrowserViewSourceOfURL(webNav.currentURI.spec, docCharset, pageCookie); + ViewSourceOfURL(webNav.currentURI.spec, pageCookie, aDocument); } -function BrowserViewSourceOfURL(url, charset, pageCookie) +function ViewSourceOfURL(aURL, aPageDescriptor, aDocument) { - // try to open a view-source window while inheriting the charset (if any) - openDialog("chrome://global/content/viewSource.xul", - "_blank", - "scrollbars,resizable,chrome,dialog=no", - url, charset, pageCookie); + if (getBoolPref("view_source.editor.external", false)) { + gViewSourceUtils.openInExternalEditor(aURL, aPageDescriptor, aDocument); + } + else { + gViewSourceUtils.openInInternalViewer(aURL, aPageDescriptor, aDocument); + } } // doc - document to use for source, or null for this window's document diff --git a/mozilla/browser/base/content/global-scripts.inc b/mozilla/browser/base/content/global-scripts.inc index c34cb30d152..4057e7f2eef 100644 --- a/mozilla/browser/base/content/global-scripts.inc +++ b/mozilla/browser/base/content/global-scripts.inc @@ -46,3 +46,4 @@