| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 #include "content/public/browser/gpu_data_manager.h" | 79 #include "content/public/browser/gpu_data_manager.h" |
| 80 #include "content/public/browser/indexed_db_context.h" | 80 #include "content/public/browser/indexed_db_context.h" |
| 81 #include "content/public/browser/notification_registrar.h" | 81 #include "content/public/browser/notification_registrar.h" |
| 82 #include "content/public/browser/notification_service.h" | 82 #include "content/public/browser/notification_service.h" |
| 83 #include "content/public/browser/plugin_service.h" | 83 #include "content/public/browser/plugin_service.h" |
| 84 #include "content/public/browser/render_process_host.h" | 84 #include "content/public/browser/render_process_host.h" |
| 85 #include "content/public/browser/storage_partition.h" | 85 #include "content/public/browser/storage_partition.h" |
| 86 #include "content/public/common/content_constants.h" | 86 #include "content/public/common/content_constants.h" |
| 87 #include "content/public/test/test_browser_thread_bundle.h" | 87 #include "content/public/test/test_browser_thread_bundle.h" |
| 88 #include "content/public/test/test_utils.h" | 88 #include "content/public/test/test_utils.h" |
| 89 #include "extensions/browser/extension_dialog_auto_confirm.h" |
| 89 #include "extensions/browser/extension_prefs.h" | 90 #include "extensions/browser/extension_prefs.h" |
| 90 #include "extensions/browser/extension_registry.h" | 91 #include "extensions/browser/extension_registry.h" |
| 91 #include "extensions/browser/extension_system.h" | 92 #include "extensions/browser/extension_system.h" |
| 92 #include "extensions/browser/external_provider_interface.h" | 93 #include "extensions/browser/external_provider_interface.h" |
| 93 #include "extensions/browser/install_flag.h" | 94 #include "extensions/browser/install_flag.h" |
| 94 #include "extensions/browser/management_policy.h" | 95 #include "extensions/browser/management_policy.h" |
| 95 #include "extensions/browser/test_management_policy.h" | 96 #include "extensions/browser/test_management_policy.h" |
| 96 #include "extensions/browser/uninstall_reason.h" | 97 #include "extensions/browser/uninstall_reason.h" |
| 97 #include "extensions/common/constants.h" | 98 #include "extensions/common/constants.h" |
| 98 #include "extensions/common/extension.h" | 99 #include "extensions/common/extension.h" |
| (...skipping 2743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2842 // Only run this on platforms that support NPAPI plugins. | 2843 // Only run this on platforms that support NPAPI plugins. |
| 2843 TEST_F(ExtensionServiceTest, LoadExtensionsWithPlugins) { | 2844 TEST_F(ExtensionServiceTest, LoadExtensionsWithPlugins) { |
| 2844 base::FilePath extension_with_plugin_path = good1_path(); | 2845 base::FilePath extension_with_plugin_path = good1_path(); |
| 2845 base::FilePath extension_no_plugin_path = good2_path(); | 2846 base::FilePath extension_no_plugin_path = good2_path(); |
| 2846 | 2847 |
| 2847 InitPluginService(); | 2848 InitPluginService(); |
| 2848 InitializeEmptyExtensionService(); | 2849 InitializeEmptyExtensionService(); |
| 2849 service()->set_show_extensions_prompts(true); | 2850 service()->set_show_extensions_prompts(true); |
| 2850 | 2851 |
| 2851 // Start by canceling any install prompts. | 2852 // Start by canceling any install prompts. |
| 2852 ExtensionInstallPrompt::g_auto_confirm_for_tests = | 2853 scoped_ptr<extensions::ScopedTestDialogAutoConfirm> auto_confirm( |
| 2853 ExtensionInstallPrompt::CANCEL; | 2854 new extensions::ScopedTestDialogAutoConfirm( |
| 2855 extensions::ScopedTestDialogAutoConfirm::CANCEL)); |
| 2854 | 2856 |
| 2855 // The extension that has a plugin should not install. | 2857 // The extension that has a plugin should not install. |
| 2856 extensions::UnpackedInstaller::Create(service()) | 2858 extensions::UnpackedInstaller::Create(service()) |
| 2857 ->Load(extension_with_plugin_path); | 2859 ->Load(extension_with_plugin_path); |
| 2858 base::RunLoop().RunUntilIdle(); | 2860 base::RunLoop().RunUntilIdle(); |
| 2859 EXPECT_EQ(0u, GetErrors().size()); | 2861 EXPECT_EQ(0u, GetErrors().size()); |
| 2860 EXPECT_EQ(0u, loaded_.size()); | 2862 EXPECT_EQ(0u, loaded_.size()); |
| 2861 EXPECT_EQ(0u, registry()->enabled_extensions().size()); | 2863 EXPECT_EQ(0u, registry()->enabled_extensions().size()); |
| 2862 EXPECT_EQ(0u, registry()->disabled_extensions().size()); | 2864 EXPECT_EQ(0u, registry()->disabled_extensions().size()); |
| 2863 | 2865 |
| 2864 // But the extension with no plugin should since there's no prompt. | 2866 // But the extension with no plugin should since there's no prompt. |
| 2865 ExtensionErrorReporter::GetInstance()->ClearErrors(); | 2867 ExtensionErrorReporter::GetInstance()->ClearErrors(); |
| 2866 extensions::UnpackedInstaller::Create(service()) | 2868 extensions::UnpackedInstaller::Create(service()) |
| 2867 ->Load(extension_no_plugin_path); | 2869 ->Load(extension_no_plugin_path); |
| 2868 base::RunLoop().RunUntilIdle(); | 2870 base::RunLoop().RunUntilIdle(); |
| 2869 EXPECT_EQ(0u, GetErrors().size()); | 2871 EXPECT_EQ(0u, GetErrors().size()); |
| 2870 EXPECT_EQ(1u, loaded_.size()); | 2872 EXPECT_EQ(1u, loaded_.size()); |
| 2871 EXPECT_EQ(1u, registry()->enabled_extensions().size()); | 2873 EXPECT_EQ(1u, registry()->enabled_extensions().size()); |
| 2872 EXPECT_EQ(0u, registry()->disabled_extensions().size()); | 2874 EXPECT_EQ(0u, registry()->disabled_extensions().size()); |
| 2873 EXPECT_TRUE(registry()->enabled_extensions().Contains(good2)); | 2875 EXPECT_TRUE(registry()->enabled_extensions().Contains(good2)); |
| 2874 | 2876 |
| 2875 // The plugin extension should install if we accept the dialog. | 2877 // The plugin extension should install if we accept the dialog. |
| 2876 ExtensionInstallPrompt::g_auto_confirm_for_tests = | 2878 auto_confirm.reset(); |
| 2877 ExtensionInstallPrompt::ACCEPT; | 2879 auto_confirm.reset(new extensions::ScopedTestDialogAutoConfirm( |
| 2880 extensions::ScopedTestDialogAutoConfirm::ACCEPT)); |
| 2878 | 2881 |
| 2879 ExtensionErrorReporter::GetInstance()->ClearErrors(); | 2882 ExtensionErrorReporter::GetInstance()->ClearErrors(); |
| 2880 extensions::UnpackedInstaller::Create(service()) | 2883 extensions::UnpackedInstaller::Create(service()) |
| 2881 ->Load(extension_with_plugin_path); | 2884 ->Load(extension_with_plugin_path); |
| 2882 base::RunLoop().RunUntilIdle(); | 2885 base::RunLoop().RunUntilIdle(); |
| 2883 EXPECT_EQ(0u, GetErrors().size()); | 2886 EXPECT_EQ(0u, GetErrors().size()); |
| 2884 EXPECT_EQ(2u, loaded_.size()); | 2887 EXPECT_EQ(2u, loaded_.size()); |
| 2885 EXPECT_EQ(2u, registry()->enabled_extensions().size()); | 2888 EXPECT_EQ(2u, registry()->enabled_extensions().size()); |
| 2886 EXPECT_EQ(0u, registry()->disabled_extensions().size()); | 2889 EXPECT_EQ(0u, registry()->disabled_extensions().size()); |
| 2887 EXPECT_TRUE(registry()->enabled_extensions().Contains(good1)); | 2890 EXPECT_TRUE(registry()->enabled_extensions().Contains(good1)); |
| 2888 EXPECT_TRUE(registry()->enabled_extensions().Contains(good2)); | 2891 EXPECT_TRUE(registry()->enabled_extensions().Contains(good2)); |
| 2889 | 2892 |
| 2890 // Make sure the granted permissions have been setup. | 2893 // Make sure the granted permissions have been setup. |
| 2891 scoped_refptr<PermissionSet> permissions( | 2894 scoped_refptr<PermissionSet> permissions( |
| 2892 ExtensionPrefs::Get(profile())->GetGrantedPermissions(good1)); | 2895 ExtensionPrefs::Get(profile())->GetGrantedPermissions(good1)); |
| 2893 EXPECT_FALSE(permissions->IsEmpty()); | 2896 EXPECT_FALSE(permissions->IsEmpty()); |
| 2894 EXPECT_TRUE(permissions->HasEffectiveFullAccess()); | 2897 EXPECT_TRUE(permissions->HasEffectiveFullAccess()); |
| 2895 EXPECT_FALSE(permissions->apis().empty()); | 2898 EXPECT_FALSE(permissions->apis().empty()); |
| 2896 EXPECT_TRUE(permissions->HasAPIPermission(APIPermission::kPlugin)); | 2899 EXPECT_TRUE(permissions->HasAPIPermission(APIPermission::kPlugin)); |
| 2897 | 2900 |
| 2898 // 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. |
| 2899 loaded_.clear(); | 2902 loaded_.clear(); |
| 2900 ExtensionInstallPrompt::g_auto_confirm_for_tests = | 2903 auto_confirm.reset(); |
| 2901 ExtensionInstallPrompt::CANCEL; | 2904 auto_confirm.reset(new extensions::ScopedTestDialogAutoConfirm( |
| 2905 extensions::ScopedTestDialogAutoConfirm::CANCEL)); |
| 2902 | 2906 |
| 2903 service()->ReloadExtension(good1); | 2907 service()->ReloadExtension(good1); |
| 2904 base::RunLoop().RunUntilIdle(); | 2908 base::RunLoop().RunUntilIdle(); |
| 2905 EXPECT_EQ(1u, loaded_.size()); | 2909 EXPECT_EQ(1u, loaded_.size()); |
| 2906 EXPECT_EQ(2u, registry()->enabled_extensions().size()); | 2910 EXPECT_EQ(2u, registry()->enabled_extensions().size()); |
| 2907 EXPECT_EQ(0u, registry()->disabled_extensions().size()); | 2911 EXPECT_EQ(0u, registry()->disabled_extensions().size()); |
| 2908 } | 2912 } |
| 2909 #endif // !defined(OS_POSIX) || defined(OS_MACOSX) | 2913 #endif // !defined(OS_POSIX) || defined(OS_MACOSX) |
| 2910 | 2914 |
| 2911 namespace { | 2915 namespace { |
| (...skipping 5152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8064 | 8068 |
| 8065 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, | 8069 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, |
| 8066 content::Source<Profile>(profile()), | 8070 content::Source<Profile>(profile()), |
| 8067 content::NotificationService::NoDetails()); | 8071 content::NotificationService::NoDetails()); |
| 8068 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); | 8072 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); |
| 8069 EXPECT_EQ(0u, registry()->enabled_extensions().size()); | 8073 EXPECT_EQ(0u, registry()->enabled_extensions().size()); |
| 8070 EXPECT_EQ(0u, registry()->disabled_extensions().size()); | 8074 EXPECT_EQ(0u, registry()->disabled_extensions().size()); |
| 8071 EXPECT_EQ(0u, registry()->terminated_extensions().size()); | 8075 EXPECT_EQ(0u, registry()->terminated_extensions().size()); |
| 8072 EXPECT_EQ(0u, registry()->blacklisted_extensions().size()); | 8076 EXPECT_EQ(0u, registry()->blacklisted_extensions().size()); |
| 8073 } | 8077 } |
| OLD | NEW |