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 "content/browser/browser_thread.h" | 13 #include "content/browser/browser_thread.h" |
| 14 #include "content/browser/content_browser_client.h" | 14 #include "content/browser/content_browser_client.h" |
| 15 #include "content/browser/plugin_service.h" | |
| 15 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 16 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 16 #include "content/browser/renderer_host/resource_dispatcher_host_delegate.h" | 17 #include "content/browser/renderer_host/resource_dispatcher_host_delegate.h" |
| 17 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" | 18 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" |
| 18 #include "content/browser/renderer_host/x509_user_cert_resource_handler.h" | 19 #include "content/browser/renderer_host/x509_user_cert_resource_handler.h" |
| 19 #include "content/common/resource_response.h" | 20 #include "content/common/resource_response.h" |
| 20 #include "net/base/io_buffer.h" | 21 #include "net/base/io_buffer.h" |
| 21 #include "net/base/mime_sniffer.h" | 22 #include "net/base/mime_sniffer.h" |
| 22 #include "net/base/mime_util.h" | 23 #include "net/base/mime_util.h" |
| 23 #include "net/base/net_errors.h" | 24 #include "net/base/net_errors.h" |
| 24 #include "net/http/http_response_headers.h" | 25 #include "net/http/http_response_headers.h" |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 381 if (host_->delegate() && | 382 if (host_->delegate() && |
| 382 host_->delegate()->ShouldForceDownloadResource(request_->url(), type)) | 383 host_->delegate()->ShouldForceDownloadResource(request_->url(), type)) |
| 383 return true; | 384 return true; |
| 384 | 385 |
| 385 // MIME type checking. | 386 // MIME type checking. |
| 386 if (net::IsSupportedMimeType(type)) | 387 if (net::IsSupportedMimeType(type)) |
| 387 return false; | 388 return false; |
| 388 | 389 |
| 389 // Finally, check the plugin list. | 390 // Finally, check the plugin list. |
| 390 bool allow_wildcard = false; | 391 bool allow_wildcard = false; |
| 392 ResourceDispatcherHostRequestInfo* info = | |
| 393 ResourceDispatcherHost::InfoForRequest(request_); | |
| 394 content::BrowserContext* browser_context = NULL; // XXX | |
|
Bernhard Bauer
2011/08/03 14:47:33
This is the only problem; I don't have a BrowserCo
jam
2011/08/03 16:20:43
Why not use ResourceContext instead of BrowserCont
Bernhard Bauer
2011/08/03 16:45:36
Because a BrowserContext is a Profile, and we alre
| |
| 391 bool stale = false; | 395 bool stale = false; |
| 392 std::vector<webkit::npapi::WebPluginInfo> plugins; | 396 webkit::npapi::WebPluginInfo plugin; |
| 393 webkit::npapi::PluginList::Singleton()->GetPluginInfoArray( | 397 bool found = PluginService::GetInstance()->GetPluginInfo( |
| 394 request_->url(), type, allow_wildcard, &stale, &plugins, NULL); | 398 info->child_id(), info->route_id(), browser_context, |
| 399 request_->url(), GURL(), type, allow_wildcard, | |
| 400 &stale, &plugin, NULL); | |
| 401 | |
| 395 if (need_plugin_list) { | 402 if (need_plugin_list) { |
| 396 if (stale) { | 403 if (stale) { |
| 397 *need_plugin_list = true; | 404 *need_plugin_list = true; |
| 398 return true; | 405 return true; |
| 399 } | 406 } |
| 400 } else { | 407 } else { |
| 401 DCHECK(!stale); | 408 DCHECK(!stale); |
| 402 } | 409 } |
| 403 | 410 |
| 404 for (size_t i = 0; i < plugins.size(); ++i) { | 411 return !found; |
| 405 if (webkit::npapi::IsPluginEnabled(plugins[i])) | |
| 406 return false; | |
| 407 } | |
| 408 return true; | |
| 409 } | 412 } |
| 410 | 413 |
| 411 void BufferedResourceHandler::UseAlternateResourceHandler( | 414 void BufferedResourceHandler::UseAlternateResourceHandler( |
| 412 int request_id, | 415 int request_id, |
| 413 ResourceHandler* handler) { | 416 ResourceHandler* handler) { |
| 414 ResourceDispatcherHostRequestInfo* info = | 417 ResourceDispatcherHostRequestInfo* info = |
| 415 ResourceDispatcherHost::InfoForRequest(request_); | 418 ResourceDispatcherHost::InfoForRequest(request_); |
| 416 if (bytes_read_) { | 419 if (bytes_read_) { |
| 417 // A Read has already occured and we need to copy the data into the new | 420 // A Read has already occured and we need to copy the data into the new |
| 418 // ResourceHandler. | 421 // ResourceHandler. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 452 wait_for_plugins_ = false; | 455 wait_for_plugins_ = false; |
| 453 if (!request_) | 456 if (!request_) |
| 454 return; | 457 return; |
| 455 | 458 |
| 456 ResourceDispatcherHostRequestInfo* info = | 459 ResourceDispatcherHostRequestInfo* info = |
| 457 ResourceDispatcherHost::InfoForRequest(request_); | 460 ResourceDispatcherHost::InfoForRequest(request_); |
| 458 host_->PauseRequest(info->child_id(), info->request_id(), false); | 461 host_->PauseRequest(info->child_id(), info->request_id(), false); |
| 459 if (!CompleteResponseStarted(info->request_id(), false)) | 462 if (!CompleteResponseStarted(info->request_id(), false)) |
| 460 host_->CancelRequest(info->child_id(), info->request_id(), false); | 463 host_->CancelRequest(info->child_id(), info->request_id(), false); |
| 461 } | 464 } |
| OLD | NEW |