Bug 196974: Cannot open attachments in new window or tab; p=Manuel Reimer <Manuel.Spam@nurfuerspam.de>, r=IanN, sr=neil

This commit is contained in:
mnyromyr%tprac.de 2007-02-14 21:54:40 +00:00
parent 894f0babc6
commit b4500b7756
2 changed files with 28 additions and 16 deletions

View File

@ -22,6 +22,7 @@
*
* Contributor(s):
* Karsten Düsterloh <mnyromyr@tprac.de>
* Manuel Reimer <manuel.reimer@gmx.de>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
@ -1007,11 +1008,19 @@ createNewAttachmentInfo.prototype.viewAttachment = function viewAttachment()
createNewAttachmentInfo.prototype.openAttachment = function openAttachment()
{
messenger.openAttachment(this.contentType,
this.url,
encodeURIComponent(this.displayName),
this.uri,
this.isExternalAttachment);
var webNavigationInfo =
Components.classes["@mozilla.org/webnavigation-info;1"]
.getService(Components.interfaces.nsIWebNavigationInfo);
if (webNavigationInfo.isTypeSupported(this.contentType, null))
openAsExternal(this.url);
else {
messenger.openAttachment(this.contentType,
this.url,
encodeURIComponent(this.displayName),
this.uri,
this.isExternalAttachment);
}
}
createNewAttachmentInfo.prototype.printAttachment = function printAttachment()

View File

@ -97,8 +97,9 @@ function getReferrer(doc)
function openAsExternal(aURL)
{
openNewTabWindowOrExistingWith(pref.getIntPref("browser.link.open_external"),
aURL, null, false);
var loadType = pref.getIntPref("browser.link.open_external");
var loadInBackground = pref.getBoolPref("browser.tabs.loadDivertedInBackground");
openNewTabWindowOrExistingWith(loadType, aURL, null, loadInBackground);
}
function openNewWindowWith(aURL, aDoc)
@ -108,10 +109,16 @@ function openNewWindowWith(aURL, aDoc)
function openNewTabWith(aURL, aDoc, aReverseBackgroundPref)
{
openNewTabWindowOrExistingWith(kNewTab, aURL, aDoc, aReverseBackgroundPref);
var loadInBackground = false;
if (pref) {
loadInBackground = pref.getBoolPref("browser.tabs.loadInBackground");
if (aReverseBackgroundPref)
loadInBackground = !loadInBackground;
}
openNewTabWindowOrExistingWith(kNewTab, aURL, aDoc, loadInBackground);
}
function openNewTabWindowOrExistingWith(aType, aURL, aDoc, aReverseBackgroundPref)
function openNewTabWindowOrExistingWith(aType, aURL, aDoc, aLoadInBackground)
{
// Make sure we are allowed to open this url
urlSecurityCheck(aURL, document);
@ -154,13 +161,9 @@ function openNewTabWindowOrExistingWith(aType, aURL, aDoc, aReverseBackgroundPre
}
// open link in new tab
var loadInBackground = false;
if (pref) {
loadInBackground = pref.getBoolPref("browser.tabs.loadInBackground");
if (aReverseBackgroundPref)
loadInBackground = !loadInBackground;
}
browser.addTab(aURL, referrer, originCharset, !loadInBackground);
browser.addTab(aURL, referrer, originCharset, !aLoadInBackground);
if (!aLoadInBackground)
browserWin.content.focus();
}
// Clientelle: (Make sure you don't break any of these)