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

Side by Side Diff: Source/core/dom/Document.cpp

Issue 19940002: [HTML Import] Respect Content Security Policy Model (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix Mac build Created 7 years, 5 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 | Annotate | Revision Log
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) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 2619 matching lines...) Expand 10 before | Expand all | Expand 10 after
2630 processHttpEquivXFrameOptions(content); 2630 processHttpEquivXFrameOptions(content);
2631 else if (equalIgnoringCase(equiv, "content-security-policy") 2631 else if (equalIgnoringCase(equiv, "content-security-policy")
2632 || equalIgnoringCase(equiv, "content-security-policy-report-only") 2632 || equalIgnoringCase(equiv, "content-security-policy-report-only")
2633 || equalIgnoringCase(equiv, "x-webkit-csp") 2633 || equalIgnoringCase(equiv, "x-webkit-csp")
2634 || equalIgnoringCase(equiv, "x-webkit-csp-report-only")) 2634 || equalIgnoringCase(equiv, "x-webkit-csp-report-only"))
2635 processHttpEquivContentSecurityPolicy(equiv, content); 2635 processHttpEquivContentSecurityPolicy(equiv, content);
2636 } 2636 }
2637 2637
2638 void Document::processHttpEquivContentSecurityPolicy(const String& equiv, const String& content) 2638 void Document::processHttpEquivContentSecurityPolicy(const String& equiv, const String& content)
2639 { 2639 {
2640 if (!this->frame())
2641 return;
2642
2640 if (equalIgnoringCase(equiv, "content-security-policy")) 2643 if (equalIgnoringCase(equiv, "content-security-policy"))
2641 contentSecurityPolicy()->didReceiveHeader(content, ContentSecurityPolicy ::Enforce); 2644 contentSecurityPolicy()->didReceiveHeader(content, ContentSecurityPolicy ::Enforce);
2642 else if (equalIgnoringCase(equiv, "content-security-policy-report-only")) 2645 else if (equalIgnoringCase(equiv, "content-security-policy-report-only"))
2643 contentSecurityPolicy()->didReceiveHeader(content, ContentSecurityPolicy ::Report); 2646 contentSecurityPolicy()->didReceiveHeader(content, ContentSecurityPolicy ::Report);
2644 else if (equalIgnoringCase(equiv, "x-webkit-csp")) 2647 else if (equalIgnoringCase(equiv, "x-webkit-csp"))
2645 contentSecurityPolicy()->didReceiveHeader(content, ContentSecurityPolicy ::PrefixedEnforce); 2648 contentSecurityPolicy()->didReceiveHeader(content, ContentSecurityPolicy ::PrefixedEnforce);
2646 else if (equalIgnoringCase(equiv, "x-webkit-csp-report-only")) 2649 else if (equalIgnoringCase(equiv, "x-webkit-csp-report-only"))
2647 contentSecurityPolicy()->didReceiveHeader(content, ContentSecurityPolicy ::PrefixedReport); 2650 contentSecurityPolicy()->didReceiveHeader(content, ContentSecurityPolicy ::PrefixedReport);
2648 else 2651 else
2649 ASSERT_NOT_REACHED(); 2652 ASSERT_NOT_REACHED();
(...skipping 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after
4200 initSecurityContext(DocumentInit(m_url, m_frame, m_import)); 4203 initSecurityContext(DocumentInit(m_url, m_frame, m_import));
4201 } 4204 }
4202 4205
4203 void Document::initSecurityContext(const DocumentInit& initializer) 4206 void Document::initSecurityContext(const DocumentInit& initializer)
4204 { 4207 {
4205 if (haveInitializedSecurityOrigin()) { 4208 if (haveInitializedSecurityOrigin()) {
4206 ASSERT(securityOrigin()); 4209 ASSERT(securityOrigin());
4207 return; 4210 return;
4208 } 4211 }
4209 4212
4210 if (!initializer.frame()) { 4213 if (!initializer.hasSecurityContext()) {
4211 // No source for a security context. 4214 // No source for a security context.
4212 // This can occur via document.implementation.createDocument(). 4215 // This can occur via document.implementation.createDocument().
abarth-chromium 2013/07/24 18:39:19 Does this occur for HTML import too? If so, it wo
4213 m_cookieURL = KURL(ParsedURLString, emptyString()); 4216 m_cookieURL = KURL(ParsedURLString, emptyString());
4214 setSecurityOrigin(SecurityOrigin::createUnique()); 4217 setSecurityOrigin(SecurityOrigin::createUnique());
4215 setContentSecurityPolicy(ContentSecurityPolicy::create(this)); 4218 setContentSecurityPolicy(ContentSecurityPolicy::create(this));
4216 return; 4219 return;
4217 } 4220 }
4218 4221
4219 // In the common case, create the security context from the currently 4222 // In the common case, create the security context from the currently
4220 // loading URL with a fresh content security policy. 4223 // loading URL with a fresh content security policy.
4221 m_cookieURL = m_url; 4224 m_cookieURL = m_url;
4222 enforceSandboxFlags(initializer.sandboxFlags()); 4225 enforceSandboxFlags(initializer.sandboxFlags());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
4274 } 4277 }
4275 4278
4276 m_cookieURL = ownerFrame->document()->cookieURL(); 4279 m_cookieURL = ownerFrame->document()->cookieURL();
4277 // We alias the SecurityOrigins to match Firefox, see Bug 15313 4280 // We alias the SecurityOrigins to match Firefox, see Bug 15313
4278 // https://bugs.webkit.org/show_bug.cgi?id=15313 4281 // https://bugs.webkit.org/show_bug.cgi?id=15313
4279 setSecurityOrigin(ownerFrame->document()->securityOrigin()); 4282 setSecurityOrigin(ownerFrame->document()->securityOrigin());
4280 } 4283 }
4281 4284
4282 void Document::initContentSecurityPolicy() 4285 void Document::initContentSecurityPolicy()
4283 { 4286 {
4284 if (!m_frame->tree()->parent() || (!shouldInheritSecurityOriginFromOwner(m_u rl) && !isPluginDocument())) 4287 if (m_frame && m_frame->tree()->parent() && (shouldInheritSecurityOriginFrom Owner(m_url) || isPluginDocument()))
4285 return; 4288 contentSecurityPolicy()->copyStateFrom(m_frame->tree()->parent()->docume nt()->contentSecurityPolicy());
4286 4289 if (HTMLImport* import = this->import())
4287 contentSecurityPolicy()->copyStateFrom(m_frame->tree()->parent()->document() ->contentSecurityPolicy()); 4290 contentSecurityPolicy()->copyStateFrom(import->master()->contentSecurity Policy());
abarth-chromium 2013/07/24 18:39:19 This looks great. My only question is about this
4288 } 4291 }
4289 4292
4290 void Document::didUpdateSecurityOrigin() 4293 void Document::didUpdateSecurityOrigin()
4291 { 4294 {
4292 if (!m_frame) 4295 if (!m_frame)
4293 return; 4296 return;
4294 m_frame->script()->updateSecurityOrigin(); 4297 m_frame->script()->updateSecurityOrigin();
4295 } 4298 }
4296 4299
4297 bool Document::isContextThread() const 4300 bool Document::isContextThread() const
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
5088 { 5091 {
5089 return DocumentLifecycleNotifier::create(this); 5092 return DocumentLifecycleNotifier::create(this);
5090 } 5093 }
5091 5094
5092 DocumentLifecycleNotifier* Document::lifecycleNotifier() 5095 DocumentLifecycleNotifier* Document::lifecycleNotifier()
5093 { 5096 {
5094 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec ycleNotifier()); 5097 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec ycleNotifier());
5095 } 5098 }
5096 5099
5097 } // namespace WebCore 5100 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698