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

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

Issue 2068443002: Revert of Move 'frame-src' CSP checks into FrameFetchContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: run revert on local machine to resolve conflicts 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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 307
308 // If the redirecting url is not allowed to display content from the target origin, 308 // If the redirecting url is not allowed to display content from the target origin,
309 // then block the redirect. 309 // then block the redirect.
310 const KURL& requestURL = m_request.url(); 310 const KURL& requestURL = m_request.url();
311 RefPtr<SecurityOrigin> redirectingOrigin = SecurityOrigin::create(redirectRe sponse.url()); 311 RefPtr<SecurityOrigin> redirectingOrigin = SecurityOrigin::create(redirectRe sponse.url());
312 if (!redirectingOrigin->canDisplay(requestURL)) { 312 if (!redirectingOrigin->canDisplay(requestURL)) {
313 FrameLoader::reportLocalLoadFailed(m_frame, requestURL.getString()); 313 FrameLoader::reportLocalLoadFailed(m_frame, requestURL.getString());
314 m_fetcher->stopFetching(); 314 m_fetcher->stopFetching();
315 return; 315 return;
316 } 316 }
317 if (!frameLoader()->shouldContinueForNavigationPolicy(m_request, SubstituteD ata(), this, m_navigationType, NavigationPolicyCurrentTab, replacesCurrentHistor yItem(), isClientRedirect())) { 317 if (!frameLoader()->shouldContinueForNavigationPolicy(m_request, SubstituteD ata(), this, CheckContentSecurityPolicy, m_navigationType, NavigationPolicyCurre ntTab, replacesCurrentHistoryItem(), isClientRedirect())) {
318 m_fetcher->stopFetching(); 318 m_fetcher->stopFetching();
319 return; 319 return;
320 } 320 }
321 321
322 ASSERT(timing().fetchStart()); 322 ASSERT(timing().fetchStart());
323 timing().addRedirect(redirectResponse.url(), requestURL); 323 timing().addRedirect(redirectResponse.url(), requestURL);
324 appendRedirect(requestURL); 324 appendRedirect(requestURL);
325 frameLoader()->receivedMainResourceRedirect(requestURL); 325 frameLoader()->receivedMainResourceRedirect(requestURL);
326 } 326 }
327 327
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 if (!shouldLoadEmpty) 607 if (!shouldLoadEmpty)
608 return false; 608 return false;
609 609
610 if (m_request.url().isEmpty() && !frameLoader()->stateMachine()->creatingIni tialEmptyDocument()) 610 if (m_request.url().isEmpty() && !frameLoader()->stateMachine()->creatingIni tialEmptyDocument())
611 m_request.setURL(blankURL()); 611 m_request.setURL(blankURL());
612 m_response = ResourceResponse(m_request.url(), "text/html", 0, nullAtom, Str ing()); 612 m_response = ResourceResponse(m_request.url(), "text/html", 0, nullAtom, Str ing());
613 finishedLoading(monotonicallyIncreasingTime()); 613 finishedLoading(monotonicallyIncreasingTime());
614 return true; 614 return true;
615 } 615 }
616 616
617 void DocumentLoader::loadUnique() 617 void DocumentLoader::startLoadingMainResource()
618 {
619 m_request = ResourceRequest(SecurityOrigin::urlWithUniqueSecurityOrigin());
620 m_response = ResourceResponse(m_request.url(), "text/html", 0, nullAtom, Str ing());
621 finishedLoading(monotonicallyIncreasingTime());
622 }
623
624 void DocumentLoader::startLoadingMainResource(ContentSecurityPolicyDisposition c spDisposition)
625 { 618 {
626 timing().markNavigationStart(); 619 timing().markNavigationStart();
627 ASSERT(!m_mainResource); 620 ASSERT(!m_mainResource);
628 ASSERT(m_state == NotStarted); 621 ASSERT(m_state == NotStarted);
629 m_state = Provisional; 622 m_state = Provisional;
630 623
631 if (maybeLoadEmpty()) 624 if (maybeLoadEmpty())
632 return; 625 return;
633 626
634 ASSERT(timing().navigationStart()); 627 ASSERT(timing().navigationStart());
635 ASSERT(!timing().fetchStart()); 628 ASSERT(!timing().fetchStart());
636 timing().markFetchStart(); 629 timing().markFetchStart();
637 630
638 DEFINE_STATIC_LOCAL(ResourceLoaderOptions, mainResourceLoadOptions, 631 DEFINE_STATIC_LOCAL(ResourceLoaderOptions, mainResourceLoadOptions,
639 (DoNotBufferData, AllowStoredCredentials, ClientRequestedCredentials, Ch eckContentSecurityPolicy, DocumentContext)); 632 (DoNotBufferData, AllowStoredCredentials, ClientRequestedCredentials, Ch eckContentSecurityPolicy, DocumentContext));
640 FetchRequest fetchRequest(m_request, FetchInitiatorTypeNames::document, main ResourceLoadOptions); 633 FetchRequest fetchRequest(m_request, FetchInitiatorTypeNames::document, main ResourceLoadOptions);
641 fetchRequest.setContentSecurityCheck(cspDisposition);
642
643 m_mainResource = RawResource::fetchMainResource(fetchRequest, fetcher(), m_s ubstituteData); 634 m_mainResource = RawResource::fetchMainResource(fetchRequest, fetcher(), m_s ubstituteData);
644 if (!m_mainResource) { 635 if (!m_mainResource) {
645 // If we block a main resource request, ensure that the resulting frame' s 636 m_request = ResourceRequest(blankURL());
646 // origin is unique, and that the redirect list is up-to-date with the 637 maybeLoadEmpty();
647 // resource we actually commit:
648 loadUnique();
649 appendRedirect(SecurityOrigin::urlWithUniqueSecurityOrigin());
650 return; 638 return;
651 } 639 }
652 // A bunch of headers are set when the underlying ResourceLoader is created, and m_request needs to include those. 640 // A bunch of headers are set when the underlying ResourceLoader is created, and m_request needs to include those.
653 // Even when using a cached resource, we may make some modification to the r equest, e.g. adding the referer header. 641 // Even when using a cached resource, we may make some modification to the r equest, e.g. adding the referer header.
654 m_request = mainResourceLoader() ? m_mainResource->resourceRequest() : fetch Request.resourceRequest(); 642 m_request = mainResourceLoader() ? m_mainResource->resourceRequest() : fetch Request.resourceRequest();
655 m_mainResource->addClient(this); 643 m_mainResource->addClient(this);
656 } 644 }
657 645
658 void DocumentLoader::endWriting(DocumentWriter* writer) 646 void DocumentLoader::endWriting(DocumentWriter* writer)
659 { 647 {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 { 690 {
703 m_writer = createWriterFor(init, mimeType(), m_writer ? m_writer->encoding() : emptyAtom, true, ForceSynchronousParsing); 691 m_writer = createWriterFor(init, mimeType(), m_writer ? m_writer->encoding() : emptyAtom, true, ForceSynchronousParsing);
704 if (!source.isNull()) 692 if (!source.isNull())
705 m_writer->appendReplacingData(source); 693 m_writer->appendReplacingData(source);
706 endWriting(m_writer.get()); 694 endWriting(m_writer.get());
707 } 695 }
708 696
709 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader); 697 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader);
710 698
711 } // namespace blink 699 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/loader/DocumentLoader.h ('k') | third_party/WebKit/Source/core/loader/FrameFetchContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698