Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 1666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1677 std::string id = extension->id(); | 1677 std::string id = extension->id(); |
| 1678 | 1678 |
| 1679 // Now make the profile supervised. | 1679 // Now make the profile supervised. |
| 1680 profile()->AsTestingProfile()->SetSupervisedUserId( | 1680 profile()->AsTestingProfile()->SetSupervisedUserId( |
| 1681 supervised_users::kChildAccountSUID); | 1681 supervised_users::kChildAccountSUID); |
| 1682 | 1682 |
| 1683 // The extension should not be enabled anymore. | 1683 // The extension should not be enabled anymore. |
| 1684 EXPECT_FALSE(registry()->enabled_extensions().Contains(id)); | 1684 EXPECT_FALSE(registry()->enabled_extensions().Contains(id)); |
| 1685 } | 1685 } |
| 1686 | 1686 |
| 1687 TEST_F(ExtensionServiceTestSupervised, | |
| 1688 DelegatedAndPreinstalledExtensionIsSUFirst) { | |
| 1689 InitServices(false /* profile_is_supervised */); | |
| 1690 | |
| 1691 // Install an extension. | |
| 1692 base::FilePath path = data_dir().AppendASCII("good.crx"); | |
| 1693 const Extension* extension = InstallCRX(path, INSTALL_NEW); | |
| 1694 std::string id = extension->id(); | |
| 1695 const std::string version("1.0.0.0"); | |
| 1696 | |
| 1697 // It should be enabled. | |
| 1698 EXPECT_TRUE(registry()->enabled_extensions().Contains(id)); | |
| 1699 | |
| 1700 // Now make the profile supervised. | |
| 1701 profile()->AsTestingProfile()->SetSupervisedUserId( | |
| 1702 supervised_users::kChildAccountSUID); | |
| 1703 | |
| 1704 // It should not be enabled now (it is not loaded at all actually). | |
| 1705 EXPECT_FALSE(registry()->enabled_extensions().Contains(id)); | |
| 1706 | |
| 1707 // Simulate data sync with the "was_installed_by_custodian" flag set to 1. | |
| 1708 sync_pb::EntitySpecifics specifics; | |
| 1709 sync_pb::ExtensionSpecifics* ext_specifics = specifics.mutable_extension(); | |
| 1710 ext_specifics->set_id(id); | |
| 1711 ext_specifics->set_enabled(true); | |
| 1712 ext_specifics->set_disable_reasons(Extension::DISABLE_NONE); | |
| 1713 ext_specifics->set_installed_by_custodian(true); | |
| 1714 ext_specifics->set_version(version); | |
| 1715 | |
| 1716 SyncChangeList list = | |
| 1717 MakeSyncChangeList(id, specifics, SyncChange::ACTION_UPDATE); | |
| 1718 | |
| 1719 extension_sync_service()->ProcessSyncChanges(FROM_HERE, list); | |
| 1720 | |
| 1721 // The extension should be enabled again. | |
| 1722 EXPECT_TRUE(registry()->enabled_extensions().Contains(id)); | |
|
Marc Treib
2016/06/13 12:17:09
This should probably be ASSERT_TRUE - if it's fals
mamir
2016/06/13 14:15:57
Done.
| |
| 1723 EXPECT_TRUE(registry() | |
| 1724 ->enabled_extensions() | |
| 1725 .GetByID(id) | |
| 1726 ->was_installed_by_custodian()); | |
|
Marc Treib
2016/06/13 12:17:09
Woah, did git cl format do this? Ugh... maybe pull
mamir
2016/06/13 14:15:57
Done.
| |
| 1727 } | |
| 1728 | |
| 1729 TEST_F(ExtensionServiceTestSupervised, | |
| 1730 DelegatedAndPreinstalledExtensionSyncFirst) { | |
| 1731 InitServices(false /* profile_is_supervised */); | |
| 1732 | |
| 1733 // Install an extension. | |
| 1734 base::FilePath path = data_dir().AppendASCII("good.crx"); | |
| 1735 const Extension* extension = InstallCRX(path, INSTALL_NEW); | |
| 1736 std::string id = extension->id(); | |
| 1737 const std::string version("1.0.0.0"); | |
| 1738 | |
| 1739 // It should be enabled. | |
| 1740 EXPECT_TRUE(registry()->enabled_extensions().Contains(id)); | |
| 1741 | |
| 1742 // Simulate data sync with the "was_installed_by_custodian" flag set to 1. | |
| 1743 sync_pb::EntitySpecifics specifics; | |
| 1744 sync_pb::ExtensionSpecifics* ext_specifics = specifics.mutable_extension(); | |
| 1745 ext_specifics->set_id(id); | |
| 1746 ext_specifics->set_enabled(true); | |
| 1747 ext_specifics->set_disable_reasons(Extension::DISABLE_NONE); | |
| 1748 ext_specifics->set_installed_by_custodian(true); | |
| 1749 ext_specifics->set_version(version); | |
| 1750 | |
| 1751 SyncChangeList list = | |
| 1752 MakeSyncChangeList(id, specifics, SyncChange::ACTION_UPDATE); | |
| 1753 | |
| 1754 extension_sync_service()->ProcessSyncChanges(FROM_HERE, list); | |
| 1755 | |
| 1756 // Now make the profile supervised. | |
| 1757 profile()->AsTestingProfile()->SetSupervisedUserId( | |
| 1758 supervised_users::kChildAccountSUID); | |
| 1759 | |
| 1760 // The extension should be enabled. | |
| 1761 EXPECT_TRUE(registry()->enabled_extensions().Contains(id)); | |
| 1762 EXPECT_TRUE(registry() | |
| 1763 ->enabled_extensions() | |
| 1764 .GetByID(id) | |
| 1765 ->was_installed_by_custodian()); | |
| 1766 } | |
| 1767 | |
| 1687 TEST_F(ExtensionServiceTestSupervised, UpdateWithoutPermissionIncrease) { | 1768 TEST_F(ExtensionServiceTestSupervised, UpdateWithoutPermissionIncrease) { |
| 1688 InitServices(true /* profile_is_supervised */); | 1769 InitServices(true /* profile_is_supervised */); |
| 1689 | 1770 |
| 1690 base::FilePath base_path = data_dir().AppendASCII("autoupdate"); | 1771 base::FilePath base_path = data_dir().AppendASCII("autoupdate"); |
| 1691 base::FilePath pem_path = base_path.AppendASCII("key.pem"); | 1772 base::FilePath pem_path = base_path.AppendASCII("key.pem"); |
| 1692 | 1773 |
| 1693 const Extension* extension = | 1774 const Extension* extension = |
| 1694 PackAndInstallCRX(base_path.AppendASCII("v1"), pem_path, INSTALL_NEW, | 1775 PackAndInstallCRX(base_path.AppendASCII("v1"), pem_path, INSTALL_NEW, |
| 1695 Extension::WAS_INSTALLED_BY_CUSTODIAN); | 1776 Extension::WAS_INSTALLED_BY_CUSTODIAN); |
| 1696 // The extension must now be installed and enabled. | 1777 // The extension must now be installed and enabled. |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2054 break; | 2135 break; |
| 2055 } | 2136 } |
| 2056 } | 2137 } |
| 2057 } | 2138 } |
| 2058 EXPECT_TRUE(found_delete); | 2139 EXPECT_TRUE(found_delete); |
| 2059 | 2140 |
| 2060 // Make sure there is one extension, and there are no more apps. | 2141 // Make sure there is one extension, and there are no more apps. |
| 2061 EXPECT_EQ(1u, extensions_processor.data().size()); | 2142 EXPECT_EQ(1u, extensions_processor.data().size()); |
| 2062 EXPECT_TRUE(apps_processor.data().empty()); | 2143 EXPECT_TRUE(apps_processor.data().empty()); |
| 2063 } | 2144 } |
| OLD | NEW |