diff options
author | asanka@chromium.org <asanka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-23 15:16:20 +0000 |
---|---|---|
committer | asanka@chromium.org <asanka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-23 15:16:20 +0000 |
commit | cafe0d009faf87ee673767bfe0b1d77c531f8e6f (patch) | |
tree | bd7b0f2bef0c915d776c951fa0a3ab970c55ea51 /content/browser/download | |
parent | 1f1d74ea63dec5a9806f29e89f026fa15c1ebd0b (diff) | |
download | chromium_src-cafe0d009faf87ee673767bfe0b1d77c531f8e6f.zip chromium_src-cafe0d009faf87ee673767bfe0b1d77c531f8e6f.tar.gz chromium_src-cafe0d009faf87ee673767bfe0b1d77c531f8e6f.tar.bz2 |
Don't override application/octet-stream MIME type.
When enumerating candidate plug-ins for handling a document,
PluginList::GetPluginInfoArray() attemps to match the MIME type of the
document, and then matches the file type based on the URL. Matching by
file type is done if the MIME type of the document is either empty or if
is application/octet-stream.
This change disallows plugin matching based on file type if the MIME
type is application/octet-stream. This will, for example, prevent
http://example.com/foo.pdf from being associated with the PDF plug-in if
it is served with a MIME type of application/octet-stream.
As a side-effect, this brings the BufferedResourceHandler's decision of
whether a resource should be rendered or downloaded closer in line with
Blink's.
BUG=104331
Review URL: https://chromiumcodereview.appspot.com/18364005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@213119 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/download')
-rw-r--r-- | content/browser/download/download_browsertest.cc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/content/browser/download/download_browsertest.cc b/content/browser/download/download_browsertest.cc index 38663b8..79ad19c 100644 --- a/content/browser/download/download_browsertest.cc +++ b/content/browser/download/download_browsertest.cc @@ -10,15 +10,18 @@ #include "base/files/file_path.h" #include "base/files/scoped_temp_dir.h" #include "base/strings/stringprintf.h" +#include "base/strings/utf_string_conversions.h" #include "content/browser/byte_stream.h" #include "content/browser/download/download_file_factory.h" #include "content/browser/download/download_file_impl.h" #include "content/browser/download/download_item_impl.h" #include "content/browser/download/download_manager_impl.h" #include "content/browser/download/download_resource_handler.h" +#include "content/browser/plugin_service_impl.h" #include "content/browser/web_contents/web_contents_impl.h" #include "content/public/browser/power_save_blocker.h" #include "content/public/common/content_switches.h" +#include "content/public/common/webplugininfo.h" #include "content/public/test/download_test_observer.h" #include "content/public/test/test_file_error_injector.h" #include "content/public/test/test_utils.h" @@ -779,6 +782,28 @@ IN_PROC_BROWSER_TEST_F(DownloadContentTest, MultiDownload) { file2, GetTestFilePath("download", "download-test.lib"))); } +#if defined(ENABLE_PLUGINS) +// Content served with a MIME type of application/octet-stream should be +// downloaded even when a plugin can be found that handles the file type. +IN_PROC_BROWSER_TEST_F(DownloadContentTest, DownloadOctetStream) { + const base::FilePath::CharType kTestFilePath[] = + FILE_PATH_LITERAL("octet-stream.abc"); + const char kTestPluginName[] = "TestPlugin"; + const char kTestMimeType[] = "application/x-test-mime-type"; + const char kTestFileType[] = "abc"; + + WebPluginInfo plugin_info; + plugin_info.name = base::ASCIIToUTF16(kTestPluginName); + plugin_info.mime_types.push_back( + WebPluginMimeType(kTestMimeType, kTestFileType, "")); + PluginServiceImpl::GetInstance()->RegisterInternalPlugin(plugin_info, false); + + // The following is served with a Content-Type of application/octet-stream. + GURL url(URLRequestMockHTTPJob::GetMockUrl(base::FilePath(kTestFilePath))); + DownloadAndWait(shell(), url, DownloadItem::COMPLETE); +} +#endif + // Try to cancel just before we release the download file, by delaying final // rename callback. IN_PROC_BROWSER_TEST_F(DownloadContentTest, CancelAtFinalRename) { |