| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 PingLoader::SendBeacon(GetSupplementable()->GetFrame(), allowance, url, | 120 PingLoader::SendBeacon(GetSupplementable()->GetFrame(), allowance, url, |
| 121 data.getAsArrayBufferView().View(), 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 any of the " |
| 131 "type is disallowed experimentally. See http://crbug.com/490015 " | 131 "CORS-safelisted values for the Content-Type request header is " |
| 132 "for details."); | 132 "disabled temporarily. See http://crbug.com/490015 for details."); |
| 133 return false; | 133 return false; |
| 134 } | 134 } |
| 135 } | 135 } |
| 136 allowed = PingLoader::SendBeacon(GetSupplementable()->GetFrame(), allowance, | 136 allowed = PingLoader::SendBeacon(GetSupplementable()->GetFrame(), allowance, |
| 137 url, blob, beacon_size); | 137 url, blob, beacon_size); |
| 138 } else if (data.isString()) { | 138 } else if (data.isString()) { |
| 139 allowed = PingLoader::SendBeacon(GetSupplementable()->GetFrame(), allowance, | 139 allowed = PingLoader::SendBeacon(GetSupplementable()->GetFrame(), allowance, |
| 140 url, data.getAsString(), beacon_size); | 140 url, data.getAsString(), beacon_size); |
| 141 } else if (data.isFormData()) { | 141 } else if (data.isFormData()) { |
| 142 allowed = PingLoader::SendBeacon(GetSupplementable()->GetFrame(), allowance, | 142 allowed = PingLoader::SendBeacon(GetSupplementable()->GetFrame(), allowance, |
| 143 url, data.getAsFormData(), beacon_size); | 143 url, data.getAsFormData(), beacon_size); |
| 144 } else { | 144 } else { |
| 145 allowed = PingLoader::SendBeacon(GetSupplementable()->GetFrame(), allowance, | 145 allowed = PingLoader::SendBeacon(GetSupplementable()->GetFrame(), allowance, |
| 146 url, String(), beacon_size); | 146 url, String(), beacon_size); |
| 147 } | 147 } |
| 148 | 148 |
| 149 if (!allowed) { | 149 if (!allowed) { |
| 150 UseCounter::Count(context, UseCounter::kSendBeaconQuotaExceeded); | 150 UseCounter::Count(context, UseCounter::kSendBeaconQuotaExceeded); |
| 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 |