Index: chrome/browser/download/download_browsertest.cc |
diff --git a/chrome/browser/download/download_browsertest.cc b/chrome/browser/download/download_browsertest.cc |
index a85588646eac1bf7c81cd56087a61af2f7a6e5d6..26262c00ceb47d7d445a78250c290bf262c74e69 100644 |
--- a/chrome/browser/download/download_browsertest.cc |
+++ b/chrome/browser/download/download_browsertest.cc |
@@ -203,6 +203,13 @@ bool WasAutoOpened(DownloadItem* item) { |
return item->GetAutoOpened(); |
} |
+// Called when a download starts. Marks the download as hidden. |
+void SetHiddenDownloadCallback(scoped_refptr<DownloadManager> download_manager, |
+ DownloadItem* item, |
+ net::Error error) { |
+ download_util::SetShouldShowInShelf(item, false); |
+} |
+ |
} // namespace |
// While an object of this class exists, it will mock out download |
@@ -2244,3 +2251,30 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, LoadURLExternallyReferrerPolicy) { |
std::string expected_contents = test_server()->GetURL("").spec(); |
ASSERT_TRUE(VerifyFile(file, expected_contents, expected_contents.length())); |
} |
+ |
+IN_PROC_BROWSER_TEST_F(DownloadTest, HiddenDownload) { |
+ FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
+ GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
+ |
+ scoped_refptr<DownloadManager> download_manager = |
+ DownloadManagerForBrowser(browser()); |
+ scoped_ptr<content::DownloadTestObserver> observer( |
+ new content::DownloadTestObserverTerminal( |
+ download_manager, |
+ 1, |
+ content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL)); |
+ content::DownloadSaveInfo save_info; |
+ save_info.prompt_for_save_location = false; |
+ |
+ // Download and set IsHiddenDownload to true. |
+ WebContents* web_contents = chrome::GetActiveWebContents(browser()); |
+ scoped_ptr<DownloadUrlParameters> params( |
+ DownloadUrlParameters::FromWebContents(web_contents, url, save_info)); |
+ params->set_callback( |
+ base::Bind(&SetHiddenDownloadCallback, download_manager)); |
+ download_manager->DownloadUrl(params.Pass()); |
+ observer->WaitForFinished(); |
+ |
+ // Verify that download shelf is not shown. |
+ EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); |
+} |