diff options
author | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-14 14:38:00 +0000 |
---|---|---|
committer | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-14 14:38:00 +0000 |
commit | a40996367757f82fb2e22035ac65c9d0510e1651 (patch) | |
tree | b4676838b8c03991dc09736ea0046cd61a27442c /chrome/browser/renderer_host/resource_dispatcher_host.cc | |
parent | d90bcafafdccbef95760c2d9c1b4ce8206d46b7b (diff) | |
download | chromium_src-a40996367757f82fb2e22035ac65c9d0510e1651.zip chromium_src-a40996367757f82fb2e22035ac65c9d0510e1651.tar.gz chromium_src-a40996367757f82fb2e22035ac65c9d0510e1651.tar.bz2 |
Reverting 23420. It caused a reliability regression.
TBR=jam
BUG=none
TEST=reliability
Review URL: http://codereview.chromium.org/165532
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23437 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host/resource_dispatcher_host.cc')
-rw-r--r-- | chrome/browser/renderer_host/resource_dispatcher_host.cc | 54 |
1 files changed, 51 insertions, 3 deletions
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.cc b/chrome/browser/renderer_host/resource_dispatcher_host.cc index 9b32684..b71f64f 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host.cc +++ b/chrome/browser/renderer_host/resource_dispatcher_host.cc @@ -254,6 +254,7 @@ ResourceDispatcherHost::ResourceDispatcherHost(MessageLoop* io_loop) safe_browsing_(new SafeBrowsingService), webkit_thread_(new WebKitThread), request_id_(-1), + plugin_service_(PluginService::GetInstance()), ALLOW_THIS_IN_INITIALIZER_LIST(method_runner_(this)), is_shutdown_(false), max_outstanding_requests_cost_per_process_( @@ -465,7 +466,7 @@ void ResourceDispatcherHost::BeginRequest( // requests. Does nothing if they are already loaded. // TODO(mpcomplete): This takes 200 ms! Investigate parallelizing this by // starting the load earlier in a BG thread. - PluginService::GetInstance()->LoadChromePlugins(this); + plugin_service_->LoadChromePlugins(this); // Construct the event handler. scoped_refptr<ResourceHandler> handler; @@ -665,7 +666,7 @@ void ResourceDispatcherHost::BeginDownload(const GURL& url, // Ensure the Chrome plugins are loaded, as they may intercept network // requests. Does nothing if they are already loaded. - PluginService::GetInstance()->LoadChromePlugins(this); + plugin_service_->LoadChromePlugins(this); URLRequest* request = new URLRequest(url, this); request_id_--; @@ -731,7 +732,7 @@ void ResourceDispatcherHost::BeginSaveFile(const GURL& url, // Ensure the Chrome plugins are loaded, as they may intercept network // requests. Does nothing if they are already loaded. - PluginService::GetInstance()->LoadChromePlugins(this); + plugin_service_->LoadChromePlugins(this); scoped_refptr<ResourceHandler> handler = new SaveFileResourceHandler(process_id, @@ -1257,6 +1258,53 @@ void ResourceDispatcherHost::BeginRequestInternal(URLRequest* request) { } } +// This test mirrors the decision that WebKit makes in +// WebFrameLoaderClient::dispatchDecidePolicyForMIMEType. +// static. +bool ResourceDispatcherHost::ShouldDownload( + const std::string& mime_type, const std::string& content_disposition) { + std::string type = StringToLowerASCII(mime_type); + std::string disposition = StringToLowerASCII(content_disposition); + + // First, examine content-disposition. + if (!disposition.empty()) { + bool should_download = true; + + // Some broken sites just send ... + // Content-Disposition: ; filename="file" + // ... screen those out here. + if (disposition[0] == ';') + should_download = false; + + if (disposition.compare(0, 6, "inline") == 0) + should_download = false; + + // Some broken sites just send ... + // Content-Disposition: filename="file" + // ... without a disposition token... Screen those out. + if (disposition.compare(0, 8, "filename") == 0) + should_download = false; + + // Also in use is Content-Disposition: name="file" + if (disposition.compare(0, 4, "name") == 0) + should_download = false; + + // We have a content-disposition of "attachment" or unknown. + // RFC 2183, section 2.8 says that an unknown disposition + // value should be treated as "attachment". + if (should_download) + return true; + } + + // MIME type checking. + if (net::IsSupportedMimeType(type)) + return false; + + // Finally, check the plugin service. + bool allow_wildcard = false; + return !plugin_service_->HavePluginFor(type, allow_wildcard); +} + bool ResourceDispatcherHost::PauseRequestIfNeeded(ExtraRequestInfo* info) { if (info->pause_count > 0) info->is_paused = true; |