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

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

Issue 2022083002: Move 'frame-src' CSP checks into FrameFetchContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: redirects 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) 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2011 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 301
302 // If the redirecting url is not allowed to display content from the target origin, 302 // If the redirecting url is not allowed to display content from the target origin,
303 // then block the redirect. 303 // then block the redirect.
304 const KURL& requestURL = m_request.url(); 304 const KURL& requestURL = m_request.url();
305 RefPtr<SecurityOrigin> redirectingOrigin = SecurityOrigin::create(redirectRe sponse.url()); 305 RefPtr<SecurityOrigin> redirectingOrigin = SecurityOrigin::create(redirectRe sponse.url());
306 if (!redirectingOrigin->canDisplay(requestURL)) { 306 if (!redirectingOrigin->canDisplay(requestURL)) {
307 FrameLoader::reportLocalLoadFailed(m_frame, requestURL.getString()); 307 FrameLoader::reportLocalLoadFailed(m_frame, requestURL.getString());
308 m_fetcher->stopFetching(); 308 m_fetcher->stopFetching();
309 return; 309 return;
310 } 310 }
311 if (!frameLoader()->shouldContinueForNavigationPolicy(m_request, SubstituteD ata(), this, CheckContentSecurityPolicy, m_navigationType, NavigationPolicyCurre ntTab, replacesCurrentHistoryItem(), isClientRedirect())) { 311 if (!frameLoader()->shouldContinueForNavigationPolicy(m_request, SubstituteD ata(), this, m_navigationType, NavigationPolicyCurrentTab, replacesCurrentHistor yItem(), isClientRedirect())) {
312 m_fetcher->stopFetching(); 312 m_fetcher->stopFetching();
313 return; 313 return;
314 } 314 }
315 315
316 ASSERT(timing().fetchStart()); 316 ASSERT(timing().fetchStart());
317 timing().addRedirect(redirectResponse.url(), requestURL); 317 timing().addRedirect(redirectResponse.url(), requestURL);
318 appendRedirect(requestURL); 318 appendRedirect(requestURL);
319 frameLoader()->receivedMainResourceRedirect(requestURL); 319 frameLoader()->receivedMainResourceRedirect(requestURL);
320 } 320 }
321 321
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 if (!shouldLoadEmpty) 601 if (!shouldLoadEmpty)
602 return false; 602 return false;
603 603
604 if (m_request.url().isEmpty() && !frameLoader()->stateMachine()->creatingIni tialEmptyDocument()) 604 if (m_request.url().isEmpty() && !frameLoader()->stateMachine()->creatingIni tialEmptyDocument())
605 m_request.setURL(blankURL()); 605 m_request.setURL(blankURL());
606 m_response = ResourceResponse(m_request.url(), "text/html", 0, nullAtom, Str ing()); 606 m_response = ResourceResponse(m_request.url(), "text/html", 0, nullAtom, Str ing());
607 finishedLoading(monotonicallyIncreasingTime()); 607 finishedLoading(monotonicallyIncreasingTime());
608 return true; 608 return true;
609 } 609 }
610 610
611 void DocumentLoader::startLoadingMainResource() 611 void DocumentLoader::loadUnique()
612 {
613 m_request = ResourceRequest(SecurityOrigin::urlWithUniqueSecurityOrigin());
614 m_response = ResourceResponse(m_request.url(), "text/html", 0, nullAtom, Str ing());
615 finishedLoading(monotonicallyIncreasingTime());
616 }
617
618 void DocumentLoader::startLoadingMainResource(ContentSecurityPolicyDisposition c spDisposition)
612 { 619 {
613 timing().markNavigationStart(); 620 timing().markNavigationStart();
614 ASSERT(!m_mainResource); 621 ASSERT(!m_mainResource);
615 ASSERT(m_state == NotStarted); 622 ASSERT(m_state == NotStarted);
616 m_state = Provisional; 623 m_state = Provisional;
617 624
618 if (maybeLoadEmpty()) 625 if (maybeLoadEmpty())
619 return; 626 return;
620 627
621 ASSERT(timing().navigationStart()); 628 ASSERT(timing().navigationStart());
622 ASSERT(!timing().fetchStart()); 629 ASSERT(!timing().fetchStart());
623 timing().markFetchStart(); 630 timing().markFetchStart();
624 631
625 DEFINE_STATIC_LOCAL(ResourceLoaderOptions, mainResourceLoadOptions, 632 DEFINE_STATIC_LOCAL(ResourceLoaderOptions, mainResourceLoadOptions,
626 (DoNotBufferData, AllowStoredCredentials, ClientRequestedCredentials, Ch eckContentSecurityPolicy, DocumentContext)); 633 (DoNotBufferData, AllowStoredCredentials, ClientRequestedCredentials, Ch eckContentSecurityPolicy, DocumentContext));
627 FetchRequest fetchRequest(m_request, FetchInitiatorTypeNames::document, main ResourceLoadOptions); 634 FetchRequest fetchRequest(m_request, FetchInitiatorTypeNames::document, main ResourceLoadOptions);
635 fetchRequest.setContentSecurityCheck(cspDisposition);
636
628 m_mainResource = RawResource::fetchMainResource(fetchRequest, fetcher(), m_s ubstituteData); 637 m_mainResource = RawResource::fetchMainResource(fetchRequest, fetcher(), m_s ubstituteData);
629 if (!m_mainResource) { 638 if (!m_mainResource) {
630 m_request = ResourceRequest(blankURL()); 639 // If we block a main resource request, ensure that the resulting frame' s
631 maybeLoadEmpty(); 640 // origin is unique, and that the redirect list is up-to-date with the
641 // resource we actually commit:
642 loadUnique();
643 appendRedirect(SecurityOrigin::urlWithUniqueSecurityOrigin());
Mike West 2016/06/06 08:40:10 Charlie: It seems reasonable to me to treat blocki
Charlie Reis 2016/06/06 20:43:07 Hmm, that feels weird/unfortunate to me, but maybe
632 return; 644 return;
633 } 645 }
634 // A bunch of headers are set when the underlying ResourceLoader is created, and m_request needs to include those. 646 // A bunch of headers are set when the underlying ResourceLoader is created, and m_request needs to include those.
635 // Even when using a cached resource, we may make some modification to the r equest, e.g. adding the referer header. 647 // Even when using a cached resource, we may make some modification to the r equest, e.g. adding the referer header.
636 m_request = mainResourceLoader() ? m_mainResource->resourceRequest() : fetch Request.resourceRequest(); 648 m_request = mainResourceLoader() ? m_mainResource->resourceRequest() : fetch Request.resourceRequest();
637 m_mainResource->addClient(this); 649 m_mainResource->addClient(this);
638 } 650 }
639 651
640 void DocumentLoader::endWriting(DocumentWriter* writer) 652 void DocumentLoader::endWriting(DocumentWriter* writer)
641 { 653 {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 { 696 {
685 m_writer = createWriterFor(init, mimeType(), m_writer ? m_writer->encoding() : emptyAtom, true, ForceSynchronousParsing); 697 m_writer = createWriterFor(init, mimeType(), m_writer ? m_writer->encoding() : emptyAtom, true, ForceSynchronousParsing);
686 if (!source.isNull()) 698 if (!source.isNull())
687 m_writer->appendReplacingData(source); 699 m_writer->appendReplacingData(source);
688 endWriting(m_writer.get()); 700 endWriting(m_writer.get());
689 } 701 }
690 702
691 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader); 703 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader);
692 704
693 } // namespace blink 705 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698