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

Side by Side Diff: chrome/browser/download/download_browsertest.cc

Issue 1551503002: Convert Pass()→std::move() in //chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
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 "chrome/browser/download/download_browsertest.h"
6
5 #include <stdint.h> 7 #include <stdint.h>
6
7 #include <sstream> 8 #include <sstream>
9 #include <utility>
8 10
9 #include "base/bind.h" 11 #include "base/bind.h"
10 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
11 #include "base/command_line.h" 13 #include "base/command_line.h"
12 #include "base/feature_list.h" 14 #include "base/feature_list.h"
13 #include "base/files/file.h" 15 #include "base/files/file.h"
14 #include "base/files/file_path.h" 16 #include "base/files/file_path.h"
15 #include "base/files/file_util.h" 17 #include "base/files/file_util.h"
16 #include "base/files/scoped_temp_dir.h" 18 #include "base/files/scoped_temp_dir.h"
17 #include "base/macros.h" 19 #include "base/macros.h"
18 #include "base/memory/ref_counted.h" 20 #include "base/memory/ref_counted.h"
19 #include "base/path_service.h" 21 #include "base/path_service.h"
20 #include "base/prefs/pref_service.h" 22 #include "base/prefs/pref_service.h"
21 #include "base/stl_util.h" 23 #include "base/stl_util.h"
22 #include "base/strings/string_number_conversions.h" 24 #include "base/strings/string_number_conversions.h"
23 #include "base/strings/string_split.h" 25 #include "base/strings/string_split.h"
24 #include "base/strings/string_util.h" 26 #include "base/strings/string_util.h"
25 #include "base/strings/stringprintf.h" 27 #include "base/strings/stringprintf.h"
26 #include "base/strings/utf_string_conversions.h" 28 #include "base/strings/utf_string_conversions.h"
27 #include "base/sys_info.h" 29 #include "base/sys_info.h"
28 #include "base/test/test_file_util.h" 30 #include "base/test/test_file_util.h"
29 #include "build/build_config.h" 31 #include "build/build_config.h"
30 #include "chrome/app/chrome_command_ids.h" 32 #include "chrome/app/chrome_command_ids.h"
31 #include "chrome/browser/browser_process.h" 33 #include "chrome/browser/browser_process.h"
32 #include "chrome/browser/chrome_notification_types.h" 34 #include "chrome/browser/chrome_notification_types.h"
33 #include "chrome/browser/download/chrome_download_manager_delegate.h" 35 #include "chrome/browser/download/chrome_download_manager_delegate.h"
34 #include "chrome/browser/download/download_browsertest.h"
35 #include "chrome/browser/download/download_crx_util.h" 36 #include "chrome/browser/download/download_crx_util.h"
36 #include "chrome/browser/download/download_history.h" 37 #include "chrome/browser/download/download_history.h"
37 #include "chrome/browser/download/download_item_model.h" 38 #include "chrome/browser/download/download_item_model.h"
38 #include "chrome/browser/download/download_prefs.h" 39 #include "chrome/browser/download/download_prefs.h"
39 #include "chrome/browser/download/download_request_limiter.h" 40 #include "chrome/browser/download/download_request_limiter.h"
40 #include "chrome/browser/download/download_service.h" 41 #include "chrome/browser/download/download_service.h"
41 #include "chrome/browser/download/download_service_factory.h" 42 #include "chrome/browser/download/download_service_factory.h"
42 #include "chrome/browser/download/download_shelf.h" 43 #include "chrome/browser/download/download_shelf.h"
43 #include "chrome/browser/download/download_target_determiner.h" 44 #include "chrome/browser/download/download_target_determiner.h"
44 #include "chrome/browser/download/download_test_file_activity_observer.h" 45 #include "chrome/browser/download/download_test_file_activity_observer.h"
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 scoped_ptr<std::vector<history::DownloadRow> >* results) { 265 scoped_ptr<std::vector<history::DownloadRow> >* results) {
265 history::HistoryService* hs = HistoryServiceFactory::GetForProfile( 266 history::HistoryService* hs = HistoryServiceFactory::GetForProfile(
266 profile_, ServiceAccessType::EXPLICIT_ACCESS); 267 profile_, ServiceAccessType::EXPLICIT_ACCESS);
267 DCHECK(hs); 268 DCHECK(hs);
268 hs->QueryDownloads( 269 hs->QueryDownloads(
269 base::Bind(&DownloadsHistoryDataCollector::OnQueryDownloadsComplete, 270 base::Bind(&DownloadsHistoryDataCollector::OnQueryDownloadsComplete,
270 base::Unretained(this))); 271 base::Unretained(this)));
271 272
272 content::RunMessageLoop(); 273 content::RunMessageLoop();
273 if (result_valid_) { 274 if (result_valid_) {
274 *results = results_.Pass(); 275 *results = std::move(results_);
275 } 276 }
276 return result_valid_; 277 return result_valid_;
277 } 278 }
278 279
279 private: 280 private:
280 void OnQueryDownloadsComplete( 281 void OnQueryDownloadsComplete(
281 scoped_ptr<std::vector<history::DownloadRow> > entries) { 282 scoped_ptr<std::vector<history::DownloadRow> > entries) {
282 result_valid_ = true; 283 result_valid_ = true;
283 results_ = entries.Pass(); 284 results_ = std::move(entries);
284 base::MessageLoopForUI::current()->QuitWhenIdle(); 285 base::MessageLoopForUI::current()->QuitWhenIdle();
285 } 286 }
286 287
287 Profile* profile_; 288 Profile* profile_;
288 scoped_ptr<std::vector<history::DownloadRow> > results_; 289 scoped_ptr<std::vector<history::DownloadRow> > results_;
289 bool result_valid_; 290 bool result_valid_;
290 291
291 DISALLOW_COPY_AND_ASSIGN(DownloadsHistoryDataCollector); 292 DISALLOW_COPY_AND_ASSIGN(DownloadsHistoryDataCollector);
292 }; 293 };
293 294
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 } 868 }
868 869
869 if (download_info.download_method == DOWNLOAD_DIRECT) { 870 if (download_info.download_method == DOWNLOAD_DIRECT) {
870 // Go directly to download. Don't wait for navigation. 871 // Go directly to download. Don't wait for navigation.
871 scoped_refptr<content::DownloadTestItemCreationObserver> 872 scoped_refptr<content::DownloadTestItemCreationObserver>
872 creation_observer(new content::DownloadTestItemCreationObserver); 873 creation_observer(new content::DownloadTestItemCreationObserver);
873 874
874 scoped_ptr<DownloadUrlParameters> params( 875 scoped_ptr<DownloadUrlParameters> params(
875 DownloadUrlParameters::FromWebContents(web_contents, url)); 876 DownloadUrlParameters::FromWebContents(web_contents, url));
876 params->set_callback(creation_observer->callback()); 877 params->set_callback(creation_observer->callback());
877 DownloadManagerForBrowser(browser())->DownloadUrl(params.Pass()); 878 DownloadManagerForBrowser(browser())->DownloadUrl(std::move(params));
878 879
879 // Wait until the item is created, or we have determined that it 880 // Wait until the item is created, or we have determined that it
880 // won't be. 881 // won't be.
881 creation_observer->WaitForDownloadItemCreation(); 882 creation_observer->WaitForDownloadItemCreation();
882 883
883 ASSERT_EQ(download_info.show_download_item, 884 ASSERT_EQ(download_info.show_download_item,
884 creation_observer->succeeded()); 885 creation_observer->succeeded());
885 if (download_info.show_download_item) { 886 if (download_info.show_download_item) {
886 EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_NONE, 887 EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_NONE,
887 creation_observer->interrupt_reason()); 888 creation_observer->interrupt_reason());
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 // S -> C: HTTP/1.1 200 OK 1184 // S -> C: HTTP/1.1 200 OK
1184 // Content-Type: foo/bar 1185 // Content-Type: foo/bar
1185 // ... 1186 // ...
1186 static scoped_ptr<net::test_server::HttpResponse> RespondWithContentTypeHandler( 1187 static scoped_ptr<net::test_server::HttpResponse> RespondWithContentTypeHandler(
1187 const net::test_server::HttpRequest& request) { 1188 const net::test_server::HttpRequest& request) {
1188 scoped_ptr<net::test_server::BasicHttpResponse> response( 1189 scoped_ptr<net::test_server::BasicHttpResponse> response(
1189 new net::test_server::BasicHttpResponse()); 1190 new net::test_server::BasicHttpResponse());
1190 response->set_content_type(request.relative_url.substr(1)); 1191 response->set_content_type(request.relative_url.substr(1));
1191 response->set_code(net::HTTP_OK); 1192 response->set_code(net::HTTP_OK);
1192 response->set_content("ooogaboogaboogabooga"); 1193 response->set_content("ooogaboogaboogabooga");
1193 return response.Pass(); 1194 return std::move(response);
1194 } 1195 }
1195 1196
1196 IN_PROC_BROWSER_TEST_F(DownloadTest, MimeTypesToShowNotDownload) { 1197 IN_PROC_BROWSER_TEST_F(DownloadTest, MimeTypesToShowNotDownload) {
1197 embedded_test_server()->RegisterRequestHandler( 1198 embedded_test_server()->RegisterRequestHandler(
1198 base::Bind(&RespondWithContentTypeHandler)); 1199 base::Bind(&RespondWithContentTypeHandler));
1199 ASSERT_TRUE(embedded_test_server()->Start()); 1200 ASSERT_TRUE(embedded_test_server()->Start());
1200 1201
1201 // These files should all be displayed in the browser. 1202 // These files should all be displayed in the browser.
1202 const char* mime_types[] = { 1203 const char* mime_types[] = {
1203 // It is unclear whether to display text/css or download it. 1204 // It is unclear whether to display text/css or download it.
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
1602 content::WebContents::CreateParams(tab->GetBrowserContext())); 1603 content::WebContents::CreateParams(tab->GetBrowserContext()));
1603 ASSERT_TRUE(new_tab); 1604 ASSERT_TRUE(new_tab);
1604 ASSERT_TRUE(new_tab->GetController().IsInitialNavigation()); 1605 ASSERT_TRUE(new_tab->GetController().IsInitialNavigation());
1605 browser()->tab_strip_model()->AppendWebContents(new_tab, true); 1606 browser()->tab_strip_model()->AppendWebContents(new_tab, true);
1606 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 1607 EXPECT_EQ(2, browser()->tab_strip_model()->count());
1607 1608
1608 // Download a file in that new tab, having it open a file picker 1609 // Download a file in that new tab, having it open a file picker
1609 scoped_ptr<DownloadUrlParameters> params( 1610 scoped_ptr<DownloadUrlParameters> params(
1610 DownloadUrlParameters::FromWebContents(new_tab, slow_download_url)); 1611 DownloadUrlParameters::FromWebContents(new_tab, slow_download_url));
1611 params->set_prompt(true); 1612 params->set_prompt(true);
1612 manager->DownloadUrl(params.Pass()); 1613 manager->DownloadUrl(std::move(params));
1613 observer->WaitForFinished(); 1614 observer->WaitForFinished();
1614 1615
1615 DownloadManager::DownloadVector items; 1616 DownloadManager::DownloadVector items;
1616 manager->GetAllDownloads(&items); 1617 manager->GetAllDownloads(&items);
1617 ASSERT_NE(0u, items.size()); 1618 ASSERT_NE(0u, items.size());
1618 DownloadItem* item = items[0]; 1619 DownloadItem* item = items[0];
1619 EXPECT_TRUE(item != nullptr); 1620 EXPECT_TRUE(item != nullptr);
1620 1621
1621 // When the download is canceled, the second tab should close. 1622 // When the download is canceled, the second tab should close.
1622 EXPECT_EQ(item->GetState(), DownloadItem::CANCELLED); 1623 EXPECT_EQ(item->GetState(), DownloadItem::CANCELLED);
(...skipping 12 matching lines...) Expand all
1635 scoped_ptr<net::test_server::BasicHttpResponse> response( 1636 scoped_ptr<net::test_server::BasicHttpResponse> response(
1636 new net::test_server::BasicHttpResponse()); 1637 new net::test_server::BasicHttpResponse());
1637 size_t query_position = request.relative_url.find('?'); 1638 size_t query_position = request.relative_url.find('?');
1638 1639
1639 if (query_position == std::string::npos) { 1640 if (query_position == std::string::npos) {
1640 response->set_code(net::HTTP_PERMANENT_REDIRECT); 1641 response->set_code(net::HTTP_PERMANENT_REDIRECT);
1641 response->AddCustomHeader("Location", 1642 response->AddCustomHeader("Location",
1642 "https://request-had-no-query-string"); 1643 "https://request-had-no-query-string");
1643 response->set_content_type("text/plain"); 1644 response->set_content_type("text/plain");
1644 response->set_content("Error"); 1645 response->set_content("Error");
1645 return response.Pass(); 1646 return std::move(response);
1646 } 1647 }
1647 1648
1648 response->set_code(net::HTTP_PERMANENT_REDIRECT); 1649 response->set_code(net::HTTP_PERMANENT_REDIRECT);
1649 response->AddCustomHeader("Location", 1650 response->AddCustomHeader("Location",
1650 request.relative_url.substr(query_position + 1)); 1651 request.relative_url.substr(query_position + 1));
1651 response->set_content_type("text/plain"); 1652 response->set_content_type("text/plain");
1652 response->set_content("It's gone!"); 1653 response->set_content("It's gone!");
1653 return response.Pass(); 1654 return std::move(response);
1654 } 1655 }
1655 1656
1656 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadHistoryCheck) { 1657 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadHistoryCheck) {
1657 GURL download_url(net::URLRequestSlowDownloadJob::kKnownSizeUrl); 1658 GURL download_url(net::URLRequestSlowDownloadJob::kKnownSizeUrl);
1658 base::FilePath file(net::GenerateFileName(download_url, 1659 base::FilePath file(net::GenerateFileName(download_url,
1659 std::string(), 1660 std::string(),
1660 std::string(), 1661 std::string(),
1661 std::string(), 1662 std::string(),
1662 std::string(), 1663 std::string(),
1663 std::string())); 1664 std::string()));
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
2075 browser()->tab_strip_model()->GetActiveWebContents(); 2076 browser()->tab_strip_model()->GetActiveWebContents();
2076 ASSERT_TRUE(web_contents); 2077 ASSERT_TRUE(web_contents);
2077 2078
2078 content::DownloadTestObserver* observer( 2079 content::DownloadTestObserver* observer(
2079 new content::DownloadTestObserverTerminal( 2080 new content::DownloadTestObserverTerminal(
2080 DownloadManagerForBrowser(browser()), 1, 2081 DownloadManagerForBrowser(browser()), 1,
2081 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL)); 2082 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL));
2082 scoped_ptr<DownloadUrlParameters> params( 2083 scoped_ptr<DownloadUrlParameters> params(
2083 DownloadUrlParameters::FromWebContents(web_contents, url)); 2084 DownloadUrlParameters::FromWebContents(web_contents, url));
2084 params->set_prompt(true); 2085 params->set_prompt(true);
2085 DownloadManagerForBrowser(browser())->DownloadUrl(params.Pass()); 2086 DownloadManagerForBrowser(browser())->DownloadUrl(std::move(params));
2086 observer->WaitForFinished(); 2087 observer->WaitForFinished();
2087 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::COMPLETE)); 2088 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::COMPLETE));
2088 CheckDownloadStates(1, DownloadItem::COMPLETE); 2089 CheckDownloadStates(1, DownloadItem::COMPLETE);
2089 EXPECT_TRUE(DidShowFileChooser()); 2090 EXPECT_TRUE(DidShowFileChooser());
2090 2091
2091 // Check state. 2092 // Check state.
2092 base::FilePath file(FILE_PATH_LITERAL("download-test1.lib")); 2093 base::FilePath file(FILE_PATH_LITERAL("download-test1.lib"));
2093 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 2094 EXPECT_EQ(1, browser()->tab_strip_model()->count());
2094 ASSERT_TRUE(CheckDownload(browser(), file, file)); 2095 ASSERT_TRUE(CheckDownload(browser(), file, file));
2095 } 2096 }
2096 2097
2097 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadUrlToPath) { 2098 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadUrlToPath) {
2098 GURL url(URLRequestMockHTTPJob::GetMockUrl(kDownloadTest1Path)); 2099 GURL url(URLRequestMockHTTPJob::GetMockUrl(kDownloadTest1Path));
2099 2100
2100 WebContents* web_contents = 2101 WebContents* web_contents =
2101 browser()->tab_strip_model()->GetActiveWebContents(); 2102 browser()->tab_strip_model()->GetActiveWebContents();
2102 ASSERT_TRUE(web_contents); 2103 ASSERT_TRUE(web_contents);
2103 2104
2104 base::FilePath file(FILE_PATH_LITERAL("download-test1.lib")); 2105 base::FilePath file(FILE_PATH_LITERAL("download-test1.lib"));
2105 base::ScopedTempDir other_directory; 2106 base::ScopedTempDir other_directory;
2106 ASSERT_TRUE(other_directory.CreateUniqueTempDir()); 2107 ASSERT_TRUE(other_directory.CreateUniqueTempDir());
2107 base::FilePath target_file_full_path 2108 base::FilePath target_file_full_path
2108 = other_directory.path().Append(file.BaseName()); 2109 = other_directory.path().Append(file.BaseName());
2109 content::DownloadTestObserver* observer(CreateWaiter(browser(), 1)); 2110 content::DownloadTestObserver* observer(CreateWaiter(browser(), 1));
2110 scoped_ptr<DownloadUrlParameters> params( 2111 scoped_ptr<DownloadUrlParameters> params(
2111 DownloadUrlParameters::FromWebContents(web_contents, url)); 2112 DownloadUrlParameters::FromWebContents(web_contents, url));
2112 params->set_file_path(target_file_full_path); 2113 params->set_file_path(target_file_full_path);
2113 DownloadManagerForBrowser(browser())->DownloadUrl(params.Pass()); 2114 DownloadManagerForBrowser(browser())->DownloadUrl(std::move(params));
2114 observer->WaitForFinished(); 2115 observer->WaitForFinished();
2115 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::COMPLETE)); 2116 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::COMPLETE));
2116 2117
2117 // Check state. 2118 // Check state.
2118 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 2119 EXPECT_EQ(1, browser()->tab_strip_model()->count());
2119 ASSERT_TRUE(CheckDownloadFullPaths(browser(), 2120 ASSERT_TRUE(CheckDownloadFullPaths(browser(),
2120 target_file_full_path, 2121 target_file_full_path,
2121 OriginFile(file))); 2122 OriginFile(file)));
2122 2123
2123 // Temporary are treated as auto-opened, and after that open won't be 2124 // Temporary are treated as auto-opened, and after that open won't be
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
2196 // with query string ?allow-post-only, and returns a 404 response if the method 2197 // with query string ?allow-post-only, and returns a 404 response if the method
2197 // is not POST. 2198 // is not POST.
2198 static scoped_ptr<net::test_server::HttpResponse> FilterPostOnlyURLsHandler( 2199 static scoped_ptr<net::test_server::HttpResponse> FilterPostOnlyURLsHandler(
2199 const net::test_server::HttpRequest& request) { 2200 const net::test_server::HttpRequest& request) {
2200 scoped_ptr<net::test_server::BasicHttpResponse> response; 2201 scoped_ptr<net::test_server::BasicHttpResponse> response;
2201 if (request.relative_url.find("?allow-post-only") != std::string::npos && 2202 if (request.relative_url.find("?allow-post-only") != std::string::npos &&
2202 request.method != net::test_server::METHOD_POST) { 2203 request.method != net::test_server::METHOD_POST) {
2203 response.reset(new net::test_server::BasicHttpResponse()); 2204 response.reset(new net::test_server::BasicHttpResponse());
2204 response->set_code(net::HTTP_NOT_FOUND); 2205 response->set_code(net::HTTP_NOT_FOUND);
2205 } 2206 }
2206 return response.Pass(); 2207 return std::move(response);
2207 } 2208 }
2208 2209
2209 IN_PROC_BROWSER_TEST_F(DownloadTest, SavePageNonHTMLViaPost) { 2210 IN_PROC_BROWSER_TEST_F(DownloadTest, SavePageNonHTMLViaPost) {
2210 embedded_test_server()->RegisterRequestHandler( 2211 embedded_test_server()->RegisterRequestHandler(
2211 base::Bind(&FilterPostOnlyURLsHandler)); 2212 base::Bind(&FilterPostOnlyURLsHandler));
2212 embedded_test_server()->ServeFilesFromDirectory(GetTestDataDirectory()); 2213 embedded_test_server()->ServeFilesFromDirectory(GetTestDataDirectory());
2213 ASSERT_TRUE(embedded_test_server()->Start()); 2214 ASSERT_TRUE(embedded_test_server()->Start());
2214 EnableFileChooser(true); 2215 EnableFileChooser(true);
2215 std::vector<DownloadItem*> download_items; 2216 std::vector<DownloadItem*> download_items;
2216 GetDownloads(browser(), &download_items); 2217 GetDownloads(browser(), &download_items);
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
2585 if (request.relative_url.find("/echoreferrer") != 0) 2586 if (request.relative_url.find("/echoreferrer") != 0)
2586 return scoped_ptr<net::test_server::HttpResponse>(); 2587 return scoped_ptr<net::test_server::HttpResponse>();
2587 2588
2588 scoped_ptr<net::test_server::BasicHttpResponse> response( 2589 scoped_ptr<net::test_server::BasicHttpResponse> response(
2589 new net::test_server::BasicHttpResponse()); 2590 new net::test_server::BasicHttpResponse());
2590 response->set_code(net::HTTP_OK); 2591 response->set_code(net::HTTP_OK);
2591 response->set_content_type("text/plain"); 2592 response->set_content_type("text/plain");
2592 auto referrer_header = request.headers.find(kReferrerHeader); 2593 auto referrer_header = request.headers.find(kReferrerHeader);
2593 if (referrer_header != request.headers.end()) 2594 if (referrer_header != request.headers.end())
2594 response->set_content(referrer_header->second); 2595 response->set_content(referrer_header->second);
2595 return response.Pass(); 2596 return std::move(response);
2596 } 2597 }
2597 2598
2598 IN_PROC_BROWSER_TEST_F(DownloadTest, LoadURLExternallyReferrerPolicy) { 2599 IN_PROC_BROWSER_TEST_F(DownloadTest, LoadURLExternallyReferrerPolicy) {
2599 embedded_test_server()->RegisterRequestHandler( 2600 embedded_test_server()->RegisterRequestHandler(
2600 base::Bind(&EchoReferrerRequestHandler)); 2601 base::Bind(&EchoReferrerRequestHandler));
2601 embedded_test_server()->ServeFilesFromDirectory(GetTestDataDirectory()); 2602 embedded_test_server()->ServeFilesFromDirectory(GetTestDataDirectory());
2602 ASSERT_TRUE(embedded_test_server()->Start()); 2603 ASSERT_TRUE(embedded_test_server()->Start());
2603 EnableFileChooser(true); 2604 EnableFileChooser(true);
2604 std::vector<DownloadItem*> download_items; 2605 std::vector<DownloadItem*> download_items;
2605 GetDownloads(browser(), &download_items); 2606 GetDownloads(browser(), &download_items);
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after
3599 new content::DownloadTestObserverTerminal( 3600 new content::DownloadTestObserverTerminal(
3600 download_manager, 1, 3601 download_manager, 1,
3601 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL)); 3602 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL));
3602 3603
3603 // Download and set IsHiddenDownload to true. 3604 // Download and set IsHiddenDownload to true.
3604 WebContents* web_contents = 3605 WebContents* web_contents =
3605 browser()->tab_strip_model()->GetActiveWebContents(); 3606 browser()->tab_strip_model()->GetActiveWebContents();
3606 scoped_ptr<DownloadUrlParameters> params( 3607 scoped_ptr<DownloadUrlParameters> params(
3607 DownloadUrlParameters::FromWebContents(web_contents, url)); 3608 DownloadUrlParameters::FromWebContents(web_contents, url));
3608 params->set_callback(base::Bind(&SetHiddenDownloadCallback)); 3609 params->set_callback(base::Bind(&SetHiddenDownloadCallback));
3609 download_manager->DownloadUrl(params.Pass()); 3610 download_manager->DownloadUrl(std::move(params));
3610 observer->WaitForFinished(); 3611 observer->WaitForFinished();
3611 3612
3612 // Verify that download shelf is not shown. 3613 // Verify that download shelf is not shown.
3613 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); 3614 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible());
3614 } 3615 }
3615 3616
3616 // Test to make sure auto-open works. 3617 // Test to make sure auto-open works.
3617 IN_PROC_BROWSER_TEST_F(DownloadTestWithShelf, AutoOpen) { 3618 IN_PROC_BROWSER_TEST_F(DownloadTestWithShelf, AutoOpen) {
3618 base::FilePath file(FILE_PATH_LITERAL("download-autoopen.txt")); 3619 base::FilePath file(FILE_PATH_LITERAL("download-autoopen.txt"));
3619 GURL url(URLRequestMockHTTPJob::GetMockUrl("download-autoopen.txt")); 3620 GURL url(URLRequestMockHTTPJob::GetMockUrl("download-autoopen.txt"));
(...skipping 17 matching lines...) Expand all
3637 3638
3638 scoped_ptr<content::DownloadTestObserver> observer(DangerousDownloadWaiter( 3639 scoped_ptr<content::DownloadTestObserver> observer(DangerousDownloadWaiter(
3639 browser(), 1, content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); 3640 browser(), 1, content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY));
3640 ui_test_utils::NavigateToURL(browser(), extension_url); 3641 ui_test_utils::NavigateToURL(browser(), extension_url);
3641 3642
3642 observer->WaitForFinished(); 3643 observer->WaitForFinished();
3643 3644
3644 // Download shelf should close. 3645 // Download shelf should close.
3645 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); 3646 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible());
3646 } 3647 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698