зеркало из https://github.com/mozilla/pjs.git
Bug #216133 --> port thunderbird changes for the new content policy manager from the branch to the trunk.
This commit is contained in:
Родитель
d9af05efc3
Коммит
764b6162b9
|
@ -108,6 +108,8 @@ pref("mailnews.hints_and_tips.url","chrome://messenger-region/locale/region.prop
|
|||
pref("compose.throbber.url","chrome://messenger-region/locale/region.properties");
|
||||
pref("addressbook.throbber.url","chrome://messenger-region/locale/region.properties");
|
||||
|
||||
pref("network.image.imageBehavior", 2);
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// End seamonkey suite mailnews.js pref overrides
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -459,6 +459,7 @@ function loadStartPage() {
|
|||
try {
|
||||
// collapse the junk bar
|
||||
SetUpJunkBar(null);
|
||||
SetUpRemoteContentBar(null);
|
||||
|
||||
var startpageenabled = pref.getBoolPref("mailnews.start_page.enabled");
|
||||
|
||||
|
|
|
@ -34,6 +34,14 @@ const kClassicMailLayout = 0;
|
|||
const kWideMailLayout = 1;
|
||||
const kVerticalMailLayout = 2;
|
||||
|
||||
// Per message headder flags to keep track of whether the user is allowing remote
|
||||
// content for a particular message.
|
||||
// if you change or add more values to these constants, be sure to modify
|
||||
// the corresponding definitions in nsMsgContentPolicy.cpp
|
||||
const kNoRemoteContentPolicy = 0;
|
||||
const kBlockRemoteContent = 1;
|
||||
const kAllowRemoteContent = 2;
|
||||
|
||||
var gMessengerBundle;
|
||||
var gPromptService;
|
||||
var gOfflinePromptsBundle;
|
||||
|
@ -2048,6 +2056,41 @@ function SetUpJunkBar(aMsgHdr)
|
|||
return (isJunk && isAlreadyCollapsed) || (!isJunk && !isAlreadyCollapsed);
|
||||
}
|
||||
|
||||
// hides or shows the remote content bar based on the property in the msg hdr
|
||||
function SetUpRemoteContentBar(aMsgHdr)
|
||||
{
|
||||
var showRemoteContentBar = false;
|
||||
if (aMsgHdr && aMsgHdr.getUint32Property("remoteContentPolicy") == kBlockRemoteContent)
|
||||
showRemoteContentBar = true;
|
||||
|
||||
var remoteContentBar = document.getElementById("remoteContentBar");
|
||||
|
||||
if (showRemoteContentBar)
|
||||
remoteContentBar.removeAttribute("collapsed");
|
||||
else
|
||||
remoteContentBar.setAttribute("collapsed","true");
|
||||
}
|
||||
|
||||
function LoadMsgWithRemoteContent()
|
||||
{
|
||||
// we want to get the msg hdr for the currently selected message
|
||||
// change the "remoteContentBar" property on it
|
||||
// then reload the message
|
||||
|
||||
var msgURI = GetLoadedMessage();
|
||||
var msgHdr = null;
|
||||
|
||||
if (msgURI && !(/type=x-message-display/.test(msgURI)))
|
||||
{
|
||||
msgHdr = messenger.messageServiceFromURI(msgURI).messageURIToMsgHdr(msgURI);
|
||||
if (msgHdr)
|
||||
{
|
||||
msgHdr.setUint32Property("remoteContentPolicy", kAllowRemoteContent);
|
||||
MsgReload();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function MarkCurrentMessageAsRead()
|
||||
{
|
||||
gDBView.doCommand(nsMsgViewCommandType.markMessagesRead);
|
||||
|
@ -2082,13 +2125,10 @@ function OnMsgLoaded(aUrl)
|
|||
if (!folder || !msgURI)
|
||||
return;
|
||||
|
||||
if (/type=x-message-display/.test(msgURI))
|
||||
SetUpJunkBar(null);
|
||||
else
|
||||
{
|
||||
if (!(/type=x-message-display/.test(msgURI)))
|
||||
msgHdr = messenger.messageServiceFromURI(msgURI).messageURIToMsgHdr(msgURI);
|
||||
SetUpJunkBar(msgHdr);
|
||||
}
|
||||
|
||||
SetUpJunkBar(msgHdr);
|
||||
|
||||
// we just finished loading a message. set a timer to actually mark the message is read after n seconds
|
||||
// where n can be configured by the user.
|
||||
|
|
|
@ -1837,6 +1837,13 @@
|
|||
<button label="¬JunkButton.label;" oncommand="JunkSelectedMessages(false)"/>
|
||||
</hbox>
|
||||
|
||||
<hbox id="remoteContentBar" collapsed="true" align="center">
|
||||
<image id="remoteContentImage"/>
|
||||
<label id="remoteContentMessage" value="&remoteContenMessage.label;"/>
|
||||
<spacer flex="1"/>
|
||||
<button label="&loadRemoteContentButton.label;" oncommand="LoadMsgWithRemoteContent()"/>
|
||||
</hbox>
|
||||
|
||||
<statusbar class="chromeclass-status" id="status-bar">
|
||||
<hbox insertbefore="unreadMessageCount" flex="1">
|
||||
<statusbarpanel id="statusText" label="&statusText.label;" flex="1"/>
|
||||
|
|
|
@ -132,6 +132,7 @@
|
|||
ondragexit="nsDragAndDrop.dragExit(event, messagepaneObserver);">
|
||||
|
||||
<hbox id="junkBar"/>
|
||||
<hbox id="remoteContentBar"/>
|
||||
|
||||
<hbox id="msgHeaderView"/>
|
||||
|
||||
|
|
|
@ -365,6 +365,7 @@
|
|||
|
||||
<vbox id="messagepanebox" flex="1" minheight="100" height="200" minwidth="100" width="200" persist="collapsed height width">
|
||||
<hbox id="junkBar"/>
|
||||
<hbox id="remoteContentBar"/>
|
||||
<hbox id="msgHeaderView"/>
|
||||
<browser id="messagepane" context="messagePaneContext" autofind="false"
|
||||
minheight="1" flex="1" name="messagepane"
|
||||
|
|
|
@ -306,6 +306,7 @@ var messageHeaderSink = {
|
|||
gBuildAttachmentPopupForCurrentMsg = true;
|
||||
ClearAttachmentList();
|
||||
ClearEditMessageButton();
|
||||
SetUpRemoteContentBar(null);
|
||||
|
||||
for (index in gMessageListeners)
|
||||
gMessageListeners[index].onStartHeaders();
|
||||
|
@ -436,6 +437,11 @@ var messageHeaderSink = {
|
|||
{
|
||||
OnMsgLoaded(url);
|
||||
},
|
||||
onMsgHasRemoteContent: function(aMsgHdr)
|
||||
{
|
||||
dump('entering on msg has remote content\n\n');
|
||||
SetUpRemoteContentBar(aMsgHdr);
|
||||
},
|
||||
|
||||
mSecurityInfo : null,
|
||||
getSecurityInfo: function()
|
||||
|
@ -892,7 +898,13 @@ function AddExtraAddressProcessing(emailAddress, addressNode)
|
|||
var displayName = addressNode.getTextAttribute("displayName");
|
||||
var emailAddress = addressNode.getTextAttribute("emailAddress");
|
||||
|
||||
if (gShowCondensedEmailAddresses && displayName && useDisplayNameForAddress(emailAddress))
|
||||
// always show the address for the from and reply-to fields
|
||||
var parentElementId = addressNode.parentNode.id;
|
||||
var condenseName = true;
|
||||
if (parentElementId == "expandedfromBox" || parentElementId == "expandedreply-toBox")
|
||||
condenseName = false;
|
||||
|
||||
if (condenseName && gShowCondensedEmailAddresses && displayName && useDisplayNameForAddress(emailAddress))
|
||||
{
|
||||
addressNode.setAttribute('label', displayName);
|
||||
addressNode.setAttribute("tooltiptext", emailAddress);
|
||||
|
|
|
@ -1205,6 +1205,7 @@ function ClearMessagePane()
|
|||
|
||||
// hide the junk bar
|
||||
SetUpJunkBar(null);
|
||||
SetUpRemoteContentBar(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -584,6 +584,10 @@
|
|||
<!ENTITY notJunkButton.label "This is Not Junk">
|
||||
<!ENTITY junkInfoButton.label "?">
|
||||
|
||||
<!-- Remote Content Bar -->
|
||||
<!ENTITY remoteContenMessage.label "To protect your privacy, &brandShortName; has blocked remote images in this message." >
|
||||
<!ENTITY loadRemoteContentButton.label "Show Images">
|
||||
|
||||
<!-- Search Bar -->
|
||||
<!ENTITY quickSearchCmd.key "k">
|
||||
|
||||
|
|
|
@ -414,6 +414,10 @@ var messageHeaderSink = {
|
|||
{
|
||||
OnMsgLoaded(url);
|
||||
},
|
||||
|
||||
onMsgHasRemoteContent: function(aMsgHdr)
|
||||
{
|
||||
},
|
||||
|
||||
mSecurityInfo : null,
|
||||
getSecurityInfo: function()
|
||||
|
|
|
@ -47,9 +47,24 @@
|
|||
#include "nsString.h"
|
||||
#include "nsIContentPolicy.h"
|
||||
|
||||
#include "nsIMsgMailNewsUrl.h"
|
||||
#include "nsIMsgWindow.h"
|
||||
#include "nsIMimeMiscStatus.h"
|
||||
#include "nsIMsgMessageService.h"
|
||||
#include "nsIMsgHdr.h"
|
||||
#include "nsMsgUtils.h"
|
||||
|
||||
static const char kBlockRemoteImages[] = "mailnews.message_display.disable_remote_image";
|
||||
static const char kAllowPlugins[] = "mailnews.message_display.allow.plugins";
|
||||
|
||||
// Per message headder flags to keep track of whether the user is allowing remote
|
||||
// content for a particular message.
|
||||
// if you change or add more values to these constants, be sure to modify
|
||||
// the corresponding definitions in mailWindowOverlay.js
|
||||
#define kNoRemoteContentPolicy 0
|
||||
#define kBlockRemoteContent 1
|
||||
#define kAllowRemoteContent 2
|
||||
|
||||
NS_IMPL_ADDREF(nsMsgContentPolicy)
|
||||
NS_IMPL_RELEASE(nsMsgContentPolicy)
|
||||
|
||||
|
@ -149,6 +164,53 @@ nsMsgContentPolicy::ShouldLoad(PRUint32 aContentType,
|
|||
// check the 'disable remote images pref' and block the image if appropriate
|
||||
*aDecision = mBlockRemoteImages ? nsIContentPolicy::REJECT_REQUEST :
|
||||
nsIContentPolicy::ACCEPT;
|
||||
|
||||
// get the msg hdr for the message URI we are actually loading
|
||||
NS_ENSURE_TRUE(aRequestingLocation, NS_OK);
|
||||
nsCOMPtr<nsIMsgMessageUrl> msgUrl = do_QueryInterface(aRequestingLocation, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsXPIDLCString resourceURI;
|
||||
msgUrl->GetUri(getter_Copies(resourceURI));
|
||||
|
||||
// now get the msg service for this URI
|
||||
nsCOMPtr<nsIMsgMessageService> msgService;
|
||||
|
||||
rv = GetMessageServiceFromURI(resourceURI.get(), getter_AddRefs(msgService));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIMsgDBHdr> msgHdr;
|
||||
msgService->MessageURIToMsgHdr(resourceURI, getter_AddRefs(msgHdr));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// first, get the hasRemoteContent property
|
||||
PRUint32 remoteContentPolicy = kNoRemoteContentPolicy;
|
||||
msgHdr->GetUint32Property("remoteContentPolicy", &remoteContentPolicy);
|
||||
|
||||
if (!remoteContentPolicy) // kNoRemoteContentPolicy means we have never set a value on the message
|
||||
msgHdr->SetUint32Property("remoteContentPolicy", kBlockRemoteContent); // this message contains blocked remote content
|
||||
|
||||
if (remoteContentPolicy != kAllowRemoteContent && mBlockRemoteImages)
|
||||
{
|
||||
// now we need to call out the msg sink informing it that this message has remote content
|
||||
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(aRequestingLocation, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIMsgWindow> msgWindow;
|
||||
rv = mailnewsUrl->GetMsgWindow(getter_AddRefs(msgWindow));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIMsgHeaderSink> msgHdrSink;
|
||||
rv = msgWindow->GetMsgHeaderSink(getter_AddRefs(msgHdrSink));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
msgHdrSink->OnMsgHasRemoteContent(msgHdr); // notify the UI to show the remote content hdr bar so the user can overide
|
||||
}
|
||||
else if (remoteContentPolicy == kAllowRemoteContent)
|
||||
{
|
||||
// user wants to see the remote content for this mesage
|
||||
*aDecision = nsIContentPolicy::ACCEPT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -674,6 +674,12 @@ NS_IMETHODIMP TokenStreamListener::OnEndMsgDownload(nsIMsgMailNewsUrl *url)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP TokenStreamListener::OnMsgHasRemoteContent(nsIMsgDBHdr * aMsgHdr)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP TokenStreamListener::OnEndMsgHeaders(nsIMsgMailNewsUrl *url)
|
||||
{
|
||||
return NS_OK;
|
||||
|
|
|
@ -44,6 +44,7 @@ interface nsIStreamListener;
|
|||
interface nsIChannel;
|
||||
interface nsIMsgMailNewsUrl;
|
||||
interface nsIUTF8StringEnumerator;
|
||||
interface nsIMsgDBHdr;
|
||||
|
||||
[scriptable, uuid(4644FB25-5255-11d3-82B8-444553540002)]
|
||||
interface nsIMimeMiscStatus : nsISupports{
|
||||
|
@ -79,4 +80,6 @@ interface nsIMsgHeaderSink : nsISupports {
|
|||
void onEndMsgDownload(in nsImsgMailNewsUrl url);
|
||||
|
||||
attribute nsISupports securityInfo;
|
||||
|
||||
void onMsgHasRemoteContent(in nsIMsgDBHdr aMsgHdr);
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче