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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 if (!CanSendBeacon(context, url, exception_state)) | 111 if (!CanSendBeacon(context, url, exception_state)) |
112 return false; | 112 return false; |
113 | 113 |
114 int allowance = MaxAllowance(); | 114 int allowance = MaxAllowance(); |
115 size_t beacon_size = 0; | 115 size_t beacon_size = 0; |
116 bool allowed; | 116 bool allowed; |
117 | 117 |
118 if (data.isArrayBufferView()) { | 118 if (data.isArrayBufferView()) { |
119 allowed = | 119 allowed = |
120 PingLoader::SendBeacon(GetSupplementable()->GetFrame(), allowance, url, | 120 PingLoader::SendBeacon(GetSupplementable()->GetFrame(), allowance, url, |
121 data.getAsArrayBufferView(), beacon_size); | 121 data.getAsArrayBufferView().View(), beacon_size); |
122 } else if (data.isBlob()) { | 122 } else if (data.isBlob()) { |
123 Blob* blob = data.getAsBlob(); | 123 Blob* blob = data.getAsBlob(); |
124 if (!FetchUtils::IsSimpleContentType(AtomicString(blob->type()))) { | 124 if (!FetchUtils::IsSimpleContentType(AtomicString(blob->type()))) { |
125 UseCounter::Count(context, | 125 UseCounter::Count(context, |
126 UseCounter::kSendBeaconWithNonSimpleContentType); | 126 UseCounter::kSendBeaconWithNonSimpleContentType); |
127 if (RuntimeEnabledFeatures:: | 127 if (RuntimeEnabledFeatures:: |
128 sendBeaconThrowForBlobWithNonSimpleTypeEnabled()) { | 128 sendBeaconThrowForBlobWithNonSimpleTypeEnabled()) { |
129 exception_state.ThrowSecurityError( | 129 exception_state.ThrowSecurityError( |
130 "sendBeacon() with a Blob whose type is not CORS-safelisted MIME " | 130 "sendBeacon() with a Blob whose type is not CORS-safelisted MIME " |
131 "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... |
151 return false; | 151 return false; |
152 } | 152 } |
153 | 153 |
154 // Only accumulate transmission size if a limit is imposed. | 154 // Only accumulate transmission size if a limit is imposed. |
155 if (allowance >= 0) | 155 if (allowance >= 0) |
156 AddTransmittedBytes(beacon_size); | 156 AddTransmittedBytes(beacon_size); |
157 return true; | 157 return true; |
158 } | 158 } |
159 | 159 |
160 } // namespace blink | 160 } // namespace blink |
OLD | NEW |