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

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: yoav comments 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..d0ca9b2352376ea8bb9527122fc4ca2aaa865e12 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 {
@@ -91,6 +92,7 @@ HTMLImageElement::HTMLImageElement(Document& document, HTMLFormElement* form, bo
, m_intrinsicSizingViewportDependant(false)
, m_useFallbackContent(false)
, m_isFallbackImage(false)
+ , m_referrerPolicy(ReferrerPolicyDefault)
{
setHasCustomStyleCallbacks();
if (form && form->inDocument()) {
@@ -268,6 +270,13 @@ void HTMLImageElement::parseAttribute(const QualifiedName& name, const AtomicStr
selectSourceURL(ImageLoader::UpdateIgnorePreviousError);
} else if (name == usemapAttr) {
setIsLink(!value.isNull());
+ } else if (name == referrerpolicyAttr) {
+ ReferrerPolicy parsedPolicy;
+ if (value.isNull() || !SecurityPolicy::referrerPolicyFromString(value, &parsedPolicy)) {
+ m_referrerPolicy = ReferrerPolicyDefault;
+ } else {
+ m_referrerPolicy = parsedPolicy;
+ }
Yoav Weiss 2015/08/18 21:09:21 We could replace the if{}else{} here similarly to
estark 2015/08/19 02:53:22 Done.
} else {
HTMLElement::parseAttribute(name, value);
}
@@ -385,7 +394,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, m_referrerPolicy);
return HTMLElement::insertedInto(insertionPoint);
}
@@ -660,7 +669,7 @@ float HTMLImageElement::sourceSize(Element& element)
void HTMLImageElement::forceReload() const
{
- imageLoader().updateFromElement(ImageLoader::UpdateForcedReload);
+ imageLoader().updateFromElement(ImageLoader::UpdateForcedReload, m_referrerPolicy);
}
void HTMLImageElement::selectSourceURL(ImageLoader::UpdateFromElementBehavior behavior)
@@ -683,7 +692,7 @@ void HTMLImageElement::selectSourceURL(ImageLoader::UpdateFromElementBehavior be
m_listener = ViewportChangeListener::create(this);
document().mediaQueryMatcher().addViewportListener(m_listener);
}
- imageLoader().updateFromElement(behavior);
+ imageLoader().updateFromElement(behavior, m_referrerPolicy);
if (imageLoader().image() || (imageLoader().hasPendingActivity() && !imageSourceURL().isEmpty()))
ensurePrimaryContent();

Powered by Google App Engine
This is Rietveld 408576698