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_delegate.h" |
16 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" | 17 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" |
17 #include "content/browser/renderer_host/x509_user_cert_resource_handler.h" | 18 #include "content/browser/renderer_host/x509_user_cert_resource_handler.h" |
18 #include "content/common/resource_response.h" | 19 #include "content/common/resource_response.h" |
19 #include "net/base/io_buffer.h" | 20 #include "net/base/io_buffer.h" |
20 #include "net/base/mime_sniffer.h" | 21 #include "net/base/mime_sniffer.h" |
21 #include "net/base/mime_util.h" | 22 #include "net/base/mime_util.h" |
22 #include "net/base/net_errors.h" | 23 #include "net/base/net_errors.h" |
23 #include "net/http/http_response_headers.h" | 24 #include "net/http/http_response_headers.h" |
24 #include "webkit/plugins/npapi/plugin_list.h" | 25 #include "webkit/plugins/npapi/plugin_list.h" |
25 | 26 |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 if (disposition.compare(0, 4, "name") == 0) | 371 if (disposition.compare(0, 4, "name") == 0) |
371 should_download = false; | 372 should_download = false; |
372 | 373 |
373 // We have a content-disposition of "attachment" or unknown. | 374 // We have a content-disposition of "attachment" or unknown. |
374 // RFC 2183, section 2.8 says that an unknown disposition | 375 // RFC 2183, section 2.8 says that an unknown disposition |
375 // value should be treated as "attachment". | 376 // value should be treated as "attachment". |
376 if (should_download) | 377 if (should_download) |
377 return true; | 378 return true; |
378 } | 379 } |
379 | 380 |
380 // Special-case user scripts to get downloaded instead of viewed. | 381 if (host_->delegate()->ShouldForceDownloadResource(request_->url(), type)) |
381 if (UserScript::IsURLUserScript(request_->url(), type)) | |
382 return true; | 382 return true; |
383 | 383 |
384 // MIME type checking. | 384 // MIME type checking. |
385 if (net::IsSupportedMimeType(type)) | 385 if (net::IsSupportedMimeType(type)) |
386 return false; | 386 return false; |
387 | 387 |
388 if (need_plugin_list) { | 388 if (need_plugin_list) { |
389 if (!webkit::npapi::PluginList::Singleton()->PluginsLoaded()) { | 389 if (!webkit::npapi::PluginList::Singleton()->PluginsLoaded()) { |
390 *need_plugin_list = true; | 390 *need_plugin_list = true; |
391 return true; | 391 return true; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 wait_for_plugins_ = false; | 446 wait_for_plugins_ = false; |
447 if (!request_) | 447 if (!request_) |
448 return; | 448 return; |
449 | 449 |
450 ResourceDispatcherHostRequestInfo* info = | 450 ResourceDispatcherHostRequestInfo* info = |
451 ResourceDispatcherHost::InfoForRequest(request_); | 451 ResourceDispatcherHost::InfoForRequest(request_); |
452 host_->PauseRequest(info->child_id(), info->request_id(), false); | 452 host_->PauseRequest(info->child_id(), info->request_id(), false); |
453 if (!CompleteResponseStarted(info->request_id(), false)) | 453 if (!CompleteResponseStarted(info->request_id(), false)) |
454 host_->CancelRequest(info->child_id(), info->request_id(), false); | 454 host_->CancelRequest(info->child_id(), info->request_id(), false); |
455 } | 455 } |
OLD | NEW |