Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1074)

Unified Diff: Source/core/html/HTMLImageElement.cpp

Issue 1291613010: Implement referrerpolicy attribute for img elements (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix up no-referrer test Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/html/HTMLImageElement.cpp
diff --git a/Source/core/html/HTMLImageElement.cpp b/Source/core/html/HTMLImageElement.cpp
index f6d39f0c885c1a734ffba8092e779063de159c56..8b7c1ea5f99b6bf71c668046fe00285a8a3bcdfa 100644
--- a/Source/core/html/HTMLImageElement.cpp
+++ b/Source/core/html/HTMLImageElement.cpp
@@ -51,6 +51,7 @@
#include "platform/EventDispatchForbiddenScope.h"
#include "platform/MIMETypeRegistry.h"
#include "platform/RuntimeEnabledFeatures.h"
+#include "platform/weborigin/SecurityPolicy.h"
namespace blink {
@@ -385,7 +386,7 @@ Node::InsertionNotificationRequest HTMLImageElement::insertedInto(ContainerNode*
// If we have been inserted from a layoutObject-less document,
// our loader may have not fetched the image, so do it now.
if ((insertionPoint->inDocument() && !imageLoader().image()) || imageWasModified)
- imageLoader().updateFromElement(ImageLoader::UpdateNormal);
+ imageLoader().updateFromElement(ImageLoader::UpdateNormal, referrerPolicy());
return HTMLElement::insertedInto(insertionPoint);
}
@@ -660,7 +661,7 @@ float HTMLImageElement::sourceSize(Element& element)
void HTMLImageElement::forceReload() const
{
- imageLoader().updateFromElement(ImageLoader::UpdateForcedReload);
+ imageLoader().updateFromElement(ImageLoader::UpdateForcedReload, referrerPolicy());
}
void HTMLImageElement::selectSourceURL(ImageLoader::UpdateFromElementBehavior behavior)
@@ -683,7 +684,7 @@ void HTMLImageElement::selectSourceURL(ImageLoader::UpdateFromElementBehavior be
m_listener = ViewportChangeListener::create(this);
document().mediaQueryMatcher().addViewportListener(m_listener);
}
- imageLoader().updateFromElement(behavior);
+ imageLoader().updateFromElement(behavior, referrerPolicy());
if (imageLoader().image() || (imageLoader().hasPendingActivity() && !imageSourceURL().isEmpty()))
ensurePrimaryContent();
@@ -759,4 +760,13 @@ bool HTMLImageElement::isOpaque() const
return image && image->currentFrameKnownToBeOpaque();
}
+ReferrerPolicy HTMLImageElement::referrerPolicy() const
+{
+ ReferrerPolicy policy = ReferrerPolicyDefault;
+ if (RuntimeEnabledFeatures::referrerPolicyAttributeEnabled() && hasAttribute(referrerpolicyAttr)) {
+ SecurityPolicy::referrerPolicyFromString(fastGetAttribute(referrerpolicyAttr), &policy);
+ }
+
+ return policy;
+}
Yoav Weiss 2015/08/18 07:22:17 Processing the referrer every time referrerPolicy(
estark 2015/08/18 17:34:26 Done.
}

Powered by Google App Engine
This is Rietveld 408576698