| 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 "base/at_exit.h" | 5 #include "base/at_exit.h" |
| 6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 2086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2097 target_info = RunDownloadTargetDeterminer( | 2097 target_info = RunDownloadTargetDeterminer( |
| 2098 GetPathInDownloadDir(kInitialPath), item.get()); | 2098 GetPathInDownloadDir(kInitialPath), item.get()); |
| 2099 EXPECT_TRUE(target_info->is_filetype_handled_safely); | 2099 EXPECT_TRUE(target_info->is_filetype_handled_safely); |
| 2100 | 2100 |
| 2101 // Try disabling the plugin. Handling should no longer be considered secure. | 2101 // Try disabling the plugin. Handling should no longer be considered secure. |
| 2102 EXPECT_CALL(mock_plugin_filter_, MockPluginAvailable(ppapi_plugin.path())) | 2102 EXPECT_CALL(mock_plugin_filter_, MockPluginAvailable(ppapi_plugin.path())) |
| 2103 .WillRepeatedly(Return(false)); | 2103 .WillRepeatedly(Return(false)); |
| 2104 target_info = RunDownloadTargetDeterminer( | 2104 target_info = RunDownloadTargetDeterminer( |
| 2105 GetPathInDownloadDir(kInitialPath), item.get()); | 2105 GetPathInDownloadDir(kInitialPath), item.get()); |
| 2106 EXPECT_FALSE(target_info->is_filetype_handled_safely); | 2106 EXPECT_FALSE(target_info->is_filetype_handled_safely); |
| 2107 | |
| 2108 // Now register an unsandboxed PPAPI plugin. This plugin should not be | |
| 2109 // considered secure. | |
| 2110 ScopedRegisterInternalPlugin ppapi_unsandboxed_plugin( | |
| 2111 plugin_service, | |
| 2112 content::WebPluginInfo::PLUGIN_TYPE_PEPPER_UNSANDBOXED, | |
| 2113 test_download_dir().AppendASCII("ppapi-nosandbox"), | |
| 2114 kTestMIMEType, | |
| 2115 "fakeext"); | |
| 2116 EXPECT_CALL(mock_plugin_filter_, | |
| 2117 MockPluginAvailable(ppapi_unsandboxed_plugin.path())) | |
| 2118 .WillRepeatedly(Return(true)); | |
| 2119 | |
| 2120 target_info = RunDownloadTargetDeterminer( | |
| 2121 GetPathInDownloadDir(kInitialPath), item.get()); | |
| 2122 EXPECT_FALSE(target_info->is_filetype_handled_safely); | |
| 2123 } | 2107 } |
| 2124 | 2108 |
| 2125 // Check if secure handling of filetypes is determined correctly for NPAPI | 2109 // Check if secure handling of filetypes is determined correctly for NPAPI |
| 2126 // plugins. | 2110 // plugins. |
| 2127 TEST_F(DownloadTargetDeterminerTestWithPlugin, | 2111 TEST_F(DownloadTargetDeterminerTestWithPlugin, |
| 2128 TargetDeterminer_CheckForSecureHandling_NPAPI) { | 2112 TargetDeterminer_CheckForSecureHandling_NPAPI) { |
| 2129 // All test cases run with GetPathInDownloadDir(kInitialPath) as the inital | 2113 // All test cases run with GetPathInDownloadDir(kInitialPath) as the inital |
| 2130 // path. | 2114 // path. |
| 2131 const base::FilePath::CharType kInitialPath[] = | 2115 const base::FilePath::CharType kInitialPath[] = |
| 2132 FILE_PATH_LITERAL("some_path/bar.txt"); | 2116 FILE_PATH_LITERAL("some_path/bar.txt"); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2183 EXPECT_CALL(mock_plugin_filter_, MockPluginAvailable(npapi_plugin.path())) | 2167 EXPECT_CALL(mock_plugin_filter_, MockPluginAvailable(npapi_plugin.path())) |
| 2184 .WillRepeatedly(Return(true)); | 2168 .WillRepeatedly(Return(true)); |
| 2185 | 2169 |
| 2186 target_info = RunDownloadTargetDeterminer( | 2170 target_info = RunDownloadTargetDeterminer( |
| 2187 GetPathInDownloadDir(kInitialPath), item.get()); | 2171 GetPathInDownloadDir(kInitialPath), item.get()); |
| 2188 EXPECT_FALSE(target_info->is_filetype_handled_safely); | 2172 EXPECT_FALSE(target_info->is_filetype_handled_safely); |
| 2189 } | 2173 } |
| 2190 #endif // defined(ENABLE_PLUGINS) | 2174 #endif // defined(ENABLE_PLUGINS) |
| 2191 | 2175 |
| 2192 } // namespace | 2176 } // namespace |
| OLD | NEW |