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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLIFrameElement.cpp

Issue 2680083002: Initial Implementation of Iframe Attribute for Feature Policy (Part 1) (Closed)
Patch Set: Codereview: nit, added RuntimeFeatures::FeaturePolicyExperimentalFeatures Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Simon Hausmann (hausmann@kde.org) 4 * (C) 2000 Simon Hausmann (hausmann@kde.org)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * Copyright (C) 2004, 2006, 2008, 2009 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2006, 2008, 2009 Apple Inc. All rights reserved.
7 * Copyright (C) 2009 Ericsson AB. All rights reserved. 7 * Copyright (C) 2009 Ericsson AB. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 22 matching lines...) Expand all
33 #include "platform/RuntimeEnabledFeatures.h" 33 #include "platform/RuntimeEnabledFeatures.h"
34 34
35 namespace blink { 35 namespace blink {
36 36
37 using namespace HTMLNames; 37 using namespace HTMLNames;
38 38
39 inline HTMLIFrameElement::HTMLIFrameElement(Document& document) 39 inline HTMLIFrameElement::HTMLIFrameElement(Document& document)
40 : HTMLFrameElementBase(iframeTag, document), 40 : HTMLFrameElementBase(iframeTag, document),
41 m_didLoadNonEmptyDocument(false), 41 m_didLoadNonEmptyDocument(false),
42 m_sandbox(HTMLIFrameElementSandbox::create(this)), 42 m_sandbox(HTMLIFrameElementSandbox::create(this)),
43 m_allow(HTMLIFrameElementAllow::create(this)),
43 m_referrerPolicy(ReferrerPolicyDefault) {} 44 m_referrerPolicy(ReferrerPolicyDefault) {}
44 45
45 DEFINE_NODE_FACTORY(HTMLIFrameElement) 46 DEFINE_NODE_FACTORY(HTMLIFrameElement)
46 47
47 DEFINE_TRACE(HTMLIFrameElement) { 48 DEFINE_TRACE(HTMLIFrameElement) {
48 visitor->trace(m_sandbox); 49 visitor->trace(m_sandbox);
49 visitor->trace(m_permissions); 50 visitor->trace(m_permissions);
51 visitor->trace(m_allow);
50 HTMLFrameElementBase::trace(visitor); 52 HTMLFrameElementBase::trace(visitor);
51 Supplementable<HTMLIFrameElement>::trace(visitor); 53 Supplementable<HTMLIFrameElement>::trace(visitor);
52 } 54 }
53 55
54 HTMLIFrameElement::~HTMLIFrameElement() {} 56 HTMLIFrameElement::~HTMLIFrameElement() {}
55 57
56 DOMTokenList* HTMLIFrameElement::sandbox() const { 58 DOMTokenList* HTMLIFrameElement::sandbox() const {
57 return m_sandbox.get(); 59 return m_sandbox.get();
58 } 60 }
59 61
60 DOMTokenList* HTMLIFrameElement::permissions() const { 62 DOMTokenList* HTMLIFrameElement::permissions() const {
61 if (!const_cast<HTMLIFrameElement*>(this)->initializePermissionsAttribute()) 63 if (!const_cast<HTMLIFrameElement*>(this)->initializePermissionsAttribute())
62 return nullptr; 64 return nullptr;
63 return m_permissions.get(); 65 return m_permissions.get();
64 } 66 }
65 67
68 DOMTokenList* HTMLIFrameElement::allow() const {
69 return m_allow.get();
70 }
71
66 bool HTMLIFrameElement::isPresentationAttribute( 72 bool HTMLIFrameElement::isPresentationAttribute(
67 const QualifiedName& name) const { 73 const QualifiedName& name) const {
68 if (name == widthAttr || name == heightAttr || name == alignAttr || 74 if (name == widthAttr || name == heightAttr || name == alignAttr ||
69 name == frameborderAttr) 75 name == frameborderAttr)
70 return true; 76 return true;
71 return HTMLFrameElementBase::isPresentationAttribute(name); 77 return HTMLFrameElementBase::isPresentationAttribute(name);
72 } 78 }
73 79
74 void HTMLIFrameElement::collectStyleForPresentationAttribute( 80 void HTMLIFrameElement::collectStyleForPresentationAttribute(
75 const QualifiedName& name, 81 const QualifiedName& name,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 m_csp = nullAtom; 148 m_csp = nullAtom;
143 document().addConsoleMessage(ConsoleMessage::create( 149 document().addConsoleMessage(ConsoleMessage::create(
144 OtherMessageSource, ErrorMessageLevel, 150 OtherMessageSource, ErrorMessageLevel,
145 "'csp' attribute contains non-ASCII characters: " + value)); 151 "'csp' attribute contains non-ASCII characters: " + value));
146 return; 152 return;
147 } 153 }
148 AtomicString oldCSP = m_csp; 154 AtomicString oldCSP = m_csp;
149 m_csp = value; 155 m_csp = value;
150 if (m_csp != oldCSP) 156 if (m_csp != oldCSP)
151 frameOwnerPropertiesChanged(); 157 frameOwnerPropertiesChanged();
158 } else if (RuntimeEnabledFeatures::featurePolicyEnabled() &&
159 name == allowAttr) {
160 m_allow->setValue(value);
152 } else { 161 } else {
153 if (name == srcAttr) 162 if (name == srcAttr)
154 logUpdateAttributeIfIsolatedWorldAndInDocument("iframe", params); 163 logUpdateAttributeIfIsolatedWorldAndInDocument("iframe", params);
155 HTMLFrameElementBase::parseAttribute(params); 164 HTMLFrameElementBase::parseAttribute(params);
156 } 165 }
157 } 166 }
158 167
159 bool HTMLIFrameElement::layoutObjectIsNeeded(const ComputedStyle& style) { 168 bool HTMLIFrameElement::layoutObjectIsNeeded(const ComputedStyle& style) {
160 return contentFrame() && HTMLElement::layoutObjectIsNeeded(style); 169 return contentFrame() && HTMLElement::layoutObjectIsNeeded(style);
161 } 170 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 setSandboxFlags(m_sandbox->value().isNull() 213 setSandboxFlags(m_sandbox->value().isNull()
205 ? SandboxNone 214 ? SandboxNone
206 : parseSandboxPolicy(m_sandbox->tokens(), invalidTokens)); 215 : parseSandboxPolicy(m_sandbox->tokens(), invalidTokens));
207 if (!invalidTokens.isNull()) 216 if (!invalidTokens.isNull())
208 document().addConsoleMessage(ConsoleMessage::create( 217 document().addConsoleMessage(ConsoleMessage::create(
209 OtherMessageSource, ErrorMessageLevel, 218 OtherMessageSource, ErrorMessageLevel,
210 "Error while parsing the 'sandbox' attribute: " + invalidTokens)); 219 "Error while parsing the 'sandbox' attribute: " + invalidTokens));
211 setSynchronizedLazyAttribute(sandboxAttr, m_sandbox->value()); 220 setSynchronizedLazyAttribute(sandboxAttr, m_sandbox->value());
212 } 221 }
213 222
223 void HTMLIFrameElement::allowValueWasSet() {
224 String invalidTokens;
225 m_allowedFeatureNames = m_allow->parseAllowedFeatureNames(invalidTokens);
226 if (!invalidTokens.isNull()) {
227 document().addConsoleMessage(ConsoleMessage::create(
228 OtherMessageSource, ErrorMessageLevel,
229 "Error while parsing the 'allow' attribute: " + invalidTokens));
230 }
231 setSynchronizedLazyAttribute(allowAttr, m_allow->value());
232 // TODO(lunalu): Once allowedFeatureNames is passed to frame owner, call
233 // frameOwnerPropertiesChanged.
234 // frameOwnerPropertiesChanged();
iclelland 2017/02/08 20:11:35 You can just remove this commented-out code, with
lunalu1 2017/02/08 21:06:11 Done.
235 }
236
214 ReferrerPolicy HTMLIFrameElement::referrerPolicyAttribute() { 237 ReferrerPolicy HTMLIFrameElement::referrerPolicyAttribute() {
215 return m_referrerPolicy; 238 return m_referrerPolicy;
216 } 239 }
217 240
218 bool HTMLIFrameElement::initializePermissionsAttribute() { 241 bool HTMLIFrameElement::initializePermissionsAttribute() {
219 if (!RuntimeEnabledFeatures::permissionDelegationEnabled()) 242 if (!RuntimeEnabledFeatures::permissionDelegationEnabled())
220 return false; 243 return false;
221 244
222 if (!m_permissions) 245 if (!m_permissions)
223 m_permissions = HTMLIFrameElementPermissions::create(this); 246 m_permissions = HTMLIFrameElementPermissions::create(this);
224 return true; 247 return true;
225 } 248 }
226 249
227 } // namespace blink 250 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698