| OLD | NEW |
| 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_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 bool CreateAndSetDownloadsDirectory(Browser* browser) { | 472 bool CreateAndSetDownloadsDirectory(Browser* browser) { |
| 473 if (!browser) | 473 if (!browser) |
| 474 return false; | 474 return false; |
| 475 | 475 |
| 476 if (!downloads_directory_.CreateUniqueTempDir()) | 476 if (!downloads_directory_.CreateUniqueTempDir()) |
| 477 return false; | 477 return false; |
| 478 | 478 |
| 479 browser->profile()->GetPrefs()->SetFilePath( | 479 browser->profile()->GetPrefs()->SetFilePath( |
| 480 prefs::kDownloadDefaultDirectory, | 480 prefs::kDownloadDefaultDirectory, |
| 481 downloads_directory_.path()); | 481 downloads_directory_.path()); |
| 482 browser->profile()->GetPrefs()->SetFilePath( |
| 483 prefs::kSaveFileDefaultDirectory, |
| 484 downloads_directory_.path()); |
| 482 | 485 |
| 483 return true; | 486 return true; |
| 484 } | 487 } |
| 485 | 488 |
| 486 DownloadPrefs* GetDownloadPrefs(Browser* browser) { | 489 DownloadPrefs* GetDownloadPrefs(Browser* browser) { |
| 487 return DownloadPrefs::FromDownloadManager( | 490 return DownloadPrefs::FromDownloadManager( |
| 488 DownloadManagerForBrowser(browser)); | 491 DownloadManagerForBrowser(browser)); |
| 489 } | 492 } |
| 490 | 493 |
| 491 base::FilePath GetDownloadDirectory(Browser* browser) { | 494 base::FilePath GetDownloadDirectory(Browser* browser) { |
| (...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1388 | 1391 |
| 1389 // Setup an incognito window. | 1392 // Setup an incognito window. |
| 1390 Browser* incognito = CreateIncognitoBrowser(); | 1393 Browser* incognito = CreateIncognitoBrowser(); |
| 1391 ASSERT_TRUE(incognito); | 1394 ASSERT_TRUE(incognito); |
| 1392 int window_count = BrowserList::GetInstance( | 1395 int window_count = BrowserList::GetInstance( |
| 1393 browser()->host_desktop_type())->size(); | 1396 browser()->host_desktop_type())->size(); |
| 1394 EXPECT_EQ(2, window_count); | 1397 EXPECT_EQ(2, window_count); |
| 1395 incognito->profile()->GetPrefs()->SetFilePath( | 1398 incognito->profile()->GetPrefs()->SetFilePath( |
| 1396 prefs::kDownloadDefaultDirectory, | 1399 prefs::kDownloadDefaultDirectory, |
| 1397 GetDownloadsDirectory()); | 1400 GetDownloadsDirectory()); |
| 1401 incognito->profile()->GetPrefs()->SetFilePath( |
| 1402 prefs::kSaveFileDefaultDirectory, |
| 1403 GetDownloadsDirectory()); |
| 1398 | 1404 |
| 1399 download_items.clear(); | 1405 download_items.clear(); |
| 1400 GetDownloads(incognito, &download_items); | 1406 GetDownloads(incognito, &download_items); |
| 1401 ASSERT_TRUE(download_items.empty()); | 1407 ASSERT_TRUE(download_items.empty()); |
| 1402 | 1408 |
| 1403 // Download a file in the incognito browser and check that it was downloaded | 1409 // Download a file in the incognito browser and check that it was downloaded |
| 1404 // correctly. | 1410 // correctly. |
| 1405 DownloadAndWaitWithDisposition(incognito, | 1411 DownloadAndWaitWithDisposition(incognito, |
| 1406 url, | 1412 url, |
| 1407 CURRENT_TAB, | 1413 CURRENT_TAB, |
| (...skipping 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2924 scoped_ptr<content::DownloadTestObserver> observer( | 2930 scoped_ptr<content::DownloadTestObserver> observer( |
| 2925 DangerousDownloadWaiter( | 2931 DangerousDownloadWaiter( |
| 2926 browser(), 1, | 2932 browser(), 1, |
| 2927 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); | 2933 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); |
| 2928 ui_test_utils::NavigateToURL(browser(), url); | 2934 ui_test_utils::NavigateToURL(browser(), url); |
| 2929 observer->WaitForFinished(); | 2935 observer->WaitForFinished(); |
| 2930 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::CANCELLED)); | 2936 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::CANCELLED)); |
| 2931 EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen()); | 2937 EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen()); |
| 2932 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); | 2938 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); |
| 2933 } | 2939 } |
| OLD | NEW |