| 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_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 1635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1646 // As long as we're here, confirmed everything else is good. | 1646 // As long as we're here, confirmed everything else is good. |
| 1647 EXPECT_EQ(1, browser()->tab_count()); | 1647 EXPECT_EQ(1, browser()->tab_count()); |
| 1648 CheckDownload(browser(), file, file); | 1648 CheckDownload(browser(), file, file); |
| 1649 // Download shelf should close. Download panel stays open on ChromeOS. | 1649 // Download shelf should close. Download panel stays open on ChromeOS. |
| 1650 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); | 1650 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); |
| 1651 } | 1651 } |
| 1652 | 1652 |
| 1653 // Download an extension. Expect a dangerous download warning. | 1653 // Download an extension. Expect a dangerous download warning. |
| 1654 // Deny the download. | 1654 // Deny the download. |
| 1655 IN_PROC_BROWSER_TEST_F(DownloadTest, CrxDenyInstall) { | 1655 IN_PROC_BROWSER_TEST_F(DownloadTest, CrxDenyInstall) { |
| 1656 if (!extensions::switch_utils::IsOffStoreInstallEnabled()) | 1656 if (!extensions::switch_utils::IsEasyOffStoreInstallEnabled()) |
| 1657 return; | 1657 return; |
| 1658 | 1658 |
| 1659 GURL extension_url(URLRequestMockHTTPJob::GetMockUrl(kGoodCrxPath)); | 1659 GURL extension_url(URLRequestMockHTTPJob::GetMockUrl(kGoodCrxPath)); |
| 1660 | 1660 |
| 1661 scoped_ptr<DownloadTestObserver> observer( | 1661 scoped_ptr<DownloadTestObserver> observer( |
| 1662 DangerousDownloadWaiter( | 1662 DangerousDownloadWaiter( |
| 1663 browser(), 1, | 1663 browser(), 1, |
| 1664 DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); | 1664 DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); |
| 1665 ui_test_utils::NavigateToURL(browser(), extension_url); | 1665 ui_test_utils::NavigateToURL(browser(), extension_url); |
| 1666 | 1666 |
| 1667 observer->WaitForFinished(); | 1667 observer->WaitForFinished(); |
| 1668 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::CANCELLED)); | 1668 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::CANCELLED)); |
| 1669 EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen()); | 1669 EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen()); |
| 1670 | 1670 |
| 1671 // Download shelf should close. Download panel stays open on ChromeOS. | 1671 // Download shelf should close. Download panel stays open on ChromeOS. |
| 1672 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); | 1672 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); |
| 1673 | 1673 |
| 1674 // Check that the CRX is not installed. | 1674 // Check that the CRX is not installed. |
| 1675 ExtensionService* extension_service = | 1675 ExtensionService* extension_service = |
| 1676 browser()->profile()->GetExtensionService(); | 1676 browser()->profile()->GetExtensionService(); |
| 1677 ASSERT_FALSE(extension_service->GetExtensionById(kGoodCrxId, false)); | 1677 ASSERT_FALSE(extension_service->GetExtensionById(kGoodCrxId, false)); |
| 1678 } | 1678 } |
| 1679 | 1679 |
| 1680 // Download an extension. Expect a dangerous download warning. | 1680 // Download an extension. Expect a dangerous download warning. |
| 1681 // Allow the download, deny the install. | 1681 // Allow the download, deny the install. |
| 1682 IN_PROC_BROWSER_TEST_F(DownloadTest, CrxInstallDenysPermissions) { | 1682 IN_PROC_BROWSER_TEST_F(DownloadTest, CrxInstallDenysPermissions) { |
| 1683 if (!extensions::switch_utils::IsOffStoreInstallEnabled()) | 1683 if (!extensions::switch_utils::IsEasyOffStoreInstallEnabled()) |
| 1684 return; | 1684 return; |
| 1685 | 1685 |
| 1686 GURL extension_url(URLRequestMockHTTPJob::GetMockUrl(kGoodCrxPath)); | 1686 GURL extension_url(URLRequestMockHTTPJob::GetMockUrl(kGoodCrxPath)); |
| 1687 | 1687 |
| 1688 // Install a mock install UI that simulates a user denying permission to | 1688 // Install a mock install UI that simulates a user denying permission to |
| 1689 // finish the install. | 1689 // finish the install. |
| 1690 download_crx_util::SetMockInstallUIForTesting( | 1690 download_crx_util::SetMockInstallUIForTesting( |
| 1691 new MockAbortExtensionInstallUI()); | 1691 new MockAbortExtensionInstallUI()); |
| 1692 | 1692 |
| 1693 scoped_ptr<DownloadTestObserver> observer( | 1693 scoped_ptr<DownloadTestObserver> observer( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1706 | 1706 |
| 1707 // Check that the extension was not installed. | 1707 // Check that the extension was not installed. |
| 1708 ExtensionService* extension_service = | 1708 ExtensionService* extension_service = |
| 1709 browser()->profile()->GetExtensionService(); | 1709 browser()->profile()->GetExtensionService(); |
| 1710 ASSERT_FALSE(extension_service->GetExtensionById(kGoodCrxId, false)); | 1710 ASSERT_FALSE(extension_service->GetExtensionById(kGoodCrxId, false)); |
| 1711 } | 1711 } |
| 1712 | 1712 |
| 1713 // Download an extension. Expect a dangerous download warning. | 1713 // Download an extension. Expect a dangerous download warning. |
| 1714 // Allow the download, and the install. | 1714 // Allow the download, and the install. |
| 1715 IN_PROC_BROWSER_TEST_F(DownloadTest, CrxInstallAcceptPermissions) { | 1715 IN_PROC_BROWSER_TEST_F(DownloadTest, CrxInstallAcceptPermissions) { |
| 1716 if (!extensions::switch_utils::IsOffStoreInstallEnabled()) | 1716 if (!extensions::switch_utils::IsEasyOffStoreInstallEnabled()) |
| 1717 return; | 1717 return; |
| 1718 | 1718 |
| 1719 GURL extension_url(URLRequestMockHTTPJob::GetMockUrl(kGoodCrxPath)); | 1719 GURL extension_url(URLRequestMockHTTPJob::GetMockUrl(kGoodCrxPath)); |
| 1720 | 1720 |
| 1721 // Install a mock install UI that simulates a user allowing permission to | 1721 // Install a mock install UI that simulates a user allowing permission to |
| 1722 // finish the install. | 1722 // finish the install. |
| 1723 download_crx_util::SetMockInstallUIForTesting( | 1723 download_crx_util::SetMockInstallUIForTesting( |
| 1724 new MockAutoConfirmExtensionInstallUI(browser()->profile())); | 1724 new MockAutoConfirmExtensionInstallUI(browser()->profile())); |
| 1725 | 1725 |
| 1726 scoped_ptr<DownloadTestObserver> observer( | 1726 scoped_ptr<DownloadTestObserver> observer( |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1765 CheckDownloadStates(1, DownloadItem::COMPLETE); | 1765 CheckDownloadStates(1, DownloadItem::COMPLETE); |
| 1766 | 1766 |
| 1767 // Check that the extension was not installed. | 1767 // Check that the extension was not installed. |
| 1768 ExtensionService* extension_service = | 1768 ExtensionService* extension_service = |
| 1769 browser()->profile()->GetExtensionService(); | 1769 browser()->profile()->GetExtensionService(); |
| 1770 ASSERT_FALSE(extension_service->GetExtensionById(kGoodCrxId, false)); | 1770 ASSERT_FALSE(extension_service->GetExtensionById(kGoodCrxId, false)); |
| 1771 } | 1771 } |
| 1772 | 1772 |
| 1773 // Install a large (100kb) theme. | 1773 // Install a large (100kb) theme. |
| 1774 IN_PROC_BROWSER_TEST_F(DownloadTest, CrxLargeTheme) { | 1774 IN_PROC_BROWSER_TEST_F(DownloadTest, CrxLargeTheme) { |
| 1775 if (!extensions::switch_utils::IsOffStoreInstallEnabled()) | 1775 if (!extensions::switch_utils::IsEasyOffStoreInstallEnabled()) |
| 1776 return; | 1776 return; |
| 1777 | 1777 |
| 1778 GURL extension_url(URLRequestMockHTTPJob::GetMockUrl(kLargeThemePath)); | 1778 GURL extension_url(URLRequestMockHTTPJob::GetMockUrl(kLargeThemePath)); |
| 1779 | 1779 |
| 1780 // Install a mock install UI that simulates a user allowing permission to | 1780 // Install a mock install UI that simulates a user allowing permission to |
| 1781 // finish the install. | 1781 // finish the install. |
| 1782 download_crx_util::SetMockInstallUIForTesting( | 1782 download_crx_util::SetMockInstallUIForTesting( |
| 1783 new MockAutoConfirmExtensionInstallUI(browser()->profile())); | 1783 new MockAutoConfirmExtensionInstallUI(browser()->profile())); |
| 1784 | 1784 |
| 1785 scoped_ptr<DownloadTestObserver> observer( | 1785 scoped_ptr<DownloadTestObserver> observer( |
| (...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2455 GetDownloads(browser(), &download_items); | 2455 GetDownloads(browser(), &download_items); |
| 2456 ASSERT_EQ(1u, download_items.size()); | 2456 ASSERT_EQ(1u, download_items.size()); |
| 2457 ASSERT_EQ(test_server()->GetURL("echoheader?Referer"), | 2457 ASSERT_EQ(test_server()->GetURL("echoheader?Referer"), |
| 2458 download_items[0]->GetOriginalUrl()); | 2458 download_items[0]->GetOriginalUrl()); |
| 2459 | 2459 |
| 2460 // Check that the file contains the expected referrer. | 2460 // Check that the file contains the expected referrer. |
| 2461 FilePath file(download_items[0]->GetFullPath()); | 2461 FilePath file(download_items[0]->GetFullPath()); |
| 2462 std::string expected_contents = test_server()->GetURL("").spec(); | 2462 std::string expected_contents = test_server()->GetURL("").spec(); |
| 2463 ASSERT_TRUE(VerifyFile(file, expected_contents, expected_contents.length())); | 2463 ASSERT_TRUE(VerifyFile(file, expected_contents, expected_contents.length())); |
| 2464 } | 2464 } |
| OLD | NEW |