OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/loader/buffered_resource_handler.h" | 5 #include "content/browser/loader/buffered_resource_handler.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 const std::string& mime_type = response_->head.mime_type; | 305 const std::string& mime_type = response_->head.mime_type; |
306 | 306 |
307 if (net::IsSupportedCertificateMimeType(mime_type)) { | 307 if (net::IsSupportedCertificateMimeType(mime_type)) { |
308 // Install certificate file. | 308 // Install certificate file. |
309 info->set_is_download(true); | 309 info->set_is_download(true); |
310 scoped_ptr<ResourceHandler> handler( | 310 scoped_ptr<ResourceHandler> handler( |
311 new CertificateResourceHandler(request())); | 311 new CertificateResourceHandler(request())); |
312 return UseAlternateNextHandler(handler.Pass(), std::string()); | 312 return UseAlternateNextHandler(handler.Pass(), std::string()); |
313 } | 313 } |
314 | 314 |
| 315 // Allow requests for object/embed tags to be intercepted as streams. |
| 316 if (info->GetResourceType() == content::RESOURCE_TYPE_OBJECT) { |
| 317 DCHECK(!info->allow_download()); |
| 318 std::string payload; |
| 319 scoped_ptr<ResourceHandler> handler( |
| 320 host_->MaybeInterceptAsStream(request(), response_.get(), &payload)); |
| 321 if (handler) { |
| 322 DCHECK(!net::IsSupportedMimeType(mime_type)); |
| 323 return UseAlternateNextHandler(handler.Pass(), payload); |
| 324 } |
| 325 } |
| 326 |
315 if (!info->allow_download()) | 327 if (!info->allow_download()) |
316 return true; | 328 return true; |
317 | 329 |
| 330 // info->allow_download() == true implies |
| 331 // info->GetResourceType() == RESOURCE_TYPE_MAIN_FRAME or |
| 332 // info->GetResourceType() == RESOURCE_TYPE_SUB_FRAME. |
| 333 DCHECK(info->GetResourceType() == RESOURCE_TYPE_MAIN_FRAME || |
| 334 info->GetResourceType() == RESOURCE_TYPE_SUB_FRAME); |
| 335 |
318 bool must_download = MustDownload(); | 336 bool must_download = MustDownload(); |
319 if (!must_download) { | 337 if (!must_download) { |
320 if (net::IsSupportedMimeType(mime_type)) | 338 if (net::IsSupportedMimeType(mime_type)) |
321 return true; | 339 return true; |
322 | 340 |
323 std::string payload; | 341 std::string payload; |
324 scoped_ptr<ResourceHandler> handler( | 342 scoped_ptr<ResourceHandler> handler( |
325 host_->MaybeInterceptAsStream(request(), response_.get(), &payload)); | 343 host_->MaybeInterceptAsStream(request(), response_.get(), &payload)); |
326 if (handler) { | 344 if (handler) { |
327 return UseAlternateNextHandler(handler.Pass(), payload); | 345 return UseAlternateNextHandler(handler.Pass(), payload); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 request()->LogUnblocked(); | 512 request()->LogUnblocked(); |
495 bool defer = false; | 513 bool defer = false; |
496 if (!ProcessResponse(&defer)) { | 514 if (!ProcessResponse(&defer)) { |
497 controller()->Cancel(); | 515 controller()->Cancel(); |
498 } else if (!defer) { | 516 } else if (!defer) { |
499 controller()->Resume(); | 517 controller()->Resume(); |
500 } | 518 } |
501 } | 519 } |
502 | 520 |
503 } // namespace content | 521 } // namespace content |
OLD | NEW |