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/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
9 #include "bindings/modules/v8/ArrayBufferViewOrBlobOrStringOrFormData.h" | 9 #include "bindings/modules/v8/ArrayBufferViewOrBlobOrStringOrFormData.h" |
10 #include "core/dom/DOMArrayBufferView.h" | 10 #include "core/dom/DOMArrayBufferView.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 ExecutionContext* context = scriptState->getExecutionContext(); | 109 ExecutionContext* context = scriptState->getExecutionContext(); |
110 KURL url = context->completeURL(urlstring); | 110 KURL url = context->completeURL(urlstring); |
111 if (!canSendBeacon(context, url, exceptionState)) | 111 if (!canSendBeacon(context, url, exceptionState)) |
112 return false; | 112 return false; |
113 | 113 |
114 int allowance = maxAllowance(); | 114 int allowance = maxAllowance(); |
115 size_t beaconSize = 0; | 115 size_t beaconSize = 0; |
116 bool allowed; | 116 bool allowed; |
117 | 117 |
118 if (data.isArrayBufferView()) { | 118 if (data.isArrayBufferView()) { |
119 allowed = PingLoader::sendBeacon(supplementable()->frame(), allowance, url, | 119 allowed = |
120 data.getAsArrayBufferView(), beaconSize); | 120 PingLoader::sendBeacon(supplementable()->frame(), allowance, url, |
| 121 data.getAsArrayBufferView().view(), beaconSize); |
121 } else if (data.isBlob()) { | 122 } else if (data.isBlob()) { |
122 Blob* blob = data.getAsBlob(); | 123 Blob* blob = data.getAsBlob(); |
123 if (!FetchUtils::isSimpleContentType(AtomicString(blob->type()))) { | 124 if (!FetchUtils::isSimpleContentType(AtomicString(blob->type()))) { |
124 UseCounter::count(context, | 125 UseCounter::count(context, |
125 UseCounter::SendBeaconWithNonSimpleContentType); | 126 UseCounter::SendBeaconWithNonSimpleContentType); |
126 if (RuntimeEnabledFeatures:: | 127 if (RuntimeEnabledFeatures:: |
127 sendBeaconThrowForBlobWithNonSimpleTypeEnabled()) { | 128 sendBeaconThrowForBlobWithNonSimpleTypeEnabled()) { |
128 exceptionState.throwSecurityError( | 129 exceptionState.throwSecurityError( |
129 "sendBeacon() with a Blob whose type is not CORS-safelisted MIME " | 130 "sendBeacon() with a Blob whose type is not CORS-safelisted MIME " |
130 "type is disallowed experimentally. See http://crbug.com/490015 " | 131 "type is disallowed experimentally. See http://crbug.com/490015 " |
(...skipping 19 matching lines...) Expand all Loading... |
150 return false; | 151 return false; |
151 } | 152 } |
152 | 153 |
153 // Only accumulate transmission size if a limit is imposed. | 154 // Only accumulate transmission size if a limit is imposed. |
154 if (allowance >= 0) | 155 if (allowance >= 0) |
155 addTransmittedBytes(beaconSize); | 156 addTransmittedBytes(beaconSize); |
156 return true; | 157 return true; |
157 } | 158 } |
158 | 159 |
159 } // namespace blink | 160 } // namespace blink |
OLD | NEW |