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 <algorithm> | 5 #include <algorithm> |
6 #include <set> | 6 #include <set> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 "}"; | 785 "}"; |
786 gpu::GPUInfo gpu_info; | 786 gpu::GPUInfo gpu_info; |
787 content::GpuDataManager::GetInstance()->InitializeForTesting( | 787 content::GpuDataManager::GetInstance()->InitializeForTesting( |
788 json_blacklist, gpu_info); | 788 json_blacklist, gpu_info); |
789 } | 789 } |
790 | 790 |
791 // Grants all optional permissions stated in manifest to active permission | 791 // Grants all optional permissions stated in manifest to active permission |
792 // set for extension |id|. | 792 // set for extension |id|. |
793 void GrantAllOptionalPermissions(const std::string& id) { | 793 void GrantAllOptionalPermissions(const std::string& id) { |
794 const Extension* extension = service()->GetInstalledExtension(id); | 794 const Extension* extension = service()->GetInstalledExtension(id); |
795 scoped_refptr<const PermissionSet> all_optional_permissions = | 795 const PermissionSet* all_optional_permissions = |
796 extensions::PermissionsParser::GetOptionalPermissions(extension); | 796 extensions::PermissionsParser::GetOptionalPermissions(extension); |
797 extensions::PermissionsUpdater perms_updater(profile()); | 797 extensions::PermissionsUpdater perms_updater(profile()); |
798 perms_updater.AddPermissions(extension, all_optional_permissions.get()); | 798 perms_updater.AddPermissions(extension, all_optional_permissions); |
799 } | 799 } |
800 | 800 |
801 // Helper method to set up a WindowedNotificationObserver to wait for a | 801 // Helper method to set up a WindowedNotificationObserver to wait for a |
802 // specific CrxInstaller to finish if we don't know the value of the | 802 // specific CrxInstaller to finish if we don't know the value of the |
803 // |installer| yet. | 803 // |installer| yet. |
804 static bool IsCrxInstallerDone(extensions::CrxInstaller** installer, | 804 static bool IsCrxInstallerDone(extensions::CrxInstaller** installer, |
805 const content::NotificationSource& source, | 805 const content::NotificationSource& source, |
806 const content::NotificationDetails& details) { | 806 const content::NotificationDetails& details) { |
807 return content::Source<extensions::CrxInstaller>(source).ptr() == | 807 return content::Source<extensions::CrxInstaller>(source).ptr() == |
808 *installer; | 808 *installer; |
(...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1844 ASSERT_TRUE(base::PathExists(pem_path)); | 1844 ASSERT_TRUE(base::PathExists(pem_path)); |
1845 ASSERT_TRUE(base::PathExists(path)); | 1845 ASSERT_TRUE(base::PathExists(path)); |
1846 | 1846 |
1847 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); | 1847 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); |
1848 | 1848 |
1849 APIPermissionSet expected_api_perms; | 1849 APIPermissionSet expected_api_perms; |
1850 URLPatternSet expected_host_perms; | 1850 URLPatternSet expected_host_perms; |
1851 | 1851 |
1852 // Make sure there aren't any granted permissions before the | 1852 // Make sure there aren't any granted permissions before the |
1853 // extension is installed. | 1853 // extension is installed. |
1854 scoped_refptr<const PermissionSet> known_perms( | 1854 EXPECT_FALSE(prefs->GetGrantedPermissions(permissions_crx).get()); |
1855 prefs->GetGrantedPermissions(permissions_crx)); | |
1856 EXPECT_FALSE(known_perms.get()); | |
1857 | 1855 |
1858 const Extension* extension = PackAndInstallCRX(path, pem_path, INSTALL_NEW); | 1856 const Extension* extension = PackAndInstallCRX(path, pem_path, INSTALL_NEW); |
1859 | 1857 |
1860 EXPECT_EQ(0u, GetErrors().size()); | 1858 EXPECT_EQ(0u, GetErrors().size()); |
1861 ASSERT_EQ(1u, registry()->enabled_extensions().size()); | 1859 ASSERT_EQ(1u, registry()->enabled_extensions().size()); |
1862 EXPECT_EQ(permissions_crx, extension->id()); | 1860 EXPECT_EQ(permissions_crx, extension->id()); |
1863 | 1861 |
1864 // Verify that the valid API permissions have been recognized. | 1862 // Verify that the valid API permissions have been recognized. |
1865 expected_api_perms.insert(APIPermission::kTab); | 1863 expected_api_perms.insert(APIPermission::kTab); |
1866 | 1864 |
1867 AddPattern(&expected_host_perms, "http://*.google.com/*"); | 1865 AddPattern(&expected_host_perms, "http://*.google.com/*"); |
1868 AddPattern(&expected_host_perms, "https://*.google.com/*"); | 1866 AddPattern(&expected_host_perms, "https://*.google.com/*"); |
1869 AddPattern(&expected_host_perms, "http://*.google.com.hk/*"); | 1867 AddPattern(&expected_host_perms, "http://*.google.com.hk/*"); |
1870 AddPattern(&expected_host_perms, "http://www.example.com/*"); | 1868 AddPattern(&expected_host_perms, "http://www.example.com/*"); |
1871 | 1869 |
1872 known_perms = prefs->GetGrantedPermissions(extension->id()); | 1870 scoped_ptr<const PermissionSet> known_perms = |
| 1871 prefs->GetGrantedPermissions(extension->id()); |
1873 EXPECT_TRUE(known_perms.get()); | 1872 EXPECT_TRUE(known_perms.get()); |
1874 EXPECT_FALSE(known_perms->IsEmpty()); | 1873 EXPECT_FALSE(known_perms->IsEmpty()); |
1875 EXPECT_EQ(expected_api_perms, known_perms->apis()); | 1874 EXPECT_EQ(expected_api_perms, known_perms->apis()); |
1876 EXPECT_FALSE(known_perms->HasEffectiveFullAccess()); | 1875 EXPECT_FALSE(known_perms->HasEffectiveFullAccess()); |
1877 EXPECT_EQ(expected_host_perms, known_perms->effective_hosts()); | 1876 EXPECT_EQ(expected_host_perms, known_perms->effective_hosts()); |
1878 } | 1877 } |
1879 | 1878 |
1880 | 1879 |
1881 #if !defined(OS_CHROMEOS) | 1880 #if !defined(OS_CHROMEOS) |
1882 // This tests that the granted permissions preferences are correctly set for | 1881 // This tests that the granted permissions preferences are correctly set for |
1883 // default apps. | 1882 // default apps. |
1884 TEST_F(ExtensionServiceTest, DefaultAppsGrantedPermissions) { | 1883 TEST_F(ExtensionServiceTest, DefaultAppsGrantedPermissions) { |
1885 InitializeEmptyExtensionService(); | 1884 InitializeEmptyExtensionService(); |
1886 base::FilePath path = data_dir().AppendASCII("permissions"); | 1885 base::FilePath path = data_dir().AppendASCII("permissions"); |
1887 | 1886 |
1888 base::FilePath pem_path = path.AppendASCII("unknown.pem"); | 1887 base::FilePath pem_path = path.AppendASCII("unknown.pem"); |
1889 path = path.AppendASCII("unknown"); | 1888 path = path.AppendASCII("unknown"); |
1890 | 1889 |
1891 ASSERT_TRUE(base::PathExists(pem_path)); | 1890 ASSERT_TRUE(base::PathExists(pem_path)); |
1892 ASSERT_TRUE(base::PathExists(path)); | 1891 ASSERT_TRUE(base::PathExists(path)); |
1893 | 1892 |
1894 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); | 1893 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); |
1895 | 1894 |
1896 APIPermissionSet expected_api_perms; | 1895 APIPermissionSet expected_api_perms; |
1897 URLPatternSet expected_host_perms; | 1896 URLPatternSet expected_host_perms; |
1898 | 1897 |
1899 // Make sure there aren't any granted permissions before the | 1898 // Make sure there aren't any granted permissions before the |
1900 // extension is installed. | 1899 // extension is installed. |
1901 scoped_refptr<const PermissionSet> known_perms( | 1900 EXPECT_FALSE(prefs->GetGrantedPermissions(permissions_crx).get()); |
1902 prefs->GetGrantedPermissions(permissions_crx)); | |
1903 EXPECT_FALSE(known_perms.get()); | |
1904 | 1901 |
1905 const Extension* extension = PackAndInstallCRX( | 1902 const Extension* extension = PackAndInstallCRX( |
1906 path, pem_path, INSTALL_NEW, Extension::WAS_INSTALLED_BY_DEFAULT); | 1903 path, pem_path, INSTALL_NEW, Extension::WAS_INSTALLED_BY_DEFAULT); |
1907 | 1904 |
1908 EXPECT_EQ(0u, GetErrors().size()); | 1905 EXPECT_EQ(0u, GetErrors().size()); |
1909 ASSERT_EQ(1u, registry()->enabled_extensions().size()); | 1906 ASSERT_EQ(1u, registry()->enabled_extensions().size()); |
1910 EXPECT_EQ(permissions_crx, extension->id()); | 1907 EXPECT_EQ(permissions_crx, extension->id()); |
1911 | 1908 |
1912 // Verify that the valid API permissions have been recognized. | 1909 // Verify that the valid API permissions have been recognized. |
1913 expected_api_perms.insert(APIPermission::kTab); | 1910 expected_api_perms.insert(APIPermission::kTab); |
1914 | 1911 |
1915 known_perms = prefs->GetGrantedPermissions(extension->id()); | 1912 scoped_ptr<const PermissionSet> known_perms = |
| 1913 prefs->GetGrantedPermissions(extension->id()); |
1916 EXPECT_TRUE(known_perms.get()); | 1914 EXPECT_TRUE(known_perms.get()); |
1917 EXPECT_FALSE(known_perms->IsEmpty()); | 1915 EXPECT_FALSE(known_perms->IsEmpty()); |
1918 EXPECT_EQ(expected_api_perms, known_perms->apis()); | 1916 EXPECT_EQ(expected_api_perms, known_perms->apis()); |
1919 EXPECT_FALSE(known_perms->HasEffectiveFullAccess()); | 1917 EXPECT_FALSE(known_perms->HasEffectiveFullAccess()); |
1920 } | 1918 } |
1921 #endif | 1919 #endif |
1922 | 1920 |
1923 #if !defined(OS_POSIX) || defined(OS_MACOSX) | 1921 #if !defined(OS_POSIX) || defined(OS_MACOSX) |
1924 // Tests that the granted permissions full_access bit gets set correctly when | 1922 // Tests that the granted permissions full_access bit gets set correctly when |
1925 // an extension contains an NPAPI plugin. | 1923 // an extension contains an NPAPI plugin. |
1926 // Only run this on platforms that support NPAPI plugins. | 1924 // Only run this on platforms that support NPAPI plugins. |
1927 TEST_F(ExtensionServiceTest, GrantedFullAccessPermissions) { | 1925 TEST_F(ExtensionServiceTest, GrantedFullAccessPermissions) { |
1928 InitPluginService(); | 1926 InitPluginService(); |
1929 | 1927 |
1930 InitializeEmptyExtensionService(); | 1928 InitializeEmptyExtensionService(); |
1931 | 1929 |
1932 ASSERT_TRUE(base::PathExists(good1_path())); | 1930 ASSERT_TRUE(base::PathExists(good1_path())); |
1933 const Extension* extension = PackAndInstallCRX(good1_path(), INSTALL_NEW); | 1931 const Extension* extension = PackAndInstallCRX(good1_path(), INSTALL_NEW); |
1934 EXPECT_EQ(0u, GetErrors().size()); | 1932 EXPECT_EQ(0u, GetErrors().size()); |
1935 EXPECT_EQ(1u, registry()->enabled_extensions().size()); | 1933 EXPECT_EQ(1u, registry()->enabled_extensions().size()); |
1936 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); | 1934 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); |
1937 | 1935 |
1938 scoped_refptr<const PermissionSet> permissions( | 1936 scoped_ptr<const PermissionSet> permissions = |
1939 prefs->GetGrantedPermissions(extension->id())); | 1937 prefs->GetGrantedPermissions(extension->id()); |
1940 EXPECT_FALSE(permissions->IsEmpty()); | 1938 EXPECT_FALSE(permissions->IsEmpty()); |
1941 EXPECT_TRUE(permissions->HasEffectiveFullAccess()); | 1939 EXPECT_TRUE(permissions->HasEffectiveFullAccess()); |
1942 EXPECT_FALSE(permissions->apis().empty()); | 1940 EXPECT_FALSE(permissions->apis().empty()); |
1943 EXPECT_TRUE(permissions->HasAPIPermission(APIPermission::kPlugin)); | 1941 EXPECT_TRUE(permissions->HasAPIPermission(APIPermission::kPlugin)); |
1944 | 1942 |
1945 // Full access implies full host access too... | 1943 // Full access implies full host access too... |
1946 EXPECT_TRUE(permissions->HasEffectiveAccessToAllHosts()); | 1944 EXPECT_TRUE(permissions->HasEffectiveAccessToAllHosts()); |
1947 } | 1945 } |
1948 #endif | 1946 #endif |
1949 | 1947 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1991 ASSERT_FALSE(service()->IsExtensionEnabled(extension_id)); | 1989 ASSERT_FALSE(service()->IsExtensionEnabled(extension_id)); |
1992 ASSERT_TRUE(prefs->DidExtensionEscalatePermissions(extension_id)); | 1990 ASSERT_TRUE(prefs->DidExtensionEscalatePermissions(extension_id)); |
1993 | 1991 |
1994 // Now grant and re-enable the extension, making sure the prefs are updated. | 1992 // Now grant and re-enable the extension, making sure the prefs are updated. |
1995 service()->GrantPermissionsAndEnableExtension(extension); | 1993 service()->GrantPermissionsAndEnableExtension(extension); |
1996 | 1994 |
1997 ASSERT_FALSE(prefs->IsExtensionDisabled(extension_id)); | 1995 ASSERT_FALSE(prefs->IsExtensionDisabled(extension_id)); |
1998 ASSERT_TRUE(service()->IsExtensionEnabled(extension_id)); | 1996 ASSERT_TRUE(service()->IsExtensionEnabled(extension_id)); |
1999 ASSERT_FALSE(prefs->DidExtensionEscalatePermissions(extension_id)); | 1997 ASSERT_FALSE(prefs->DidExtensionEscalatePermissions(extension_id)); |
2000 | 1998 |
2001 scoped_refptr<const PermissionSet> current_perms( | 1999 scoped_ptr<const PermissionSet> current_perms = |
2002 prefs->GetGrantedPermissions(extension_id)); | 2000 prefs->GetGrantedPermissions(extension_id); |
2003 ASSERT_TRUE(current_perms.get()); | 2001 ASSERT_TRUE(current_perms.get()); |
2004 ASSERT_FALSE(current_perms->IsEmpty()); | 2002 ASSERT_FALSE(current_perms->IsEmpty()); |
2005 ASSERT_FALSE(current_perms->HasEffectiveFullAccess()); | 2003 ASSERT_FALSE(current_perms->HasEffectiveFullAccess()); |
2006 ASSERT_EQ(expected_api_permissions, current_perms->apis()); | 2004 ASSERT_EQ(expected_api_permissions, current_perms->apis()); |
2007 ASSERT_EQ(expected_host_permissions, current_perms->effective_hosts()); | 2005 ASSERT_EQ(expected_host_permissions, current_perms->effective_hosts()); |
2008 | 2006 |
2009 // Tests that the extension is disabled when a host permission is missing from | 2007 // Tests that the extension is disabled when a host permission is missing from |
2010 // the extension's granted host permissions preference. (This simulates | 2008 // the extension's granted host permissions preference. (This simulates |
2011 // updating the browser to a version which recognizes additional host | 2009 // updating the browser to a version which recognizes additional host |
2012 // permissions). | 2010 // permissions). |
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2886 ->Load(extension_with_plugin_path); | 2884 ->Load(extension_with_plugin_path); |
2887 base::RunLoop().RunUntilIdle(); | 2885 base::RunLoop().RunUntilIdle(); |
2888 EXPECT_EQ(0u, GetErrors().size()); | 2886 EXPECT_EQ(0u, GetErrors().size()); |
2889 EXPECT_EQ(2u, loaded_.size()); | 2887 EXPECT_EQ(2u, loaded_.size()); |
2890 EXPECT_EQ(2u, registry()->enabled_extensions().size()); | 2888 EXPECT_EQ(2u, registry()->enabled_extensions().size()); |
2891 EXPECT_EQ(0u, registry()->disabled_extensions().size()); | 2889 EXPECT_EQ(0u, registry()->disabled_extensions().size()); |
2892 EXPECT_TRUE(registry()->enabled_extensions().Contains(good1)); | 2890 EXPECT_TRUE(registry()->enabled_extensions().Contains(good1)); |
2893 EXPECT_TRUE(registry()->enabled_extensions().Contains(good2)); | 2891 EXPECT_TRUE(registry()->enabled_extensions().Contains(good2)); |
2894 | 2892 |
2895 // Make sure the granted permissions have been setup. | 2893 // Make sure the granted permissions have been setup. |
2896 scoped_refptr<const PermissionSet> permissions( | 2894 scoped_ptr<const PermissionSet> permissions = |
2897 ExtensionPrefs::Get(profile())->GetGrantedPermissions(good1)); | 2895 ExtensionPrefs::Get(profile())->GetGrantedPermissions(good1); |
2898 EXPECT_FALSE(permissions->IsEmpty()); | 2896 EXPECT_FALSE(permissions->IsEmpty()); |
2899 EXPECT_TRUE(permissions->HasEffectiveFullAccess()); | 2897 EXPECT_TRUE(permissions->HasEffectiveFullAccess()); |
2900 EXPECT_FALSE(permissions->apis().empty()); | 2898 EXPECT_FALSE(permissions->apis().empty()); |
2901 EXPECT_TRUE(permissions->HasAPIPermission(APIPermission::kPlugin)); | 2899 EXPECT_TRUE(permissions->HasAPIPermission(APIPermission::kPlugin)); |
2902 | 2900 |
2903 // We should be able to reload the extension without getting another prompt. | 2901 // We should be able to reload the extension without getting another prompt. |
2904 loaded_.clear(); | 2902 loaded_.clear(); |
2905 auto_confirm.reset(); | 2903 auto_confirm.reset(); |
2906 auto_confirm.reset(new extensions::ScopedTestDialogAutoConfirm( | 2904 auto_confirm.reset(new extensions::ScopedTestDialogAutoConfirm( |
2907 extensions::ScopedTestDialogAutoConfirm::CANCEL)); | 2905 extensions::ScopedTestDialogAutoConfirm::CANCEL)); |
(...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4275 // Verify all three extensions are installed and enabled. | 4273 // Verify all three extensions are installed and enabled. |
4276 ASSERT_TRUE(registry->enabled_extensions().GetByID(ext1)); | 4274 ASSERT_TRUE(registry->enabled_extensions().GetByID(ext1)); |
4277 ASSERT_TRUE(registry->enabled_extensions().GetByID(ext2)); | 4275 ASSERT_TRUE(registry->enabled_extensions().GetByID(ext2)); |
4278 ASSERT_TRUE(registry->enabled_extensions().GetByID(ext2_forced)); | 4276 ASSERT_TRUE(registry->enabled_extensions().GetByID(ext2_forced)); |
4279 | 4277 |
4280 // Grant all optional permissions to each extension. | 4278 // Grant all optional permissions to each extension. |
4281 GrantAllOptionalPermissions(ext1); | 4279 GrantAllOptionalPermissions(ext1); |
4282 GrantAllOptionalPermissions(ext2); | 4280 GrantAllOptionalPermissions(ext2); |
4283 GrantAllOptionalPermissions(ext2_forced); | 4281 GrantAllOptionalPermissions(ext2_forced); |
4284 | 4282 |
4285 scoped_refptr<const PermissionSet> active_permissions( | 4283 scoped_ptr<const PermissionSet> active_permissions = |
4286 ExtensionPrefs::Get(profile())->GetActivePermissions(ext1)); | 4284 ExtensionPrefs::Get(profile())->GetActivePermissions(ext1); |
4287 EXPECT_TRUE(active_permissions->HasAPIPermission( | 4285 EXPECT_TRUE(active_permissions->HasAPIPermission( |
4288 extensions::APIPermission::kDownloads)); | 4286 extensions::APIPermission::kDownloads)); |
4289 | 4287 |
4290 // Set policy to block 'downloads' permission. | 4288 // Set policy to block 'downloads' permission. |
4291 { | 4289 { |
4292 ManagementPrefUpdater pref(profile_->GetTestingPrefService()); | 4290 ManagementPrefUpdater pref(profile_->GetTestingPrefService()); |
4293 pref.AddBlockedPermission("*", "downloads"); | 4291 pref.AddBlockedPermission("*", "downloads"); |
4294 } | 4292 } |
4295 | 4293 |
4296 base::RunLoop().RunUntilIdle(); | 4294 base::RunLoop().RunUntilIdle(); |
(...skipping 2312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6609 syncer::SyncChange::ACTION_UPDATE, | 6607 syncer::SyncChange::ACTION_UPDATE, |
6610 sync_data); | 6608 sync_data); |
6611 syncer::SyncChangeList list(1, sync_change); | 6609 syncer::SyncChangeList list(1, sync_change); |
6612 extension_sync_service()->ProcessSyncChanges(FROM_HERE, list); | 6610 extension_sync_service()->ProcessSyncChanges(FROM_HERE, list); |
6613 | 6611 |
6614 ASSERT_TRUE(service()->pending_extension_manager()->IsIdPending(good_crx)); | 6612 ASSERT_TRUE(service()->pending_extension_manager()->IsIdPending(good_crx)); |
6615 UpdateExtension(good_crx, path, test_case.sync_enabled ? ENABLED | 6613 UpdateExtension(good_crx, path, test_case.sync_enabled ? ENABLED |
6616 : DISABLED); | 6614 : DISABLED); |
6617 EXPECT_EQ(test_case.expect_disable_reasons, | 6615 EXPECT_EQ(test_case.expect_disable_reasons, |
6618 prefs->GetDisableReasons(good_crx)); | 6616 prefs->GetDisableReasons(good_crx)); |
6619 scoped_refptr<const PermissionSet> permissions( | 6617 scoped_ptr<const PermissionSet> permissions = |
6620 prefs->GetGrantedPermissions(good_crx)); | 6618 prefs->GetGrantedPermissions(good_crx); |
6621 EXPECT_EQ(test_case.expect_permissions_granted, !permissions->IsEmpty()); | 6619 EXPECT_EQ(test_case.expect_permissions_granted, !permissions->IsEmpty()); |
6622 ASSERT_FALSE(service()->pending_extension_manager()->IsIdPending(good_crx)); | 6620 ASSERT_FALSE(service()->pending_extension_manager()->IsIdPending(good_crx)); |
6623 | 6621 |
6624 // Remove the extension again, so we can install it again for the next case. | 6622 // Remove the extension again, so we can install it again for the next case. |
6625 UninstallExtension(good_crx, false, | 6623 UninstallExtension(good_crx, false, |
6626 test_case.sync_enabled ? Extension::ENABLED | 6624 test_case.sync_enabled ? Extension::ENABLED |
6627 : Extension::DISABLED); | 6625 : Extension::DISABLED); |
6628 } | 6626 } |
6629 } | 6627 } |
6630 | 6628 |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6954 // during updating). | 6952 // during updating). |
6955 { | 6953 { |
6956 const Extension* extension = InstallCRX(crx_path_v1, INSTALL_NEW); | 6954 const Extension* extension = InstallCRX(crx_path_v1, INSTALL_NEW); |
6957 // The extension should now be installed and enabled. | 6955 // The extension should now be installed and enabled. |
6958 ASSERT_TRUE(extension); | 6956 ASSERT_TRUE(extension); |
6959 ASSERT_EQ(v1, extension->VersionString()); | 6957 ASSERT_EQ(v1, extension->VersionString()); |
6960 id = extension->id(); | 6958 id = extension->id(); |
6961 } | 6959 } |
6962 ASSERT_TRUE(registry()->enabled_extensions().Contains(id)); | 6960 ASSERT_TRUE(registry()->enabled_extensions().Contains(id)); |
6963 | 6961 |
6964 scoped_refptr<const PermissionSet> granted_permissions_v1( | 6962 scoped_ptr<const PermissionSet> granted_permissions_v1 = |
6965 prefs->GetGrantedPermissions(id)); | 6963 prefs->GetGrantedPermissions(id); |
6966 | 6964 |
6967 // Update to a new version with increased permissions. | 6965 // Update to a new version with increased permissions. |
6968 UpdateExtension(id, crx_path_v2, DISABLED); | 6966 UpdateExtension(id, crx_path_v2, DISABLED); |
6969 | 6967 |
6970 // Now the extension should be disabled due to a permissions increase. | 6968 // Now the extension should be disabled due to a permissions increase. |
6971 { | 6969 { |
6972 const Extension* extension = | 6970 const Extension* extension = |
6973 registry()->disabled_extensions().GetByID(id); | 6971 registry()->disabled_extensions().GetByID(id); |
6974 ASSERT_TRUE(extension); | 6972 ASSERT_TRUE(extension); |
6975 ASSERT_EQ(v2, extension->VersionString()); | 6973 ASSERT_EQ(v2, extension->VersionString()); |
6976 } | 6974 } |
6977 ASSERT_TRUE(prefs->HasDisableReason( | 6975 ASSERT_TRUE(prefs->HasDisableReason( |
6978 id, Extension::DISABLE_PERMISSIONS_INCREASE)); | 6976 id, Extension::DISABLE_PERMISSIONS_INCREASE)); |
6979 | 6977 |
6980 // No new permissions should have been granted. | 6978 // No new permissions should have been granted. |
6981 scoped_refptr<const PermissionSet> granted_permissions_v2( | 6979 scoped_ptr<const PermissionSet> granted_permissions_v2 = |
6982 prefs->GetGrantedPermissions(id)); | 6980 prefs->GetGrantedPermissions(id); |
6983 ASSERT_EQ(*granted_permissions_v1, *granted_permissions_v2); | 6981 ASSERT_EQ(*granted_permissions_v1, *granted_permissions_v2); |
6984 | 6982 |
6985 // Now a sync update comes in. | 6983 // Now a sync update comes in. |
6986 sync_pb::EntitySpecifics specifics; | 6984 sync_pb::EntitySpecifics specifics; |
6987 sync_pb::ExtensionSpecifics* ext_specifics = specifics.mutable_extension(); | 6985 sync_pb::ExtensionSpecifics* ext_specifics = specifics.mutable_extension(); |
6988 ext_specifics->set_id(id); | 6986 ext_specifics->set_id(id); |
6989 ext_specifics->set_enabled(true); | 6987 ext_specifics->set_enabled(true); |
6990 ext_specifics->set_version(test_case.sync_version); | 6988 ext_specifics->set_version(test_case.sync_version); |
6991 if (test_case.sync_disable_reasons != -1) | 6989 if (test_case.sync_disable_reasons != -1) |
6992 ext_specifics->set_disable_reasons(test_case.sync_disable_reasons); | 6990 ext_specifics->set_disable_reasons(test_case.sync_disable_reasons); |
6993 | 6991 |
6994 syncer::SyncData sync_data = | 6992 syncer::SyncData sync_data = |
6995 syncer::SyncData::CreateLocalData(good_crx, "Name", specifics); | 6993 syncer::SyncData::CreateLocalData(good_crx, "Name", specifics); |
6996 syncer::SyncChange sync_change(FROM_HERE, | 6994 syncer::SyncChange sync_change(FROM_HERE, |
6997 syncer::SyncChange::ACTION_UPDATE, | 6995 syncer::SyncChange::ACTION_UPDATE, |
6998 sync_data); | 6996 sync_data); |
6999 syncer::SyncChangeList list(1, sync_change); | 6997 syncer::SyncChangeList list(1, sync_change); |
7000 extension_sync_service()->ProcessSyncChanges(FROM_HERE, list); | 6998 extension_sync_service()->ProcessSyncChanges(FROM_HERE, list); |
7001 | 6999 |
7002 // Check expectations. | 7000 // Check expectations. |
7003 EXPECT_TRUE(registry()->GetExtensionById(id, ExtensionRegistry::ENABLED)); | 7001 EXPECT_TRUE(registry()->GetExtensionById(id, ExtensionRegistry::ENABLED)); |
7004 scoped_refptr<const PermissionSet> granted_permissions( | 7002 scoped_ptr<const PermissionSet> granted_permissions = |
7005 prefs->GetGrantedPermissions(id)); | 7003 prefs->GetGrantedPermissions(id); |
7006 if (test_case.expect_permissions_granted) { | 7004 if (test_case.expect_permissions_granted) { |
7007 scoped_refptr<const PermissionSet> active_permissions( | 7005 scoped_ptr<const PermissionSet> active_permissions = |
7008 prefs->GetActivePermissions(id)); | 7006 prefs->GetActivePermissions(id); |
7009 EXPECT_EQ(*granted_permissions, *active_permissions); | 7007 EXPECT_EQ(*granted_permissions, *active_permissions); |
7010 } else { | 7008 } else { |
7011 EXPECT_EQ(*granted_permissions, *granted_permissions_v1); | 7009 EXPECT_EQ(*granted_permissions, *granted_permissions_v1); |
7012 } | 7010 } |
7013 EXPECT_EQ(Extension::DISABLE_NONE, prefs->GetDisableReasons(id)); | 7011 EXPECT_EQ(Extension::DISABLE_NONE, prefs->GetDisableReasons(id)); |
7014 | 7012 |
7015 // Remove the extension again, so we can install it again for the next case. | 7013 // Remove the extension again, so we can install it again for the next case. |
7016 UninstallExtension(id, false); | 7014 UninstallExtension(id, false); |
7017 } | 7015 } |
7018 } | 7016 } |
(...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8173 | 8171 |
8174 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, | 8172 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, |
8175 content::Source<Profile>(profile()), | 8173 content::Source<Profile>(profile()), |
8176 content::NotificationService::NoDetails()); | 8174 content::NotificationService::NoDetails()); |
8177 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); | 8175 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); |
8178 EXPECT_EQ(0u, registry()->enabled_extensions().size()); | 8176 EXPECT_EQ(0u, registry()->enabled_extensions().size()); |
8179 EXPECT_EQ(0u, registry()->disabled_extensions().size()); | 8177 EXPECT_EQ(0u, registry()->disabled_extensions().size()); |
8180 EXPECT_EQ(0u, registry()->terminated_extensions().size()); | 8178 EXPECT_EQ(0u, registry()->terminated_extensions().size()); |
8181 EXPECT_EQ(0u, registry()->blacklisted_extensions().size()); | 8179 EXPECT_EQ(0u, registry()->blacklisted_extensions().size()); |
8182 } | 8180 } |
OLD | NEW |