Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/renderer_host/buffered_resource_handler.h" | 5 #include "content/browser/renderer_host/buffered_resource_handler.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "chrome/browser/renderer_host/download_throttling_resource_handler.h" | 12 #include "chrome/browser/renderer_host/download_throttling_resource_handler.h" |
| 13 #include "chrome/common/extensions/user_script.h" | |
| 14 #include "content/browser/browser_thread.h" | 13 #include "content/browser/browser_thread.h" |
| 14 #include "content/browser/content_browser_client.h" | |
| 15 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 15 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 16 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" | 16 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" |
| 17 #include "content/browser/renderer_host/x509_user_cert_resource_handler.h" | 17 #include "content/browser/renderer_host/x509_user_cert_resource_handler.h" |
| 18 #include "content/common/resource_response.h" | 18 #include "content/common/resource_response.h" |
| 19 #include "net/base/io_buffer.h" | 19 #include "net/base/io_buffer.h" |
| 20 #include "net/base/mime_sniffer.h" | 20 #include "net/base/mime_sniffer.h" |
| 21 #include "net/base/mime_util.h" | 21 #include "net/base/mime_util.h" |
| 22 #include "net/base/net_errors.h" | 22 #include "net/base/net_errors.h" |
| 23 #include "net/http/http_response_headers.h" | 23 #include "net/http/http_response_headers.h" |
| 24 #include "webkit/plugins/npapi/plugin_list.h" | 24 #include "webkit/plugins/npapi/plugin_list.h" |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 370 if (disposition.compare(0, 4, "name") == 0) | 370 if (disposition.compare(0, 4, "name") == 0) |
| 371 should_download = false; | 371 should_download = false; |
| 372 | 372 |
| 373 // We have a content-disposition of "attachment" or unknown. | 373 // We have a content-disposition of "attachment" or unknown. |
| 374 // RFC 2183, section 2.8 says that an unknown disposition | 374 // RFC 2183, section 2.8 says that an unknown disposition |
| 375 // value should be treated as "attachment". | 375 // value should be treated as "attachment". |
| 376 if (should_download) | 376 if (should_download) |
| 377 return true; | 377 return true; |
| 378 } | 378 } |
| 379 | 379 |
| 380 // Special-case user scripts to get downloaded instead of viewed. | 380 if (content::GetContentClient()->browser()->ShouldForceDownloadResource( |
|
jam
2011/06/07 23:17:53
i'm curious what you think about putting this call
Matt Perry
2011/06/07 23:58:10
Done.
| |
| 381 if (UserScript::IsURLUserScript(request_->url(), type)) | 381 request_->url(), type)) { |
| 382 return true; | 382 return true; |
| 383 } | |
| 383 | 384 |
| 384 // MIME type checking. | 385 // MIME type checking. |
| 385 if (net::IsSupportedMimeType(type)) | 386 if (net::IsSupportedMimeType(type)) |
| 386 return false; | 387 return false; |
| 387 | 388 |
| 388 if (need_plugin_list) { | 389 if (need_plugin_list) { |
| 389 if (!webkit::npapi::PluginList::Singleton()->PluginsLoaded()) { | 390 if (!webkit::npapi::PluginList::Singleton()->PluginsLoaded()) { |
| 390 *need_plugin_list = true; | 391 *need_plugin_list = true; |
| 391 return true; | 392 return true; |
| 392 } | 393 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 446 wait_for_plugins_ = false; | 447 wait_for_plugins_ = false; |
| 447 if (!request_) | 448 if (!request_) |
| 448 return; | 449 return; |
| 449 | 450 |
| 450 ResourceDispatcherHostRequestInfo* info = | 451 ResourceDispatcherHostRequestInfo* info = |
| 451 ResourceDispatcherHost::InfoForRequest(request_); | 452 ResourceDispatcherHost::InfoForRequest(request_); |
| 452 host_->PauseRequest(info->child_id(), info->request_id(), false); | 453 host_->PauseRequest(info->child_id(), info->request_id(), false); |
| 453 if (!CompleteResponseStarted(info->request_id(), false)) | 454 if (!CompleteResponseStarted(info->request_id(), false)) |
| 454 host_->CancelRequest(info->child_id(), info->request_id(), false); | 455 host_->CancelRequest(info->child_id(), info->request_id(), false); |
| 455 } | 456 } |
| OLD | NEW |