mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 01:05:45 +00:00
Bug 1277803 - Part 2: Make favicons loaded through XUL:image use the correct principal. r=Gijs, r=tnikkel
--HG-- extra : rebase_source : defe714eda519459c2bd9bc54e6668a37c8fff28
This commit is contained in:
parent
b7324dcec9
commit
0c89a42cb1
@ -6460,7 +6460,7 @@
|
||||
class="tab-throbber"
|
||||
role="presentation"
|
||||
layer="true" />
|
||||
<xul:image xbl:inherits="src=image,fadein,pinned,selected=visuallyselected,busy,crashed,sharing"
|
||||
<xul:image xbl:inherits="src=image,loadingprincipal=iconLoadingPrincipal,fadein,pinned,selected=visuallyselected,busy,crashed,sharing"
|
||||
anonid="tab-icon-image"
|
||||
class="tab-icon-image"
|
||||
validate="never"
|
||||
|
@ -557,6 +557,7 @@ GK_ATOM(listing, "listing")
|
||||
GK_ATOM(listitem, "listitem")
|
||||
GK_ATOM(listrows, "listrows")
|
||||
GK_ATOM(load, "load")
|
||||
GK_ATOM(loadingprincipal, "loadingprincipal")
|
||||
GK_ATOM(localedir, "localedir")
|
||||
GK_ATOM(localName, "local-name")
|
||||
GK_ATOM(longdesc, "longdesc")
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include "nsIContent.h"
|
||||
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsSerializationHelper.h"
|
||||
|
||||
#include "mozilla/BasicEvents.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
@ -226,6 +227,29 @@ nsImageBoxFrame::UpdateImage()
|
||||
if (mUseSrcAttr) {
|
||||
nsIDocument* doc = mContent->GetComposedDoc();
|
||||
if (doc) {
|
||||
// Use the serialized loadingPrincipal from the image element. Fall back
|
||||
// to mContent's principal (SystemPrincipal) if not available.
|
||||
nsContentPolicyType contentPolicyType = nsIContentPolicy::TYPE_INTERNAL_IMAGE;
|
||||
nsCOMPtr<nsIPrincipal> loadingPrincipal = mContent->NodePrincipal();
|
||||
nsAutoString imageLoadingPrincipal;
|
||||
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::loadingprincipal,
|
||||
imageLoadingPrincipal);
|
||||
if (!imageLoadingPrincipal.IsEmpty()) {
|
||||
nsCOMPtr<nsISupports> serializedPrincipal;
|
||||
NS_DeserializeObject(NS_ConvertUTF16toUTF8(imageLoadingPrincipal),
|
||||
getter_AddRefs(serializedPrincipal));
|
||||
loadingPrincipal = do_QueryInterface(serializedPrincipal);
|
||||
|
||||
if (loadingPrincipal) {
|
||||
// Set the content policy type to TYPE_INTERNAL_IMAGE_FAVICON for
|
||||
// indicating it's a favicon loading.
|
||||
contentPolicyType = nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON;
|
||||
} else {
|
||||
// Fallback if the deserialization is failed.
|
||||
loadingPrincipal = mContent->NodePrincipal();
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> baseURI = mContent->GetBaseURI();
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(uri),
|
||||
@ -233,10 +257,11 @@ nsImageBoxFrame::UpdateImage()
|
||||
doc,
|
||||
baseURI);
|
||||
if (uri) {
|
||||
nsresult rv = nsContentUtils::LoadImage(uri, mContent, doc, mContent->NodePrincipal(),
|
||||
nsresult rv = nsContentUtils::LoadImage(uri, mContent, doc, loadingPrincipal,
|
||||
doc->GetDocumentURI(), doc->GetReferrerPolicy(),
|
||||
mListener, mLoadFlags,
|
||||
EmptyString(), getter_AddRefs(mImageRequest));
|
||||
EmptyString(), getter_AddRefs(mImageRequest),
|
||||
contentPolicyType);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && mImageRequest) {
|
||||
nsLayoutUtils::RegisterImageRequestIfAnimated(presContext,
|
||||
|
Loading…
Reference in New Issue
Block a user