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

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

Issue 2500023002: <a ping="..."> should be covered by connect-src CSP directive. (Closed)
Patch Set: Created 4 years, 1 month 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) 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 15 matching lines...) Expand all
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 * 29 *
30 */ 30 */
31 31
32 #include "core/loader/PingLoader.h" 32 #include "core/loader/PingLoader.h"
33 33
34 #include "core/dom/DOMArrayBufferView.h" 34 #include "core/dom/DOMArrayBufferView.h"
35 #include "core/dom/Document.h" 35 #include "core/dom/Document.h"
36 #include "core/dom/SecurityContext.h"
36 #include "core/fetch/CrossOriginAccessControl.h" 37 #include "core/fetch/CrossOriginAccessControl.h"
37 #include "core/fetch/FetchContext.h" 38 #include "core/fetch/FetchContext.h"
38 #include "core/fetch/FetchInitiatorTypeNames.h" 39 #include "core/fetch/FetchInitiatorTypeNames.h"
39 #include "core/fetch/FetchUtils.h" 40 #include "core/fetch/FetchUtils.h"
40 #include "core/fetch/ResourceFetcher.h" 41 #include "core/fetch/ResourceFetcher.h"
41 #include "core/fetch/UniqueIdentifier.h" 42 #include "core/fetch/UniqueIdentifier.h"
42 #include "core/fileapi/File.h" 43 #include "core/fileapi/File.h"
43 #include "core/frame/FrameConsole.h" 44 #include "core/frame/FrameConsole.h"
44 #include "core/frame/LocalFrame.h" 45 #include "core/frame/LocalFrame.h"
46 #include "core/frame/csp/ContentSecurityPolicy.h"
45 #include "core/html/FormData.h" 47 #include "core/html/FormData.h"
46 #include "core/inspector/ConsoleMessage.h" 48 #include "core/inspector/ConsoleMessage.h"
47 #include "core/inspector/InspectorInstrumentation.h" 49 #include "core/inspector/InspectorInstrumentation.h"
48 #include "core/inspector/InspectorTraceEvents.h" 50 #include "core/inspector/InspectorTraceEvents.h"
49 #include "core/loader/FrameLoader.h" 51 #include "core/loader/FrameLoader.h"
50 #include "core/loader/FrameLoaderClient.h" 52 #include "core/loader/FrameLoaderClient.h"
51 #include "core/loader/MixedContentChecker.h" 53 #include "core/loader/MixedContentChecker.h"
52 #include "core/page/Page.h" 54 #include "core/page/Page.h"
53 #include "platform/exported/WrappedResourceRequest.h" 55 #include "platform/exported/WrappedResourceRequest.h"
54 #include "platform/exported/WrappedResourceResponse.h" 56 #include "platform/exported/WrappedResourceResponse.h"
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 AllowStoredCredentials, false); 468 AllowStoredCredentials, false);
467 } 469 }
468 470
469 // http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#hyperl ink-auditing 471 // http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#hyperl ink-auditing
470 void PingLoader::sendLinkAuditPing(LocalFrame* frame, 472 void PingLoader::sendLinkAuditPing(LocalFrame* frame,
471 const KURL& pingURL, 473 const KURL& pingURL,
472 const KURL& destinationURL) { 474 const KURL& destinationURL) {
473 if (!pingURL.protocolIsInHTTPFamily()) 475 if (!pingURL.protocolIsInHTTPFamily())
474 return; 476 return;
475 477
478 if (ContentSecurityPolicy* policy =
479 frame->securityContext()->contentSecurityPolicy()) {
480 if (!policy->allowConnectToSource(pingURL))
481 return;
482 }
483
476 ResourceRequest request(pingURL); 484 ResourceRequest request(pingURL);
477 request.setHTTPMethod(HTTPNames::POST); 485 request.setHTTPMethod(HTTPNames::POST);
478 request.setHTTPContentType("text/ping"); 486 request.setHTTPContentType("text/ping");
479 request.setHTTPBody(EncodedFormData::create("PING")); 487 request.setHTTPBody(EncodedFormData::create("PING"));
480 request.setHTTPHeaderField(HTTPNames::Cache_Control, "max-age=0"); 488 request.setHTTPHeaderField(HTTPNames::Cache_Control, "max-age=0");
481 finishPingRequestInitialization(request, frame, 489 finishPingRequestInitialization(request, frame,
482 WebURLRequest::RequestContextPing); 490 WebURLRequest::RequestContextPing);
483 491
484 // addAdditionalRequestHeaders() will have added a referrer for same origin 492 // addAdditionalRequestHeaders() will have added a referrer for same origin
485 // requests, but the spec omits the referrer. 493 // requests, but the spec omits the referrer.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 bool PingLoader::sendBeacon(LocalFrame* frame, 559 bool PingLoader::sendBeacon(LocalFrame* frame,
552 int allowance, 560 int allowance,
553 const KURL& beaconURL, 561 const KURL& beaconURL,
554 Blob* data, 562 Blob* data,
555 int& payloadLength) { 563 int& payloadLength) {
556 BeaconBlob beacon(data); 564 BeaconBlob beacon(data);
557 return sendBeaconCommon(frame, allowance, beaconURL, beacon, payloadLength); 565 return sendBeaconCommon(frame, allowance, beaconURL, beacon, payloadLength);
558 } 566 }
559 567
560 } // namespace blink 568 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/connect-src-anchor-ping-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698