| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/extensions/extension_service.h" | 5 #include "chrome/browser/extensions/extension_service.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 1694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1705 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); | 1705 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); |
| 1706 | 1706 |
| 1707 APIPermissionSet expected_api_perms; | 1707 APIPermissionSet expected_api_perms; |
| 1708 URLPatternSet expected_host_perms; | 1708 URLPatternSet expected_host_perms; |
| 1709 | 1709 |
| 1710 // Make sure there aren't any granted permissions before the | 1710 // Make sure there aren't any granted permissions before the |
| 1711 // extension is installed. | 1711 // extension is installed. |
| 1712 EXPECT_FALSE(prefs->GetGrantedPermissions(permissions_crx).get()); | 1712 EXPECT_FALSE(prefs->GetGrantedPermissions(permissions_crx).get()); |
| 1713 | 1713 |
| 1714 const Extension* extension = PackAndInstallCRX( | 1714 const Extension* extension = PackAndInstallCRX( |
| 1715 path, pem_path, INSTALL_NEW, Extension::WAS_INSTALLED_BY_DEFAULT); | 1715 path, pem_path, INSTALL_NEW, Extension::WAS_INSTALLED_BY_DEFAULT, |
| 1716 Manifest::Location::INTERNAL); |
| 1716 | 1717 |
| 1717 EXPECT_EQ(0u, GetErrors().size()); | 1718 EXPECT_EQ(0u, GetErrors().size()); |
| 1718 ASSERT_EQ(1u, registry()->enabled_extensions().size()); | 1719 ASSERT_EQ(1u, registry()->enabled_extensions().size()); |
| 1719 EXPECT_EQ(permissions_crx, extension->id()); | 1720 EXPECT_EQ(permissions_crx, extension->id()); |
| 1720 | 1721 |
| 1721 // Verify that the valid API permissions have been recognized. | 1722 // Verify that the valid API permissions have been recognized. |
| 1722 expected_api_perms.insert(APIPermission::kTab); | 1723 expected_api_perms.insert(APIPermission::kTab); |
| 1723 | 1724 |
| 1724 std::unique_ptr<const PermissionSet> known_perms = | 1725 std::unique_ptr<const PermissionSet> known_perms = |
| 1725 prefs->GetGrantedPermissions(extension->id()); | 1726 prefs->GetGrantedPermissions(extension->id()); |
| (...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2585 EXPECT_TRUE(extensions::util::IsIncognitoEnabled(good2->id(), profile())); | 2586 EXPECT_TRUE(extensions::util::IsIncognitoEnabled(good2->id(), profile())); |
| 2586 EXPECT_EQ(Extension::DISABLE_USER_ACTION, | 2587 EXPECT_EQ(Extension::DISABLE_USER_ACTION, |
| 2587 ExtensionPrefs::Get(profile())->GetDisableReasons(good2->id())); | 2588 ExtensionPrefs::Get(profile())->GetDisableReasons(good2->id())); |
| 2588 } | 2589 } |
| 2589 | 2590 |
| 2590 // Tests that updating preserves extension location. | 2591 // Tests that updating preserves extension location. |
| 2591 TEST_F(ExtensionServiceTest, UpdateExtensionPreservesLocation) { | 2592 TEST_F(ExtensionServiceTest, UpdateExtensionPreservesLocation) { |
| 2592 InitializeEmptyExtensionService(); | 2593 InitializeEmptyExtensionService(); |
| 2593 base::FilePath path = data_dir().AppendASCII("good.crx"); | 2594 base::FilePath path = data_dir().AppendASCII("good.crx"); |
| 2594 | 2595 |
| 2595 const Extension* good = | 2596 const Extension* good = InstallCRX(path, Manifest::EXTERNAL_PREF, INSTALL_NEW, |
| 2596 InstallCRXWithLocation(path, Manifest::EXTERNAL_PREF, INSTALL_NEW); | 2597 Extension::NO_FLAGS); |
| 2597 | 2598 |
| 2598 ASSERT_EQ("1.0.0.0", good->VersionString()); | 2599 ASSERT_EQ("1.0.0.0", good->VersionString()); |
| 2599 ASSERT_EQ(good_crx, good->id()); | 2600 ASSERT_EQ(good_crx, good->id()); |
| 2600 | 2601 |
| 2601 path = data_dir().AppendASCII("good2.crx"); | 2602 path = data_dir().AppendASCII("good2.crx"); |
| 2602 UpdateExtension(good_crx, path, ENABLED); | 2603 UpdateExtension(good_crx, path, ENABLED); |
| 2603 const Extension* good2 = service()->GetExtensionById(good_crx, false); | 2604 const Extension* good2 = service()->GetExtensionById(good_crx, false); |
| 2604 ASSERT_EQ("1.0.0.1", good2->version()->GetString()); | 2605 ASSERT_EQ("1.0.0.1", good2->version()->GetString()); |
| 2605 EXPECT_EQ(good2->location(), Manifest::EXTERNAL_PREF); | 2606 EXPECT_EQ(good2->location(), Manifest::EXTERNAL_PREF); |
| 2606 } | 2607 } |
| (...skipping 4344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6951 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); | 6952 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); |
| 6952 EXPECT_TRUE(registry()->disabled_extensions().Contains(id)); | 6953 EXPECT_TRUE(registry()->disabled_extensions().Contains(id)); |
| 6953 EXPECT_TRUE(prefs->HasDisableReason(id, Extension::DISABLE_CORRUPTED)); | 6954 EXPECT_TRUE(prefs->HasDisableReason(id, Extension::DISABLE_CORRUPTED)); |
| 6954 | 6955 |
| 6955 base::FilePath v2_path = data_dir().AppendASCII("good2.crx"); | 6956 base::FilePath v2_path = data_dir().AppendASCII("good2.crx"); |
| 6956 UpdateExtension(id, v2_path, ENABLED); | 6957 UpdateExtension(id, v2_path, ENABLED); |
| 6957 | 6958 |
| 6958 EXPECT_FALSE(registry()->disabled_extensions().Contains(id)); | 6959 EXPECT_FALSE(registry()->disabled_extensions().Contains(id)); |
| 6959 EXPECT_FALSE(prefs->HasDisableReason(id, Extension::DISABLE_CORRUPTED)); | 6960 EXPECT_FALSE(prefs->HasDisableReason(id, Extension::DISABLE_CORRUPTED)); |
| 6960 } | 6961 } |
| OLD | NEW |