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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/download/download_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <sstream> 5 #include <sstream>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 return false; 196 return false;
197 } 197 }
198 198
199 DISALLOW_COPY_AND_ASSIGN(TestRenderViewContextMenu); 199 DISALLOW_COPY_AND_ASSIGN(TestRenderViewContextMenu);
200 }; 200 };
201 201
202 bool WasAutoOpened(DownloadItem* item) { 202 bool WasAutoOpened(DownloadItem* item) {
203 return item->GetAutoOpened(); 203 return item->GetAutoOpened();
204 } 204 }
205 205
206 // Called when a download starts. Marks the download as hidden.
207 void SetHiddenDownloadCallback(scoped_refptr<DownloadManager> download_manager,
208 DownloadItem* item,
209 net::Error error) {
210 download_util::SetShouldShowInShelf(item, false);
211 }
212
206 } // namespace 213 } // namespace
207 214
208 // While an object of this class exists, it will mock out download 215 // While an object of this class exists, it will mock out download
209 // opening for all downloads created on the specified download manager. 216 // opening for all downloads created on the specified download manager.
210 class MockDownloadOpeningObserver : public DownloadManager::Observer { 217 class MockDownloadOpeningObserver : public DownloadManager::Observer {
211 public: 218 public:
212 explicit MockDownloadOpeningObserver(DownloadManager* manager) 219 explicit MockDownloadOpeningObserver(DownloadManager* manager)
213 : download_manager_(manager) { 220 : download_manager_(manager) {
214 download_manager_->AddObserver(this); 221 download_manager_->AddObserver(this);
215 } 222 }
(...skipping 2021 matching lines...) Expand 10 before | Expand all | Expand 10 after
2237 GetDownloads(browser(), &download_items); 2244 GetDownloads(browser(), &download_items);
2238 ASSERT_EQ(1u, download_items.size()); 2245 ASSERT_EQ(1u, download_items.size());
2239 ASSERT_EQ(test_server()->GetURL("echoheader?Referer"), 2246 ASSERT_EQ(test_server()->GetURL("echoheader?Referer"),
2240 download_items[0]->GetOriginalUrl()); 2247 download_items[0]->GetOriginalUrl());
2241 2248
2242 // Check that the file contains the expected referrer. 2249 // Check that the file contains the expected referrer.
2243 FilePath file(download_items[0]->GetFullPath()); 2250 FilePath file(download_items[0]->GetFullPath());
2244 std::string expected_contents = test_server()->GetURL("").spec(); 2251 std::string expected_contents = test_server()->GetURL("").spec();
2245 ASSERT_TRUE(VerifyFile(file, expected_contents, expected_contents.length())); 2252 ASSERT_TRUE(VerifyFile(file, expected_contents, expected_contents.length()));
2246 } 2253 }
2254
2255 IN_PROC_BROWSER_TEST_F(DownloadTest, HiddenDownload) {
2256 FilePath file(FILE_PATH_LITERAL("download-test1.lib"));
2257 GURL url(URLRequestMockHTTPJob::GetMockUrl(file));
2258
2259 scoped_refptr<DownloadManager> download_manager =
2260 DownloadManagerForBrowser(browser());
2261 scoped_ptr<content::DownloadTestObserver> observer(
2262 new content::DownloadTestObserverTerminal(
2263 download_manager,
2264 1,
2265 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL));
2266 content::DownloadSaveInfo save_info;
2267 save_info.prompt_for_save_location = false;
2268
2269 // Download and set IsHiddenDownload to true.
2270 WebContents* web_contents = chrome::GetActiveWebContents(browser());
2271 scoped_ptr<DownloadUrlParameters> params(
2272 DownloadUrlParameters::FromWebContents(web_contents, url, save_info));
2273 params->set_callback(
2274 base::Bind(&SetHiddenDownloadCallback, download_manager));
2275 download_manager->DownloadUrl(params.Pass());
2276 observer->WaitForFinished();
2277
2278 // Verify that download shelf is not shown.
2279 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible());
2280 }
OLDNEW
« 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