nsCOMPtr<nsPIDOMWindow> domWindow = do_QueryInterface(imgDoc->GetScriptGlobalObject()); NS_ENSURE_TRUE(domWindow, NS_ERROR_UNEXPECTED);   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; }
ImageListener::OnStartRequest(nsIRequest* request, nsISupports *ctxt){  NS_ENSURE_TRUE(mDocument, NS_ERROR_FAILURE);  nsImageDocument *imgDoc = (nsImageDocument*)mDocument.get();  nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);  if (!channel) {    return NS_ERROR_FAILURE;  }  nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(imgDoc->mImageElement);  NS_ENSURE_TRUE(imageLoader, NS_ERROR_UNEXPECTED);  imageLoader->AddObserver(imgDoc);  imageLoader->LoadImageWithChannel(channel, getter_AddRefs(mNextStream));  return nsMediaDocumentStreamListener::OnStartRequest(request, ctxt);}