OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "webkit/glue/media/buffered_resource_loader.h" | 5 #include "webkit/glue/media/buffered_resource_loader.h" |
6 | 6 |
7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 const WebURLResponse& redirectResponse) { | 241 const WebURLResponse& redirectResponse) { |
242 | 242 |
243 // The load may have been stopped and |start_callback| is destroyed. | 243 // The load may have been stopped and |start_callback| is destroyed. |
244 // In this case we shouldn't do anything. | 244 // In this case we shouldn't do anything. |
245 if (!start_callback_.get()) { | 245 if (!start_callback_.get()) { |
246 // Set the url in the request to an invalid value (empty url). | 246 // Set the url in the request to an invalid value (empty url). |
247 newRequest.setURL(WebKit::WebURL()); | 247 newRequest.setURL(WebKit::WebURL()); |
248 return; | 248 return; |
249 } | 249 } |
250 | 250 |
251 if (!IsProtocolSupportedForMedia(newRequest.url())) { | 251 // Only allow |single_origin_| if we haven't seen a different origin yet. |
| 252 if (single_origin_) |
| 253 single_origin_ = url_.GetOrigin() == GURL(newRequest.url()).GetOrigin(); |
| 254 |
| 255 // Enforce same-origin policy and cause redirects to other origins to |
| 256 // look like network errors. |
| 257 // http://dev.w3.org/html5/spec/Overview.html#concept-media-load-resource |
| 258 // http://dev.w3.org/html5/spec/Overview.html#fetch |
| 259 if (!single_origin_ || !IsProtocolSupportedForMedia(newRequest.url())) { |
252 // Set the url in the request to an invalid value (empty url). | 260 // Set the url in the request to an invalid value (empty url). |
253 newRequest.setURL(WebKit::WebURL()); | 261 newRequest.setURL(WebKit::WebURL()); |
254 DoneStart(net::ERR_ADDRESS_INVALID); | 262 DoneStart(net::ERR_ADDRESS_INVALID); |
255 Stop(); | |
256 return; | 263 return; |
257 } | 264 } |
258 | 265 |
259 // Only allow |single_origin_| if we haven't seen a different origin yet. | |
260 if (single_origin_) | |
261 single_origin_ = url_.GetOrigin() == GURL(newRequest.url()).GetOrigin(); | |
262 | |
263 url_ = newRequest.url(); | 266 url_ = newRequest.url(); |
264 } | 267 } |
265 | 268 |
266 void BufferedResourceLoader::didSendData( | 269 void BufferedResourceLoader::didSendData( |
267 WebURLLoader* loader, | 270 WebURLLoader* loader, |
268 unsigned long long bytes_sent, | 271 unsigned long long bytes_sent, |
269 unsigned long long total_bytes_to_be_sent) { | 272 unsigned long long total_bytes_to_be_sent) { |
270 NOTIMPLEMENTED(); | 273 NOTIMPLEMENTED(); |
271 } | 274 } |
272 | 275 |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 start_callback_->RunWithParams(Tuple1<int>(error)); | 581 start_callback_->RunWithParams(Tuple1<int>(error)); |
579 start_callback_.reset(); | 582 start_callback_.reset(); |
580 } | 583 } |
581 | 584 |
582 void BufferedResourceLoader::NotifyNetworkEvent() { | 585 void BufferedResourceLoader::NotifyNetworkEvent() { |
583 if (event_callback_.get()) | 586 if (event_callback_.get()) |
584 event_callback_->Run(); | 587 event_callback_->Run(); |
585 } | 588 } |
586 | 589 |
587 } // namespace webkit_glue | 590 } // namespace webkit_glue |
OLD | NEW |