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

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

Issue 2943763002: Add a new group policy to disable safe browsing for files downloaded from trusted sources. (Closed)
Patch Set: D'Ho! Created 3 years, 6 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
Index: chrome/browser/download/chrome_download_manager_delegate_unittest.cc
diff --git a/chrome/browser/download/chrome_download_manager_delegate_unittest.cc b/chrome/browser/download/chrome_download_manager_delegate_unittest.cc
index ed6f7b6df6918371a43f614a23102951aa426fcf..4109a81fb766f10b48e4da024051b9676c2ac9ab 100644
--- a/chrome/browser/download/chrome_download_manager_delegate_unittest.cc
+++ b/chrome/browser/download/chrome_download_manager_delegate_unittest.cc
@@ -7,6 +7,7 @@
#include <string>
+#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
@@ -20,6 +21,7 @@
#include "chrome/browser/download/download_item_model.h"
#include "chrome/browser/download/download_prefs.h"
#include "chrome/browser/download/download_target_info.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/features.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
@@ -883,6 +885,44 @@ TEST_P(ChromeDownloadManagerDelegateTestWithSafeBrowsing, CheckClientDownload) {
run_loop.Run();
}
+TEST_F(ChromeDownloadManagerDelegateTestWithSafeBrowsing,
+ TrustedSourcesPolicyNotTrusted) {
+ GURL download_url("http://untrusted.com/best-download-ever.exe");
+ pref_service()->SetBoolean(prefs::kSafeBrowsingForTrustedSourcesEnabled,
+ false);
+ std::unique_ptr<content::MockDownloadItem> download_item =
+ CreateActiveDownloadItem(0);
+ EXPECT_CALL(*download_item, GetURL()).WillRepeatedly(ReturnRef(download_url));
+
+ EXPECT_CALL(*delegate(), GetDownloadProtectionService());
+ EXPECT_CALL(*download_protection_service(), MockCheckClientDownload())
+ .WillOnce(Return(safe_browsing::DownloadProtectionService::SAFE));
+ EXPECT_CALL(*download_item, GetDangerType())
+ .WillRepeatedly(Return(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS));
+
+ base::RunLoop run_loop;
+ ASSERT_FALSE(delegate()->ShouldCompleteDownload(download_item.get(),
+ run_loop.QuitClosure()));
+ run_loop.Run();
+}
+
+TEST_F(ChromeDownloadManagerDelegateTestWithSafeBrowsing,
+ TrustedSourcesPolicyTrusted) {
+ base::CommandLine* command_line(base::CommandLine::ForCurrentProcess());
+ DCHECK(command_line);
+ command_line->AppendSwitchASCII(switches::kTrustedDownloadSources,
+ "trusted.com");
+ GURL download_url("http://trusted.com/best-download-ever.exe");
+ pref_service()->SetBoolean(prefs::kSafeBrowsingForTrustedSourcesEnabled,
+ false);
+ std::unique_ptr<content::MockDownloadItem> download_item =
+ CreateActiveDownloadItem(0);
+ EXPECT_CALL(*download_item, GetURL()).WillRepeatedly(ReturnRef(download_url));
+ EXPECT_CALL(*delegate(), GetDownloadProtectionService()).Times(0);
+ EXPECT_TRUE(
+ delegate()->ShouldCompleteDownload(download_item.get(), base::Closure()));
+}
+
#endif // FULL_SAFE_BROWSING
#if defined(OS_ANDROID)

Powered by Google App Engine
This is Rietveld 408576698