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

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: Fix an XML goof Created 3 years, 5 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 e07149de60634e9c9bb2dab4c713a88a683cd105..9661b63125d986c801a7af0149ceb7de8145f893 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,46 @@ 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();
+}
+
+#if !defined(OS_WIN)
+// TODO(crbug.com/739204) Add a Windows version of this test.
+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 // OS_WIN
#endif // FULL_SAFE_BROWSING
#if defined(OS_ANDROID)
« no previous file with comments | « chrome/browser/download/chrome_download_manager_delegate.cc ('k') | chrome/browser/download/download_prefs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698