OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/beacon/NavigatorBeacon.h" | 5 #include "modules/beacon/NavigatorBeacon.h" |
6 | 6 |
7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
8 #include "bindings/modules/v8/ArrayBufferViewOrBlobOrStringOrFormData.h" | 8 #include "bindings/modules/v8/ArrayBufferViewOrBlobOrStringOrFormData.h" |
9 #include "core/dom/DOMArrayBufferView.h" | 9 #include "core/dom/DOMArrayBufferView.h" |
10 #include "core/dom/ExceptionCode.h" | 10 #include "core/dom/ExceptionCode.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 } | 54 } |
55 // For now, only support HTTP and related. | 55 // For now, only support HTTP and related. |
56 if (!url.protocolIsInHTTPFamily()) { | 56 if (!url.protocolIsInHTTPFamily()) { |
57 exceptionState.throwDOMException( | 57 exceptionState.throwDOMException( |
58 SyntaxError, "Beacons are only supported over HTTP(S)."); | 58 SyntaxError, "Beacons are only supported over HTTP(S)."); |
59 return false; | 59 return false; |
60 } | 60 } |
61 // FIXME: CSP is not enforced on redirects, crbug.com/372197 | 61 // FIXME: CSP is not enforced on redirects, crbug.com/372197 |
62 if (!ContentSecurityPolicy::shouldBypassMainWorld(context) && | 62 if (!ContentSecurityPolicy::shouldBypassMainWorld(context) && |
63 !context->contentSecurityPolicy()->allowConnectToSource(url)) { | 63 !context->contentSecurityPolicy()->allowConnectToSource(url)) { |
64 // We can safely expose the URL to JavaScript, as these checks happen synchr
onously before redirection. JavaScript receives no new information. | 64 // We can safely expose the URL to JavaScript, as these checks happen |
| 65 // synchronously before redirection. JavaScript receives no new information. |
65 exceptionState.throwSecurityError( | 66 exceptionState.throwSecurityError( |
66 "Refused to send beacon to '" + url.elidedString() + | 67 "Refused to send beacon to '" + url.elidedString() + |
67 "' because it violates the document's Content Security Policy."); | 68 "' because it violates the document's Content Security Policy."); |
68 return false; | 69 return false; |
69 } | 70 } |
70 | 71 |
71 // If detached from frame, do not allow sending a Beacon. | 72 // If detached from frame, do not allow sending a Beacon. |
72 if (!frame() || !frame()->client()) | 73 if (!frame() || !frame()->client()) |
73 return false; | 74 return false; |
74 | 75 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 if (allowed) { | 141 if (allowed) { |
141 impl.addTransmittedBytes(bytes); | 142 impl.addTransmittedBytes(bytes); |
142 return true; | 143 return true; |
143 } | 144 } |
144 | 145 |
145 UseCounter::count(context, UseCounter::SendBeaconQuotaExceeded); | 146 UseCounter::count(context, UseCounter::SendBeaconQuotaExceeded); |
146 return false; | 147 return false; |
147 } | 148 } |
148 | 149 |
149 } // namespace blink | 150 } // namespace blink |
OLD | NEW |