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

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

Issue 2147473002: Set 'ResourceRequest::requestorOrigin' in Blink for more request types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: jochen Created 4 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
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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 191
192 if (frame()->loader().loadType() == FrameLoadTypeReload) 192 if (frame()->loader().loadType() == FrameLoadTypeReload)
193 request.clearHTTPHeaderField("Save-Data"); 193 request.clearHTTPHeaderField("Save-Data");
194 194
195 if (frame()->settings() && frame()->settings()->dataSaverEnabled()) 195 if (frame()->settings() && frame()->settings()->dataSaverEnabled())
196 request.setHTTPHeaderField("Save-Data", "on"); 196 request.setHTTPHeaderField("Save-Data", "on");
197 197
198 frame()->loader().applyUserAgent(request); 198 frame()->loader().applyUserAgent(request);
199 } 199 }
200 200
201 void FrameFetchContext::setFirstPartyForCookies(ResourceRequest& request)
202 {
203 if (frame()->tree().top()->isLocalFrame())
204 request.setFirstPartyForCookies(toLocalFrame(frame()->tree().top())->doc ument()->firstPartyForCookies());
205 }
206
207 CachePolicy FrameFetchContext::getCachePolicy() const 201 CachePolicy FrameFetchContext::getCachePolicy() const
208 { 202 {
209 if (m_document && m_document->loadEventFinished()) 203 if (m_document && m_document->loadEventFinished())
210 return CachePolicyVerify; 204 return CachePolicyVerify;
211 205
212 FrameLoadType loadType = frame()->loader().loadType(); 206 FrameLoadType loadType = frame()->loader().loadType();
213 if (loadType == FrameLoadTypeReloadBypassingCache) 207 if (loadType == FrameLoadTypeReloadBypassingCache)
214 return CachePolicyReload; 208 return CachePolicyReload;
215 209
216 Frame* parentFrame = frame()->tree().parent(); 210 Frame* parentFrame = frame()->tree().parent();
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 void FrameFetchContext::addCSPHeaderIfNecessary(Resource::Type type, FetchReques t& fetchRequest) 735 void FrameFetchContext::addCSPHeaderIfNecessary(Resource::Type type, FetchReques t& fetchRequest)
742 { 736 {
743 if (!m_document) 737 if (!m_document)
744 return; 738 return;
745 739
746 const ContentSecurityPolicy* csp = m_document->contentSecurityPolicy(); 740 const ContentSecurityPolicy* csp = m_document->contentSecurityPolicy();
747 if (csp->shouldSendCSPHeader(type)) 741 if (csp->shouldSendCSPHeader(type))
748 fetchRequest.mutableResourceRequest().addHTTPHeaderField("CSP", "active" ); 742 fetchRequest.mutableResourceRequest().addHTTPHeaderField("CSP", "active" );
749 } 743 }
750 744
745 void FrameFetchContext::populateRequestData(ResourceRequest& request)
746 {
747 if (!m_document)
748 return;
749
750 if (request.firstPartyForCookies().isNull()) {
751 request.setFirstPartyForCookies(m_document
752 ? m_document->firstPartyForCookies()
753 : SecurityOrigin::urlWithUniqueSecurityOrigin());
754 }
755
756 // Subresource requests inherit their requestor origin from |m_document| dir ectly.
757 // Top-level and nested frame types are taken care of in 'FrameLoadRequest() '.
758 // Auxiliary frame types in 'createWindow()' and 'FrameLoader::load'.
759 if (request.frameType() == WebURLRequest::FrameTypeNone && !request.requesto rOrigin()) {
760 request.setRequestorOrigin(m_document->isSandboxed(SandboxOrigin)
761 ? SecurityOrigin::create(m_document->url())
762 : m_document->getSecurityOrigin());
763 }
764 }
765
751 MHTMLArchive* FrameFetchContext::archive() const 766 MHTMLArchive* FrameFetchContext::archive() const
752 { 767 {
753 ASSERT(!isMainFrame()); 768 ASSERT(!isMainFrame());
754 // TODO(nasko): How should this work with OOPIF? 769 // TODO(nasko): How should this work with OOPIF?
755 // The MHTMLArchive is parsed as a whole, but can be constructed from 770 // The MHTMLArchive is parsed as a whole, but can be constructed from
756 // frames in mutliple processes. In that case, which process should parse 771 // frames in mutliple processes. In that case, which process should parse
757 // it and how should the output be spread back across multiple processes? 772 // it and how should the output be spread back across multiple processes?
758 if (!frame()->tree().parent()->isLocalFrame()) 773 if (!frame()->tree().parent()->isLocalFrame())
759 return nullptr; 774 return nullptr;
760 return toLocalFrame(frame()->tree().parent())->loader().documentLoader()->fe tcher()->archive(); 775 return toLocalFrame(frame()->tree().parent())->loader().documentLoader()->fe tcher()->archive();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 } 809 }
795 810
796 DEFINE_TRACE(FrameFetchContext) 811 DEFINE_TRACE(FrameFetchContext)
797 { 812 {
798 visitor->trace(m_document); 813 visitor->trace(m_document);
799 visitor->trace(m_documentLoader); 814 visitor->trace(m_documentLoader);
800 FetchContext::trace(visitor); 815 FetchContext::trace(visitor);
801 } 816 }
802 817
803 } // namespace blink 818 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698