mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 05:15:45 +00:00
Fix image blocking for iframes. Bug 200433, r=mvl, sr=jst.
This commit is contained in:
parent
eba2b10059
commit
23673826b6
@ -58,6 +58,11 @@
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsMediaDocument.h"
|
||||
#include "nsStyleSet.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIContentPolicy.h"
|
||||
#include "nsContentPolicyUtils.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIDOMElement.h"
|
||||
|
||||
#define AUTOMATIC_IMAGE_RESIZING_PREF "browser.enable_automatic_image_resizing"
|
||||
|
||||
@ -158,6 +163,31 @@ ImageListener::OnStartRequest(nsIRequest* request, nsISupports *ctxt)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> domWindow =
|
||||
do_QueryInterface(imgDoc->GetScriptGlobalObject());
|
||||
NS_ENSURE_TRUE(domWindow, NS_ERROR_UNEXPECTED);
|
||||
|
||||
// Do a ShouldProcess check to see whether to keep loading the image.
|
||||
nsCOMPtr<nsIURI> channelURI;
|
||||
channel->GetURI(getter_AddRefs(channelURI));
|
||||
|
||||
nsCAutoString mimeType;
|
||||
channel->GetContentType(mimeType);
|
||||
|
||||
PRInt16 decision = nsIContentPolicy::ACCEPT;
|
||||
nsresult rv = NS_CheckContentProcessPolicy(nsIContentPolicy::TYPE_IMAGE,
|
||||
channelURI,
|
||||
nsnull,
|
||||
domWindow->GetFrameElementInternal(),
|
||||
mimeType,
|
||||
nsnull,
|
||||
&decision);
|
||||
|
||||
if (NS_FAILED(rv) || NS_CP_REJECTED(decision)) {
|
||||
request->Cancel(NS_ERROR_CONTENT_BLOCKED);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(imgDoc->mImageElement);
|
||||
NS_ENSURE_TRUE(imageLoader, NS_ERROR_UNEXPECTED);
|
||||
|
||||
|
@ -227,11 +227,25 @@ NS_IMETHODIMP nsImgManager::ShouldProcess(PRUint32 aContentType,
|
||||
nsISupports *aExtra,
|
||||
PRInt16 *aDecision)
|
||||
{
|
||||
//TODO: implement this to check images loaded into a raw document (as in,
|
||||
//outside of a web page)
|
||||
|
||||
*aDecision = nsIContentPolicy::ACCEPT;
|
||||
return NS_OK;
|
||||
// For loads where aRequestingNode is chrome, we should just accept. Those
|
||||
// are most likely toplevel loads in windows, and chrome generally knows
|
||||
// what it's doing anyway.
|
||||
nsCOMPtr<nsIDocShellTreeItem> item =
|
||||
do_QueryInterface(NS_CP_GetDocShellFromDOMNode(aRequestingNode));
|
||||
|
||||
if (item) {
|
||||
PRInt32 type;
|
||||
item->GetItemType(&type);
|
||||
if (type == nsIDocShellTreeItem::typeChrome) {
|
||||
*aDecision = nsIContentPolicy::ACCEPT;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// This isn't a load from chrome. Just do a ShouldLoad() check --
|
||||
// we want the same answer here
|
||||
return ShouldLoad(aContentType, aContentLocation, aRequestingLocation,
|
||||
aRequestingNode, aMimeGuess, aExtra, aDecision);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
Loading…
Reference in New Issue
Block a user