| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "core/loader/UniqueIdentifier.h" | 43 #include "core/loader/UniqueIdentifier.h" |
| 44 #include "core/page/Page.h" | 44 #include "core/page/Page.h" |
| 45 #include "platform/exported/WrappedResourceRequest.h" | 45 #include "platform/exported/WrappedResourceRequest.h" |
| 46 #include "platform/network/ResourceError.h" | 46 #include "platform/network/ResourceError.h" |
| 47 #include "platform/network/ResourceRequest.h" | 47 #include "platform/network/ResourceRequest.h" |
| 48 #include "platform/network/ResourceResponse.h" | 48 #include "platform/network/ResourceResponse.h" |
| 49 #include "platform/weborigin/SecurityOrigin.h" | 49 #include "platform/weborigin/SecurityOrigin.h" |
| 50 #include "platform/weborigin/SecurityPolicy.h" | 50 #include "platform/weborigin/SecurityPolicy.h" |
| 51 #include "public/platform/Platform.h" | 51 #include "public/platform/Platform.h" |
| 52 #include "public/platform/WebURLLoader.h" | 52 #include "public/platform/WebURLLoader.h" |
| 53 #include "public/platform/WebURLRequest.h" |
| 53 #include "public/platform/WebURLResponse.h" | 54 #include "public/platform/WebURLResponse.h" |
| 54 #include "wtf/OwnPtr.h" | 55 #include "wtf/OwnPtr.h" |
| 55 | 56 |
| 56 namespace WebCore { | 57 namespace WebCore { |
| 57 | 58 |
| 58 void PingLoader::loadImage(LocalFrame* frame, const KURL& url) | 59 void PingLoader::loadImage(LocalFrame* frame, const KURL& url) |
| 59 { | 60 { |
| 60 if (!frame->document()->securityOrigin()->canDisplay(url)) { | 61 if (!frame->document()->securityOrigin()->canDisplay(url)) { |
| 61 FrameLoader::reportLocalLoadFailed(frame, url.string()); | 62 FrameLoader::reportLocalLoadFailed(frame, url.string()); |
| 62 return; | 63 return; |
| 63 } | 64 } |
| 64 | 65 |
| 65 ResourceRequest request(url); | 66 ResourceRequest request(url); |
| 66 request.setTargetType(ResourceRequest::TargetIsPing); | 67 request.setRequestContext(blink::WebURLRequest::RequestContextPing); |
| 67 request.setHTTPHeaderField("Cache-Control", "max-age=0"); | 68 request.setHTTPHeaderField("Cache-Control", "max-age=0"); |
| 68 frame->loader().fetchContext().addAdditionalRequestHeaders(frame->document()
, request, FetchSubresource); | 69 frame->loader().fetchContext().addAdditionalRequestHeaders(frame->document()
, request, FetchSubresource); |
| 69 frame->loader().fetchContext().setFirstPartyForCookies(request); | 70 frame->loader().fetchContext().setFirstPartyForCookies(request); |
| 70 | 71 |
| 71 FetchInitiatorInfo initiatorInfo; | 72 FetchInitiatorInfo initiatorInfo; |
| 72 initiatorInfo.name = FetchInitiatorTypeNames::ping; | 73 initiatorInfo.name = FetchInitiatorTypeNames::ping; |
| 73 PingLoader::start(frame, request, initiatorInfo); | 74 PingLoader::start(frame, request, initiatorInfo); |
| 74 } | 75 } |
| 75 | 76 |
| 76 // http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#hyperl
ink-auditing | 77 // http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#hyperl
ink-auditing |
| 77 void PingLoader::sendLinkAuditPing(LocalFrame* frame, const KURL& pingURL, const
KURL& destinationURL) | 78 void PingLoader::sendLinkAuditPing(LocalFrame* frame, const KURL& pingURL, const
KURL& destinationURL) |
| 78 { | 79 { |
| 79 ResourceRequest request(pingURL); | 80 ResourceRequest request(pingURL); |
| 80 request.setTargetType(ResourceRequest::TargetIsPing); | 81 request.setRequestContext(blink::WebURLRequest::RequestContextPing); |
| 81 request.setHTTPMethod("POST"); | 82 request.setHTTPMethod("POST"); |
| 82 request.setHTTPContentType("text/ping"); | 83 request.setHTTPContentType("text/ping"); |
| 83 request.setHTTPBody(FormData::create("PING")); | 84 request.setHTTPBody(FormData::create("PING")); |
| 84 request.setHTTPHeaderField("Cache-Control", "max-age=0"); | 85 request.setHTTPHeaderField("Cache-Control", "max-age=0"); |
| 85 frame->loader().fetchContext().addAdditionalRequestHeaders(frame->document()
, request, FetchSubresource); | 86 frame->loader().fetchContext().addAdditionalRequestHeaders(frame->document()
, request, FetchSubresource); |
| 86 frame->loader().fetchContext().setFirstPartyForCookies(request); | 87 frame->loader().fetchContext().setFirstPartyForCookies(request); |
| 87 | 88 |
| 88 RefPtr<SecurityOrigin> pingOrigin = SecurityOrigin::create(pingURL); | 89 RefPtr<SecurityOrigin> pingOrigin = SecurityOrigin::create(pingURL); |
| 89 // addAdditionalRequestHeaders() will have added a referrer for same origin
requests, | 90 // addAdditionalRequestHeaders() will have added a referrer for same origin
requests, |
| 90 // but the spec omits the referrer for same origin. | 91 // but the spec omits the referrer for same origin. |
| 91 if (frame->document()->securityOrigin()->isSameSchemeHostPort(pingOrigin.get
())) | 92 if (frame->document()->securityOrigin()->isSameSchemeHostPort(pingOrigin.get
())) |
| 92 request.clearHTTPReferrer(); | 93 request.clearHTTPReferrer(); |
| 93 | 94 |
| 94 request.setHTTPHeaderField("Ping-To", AtomicString(destinationURL.string()))
; | 95 request.setHTTPHeaderField("Ping-To", AtomicString(destinationURL.string()))
; |
| 95 | 96 |
| 96 // Ping-From follows the same rules as the default referrer beahavior for su
bresource requests. | 97 // Ping-From follows the same rules as the default referrer beahavior for su
bresource requests. |
| 97 // FIXME: Should Ping-From obey ReferrerPolicy? | 98 // FIXME: Should Ping-From obey ReferrerPolicy? |
| 98 if (!SecurityPolicy::shouldHideReferrer(pingURL, frame->document()->url().st
ring())) | 99 if (!SecurityPolicy::shouldHideReferrer(pingURL, frame->document()->url().st
ring())) |
| 99 request.setHTTPHeaderField("Ping-From", AtomicString(frame->document()->
url().string())); | 100 request.setHTTPHeaderField("Ping-From", AtomicString(frame->document()->
url().string())); |
| 100 | 101 |
| 101 FetchInitiatorInfo initiatorInfo; | 102 FetchInitiatorInfo initiatorInfo; |
| 102 initiatorInfo.name = FetchInitiatorTypeNames::ping; | 103 initiatorInfo.name = FetchInitiatorTypeNames::ping; |
| 103 PingLoader::start(frame, request, initiatorInfo); | 104 PingLoader::start(frame, request, initiatorInfo); |
| 104 } | 105 } |
| 105 | 106 |
| 106 void PingLoader::sendViolationReport(LocalFrame* frame, const KURL& reportURL, P
assRefPtr<FormData> report, ViolationReportType type) | 107 void PingLoader::sendViolationReport(LocalFrame* frame, const KURL& reportURL, P
assRefPtr<FormData> report, ViolationReportType type) |
| 107 { | 108 { |
| 108 ResourceRequest request(reportURL); | 109 ResourceRequest request(reportURL); |
| 109 request.setTargetType(ResourceRequest::TargetIsSubresource); | 110 request.setRequestContext(blink::WebURLRequest::RequestContextPing); |
| 110 request.setHTTPMethod("POST"); | 111 request.setHTTPMethod("POST"); |
| 111 request.setHTTPContentType(type == ContentSecurityPolicyViolationReport ? "a
pplication/csp-report" : "application/json"); | 112 request.setHTTPContentType(type == ContentSecurityPolicyViolationReport ? "a
pplication/csp-report" : "application/json"); |
| 112 request.setHTTPBody(report); | 113 request.setHTTPBody(report); |
| 113 frame->loader().fetchContext().addAdditionalRequestHeaders(frame->document()
, request, FetchSubresource); | 114 frame->loader().fetchContext().addAdditionalRequestHeaders(frame->document()
, request, FetchSubresource); |
| 114 frame->loader().fetchContext().setFirstPartyForCookies(request); | 115 frame->loader().fetchContext().setFirstPartyForCookies(request); |
| 115 | 116 |
| 116 FetchInitiatorInfo initiatorInfo; | 117 FetchInitiatorInfo initiatorInfo; |
| 117 initiatorInfo.name = FetchInitiatorTypeNames::violationreport; | 118 initiatorInfo.name = FetchInitiatorTypeNames::violationreport; |
| 118 PingLoader::start(frame, request, initiatorInfo, SecurityOrigin::create(repo
rtURL)->isSameSchemeHostPort(frame->document()->securityOrigin()) ? AllowStoredC
redentials : DoNotAllowStoredCredentials); | 119 PingLoader::start(frame, request, initiatorInfo, SecurityOrigin::create(repo
rtURL)->isSameSchemeHostPort(frame->document()->securityOrigin()) ? AllowStoredC
redentials : DoNotAllowStoredCredentials); |
| 119 } | 120 } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 { | 204 { |
| 204 if (Page* page = this->page()) { | 205 if (Page* page = this->page()) { |
| 205 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Re
sourceFinish", "data", InspectorResourceFinishEvent::data(m_identifier, 0, true)
); | 206 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Re
sourceFinish", "data", InspectorResourceFinishEvent::data(m_identifier, 0, true)
); |
| 206 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Ti
meline migrates to tracing. | 207 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Ti
meline migrates to tracing. |
| 207 InspectorInstrumentation::didFailLoading(page->deprecatedLocalMainFrame(
), m_identifier, ResourceError::cancelledError(m_url)); | 208 InspectorInstrumentation::didFailLoading(page->deprecatedLocalMainFrame(
), m_identifier, ResourceError::cancelledError(m_url)); |
| 208 } | 209 } |
| 209 delete this; | 210 delete this; |
| 210 } | 211 } |
| 211 | 212 |
| 212 } | 213 } |
| OLD | NEW |