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

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

Issue 2456013002: CSP: 'connect-src' should not cause exceptions. (Closed)
Patch Set: Ugh. Created 3 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
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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 } 418 }
419 419
420 bool sendBeaconCommon(LocalFrame* frame, 420 bool sendBeaconCommon(LocalFrame* frame,
421 int allowance, 421 int allowance,
422 const KURL& url, 422 const KURL& url,
423 const Beacon& beacon, 423 const Beacon& beacon,
424 int& payloadLength) { 424 int& payloadLength) {
425 if (!frame->document()) 425 if (!frame->document())
426 return false; 426 return false;
427 427
428 // TODO(mkwst): CSP is not enforced on redirects, crbug.com/372197
429 if (!ContentSecurityPolicy::shouldBypassMainWorld(frame->document()) &&
430 !frame->document()->contentSecurityPolicy()->allowConnectToSource(url)) {
431 // We're simulating a network failure here, so we return 'true'.
432 return true;
433 }
434
428 unsigned long long entitySize = beacon.size(); 435 unsigned long long entitySize = beacon.size();
429 if (allowance < 0 || static_cast<unsigned long long>(allowance) < entitySize) 436 if (allowance < 0 || static_cast<unsigned long long>(allowance) < entitySize)
430 return false; 437 return false;
431 438
432 payloadLength = entitySize; 439 payloadLength = entitySize;
433 440
434 ResourceRequest request(url); 441 ResourceRequest request(url);
435 request.setHTTPMethod(HTTPNames::POST); 442 request.setHTTPMethod(HTTPNames::POST);
436 request.setHTTPHeaderField(HTTPNames::Cache_Control, "max-age=0"); 443 request.setHTTPHeaderField(HTTPNames::Cache_Control, "max-age=0");
437 finishPingRequestInitialization(request, frame, 444 finishPingRequestInitialization(request, frame,
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 bool PingLoader::sendBeacon(LocalFrame* frame, 564 bool PingLoader::sendBeacon(LocalFrame* frame,
558 int allowance, 565 int allowance,
559 const KURL& beaconURL, 566 const KURL& beaconURL,
560 Blob* data, 567 Blob* data,
561 int& payloadLength) { 568 int& payloadLength) {
562 BeaconBlob beacon(data); 569 BeaconBlob beacon(data);
563 return sendBeaconCommon(frame, allowance, beaconURL, beacon, payloadLength); 570 return sendBeaconCommon(frame, allowance, beaconURL, beacon, payloadLength);
564 } 571 }
565 572
566 } // namespace blink 573 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698