Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1468)

Unified Diff: chrome/browser/download/download_target_determiner_unittest.cc

Issue 1095083003: Ensure that by default PDFs are opened in Chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/download/download_target_determiner.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/download_target_determiner_unittest.cc
diff --git a/chrome/browser/download/download_target_determiner_unittest.cc b/chrome/browser/download/download_target_determiner_unittest.cc
index a0b8cdee625a9e5af8fb652bccfcec4a7ab4f773..5a0008b27aa2e4d332de5708331c641429964bf0 100644
--- a/chrome/browser/download/download_target_determiner_unittest.cc
+++ b/chrome/browser/download/download_target_determiner_unittest.cc
@@ -2106,6 +2106,75 @@ TEST_F(DownloadTargetDeterminerTestWithPlugin,
EXPECT_FALSE(target_info->is_filetype_handled_safely);
}
+// Check if secure handling of filetypes is determined correctly for
+// BrowserPlugins.
+TEST_F(DownloadTargetDeterminerTestWithPlugin,
+ TargetDeterminer_CheckForSecureHandling_BrowserPlugin) {
+ // All test cases run with GetPathInDownloadDir(kInitialPath) as the inital
+ // path.
+ const base::FilePath::CharType kInitialPath[] =
+ FILE_PATH_LITERAL("some_path/bar.txt");
+ const char kTestMIMEType[] = "application/x-example-should-not-exist";
+
+ DownloadTestCase kSecureHandlingTestCase = {
+ AUTOMATIC,
+ content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
+ "http://example.com/foo.fakeext", "",
+ FILE_PATH_LITERAL(""),
+
+ FILE_PATH_LITERAL("foo.fakeext"),
+ DownloadItem::TARGET_DISPOSITION_OVERWRITE,
+
+ EXPECT_CRDOWNLOAD
+ };
+
+ content::PluginService* plugin_service =
+ content::PluginService::GetInstance();
+
+ // Verify our test assumptions.
+ {
+ ForceRefreshOfPlugins();
+ std::vector<content::WebPluginInfo> info;
+ ASSERT_FALSE(plugin_service->GetPluginInfoArray(
+ GURL(), kTestMIMEType, false, &info, NULL));
+ ASSERT_EQ(0u, info.size())
+ << "Name: " << info[0].name << ", Path: " << info[0].path.value();
+ }
+
+ ON_CALL(*delegate(), GetFileMimeType(
+ GetPathInDownloadDir(FILE_PATH_LITERAL("foo.fakeext")), _))
+ .WillByDefault(WithArg<1>(
+ ScheduleCallback(kTestMIMEType)));
+ scoped_ptr<content::MockDownloadItem> item(
+ CreateActiveDownloadItem(1, kSecureHandlingTestCase));
+ scoped_ptr<DownloadTargetInfo> target_info =
+ RunDownloadTargetDeterminer(GetPathInDownloadDir(kInitialPath),
+ item.get());
+ EXPECT_FALSE(target_info->is_filetype_handled_safely);
+
+ // Register a BrowserPlugin. This should count as handling the filetype
+ // securely.
+ ScopedRegisterInternalPlugin browser_plugin(
+ plugin_service,
+ content::WebPluginInfo::PLUGIN_TYPE_BROWSER_PLUGIN,
+ test_download_dir().AppendASCII("browser_plugin"),
+ kTestMIMEType,
+ "fakeext");
+ EXPECT_CALL(mock_plugin_filter_, MockPluginAvailable(browser_plugin.path()))
+ .WillRepeatedly(Return(true));
+
+ target_info = RunDownloadTargetDeterminer(
+ GetPathInDownloadDir(kInitialPath), item.get());
+ EXPECT_TRUE(target_info->is_filetype_handled_safely);
+
+ // Try disabling the plugin. Handling should no longer be considered secure.
+ EXPECT_CALL(mock_plugin_filter_, MockPluginAvailable(browser_plugin.path()))
+ .WillRepeatedly(Return(false));
+ target_info = RunDownloadTargetDeterminer(
+ GetPathInDownloadDir(kInitialPath), item.get());
+ EXPECT_FALSE(target_info->is_filetype_handled_safely);
+}
+
// Check if secure handling of filetypes is determined correctly for NPAPI
// plugins.
TEST_F(DownloadTargetDeterminerTestWithPlugin,
« no previous file with comments | « chrome/browser/download/download_target_determiner.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698