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

Side by Side Diff: third_party/WebKit/Source/core/loader/FrameFetchContext.cpp

Issue 2022083002: Move 'frame-src' CSP checks into FrameFetchContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase+Content+Sandbox Created 4 years, 6 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 519
520 // Don't send CSP messages for preloads, we might never actually display tho se items. 520 // Don't send CSP messages for preloads, we might never actually display tho se items.
521 ContentSecurityPolicy::ReportingStatus cspReporting = forPreload ? 521 ContentSecurityPolicy::ReportingStatus cspReporting = forPreload ?
522 ContentSecurityPolicy::SuppressReport : ContentSecurityPolicy::SendRepor t; 522 ContentSecurityPolicy::SuppressReport : ContentSecurityPolicy::SendRepor t;
523 523
524 // m_document can be null, but not in any of the cases where csp is actually used below. 524 // m_document can be null, but not in any of the cases where csp is actually used below.
525 // ImageResourceTest.MultipartImage crashes w/o the m_document null check. 525 // ImageResourceTest.MultipartImage crashes w/o the m_document null check.
526 // I believe it's the Resource::Raw case. 526 // I believe it's the Resource::Raw case.
527 const ContentSecurityPolicy* csp = m_document ? m_document->contentSecurityP olicy() : nullptr; 527 const ContentSecurityPolicy* csp = m_document ? m_document->contentSecurityP olicy() : nullptr;
528 528
529 // If we're loading a frame, grab it's parent's policy for 'frame-src' check s:
530 if (!csp && type == Resource::MainResource) {
Yoav Weiss 2016/06/02 09:15:14 I understand that the assumption here is that csp
531 if (Frame* parentFrame = frame()->tree().parent()) {
532 csp = parentFrame->securityContext()->contentSecurityPolicy();
533 if (!csp->allowChildFrameFromSource(url, redirectStatus, cspReportin g)) {
534 // TODO(mkwst): If we cancel the request after a redirect, we ne ver instantiate
535 // a document, and therefore don't inherit the loader's sandbox flags, or trigger
536 // a load event. This is strange.
537 if (redirectStatus == ResourceRequest::RedirectStatus::FollowedR edirect) {
538 frame()->document()->enforceSandboxFlags(SandboxOrigin);
539 frame()->owner()->dispatchLoad();
540 }
541 return ResourceRequestBlockedReasonCSP;
542 }
Yoav Weiss 2016/06/02 09:15:14 should we return here? Or nullify csp? Otherwise,
543 }
544 }
545
529 if (csp) { 546 if (csp) {
530 if (!shouldBypassMainWorldCSP && !csp->allowRequest(resourceRequest.requ estContext(), url, redirectStatus, cspReporting)) 547 if (!shouldBypassMainWorldCSP && !csp->allowRequest(resourceRequest.requ estContext(), url, redirectStatus, cspReporting))
531 return ResourceRequestBlockedReasonCSP; 548 return ResourceRequestBlockedReasonCSP;
532 } 549 }
533 550
534 if (type == Resource::Script || type == Resource::ImportResource) { 551 if (type == Resource::Script || type == Resource::ImportResource) {
535 ASSERT(frame()); 552 ASSERT(frame());
536 if (!frame()->loader().client()->allowScriptFromSource(!frame()->setting s() || frame()->settings()->scriptEnabled(), url)) { 553 if (!frame()->loader().client()->allowScriptFromSource(!frame()->setting s() || frame()->settings()->scriptEnabled(), url)) {
537 frame()->loader().client()->didNotAllowScript(); 554 frame()->loader().client()->didNotAllowScript();
538 // TODO(estark): Use a different ResourceRequestBlockedReason 555 // TODO(estark): Use a different ResourceRequestBlockedReason
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 } 830 }
814 831
815 DEFINE_TRACE(FrameFetchContext) 832 DEFINE_TRACE(FrameFetchContext)
816 { 833 {
817 visitor->trace(m_document); 834 visitor->trace(m_document);
818 visitor->trace(m_documentLoader); 835 visitor->trace(m_documentLoader);
819 FetchContext::trace(visitor); 836 FetchContext::trace(visitor);
820 } 837 }
821 838
822 } // namespace blink 839 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/loader/DocumentLoader.cpp ('k') | third_party/WebKit/Source/core/loader/FrameLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698