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

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 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 m_csp = nullAtom; 157 m_csp = nullAtom;
152 document().addConsoleMessage(ConsoleMessage::create( 158 document().addConsoleMessage(ConsoleMessage::create(
153 OtherMessageSource, ErrorMessageLevel, 159 OtherMessageSource, ErrorMessageLevel,
154 "'csp' attribute contains non-ASCII characters: " + value)); 160 "'csp' attribute contains non-ASCII characters: " + value));
155 return; 161 return;
156 } 162 }
157 AtomicString oldCSP = m_csp; 163 AtomicString oldCSP = m_csp;
158 m_csp = value; 164 m_csp = value;
159 if (m_csp != oldCSP) 165 if (m_csp != oldCSP)
160 frameOwnerPropertiesChanged(); 166 frameOwnerPropertiesChanged();
167 } else if (RuntimeEnabledFeatures::featurePolicyEnabled() &&
168 name == allowAttr) {
169 m_allow->setValue(value);
161 } else { 170 } else {
162 if (name == srcAttr) 171 if (name == srcAttr)
163 logUpdateAttributeIfIsolatedWorldAndInDocument("iframe", params); 172 logUpdateAttributeIfIsolatedWorldAndInDocument("iframe", params);
164 HTMLFrameElementBase::parseAttribute(params); 173 HTMLFrameElementBase::parseAttribute(params);
165 } 174 }
166 } 175 }
167 176
168 bool HTMLIFrameElement::layoutObjectIsNeeded(const ComputedStyle& style) { 177 bool HTMLIFrameElement::layoutObjectIsNeeded(const ComputedStyle& style) {
169 return contentFrame() && HTMLElement::layoutObjectIsNeeded(style); 178 return contentFrame() && HTMLElement::layoutObjectIsNeeded(style);
170 } 179 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 setSandboxFlags(m_sandbox->value().isNull() 222 setSandboxFlags(m_sandbox->value().isNull()
214 ? SandboxNone 223 ? SandboxNone
215 : parseSandboxPolicy(m_sandbox->tokens(), invalidTokens)); 224 : parseSandboxPolicy(m_sandbox->tokens(), invalidTokens));
216 if (!invalidTokens.isNull()) 225 if (!invalidTokens.isNull())
217 document().addConsoleMessage(ConsoleMessage::create( 226 document().addConsoleMessage(ConsoleMessage::create(
218 OtherMessageSource, ErrorMessageLevel, 227 OtherMessageSource, ErrorMessageLevel,
219 "Error while parsing the 'sandbox' attribute: " + invalidTokens)); 228 "Error while parsing the 'sandbox' attribute: " + invalidTokens));
220 setSynchronizedLazyAttribute(sandboxAttr, m_sandbox->value()); 229 setSynchronizedLazyAttribute(sandboxAttr, m_sandbox->value());
221 } 230 }
222 231
232 void HTMLIFrameElement::allowValueWasSet() {
233 String invalidTokens;
234 m_allowedFeatureNames = m_allow->parseAllowedFeatureNames(invalidTokens);
235 if (!invalidTokens.isNull()) {
236 document().addConsoleMessage(ConsoleMessage::create(
237 OtherMessageSource, ErrorMessageLevel,
238 "Error while parsing the 'allow' attribute: " + invalidTokens));
239 }
240 setSynchronizedLazyAttribute(allowAttr, m_allow->value());
241 // TODO(lunalu): Once allowedFeatureNames is passed to frame owner, call
242 // frameOwnerPropertiesChanged.
243 }
244
223 ReferrerPolicy HTMLIFrameElement::referrerPolicyAttribute() { 245 ReferrerPolicy HTMLIFrameElement::referrerPolicyAttribute() {
224 return m_referrerPolicy; 246 return m_referrerPolicy;
225 } 247 }
226 248
227 bool HTMLIFrameElement::initializePermissionsAttribute() { 249 bool HTMLIFrameElement::initializePermissionsAttribute() {
228 if (!RuntimeEnabledFeatures::permissionDelegationEnabled()) 250 if (!RuntimeEnabledFeatures::permissionDelegationEnabled())
229 return false; 251 return false;
230 252
231 if (!m_permissions) 253 if (!m_permissions)
232 m_permissions = HTMLIFrameElementPermissions::create(this); 254 m_permissions = HTMLIFrameElementPermissions::create(this);
233 return true; 255 return true;
234 } 256 }
235 257
236 } // namespace blink 258 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLIFrameElement.h ('k') | third_party/WebKit/Source/core/html/HTMLIFrameElement.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698