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/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/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "content/browser/download/download_resource_handler.h" | 13 #include "content/browser/download/download_resource_handler.h" |
14 #include "content/browser/download/download_stats.h" | 14 #include "content/browser/download/download_stats.h" |
15 #include "content/browser/plugin_service_impl.h" | 15 #include "content/browser/plugin_service_impl.h" |
16 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" | 16 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" |
17 #include "content/browser/renderer_host/resource_request_info_impl.h" | 17 #include "content/browser/renderer_host/resource_request_info_impl.h" |
18 #include "content/browser/renderer_host/x509_user_cert_resource_handler.h" | 18 #include "content/browser/renderer_host/x509_user_cert_resource_handler.h" |
19 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
20 #include "content/public/browser/content_browser_client.h" | 20 #include "content/public/browser/content_browser_client.h" |
21 #include "content/public/browser/download_save_info.h" | 21 #include "content/public/browser/download_save_info.h" |
22 #include "content/public/browser/resource_context.h" | 22 #include "content/public/browser/resource_context.h" |
23 #include "content/public/browser/resource_dispatcher_host_delegate.h" | 23 #include "content/public/browser/resource_dispatcher_host_delegate.h" |
24 #include "content/public/common/resource_response.h" | 24 #include "content/public/common/resource_response.h" |
25 #include "content/public/common/url_constants.h" | |
25 #include "net/base/io_buffer.h" | 26 #include "net/base/io_buffer.h" |
26 #include "net/base/mime_sniffer.h" | 27 #include "net/base/mime_sniffer.h" |
27 #include "net/base/mime_util.h" | 28 #include "net/base/mime_util.h" |
28 #include "net/base/net_errors.h" | 29 #include "net/base/net_errors.h" |
29 #include "net/http/http_content_disposition.h" | 30 #include "net/http/http_content_disposition.h" |
30 #include "net/http/http_response_headers.h" | 31 #include "net/http/http_response_headers.h" |
31 #include "webkit/plugins/webplugininfo.h" | 32 #include "webkit/plugins/webplugininfo.h" |
32 | 33 |
33 namespace content { | 34 namespace content { |
34 | 35 |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
341 base::Bind(&BufferedResourceHandler::OnPluginsLoaded, this)); | 342 base::Bind(&BufferedResourceHandler::OnPluginsLoaded, this)); |
342 return true; | 343 return true; |
343 } | 344 } |
344 | 345 |
345 // This test mirrors the decision that WebKit makes in | 346 // This test mirrors the decision that WebKit makes in |
346 // WebFrameLoaderClient::dispatchDecidePolicyForMIMEType. | 347 // WebFrameLoaderClient::dispatchDecidePolicyForMIMEType. |
347 bool BufferedResourceHandler::ShouldDownload(bool* need_plugin_list) { | 348 bool BufferedResourceHandler::ShouldDownload(bool* need_plugin_list) { |
348 if (need_plugin_list) | 349 if (need_plugin_list) |
349 *need_plugin_list = false; | 350 *need_plugin_list = false; |
350 std::string type = StringToLowerASCII(response_->mime_type); | 351 std::string type = StringToLowerASCII(response_->mime_type); |
352 if (request_->virtual_url().SchemeIs(chrome::kViewSourceScheme)) | |
darin (slow to review)
2012/03/27 03:20:49
while we can solve this bug by passing around the
chebert
2012/03/31 21:03:18
Done.
| |
353 return false; | |
351 | 354 |
352 // First, examine Content-Disposition. | 355 // First, examine Content-Disposition. |
353 std::string disposition; | 356 std::string disposition; |
354 request_->GetResponseHeaderByName("content-disposition", &disposition); | 357 request_->GetResponseHeaderByName("content-disposition", &disposition); |
355 if (!disposition.empty()) { | 358 if (!disposition.empty()) { |
356 net::HttpContentDisposition parsed_disposition(disposition, std::string()); | 359 net::HttpContentDisposition parsed_disposition(disposition, std::string()); |
357 if (parsed_disposition.is_attachment()) | 360 if (parsed_disposition.is_attachment()) |
358 return true; | 361 return true; |
359 } | 362 } |
360 | 363 |
361 if (host_->delegate() && | 364 if (host_->delegate() && |
362 host_->delegate()->ShouldForceDownloadResource(request_->url(), type)) | 365 host_->delegate()->ShouldForceDownloadResource(request_->url(), type)) |
363 return true; | 366 return true; |
364 | 367 |
365 // MIME type checking. | 368 // MIME type checking. |
366 if (net::IsSupportedMimeType(type)) | 369 if (net::IsSupportedMimeType(type)) |
367 return false; | 370 return false; |
368 | 371 |
369 // Finally, check the plugin list. | 372 // Finally, check the plugin list. |
370 bool allow_wildcard = false; | 373 bool allow_wildcard = false; |
371 ResourceRequestInfoImpl* info = | 374 ResourceRequestInfoImpl* info = |
darin (slow to review)
2012/03/27 03:23:47
each URLRequest created by the ResourceDispatcherH
chebert
2012/03/31 21:03:18
Done.
| |
372 ResourceRequestInfoImpl::ForRequest(request_); | 375 ResourceRequestInfoImpl::ForRequest(request_); |
373 bool stale = false; | 376 bool stale = false; |
374 webkit::WebPluginInfo plugin; | 377 webkit::WebPluginInfo plugin; |
375 bool found = PluginServiceImpl::GetInstance()->GetPluginInfo( | 378 bool found = PluginServiceImpl::GetInstance()->GetPluginInfo( |
376 info->GetChildID(), info->GetRouteID(), info->GetContext(), | 379 info->GetChildID(), info->GetRouteID(), info->GetContext(), |
377 request_->url(), GURL(), type, allow_wildcard, | 380 request_->url(), GURL(), type, allow_wildcard, |
378 &stale, &plugin, NULL); | 381 &stale, &plugin, NULL); |
379 | 382 |
380 if (need_plugin_list) { | 383 if (need_plugin_list) { |
381 if (stale) { | 384 if (stale) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
466 ResourceRequestInfoImpl::ForRequest(request_); | 469 ResourceRequestInfoImpl::ForRequest(request_); |
467 int child_id = info->GetChildID(); | 470 int child_id = info->GetChildID(); |
468 int request_id = info->GetRequestID(); | 471 int request_id = info->GetRequestID(); |
469 | 472 |
470 host_->PauseRequest(child_id, request_id, false); | 473 host_->PauseRequest(child_id, request_id, false); |
471 if (!CompleteResponseStarted(request_id)) | 474 if (!CompleteResponseStarted(request_id)) |
472 host_->CancelRequest(child_id, request_id, false); | 475 host_->CancelRequest(child_id, request_id, false); |
473 } | 476 } |
474 | 477 |
475 } // namespace content | 478 } // namespace content |
OLD | NEW |