OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/download/download_prefs.h" | 5 #include "chrome/browser/download/download_prefs.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "chrome/browser/download/download_extensions.h" | |
9 #include "chrome/common/pref_names.h" | 8 #include "chrome/common/pref_names.h" |
| 9 #include "chrome/common/safe_browsing/file_type_policies.h" |
10 #include "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
11 #include "components/prefs/pref_service.h" | 11 #include "components/prefs/pref_service.h" |
12 #include "content/public/test/test_browser_thread_bundle.h" | 12 #include "content/public/test/test_browser_thread_bundle.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
| 15 using safe_browsing::FileTypePolicies; |
| 16 |
15 TEST(DownloadPrefsTest, Prerequisites) { | 17 TEST(DownloadPrefsTest, Prerequisites) { |
16 // Most of the tests below are based on the assumption that .swf files are not | 18 // Most of the tests below are based on the assumption that .swf files are not |
17 // allowed to open automatically, and that .txt files are allowed. If this | 19 // allowed to open automatically, and that .txt files are allowed. If this |
18 // assumption changes, then we need to update the tests to match. | 20 // assumption changes, then we need to update the tests to match. |
19 ASSERT_FALSE(download_util::IsAllowedToOpenAutomatically( | 21 ASSERT_FALSE(FileTypePolicies::GetInstance()->IsAllowedToOpenAutomatically( |
20 base::FilePath(FILE_PATH_LITERAL("a.swf")))); | 22 base::FilePath(FILE_PATH_LITERAL("a.swf")))); |
21 ASSERT_TRUE(download_util::IsAllowedToOpenAutomatically( | 23 ASSERT_TRUE(FileTypePolicies::GetInstance()->IsAllowedToOpenAutomatically( |
22 base::FilePath(FILE_PATH_LITERAL("a.txt")))); | 24 base::FilePath(FILE_PATH_LITERAL("a.txt")))); |
23 } | 25 } |
24 | 26 |
25 TEST(DownloadPrefsTest, NoAutoOpenForDisallowedFileTypes) { | 27 TEST(DownloadPrefsTest, NoAutoOpenForDisallowedFileTypes) { |
26 const base::FilePath kDangerousFilePath(FILE_PATH_LITERAL("/b/very-bad.swf")); | 28 const base::FilePath kDangerousFilePath(FILE_PATH_LITERAL("/b/very-bad.swf")); |
27 | 29 |
28 content::TestBrowserThreadBundle threads_are_required_for_testing_profile; | 30 content::TestBrowserThreadBundle threads_are_required_for_testing_profile; |
29 TestingProfile profile; | 31 TestingProfile profile; |
30 DownloadPrefs prefs(&profile); | 32 DownloadPrefs prefs(&profile); |
31 | 33 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 110 |
109 EXPECT_TRUE(prefs.IsAutoOpenEnabledBasedOnExtension( | 111 EXPECT_TRUE(prefs.IsAutoOpenEnabledBasedOnExtension( |
110 base::FilePath(FILE_PATH_LITERAL("x.txt")))); | 112 base::FilePath(FILE_PATH_LITERAL("x.txt")))); |
111 EXPECT_TRUE(prefs.IsAutoOpenEnabledBasedOnExtension( | 113 EXPECT_TRUE(prefs.IsAutoOpenEnabledBasedOnExtension( |
112 base::FilePath(FILE_PATH_LITERAL("x.TXT")))); | 114 base::FilePath(FILE_PATH_LITERAL("x.TXT")))); |
113 EXPECT_TRUE(prefs.IsAutoOpenEnabledBasedOnExtension( | 115 EXPECT_TRUE(prefs.IsAutoOpenEnabledBasedOnExtension( |
114 base::FilePath(FILE_PATH_LITERAL("x.foo")))); | 116 base::FilePath(FILE_PATH_LITERAL("x.foo")))); |
115 EXPECT_TRUE(prefs.IsAutoOpenEnabledBasedOnExtension( | 117 EXPECT_TRUE(prefs.IsAutoOpenEnabledBasedOnExtension( |
116 base::FilePath(FILE_PATH_LITERAL("x.Bar")))); | 118 base::FilePath(FILE_PATH_LITERAL("x.Bar")))); |
117 } | 119 } |
OLD | NEW |