OLD | NEW |
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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 if (m_documentLoader) | 173 if (m_documentLoader) |
174 frame = m_documentLoader->frame(); | 174 frame = m_documentLoader->frame(); |
175 else if (m_document && m_document->importsController()) | 175 else if (m_document && m_document->importsController()) |
176 frame = m_document->importsController()->master()->frame(); | 176 frame = m_document->importsController()->master()->frame(); |
177 ASSERT(frame); | 177 ASSERT(frame); |
178 return frame; | 178 return frame; |
179 } | 179 } |
180 | 180 |
181 void FrameFetchContext::addAdditionalRequestHeaders(ResourceRequest& request, Fe
tchResourceType type) | 181 void FrameFetchContext::addAdditionalRequestHeaders(ResourceRequest& request, Fe
tchResourceType type) |
182 { | 182 { |
183 bool isMainResource = type == FetchMainResource; | 183 if (type != FetchMainResource) { |
184 if (!isMainResource) { | |
185 RefPtr<SecurityOrigin> outgoingOrigin; | 184 RefPtr<SecurityOrigin> outgoingOrigin; |
186 if (!request.didSetHTTPReferrer()) { | 185 if (!request.didSetHTTPReferrer()) { |
187 ASSERT(m_document); | 186 ASSERT(m_document); |
188 outgoingOrigin = m_document->getSecurityOrigin(); | 187 outgoingOrigin = m_document->getSecurityOrigin(); |
189 request.setHTTPReferrer(SecurityPolicy::generateReferrer(m_document-
>getReferrerPolicy(), request.url(), m_document->outgoingReferrer())); | 188 request.setHTTPReferrer(SecurityPolicy::generateReferrer(m_document-
>getReferrerPolicy(), request.url(), m_document->outgoingReferrer())); |
190 } else { | 189 } else { |
191 RELEASE_ASSERT(SecurityPolicy::generateReferrer(request.getReferrerP
olicy(), request.url(), request.httpReferrer()).referrer == request.httpReferrer
()); | 190 RELEASE_ASSERT(SecurityPolicy::generateReferrer(request.getReferrerP
olicy(), request.url(), request.httpReferrer()).referrer == request.httpReferrer
()); |
192 outgoingOrigin = SecurityOrigin::createFromString(request.httpReferr
er()); | 191 outgoingOrigin = SecurityOrigin::createFromString(request.httpReferr
er()); |
193 } | 192 } |
194 | 193 |
195 request.addHTTPOriginIfNeeded(outgoingOrigin); | 194 request.addHTTPOriginIfNeeded(outgoingOrigin); |
196 } | 195 } |
197 | 196 |
198 if (m_document) | 197 if (m_document) |
199 request.setExternalRequestStateFromRequestorAddressSpace(m_document->add
ressSpace()); | 198 request.setExternalRequestStateFromRequestorAddressSpace(m_document->add
ressSpace()); |
200 | 199 |
201 // The remaining modifications are only necessary for HTTP and HTTPS. | 200 // The remaining modifications are only necessary for HTTP and HTTPS. |
202 if (!request.url().isEmpty() && !request.url().protocolIsInHTTPFamily()) | 201 if (!request.url().isEmpty() && !request.url().protocolIsInHTTPFamily()) |
203 return; | 202 return; |
204 | 203 |
205 if (frame()->loader().loadType() == FrameLoadTypeReload) | 204 if (frame()->loader().loadType() == FrameLoadTypeReload) |
206 request.clearHTTPHeaderField("Save-Data"); | 205 request.clearHTTPHeaderField("Save-Data"); |
207 | 206 |
208 if (frame()->settings() && frame()->settings()->dataSaverEnabled()) | 207 if (frame()->settings() && frame()->settings()->dataSaverEnabled()) |
209 request.setHTTPHeaderField("Save-Data", "on"); | 208 request.setHTTPHeaderField("Save-Data", "on"); |
210 | 209 |
211 frame()->loader().applyUserAgent(request); | 210 request.setDefaultHTTPUserAgent(AtomicString(frame()->loader().userAgent()))
; |
212 } | 211 } |
213 | 212 |
214 CachePolicy FrameFetchContext::getCachePolicy() const | 213 CachePolicy FrameFetchContext::getCachePolicy() const |
215 { | 214 { |
216 if (m_document && m_document->loadEventFinished()) | 215 if (m_document && m_document->loadEventFinished()) |
217 return CachePolicyVerify; | 216 return CachePolicyVerify; |
218 | 217 |
219 FrameLoadType loadType = frame()->loader().loadType(); | 218 FrameLoadType loadType = frame()->loader().loadType(); |
220 if (loadType == FrameLoadTypeReloadBypassingCache) | 219 if (loadType == FrameLoadTypeReloadBypassingCache) |
221 return CachePolicyReload; | 220 return CachePolicyReload; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 | 314 |
316 void FrameFetchContext::dispatchDidChangeResourcePriority(unsigned long identifi
er, ResourceLoadPriority loadPriority, int intraPriorityValue) | 315 void FrameFetchContext::dispatchDidChangeResourcePriority(unsigned long identifi
er, ResourceLoadPriority loadPriority, int intraPriorityValue) |
317 { | 316 { |
318 frame()->loader().client()->dispatchDidChangeResourcePriority(identifier, lo
adPriority, intraPriorityValue); | 317 frame()->loader().client()->dispatchDidChangeResourcePriority(identifier, lo
adPriority, intraPriorityValue); |
319 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceChangePriority", TRACE_EV
ENT_SCOPE_THREAD, "data", InspectorChangeResourcePriorityEvent::data(identifier,
loadPriority)); | 318 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceChangePriority", TRACE_EV
ENT_SCOPE_THREAD, "data", InspectorChangeResourcePriorityEvent::data(identifier,
loadPriority)); |
320 InspectorInstrumentation::didChangeResourcePriority(frame(), identifier, loa
dPriority); | 319 InspectorInstrumentation::didChangeResourcePriority(frame(), identifier, loa
dPriority); |
321 } | 320 } |
322 | 321 |
323 void FrameFetchContext::prepareRequest(unsigned long identifier, ResourceRequest
& request, const ResourceResponse& redirectResponse) | 322 void FrameFetchContext::prepareRequest(unsigned long identifier, ResourceRequest
& request, const ResourceResponse& redirectResponse) |
324 { | 323 { |
325 frame()->loader().applyUserAgent(request); | 324 request.setDefaultHTTPUserAgent(AtomicString(frame()->loader().userAgent()))
; |
326 frame()->loader().client()->dispatchWillSendRequest(m_documentLoader, identi
fier, request, redirectResponse); | 325 frame()->loader().client()->dispatchWillSendRequest(m_documentLoader, identi
fier, request, redirectResponse); |
327 } | 326 } |
328 | 327 |
329 void FrameFetchContext::dispatchWillSendRequest(unsigned long identifier, Resour
ceRequest& request, const ResourceResponse& redirectResponse, const FetchInitiat
orInfo& initiatorInfo) | 328 void FrameFetchContext::dispatchWillSendRequest(unsigned long identifier, Resour
ceRequest& request, const ResourceResponse& redirectResponse, const FetchInitiat
orInfo& initiatorInfo) |
330 { | 329 { |
331 // For initial requests, prepareRequest() is called in | 330 // For initial requests, prepareRequest() is called in |
332 // willStartLoadingResource(), before revalidation policy is determined. | 331 // willStartLoadingResource(), before revalidation policy is determined. |
333 // That call doesn't exist for redirects, so call preareRequest() here. | 332 // That call doesn't exist for redirects, so call preareRequest() here. |
334 if (!redirectResponse.isNull()) | 333 if (!redirectResponse.isNull()) |
335 prepareRequest(identifier, request, redirectResponse); | 334 prepareRequest(identifier, request, redirectResponse); |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 } | 834 } |
836 | 835 |
837 DEFINE_TRACE(FrameFetchContext) | 836 DEFINE_TRACE(FrameFetchContext) |
838 { | 837 { |
839 visitor->trace(m_document); | 838 visitor->trace(m_document); |
840 visitor->trace(m_documentLoader); | 839 visitor->trace(m_documentLoader); |
841 FetchContext::trace(visitor); | 840 FetchContext::trace(visitor); |
842 } | 841 } |
843 | 842 |
844 } // namespace blink | 843 } // namespace blink |
OLD | NEW |