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

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

Issue 11016022: Don't show downloads from web intents picker in shelf (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix build Created 8 years, 2 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
« no previous file with comments | « no previous file | chrome/browser/download/download_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
+}
« no previous file with comments | « no previous file | chrome/browser/download/download_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698