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

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

Issue 1742923002: Commit empty document instead of canceling the load for blocked CSP/XFO responses. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address japhet@'s comment Created 4 years, 9 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
« no previous file with comments | « third_party/WebKit/Source/core/loader/DocumentLoader.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 , m_fetcher(FrameFetchContext::createContextAndFetcher(this)) 87 , m_fetcher(FrameFetchContext::createContextAndFetcher(this))
88 , m_originalRequest(req) 88 , m_originalRequest(req)
89 , m_substituteData(substituteData) 89 , m_substituteData(substituteData)
90 , m_request(req) 90 , m_request(req)
91 , m_isClientRedirect(false) 91 , m_isClientRedirect(false)
92 , m_replacesCurrentHistoryItem(false) 92 , m_replacesCurrentHistoryItem(false)
93 , m_navigationType(NavigationTypeOther) 93 , m_navigationType(NavigationTypeOther)
94 , m_documentLoadTiming(*this) 94 , m_documentLoadTiming(*this)
95 , m_timeOfLastDataReceived(0.0) 95 , m_timeOfLastDataReceived(0.0)
96 , m_applicationCacheHost(ApplicationCacheHost::create(this)) 96 , m_applicationCacheHost(ApplicationCacheHost::create(this))
97 , m_wasBlockedAfterXFrameOptionsOrCSP(false)
97 , m_state(NotStarted) 98 , m_state(NotStarted)
98 , m_inDataReceived(false) 99 , m_inDataReceived(false)
99 , m_dataBuffer(SharedBuffer::create()) 100 , m_dataBuffer(SharedBuffer::create())
100 { 101 {
101 } 102 }
102 103
103 FrameLoader* DocumentLoader::frameLoader() const 104 FrameLoader* DocumentLoader::frameLoader() const
104 { 105 {
105 if (!m_frame) 106 if (!m_frame)
106 return nullptr; 107 return nullptr;
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 373
373 if (!canShowMIMEType(m_response.mimeType(), m_frame->page())) 374 if (!canShowMIMEType(m_response.mimeType(), m_frame->page()))
374 return false; 375 return false;
375 return true; 376 return true;
376 } 377 }
377 378
378 void DocumentLoader::cancelLoadAfterXFrameOptionsOrCSPDenied(const ResourceRespo nse& response) 379 void DocumentLoader::cancelLoadAfterXFrameOptionsOrCSPDenied(const ResourceRespo nse& response)
379 { 380 {
380 InspectorInstrumentation::continueAfterXFrameOptionsDenied(m_frame, this, ma inResourceIdentifier(), response); 381 InspectorInstrumentation::continueAfterXFrameOptionsDenied(m_frame, this, ma inResourceIdentifier(), response);
381 382
382 frame()->document()->enforceSandboxFlags(SandboxOrigin); 383 setWasBlockedAfterXFrameOptionsOrCSP();
383 if (FrameOwner* owner = frame()->owner())
384 owner->dispatchLoad();
385 384
386 // The load event might have detached this frame. In that case, the load wil l already have been cancelled during detach. 385 // Pretend that this was an empty HTTP 200 response.
387 if (frameLoader()) 386 clearMainResourceHandle();
388 cancelMainResourceLoad(ResourceError::cancelledError(m_request.url())); 387 m_response = ResourceResponse(blankURL(), "text/html", 0, nullAtom, String() );
388 finishedLoading(monotonicallyIncreasingTime());
389
389 return; 390 return;
390 } 391 }
391 392
392 void DocumentLoader::responseReceived(Resource* resource, const ResourceResponse & response, PassOwnPtr<WebDataConsumerHandle> handle) 393 void DocumentLoader::responseReceived(Resource* resource, const ResourceResponse & response, PassOwnPtr<WebDataConsumerHandle> handle)
393 { 394 {
394 ASSERT_UNUSED(resource, m_mainResource == resource); 395 ASSERT_UNUSED(resource, m_mainResource == resource);
395 ASSERT_UNUSED(handle, !handle); 396 ASSERT_UNUSED(handle, !handle);
396 RefPtrWillBeRawPtr<DocumentLoader> protect(this); 397 RefPtrWillBeRawPtr<DocumentLoader> protect(this);
397 ASSERT(frame()); 398 ASSERT(frame());
398 399
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 { 766 {
766 m_writer = createWriterFor(ownerDocument, init, mimeType(), m_writer ? m_wri ter->encoding() : emptyAtom, true, ForceSynchronousParsing); 767 m_writer = createWriterFor(ownerDocument, init, mimeType(), m_writer ? m_wri ter->encoding() : emptyAtom, true, ForceSynchronousParsing);
767 if (!source.isNull()) 768 if (!source.isNull())
768 m_writer->appendReplacingData(source); 769 m_writer->appendReplacingData(source);
769 endWriting(m_writer.get()); 770 endWriting(m_writer.get());
770 } 771 }
771 772
772 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader); 773 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader);
773 774
774 } // namespace blink 775 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/loader/DocumentLoader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698