summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-18 04:34:14 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-18 04:34:14 +0000
commit8f337212cc8c13bbeb38c54d150f7f848e245b07 (patch)
treeb1691fa32c63bb13271eeff41f31d280ba19a45e
parent0dbcdb57b84945b2591ee93e1a7c57012383400b (diff)
downloadchromium_src-8f337212cc8c13bbeb38c54d150f7f848e245b07.zip
chromium_src-8f337212cc8c13bbeb38c54d150f7f848e245b07.tar.gz
chromium_src-8f337212cc8c13bbeb38c54d150f7f848e245b07.tar.bz2
Remove plugin_list.h includes from chrome tests in preparation for moving webkit/plugins to content/. To do this, I simplified how we disable plugin loading for tests, and also updated the test in content to use the new way.
BUG=237249 R=scottmg@chromium.org Review URL: https://codereview.chromium.org/19706002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212249 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/download/download_browsertest.cc12
-rw-r--r--chrome/browser/extensions/api/content_settings/content_settings_api.cc20
-rw-r--r--chrome/browser/extensions/api/content_settings/content_settings_api.h4
-rw-r--r--chrome/browser/extensions/api/content_settings/content_settings_apitest.cc41
-rw-r--r--chrome/browser/extensions/api/preference/preference_apitest.cc1
-rw-r--r--chrome/browser/extensions/extension_service_unittest.cc17
-rw-r--r--chrome/browser/plugins/plugin_prefs_unittest.cc39
-rw-r--r--chrome/browser/printing/print_preview_test.cc4
-rw-r--r--chrome/browser/printing/print_preview_test.h3
-rw-r--r--chrome/browser/renderer_host/plugin_info_message_filter_unittest.cc21
-rw-r--r--chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc1
-rw-r--r--chrome/chrome_tests.gypi1
-rw-r--r--chrome/chrome_tests_unit.gypi1
-rw-r--r--content/browser/plugin_service_impl.cc66
-rw-r--r--content/browser/plugin_service_impl.h10
-rw-r--r--content/content_tests.gypi1
-rw-r--r--content/public/browser/plugin_service.h35
-rw-r--r--webkit/plugins/npapi/mock_plugin_list.cc38
-rw-r--r--webkit/plugins/npapi/mock_plugin_list.h39
-rw-r--r--webkit/plugins/npapi/plugin_list.h11
-rw-r--r--webkit/plugins/npapi/plugin_list_unittest.cc20
-rw-r--r--webkit/plugins/webkit_plugins.gyp14
22 files changed, 154 insertions, 245 deletions
diff --git a/chrome/browser/download/download_browsertest.cc b/chrome/browser/download/download_browsertest.cc
index 6125d22..008660b 100644
--- a/chrome/browser/download/download_browsertest.cc
+++ b/chrome/browser/download/download_browsertest.cc
@@ -65,7 +65,6 @@
#include "content/public/browser/download_save_info.h"
#include "content/public/browser/download_url_parameters.h"
#include "content/public/browser/notification_source.h"
-#include "content/public/browser/plugin_service.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/resource_context.h"
#include "content/public/browser/web_contents.h"
@@ -83,7 +82,6 @@
#include "net/test/spawned_test_server/spawned_test_server.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h"
-#include "webkit/plugins/npapi/mock_plugin_list.h"
using content::BrowserContext;
using content::BrowserThread;
@@ -473,6 +471,10 @@ class DownloadTest : public InProcessBrowserTest {
file_activity_observer_.reset();
}
+ virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
+ command_line->AppendSwitch(switches::kDisablePluginsDiscovery);
+ }
+
// Returning false indicates a failure of the setup, and should be asserted
// in the caller.
virtual bool InitialSetup() {
@@ -1850,12 +1852,6 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadHistoryDangerCheck) {
base::FilePath file(FILE_PATH_LITERAL("downloads/dangerous/dangerous.swf"));
GURL download_url(URLRequestMockHTTPJob::GetMockUrl(file));
- // Null out plugins so that flash plugin won't interfere with testing.
-#if defined(ENABLE_PLUGINS)
- webkit::npapi::MockPluginList plugin_list;
- content::PluginService::GetInstance()->SetPluginListForTesting(&plugin_list);
-#endif
-
// Download the url and wait until the object has been stored.
scoped_ptr<content::DownloadTestObserver> download_observer(
new content::DownloadTestObserverTerminal(
diff --git a/chrome/browser/extensions/api/content_settings/content_settings_api.cc b/chrome/browser/extensions/api/content_settings/content_settings_api.cc
index 35223b8..728e805 100644
--- a/chrome/browser/extensions/api/content_settings/content_settings_api.cc
+++ b/chrome/browser/extensions/api/content_settings/content_settings_api.cc
@@ -40,8 +40,6 @@ namespace pref_keys = extensions::preference_api_constants;
namespace {
-const std::vector<webkit::WebPluginInfo>* g_testing_plugins_;
-
bool RemoveContentType(base::ListValue* args,
ContentSettingsType* content_type) {
std::string content_type_str;
@@ -260,14 +258,10 @@ bool ContentSettingsContentSettingGetResourceIdentifiersFunction::RunImpl() {
return true;
}
- if (!g_testing_plugins_) {
- PluginService::GetInstance()->GetPlugins(
- base::Bind(&ContentSettingsContentSettingGetResourceIdentifiersFunction::
- OnGotPlugins,
- this));
- } else {
- OnGotPlugins(*g_testing_plugins_);
- }
+ PluginService::GetInstance()->GetPlugins(
+ base::Bind(&ContentSettingsContentSettingGetResourceIdentifiersFunction::
+ OnGotPlugins,
+ this));
return true;
}
@@ -298,10 +292,4 @@ void ContentSettingsContentSettingGetResourceIdentifiersFunction::OnGotPlugins(
true));
}
-// static
-void ContentSettingsContentSettingGetResourceIdentifiersFunction::
- SetPluginsForTesting(const std::vector<webkit::WebPluginInfo>* plugins) {
- g_testing_plugins_ = plugins;
-}
-
} // namespace extensions
diff --git a/chrome/browser/extensions/api/content_settings/content_settings_api.h b/chrome/browser/extensions/api/content_settings/content_settings_api.h
index dbd8ac1..fcdd01f 100644
--- a/chrome/browser/extensions/api/content_settings/content_settings_api.h
+++ b/chrome/browser/extensions/api/content_settings/content_settings_api.h
@@ -68,10 +68,6 @@ class ContentSettingsContentSettingGetResourceIdentifiersFunction
// Callback method that gets executed when |plugins|
// are asynchronously fetched.
void OnGotPlugins(const std::vector<webkit::WebPluginInfo>& plugins);
-
- // Used to override the global plugin list in tests.
- static void SetPluginsForTesting(
- const std::vector<webkit::WebPluginInfo>* plugins);
};
} // namespace extensions
diff --git a/chrome/browser/extensions/api/content_settings/content_settings_apitest.cc b/chrome/browser/extensions/api/content_settings/content_settings_apitest.cc
index b142e36..f1702cc 100644
--- a/chrome/browser/extensions/api/content_settings/content_settings_apitest.cc
+++ b/chrome/browser/extensions/api/content_settings/content_settings_apitest.cc
@@ -12,7 +12,8 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
-#include "webkit/plugins/npapi/mock_plugin_list.h"
+#include "content/public/browser/plugin_service.h"
+#include "webkit/plugins/webplugininfo.h"
namespace extensions {
@@ -94,12 +95,18 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentSettings) {
url, url, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, std::string()));
}
-// Flaky on the trybots. See http://crbug.com/96725.
-IN_PROC_BROWSER_TEST_F(ExtensionApiTest,
- DISABLED_ContentSettingsGetResourceIdentifiers) {
- CommandLine::ForCurrentProcess()->AppendSwitch(
- switches::kEnableExperimentalExtensionApis);
+class ContentSettingsGetResourceIdentifiersTest : public ExtensionApiTest {
+ public:
+ virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
+ ExtensionApiTest::SetUpCommandLine(command_line);
+ command_line->AppendSwitch(switches::kDisablePluginsDiscovery);
+ command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis);
+ }
+};
+// Flaky on the trybots. See http://crbug.com/96725.
+IN_PROC_BROWSER_TEST_F(ContentSettingsGetResourceIdentifiersTest,
+ DISABLED_Test) {
base::FilePath::CharType kFooPath[] =
FILE_PATH_LITERAL("/plugins/foo.plugin");
base::FilePath::CharType kBarPath[] =
@@ -107,29 +114,21 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest,
const char* kFooName = "Foo Plugin";
const char* kBarName = "Bar Plugin";
- webkit::npapi::MockPluginList plugin_list;
- plugin_list.AddPluginToLoad(
+ content::PluginService::GetInstance()->RegisterInternalPlugin(
webkit::WebPluginInfo(ASCIIToUTF16(kFooName),
base::FilePath(kFooPath),
ASCIIToUTF16("1.2.3"),
- ASCIIToUTF16("foo")));
- plugin_list.AddPluginToLoad(
- webkit::WebPluginInfo(ASCIIToUTF16(kBarName),
+ ASCIIToUTF16("foo")),
+ false);
+ content::PluginService::GetInstance()->RegisterInternalPlugin(
+ webkit::WebPluginInfo(ASCIIToUTF16(kBarName),
base::FilePath(kBarPath),
ASCIIToUTF16("2.3.4"),
- ASCIIToUTF16("bar")));
-
- std::vector<webkit::WebPluginInfo> plugins;
- plugin_list.GetPlugins(&plugins);
-
- ContentSettingsContentSettingGetResourceIdentifiersFunction::
- SetPluginsForTesting(&plugins);
+ ASCIIToUTF16("bar")),
+ false);
EXPECT_TRUE(RunExtensionTest("content_settings/getresourceidentifiers"))
<< message_;
-
- ContentSettingsContentSettingGetResourceIdentifiersFunction::
- SetPluginsForTesting(NULL);
}
} // namespace extensions
diff --git a/chrome/browser/extensions/api/preference/preference_apitest.cc b/chrome/browser/extensions/api/preference/preference_apitest.cc
index 7b0aab5..98be5cd 100644
--- a/chrome/browser/extensions/api/preference/preference_apitest.cc
+++ b/chrome/browser/extensions/api/preference/preference_apitest.cc
@@ -11,7 +11,6 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/ui_test_utils.h"
-#include "webkit/plugins/npapi/mock_plugin_list.h"
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PreferenceApi) {
PrefService* pref_service = browser()->profile()->GetPrefs();
diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc
index 8811e48..1d5bf08 100644
--- a/chrome/browser/extensions/extension_service_unittest.cc
+++ b/chrome/browser/extensions/extension_service_unittest.cc
@@ -110,7 +110,6 @@
#include "webkit/browser/database/database_tracker.h"
#include "webkit/browser/quota/quota_manager.h"
#include "webkit/common/database/database_identifier.h"
-#include "webkit/plugins/npapi/mock_plugin_list.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/extensions/install_limiter.h"
@@ -4844,6 +4843,10 @@ class ExtensionsReadyRecorder : public content::NotificationObserver {
TEST(ExtensionServiceTestSimple, Enabledness) {
// Make sure the PluginService singleton is destroyed at the end of the test.
base::ShadowingAtExitManager at_exit_manager;
+#if defined(ENABLE_PLUGINS)
+ content::PluginService::GetInstance()->Init();
+ content::PluginService::GetInstance()->DisablePluginsDiscoveryForTesting();
+#endif
ExtensionErrorReporter::Init(false); // no noisy errors
ExtensionsReadyRecorder recorder;
@@ -4861,11 +4864,6 @@ TEST(ExtensionServiceTestSimple, Enabledness) {
base::FilePath install_dir = profile->GetPath()
.AppendASCII(extensions::kInstallDirectoryName);
-#if defined(ENABLE_PLUGINS)
- webkit::npapi::MockPluginList plugin_list;
- PluginService::GetInstance()->SetPluginListForTesting(&plugin_list);
-#endif
-
// By default, we are enabled.
command_line.reset(new CommandLine(CommandLine::NO_PROGRAM));
ExtensionService* service = static_cast<extensions::TestExtensionSystem*>(
@@ -4931,13 +4929,6 @@ TEST(ExtensionServiceTestSimple, Enabledness) {
service = NULL;
// Execute any pending deletion tasks.
loop.RunUntilIdle();
-
-#if defined(ENABLE_PLUGINS)
- // Ensure that even if the PluginService is re-used for a later test, it
- // won't still hold a reference to the stack position of our MockPluginList.
- // See crbug.com/159754.
- PluginService::GetInstance()->SetPluginListForTesting(NULL);
-#endif
}
// Test loading extensions that require limited and unlimited storage quotas.
diff --git a/chrome/browser/plugins/plugin_prefs_unittest.cc b/chrome/browser/plugins/plugin_prefs_unittest.cc
index 18863c8..40d2558 100644
--- a/chrome/browser/plugins/plugin_prefs_unittest.cc
+++ b/chrome/browser/plugins/plugin_prefs_unittest.cc
@@ -13,9 +13,10 @@
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "content/public/browser/plugin_service.h"
+#include "content/public/browser/render_process_host.h"
#include "content/public/test/test_browser_thread.h"
+#include "content/public/test/test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/plugins/npapi/mock_plugin_list.h"
#include "webkit/plugins/webplugininfo.h"
using content::BrowserThread;
@@ -46,6 +47,11 @@ base::FilePath GetBundledPepperFlashPath() {
return path;
}
+void GotPlugins(const base::Closure& quit_closure,
+ const std::vector<webkit::WebPluginInfo>& plugins) {
+ quit_closure.Run();
+}
+
} // namespace
class PluginPrefsTest : public ::testing::Test {
@@ -177,14 +183,16 @@ TEST_F(PluginPrefsTest, EnabledAndDisabledByPolicy) {
plugin_prefs_->PolicyStatusForPlugin(k42));
}
+// Linux Aura doesn't support NPAPI.
+#if !(defined(OS_LINUX) && defined(USE_AURA))
+
TEST_F(PluginPrefsTest, UnifiedPepperFlashState) {
base::ShadowingAtExitManager at_exit_manager_; // Destroys the PluginService.
base::MessageLoop message_loop;
content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop);
- webkit::npapi::MockPluginList plugin_list;
- PluginService::GetInstance()->SetPluginListForTesting(&plugin_list);
PluginService::GetInstance()->Init();
+ PluginService::GetInstance()->DisablePluginsDiscoveryForTesting();
string16 component_updated_plugin_name(
ASCIIToUTF16("Component-updated Pepper Flash"));
@@ -203,9 +211,24 @@ TEST_F(PluginPrefsTest, UnifiedPepperFlashState) {
ASCIIToUTF16("11.3.31.229"),
ASCIIToUTF16(""));
- plugin_list.AddPluginToLoad(component_updated_plugin_1);
- plugin_list.AddPluginToLoad(component_updated_plugin_2);
- plugin_list.AddPluginToLoad(bundled_plugin);
+ PluginService::GetInstance()->RegisterInternalPlugin(
+ component_updated_plugin_1, false);
+ PluginService::GetInstance()->RegisterInternalPlugin(
+ component_updated_plugin_2, false);
+ PluginService::GetInstance()->RegisterInternalPlugin(bundled_plugin, false);
+
+#if !defined(OS_WIN)
+ // Can't go out of process in unit tests.
+ content::RenderProcessHost::SetRunRendererInProcess(true);
+#endif
+ scoped_refptr<content::MessageLoopRunner> runner =
+ new content::MessageLoopRunner;
+ PluginService::GetInstance()->GetPlugins(
+ base::Bind(&GotPlugins, runner->QuitClosure()));
+ runner->Run();
+#if !defined(OS_WIN)
+ content::RenderProcessHost::SetRunRendererInProcess(false);
+#endif
// Set the state of any of the three plugins will affect the others.
EnablePluginSynchronously(true, component_updated_plugin_1.path, true);
@@ -249,6 +272,6 @@ TEST_F(PluginPrefsTest, UnifiedPepperFlashState) {
EXPECT_FALSE(plugin_prefs_->IsPluginEnabled(component_updated_plugin_1));
EXPECT_FALSE(plugin_prefs_->IsPluginEnabled(component_updated_plugin_2));
EXPECT_TRUE(plugin_prefs_->IsPluginEnabled(bundled_plugin));
-
- PluginService::GetInstance()->SetPluginListForTesting(NULL);
}
+
+#endif
diff --git a/chrome/browser/printing/print_preview_test.cc b/chrome/browser/printing/print_preview_test.cc
index 4733668..e6136a1 100644
--- a/chrome/browser/printing/print_preview_test.cc
+++ b/chrome/browser/printing/print_preview_test.cc
@@ -76,8 +76,8 @@ void PrintPreviewTest::SetUp() {
// The PluginService will be destroyed at the end of the test (due to the
// ShadowingAtExitManager in our base class).
- content::PluginService::GetInstance()->SetPluginListForTesting(
- &plugin_list_);
+ content::PluginService::GetInstance()->Init();
+ content::PluginService::GetInstance()->DisablePluginsDiscoveryForTesting();
profile()->GetPrefs()->SetBoolean(prefs::kPrintPreviewDisabled, false);
}
diff --git a/chrome/browser/printing/print_preview_test.h b/chrome/browser/printing/print_preview_test.h
index f1c6ab5..ddfee0e 100644
--- a/chrome/browser/printing/print_preview_test.h
+++ b/chrome/browser/printing/print_preview_test.h
@@ -6,7 +6,6 @@
#define CHROME_BROWSER_PRINTING_PRINT_PREVIEW_TEST_H_
#include "chrome/test/base/browser_with_test_window_test.h"
-#include "webkit/plugins/npapi/mock_plugin_list.h"
class PrintPreviewTest : public BrowserWithTestWindowTest {
public:
@@ -20,8 +19,6 @@ class PrintPreviewTest : public BrowserWithTestWindowTest {
virtual BrowserWindow* CreateBrowserWindow() OVERRIDE;
private:
- webkit::npapi::MockPluginList plugin_list_;
-
DISALLOW_COPY_AND_ASSIGN(PrintPreviewTest);
};
diff --git a/chrome/browser/renderer_host/plugin_info_message_filter_unittest.cc b/chrome/browser/renderer_host/plugin_info_message_filter_unittest.cc
index 030f659..f352fa6 100644
--- a/chrome/browser/renderer_host/plugin_info_message_filter_unittest.cc
+++ b/chrome/browser/renderer_host/plugin_info_message_filter_unittest.cc
@@ -13,10 +13,13 @@
#include "chrome/common/render_messages.h"
#include "content/public/browser/plugin_service.h"
#include "content/public/browser/plugin_service_filter.h"
+#include "content/public/browser/render_process_host.h"
#include "content/public/test/test_browser_thread.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/plugins/npapi/mock_plugin_list.h"
+
+// Linux Aura doesn't support NPAPI.
+#if !(defined(OS_LINUX) && defined(USE_AURA))
using content::PluginService;
@@ -83,7 +86,8 @@ class PluginInfoMessageFilterTest : public ::testing::Test {
webkit::WebPluginMimeType mimeType;
mimeType.mime_type = "foo/bar";
foo_plugin.mime_types.push_back(mimeType);
- plugin_list_.AddPluginToLoad(foo_plugin);
+ PluginService::GetInstance()->Init();
+ PluginService::GetInstance()->RegisterInternalPlugin(foo_plugin, false);
webkit::WebPluginInfo bar_plugin(ASCIIToUTF16("Bar Plug-in"),
bar_plugin_path_,
@@ -91,16 +95,22 @@ class PluginInfoMessageFilterTest : public ::testing::Test {
ASCIIToUTF16("The Bar plug-in."));
mimeType.mime_type = "foo/bar";
bar_plugin.mime_types.push_back(mimeType);
- plugin_list_.AddPluginToLoad(bar_plugin);
+ PluginService::GetInstance()->RegisterInternalPlugin(bar_plugin, false);
- PluginService::GetInstance()->SetPluginListForTesting(&plugin_list_);
PluginService::GetInstance()->SetFilter(&filter_);
+#if !defined(OS_WIN)
+ // Can't go out of process in unit tests.
+ content::RenderProcessHost::SetRunRendererInProcess(true);
+#endif
PluginService::GetInstance()->GetPlugins(
base::Bind(&PluginInfoMessageFilterTest::PluginsLoaded,
base::Unretained(this)));
base::RunLoop run_loop;
run_loop.Run();
+#if !defined(OS_WIN)
+ content::RenderProcessHost::SetRunRendererInProcess(false);
+#endif
}
protected:
@@ -119,7 +129,6 @@ class PluginInfoMessageFilterTest : public ::testing::Test {
// a MockPluginList.
content::TestBrowserThread file_thread_;
base::ShadowingAtExitManager at_exit_manager_; // Destroys the PluginService.
- webkit::npapi::MockPluginList plugin_list_;
};
TEST_F(PluginInfoMessageFilterTest, FindEnabledPlugin) {
@@ -172,3 +181,5 @@ TEST_F(PluginInfoMessageFilterTest, FindEnabledPlugin) {
EXPECT_EQ(FILE_PATH_LITERAL(""), plugin.path.value());
}
}
+
+#endif
diff --git a/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc b/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc
index 18cdd80..8d813fd 100644
--- a/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc
+++ b/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc
@@ -20,7 +20,6 @@
#include "content/public/browser/site_instance.h"
#include "content/public/browser/web_contents.h"
#include "printing/print_job_constants.h"
-#include "webkit/plugins/npapi/mock_plugin_list.h"
using content::WebContents;
using web_modal::WebContentsModalDialogManager;
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index f4213de..ec686a4 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1141,7 +1141,6 @@
'../ui/web_dialogs/web_dialogs.gyp:web_dialogs_test_support',
'../ui/ui.gyp:webui_test_support',
'../v8/tools/gyp/v8.gyp:v8',
- '../webkit/plugins/webkit_plugins.gyp:test_mock_plugin_list',
# Runtime dependencies
'../ppapi/ppapi_internal.gyp:ppapi_tests',
'../third_party/mesa/mesa.gyp:osmesa',
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi
index 0992697..126b736 100644
--- a/chrome/chrome_tests_unit.gypi
+++ b/chrome/chrome_tests_unit.gypi
@@ -1927,7 +1927,6 @@
'../tools/json_schema_compiler/test/json_schema_compiler_tests.gyp:json_schema_compiler_tests',
'../ui/gl/gl.gyp:gl',
'../v8/tools/gyp/v8.gyp:v8',
- '../webkit/plugins/webkit_plugins.gyp:test_mock_plugin_list',
'../webkit/webkit_resources.gyp:webkit_resources',
],
# TODO(scr): Use this in browser_tests too.
diff --git a/content/browser/plugin_service_impl.cc b/content/browser/plugin_service_impl.cc
index 904a096..92d43c5 100644
--- a/content/browser/plugin_service_impl.cc
+++ b/content/browser/plugin_service_impl.cc
@@ -138,7 +138,7 @@ PluginServiceImpl* PluginServiceImpl::GetInstance() {
}
PluginServiceImpl::PluginServiceImpl()
- : plugin_list_(NULL), filter_(NULL) {
+ : filter_(NULL) {
// Collect the total number of browser processes (which create
// PluginServiceImpl objects, to be precise). The number is used to normalize
// the number of processes which start at least one NPAPI/PPAPI Flash process.
@@ -165,11 +165,8 @@ PluginServiceImpl::~PluginServiceImpl() {
}
void PluginServiceImpl::Init() {
- if (!plugin_list_)
- plugin_list_ = webkit::npapi::PluginList::Singleton();
-
plugin_list_token_ = BrowserThread::GetBlockingPool()->GetSequenceToken();
- plugin_list_->set_will_load_plugins_callback(
+ webkit::npapi::PluginList::Singleton()->set_will_load_plugins_callback(
base::Bind(&WillLoadPluginsCallback, plugin_list_token_));
RegisterPepperPlugins();
@@ -199,10 +196,10 @@ void PluginServiceImpl::Init() {
AddExtraPluginPath(path);
path = command_line->GetSwitchValuePath(switches::kExtraPluginDir);
if (!path.empty())
- plugin_list_->AddExtraPluginDir(path);
+ webkit::npapi::PluginList::Singleton()->AddExtraPluginDir(path);
if (command_line->HasSwitch(switches::kDisablePluginsDiscovery))
- plugin_list_->DisablePluginsDiscovery();
+ webkit::npapi::PluginList::Singleton()->DisablePluginsDiscovery();
}
void PluginServiceImpl::StartWatchingPlugins() {
@@ -240,7 +237,7 @@ void PluginServiceImpl::StartWatchingPlugins() {
// Get the list of all paths for registering the FilePathWatchers
// that will track and if needed reload the list of plugins on runtime.
std::vector<base::FilePath> plugin_dirs;
- plugin_list_->GetPluginDirectories(&plugin_dirs);
+ webkit::npapi::PluginList::Singleton()->GetPluginDirectories(&plugin_dirs);
for (size_t i = 0; i < plugin_dirs.size(); ++i) {
// FilePathWatcher can not handle non-absolute paths under windows.
@@ -513,8 +510,8 @@ bool PluginServiceImpl::GetPluginInfoArray(
std::vector<webkit::WebPluginInfo>* plugins,
std::vector<std::string>* actual_mime_types) {
bool use_stale = false;
- plugin_list_->GetPluginInfoArray(url, mime_type, allow_wildcard,
- &use_stale, plugins, actual_mime_types);
+ webkit::npapi::PluginList::Singleton()->GetPluginInfoArray(
+ url, mime_type, allow_wildcard, &use_stale, plugins, actual_mime_types);
return use_stale;
}
@@ -554,7 +551,7 @@ bool PluginServiceImpl::GetPluginInfo(int render_process_id,
bool PluginServiceImpl::GetPluginInfoByPath(const base::FilePath& plugin_path,
webkit::WebPluginInfo* info) {
std::vector<webkit::WebPluginInfo> plugins;
- plugin_list_->GetPluginsNoRefresh(&plugins);
+ webkit::npapi::PluginList::Singleton()->GetPluginsNoRefresh(&plugins);
for (std::vector<webkit::WebPluginInfo>::iterator it = plugins.begin();
it != plugins.end();
@@ -603,7 +600,8 @@ void PluginServiceImpl::GetPlugins(const GetPluginsCallback& callback) {
}
#if defined(OS_POSIX)
std::vector<webkit::WebPluginInfo> cached_plugins;
- if (plugin_list_->GetPluginsNoRefresh(&cached_plugins)) {
+ if (webkit::npapi::PluginList::Singleton()->GetPluginsNoRefresh(
+ &cached_plugins)) {
// Can't assume the caller is reentrant.
target_loop->PostTask(FROM_HERE,
base::Bind(callback, cached_plugins));
@@ -628,7 +626,7 @@ void PluginServiceImpl::GetPluginsInternal(
plugin_list_token_));
std::vector<webkit::WebPluginInfo> plugins;
- plugin_list_->GetPlugins(&plugins);
+ webkit::npapi::PluginList::Singleton()->GetPlugins(&plugins);
target_loop->PostTask(FROM_HERE,
base::Bind(callback, plugins));
@@ -643,7 +641,7 @@ void PluginServiceImpl::OnWaitableEventSignaled(
hklm_key_.StartWatching();
}
- plugin_list_->RefreshPlugins();
+ webkit::npapi::PluginList::Singleton()->RefreshPlugins();
PurgePluginListCache(NULL, false);
#else
// This event should only get signaled on a Windows machine.
@@ -751,28 +749,39 @@ bool PluginServiceImpl::IsPluginUnstable(const base::FilePath& path) {
}
void PluginServiceImpl::RefreshPlugins() {
- plugin_list_->RefreshPlugins();
+ webkit::npapi::PluginList::Singleton()->RefreshPlugins();
}
void PluginServiceImpl::AddExtraPluginPath(const base::FilePath& path) {
- plugin_list_->AddExtraPluginPath(path);
+ webkit::npapi::PluginList::Singleton()->AddExtraPluginPath(path);
+}
+
+void PluginServiceImpl::RemoveExtraPluginPath(const base::FilePath& path) {
+ webkit::npapi::PluginList::Singleton()->RemoveExtraPluginPath(path);
}
void PluginServiceImpl::AddExtraPluginDir(const base::FilePath& path) {
- plugin_list_->AddExtraPluginDir(path);
+ webkit::npapi::PluginList::Singleton()->AddExtraPluginDir(path);
}
-void PluginServiceImpl::RemoveExtraPluginPath(const base::FilePath& path) {
- plugin_list_->RemoveExtraPluginPath(path);
+void PluginServiceImpl::RegisterInternalPlugin(
+ const webkit::WebPluginInfo& info,
+ bool add_at_beginning) {
+ webkit::npapi::PluginList::Singleton()->RegisterInternalPlugin(
+ info, add_at_beginning);
}
void PluginServiceImpl::UnregisterInternalPlugin(const base::FilePath& path) {
- plugin_list_->UnregisterInternalPlugin(path);
+ webkit::npapi::PluginList::Singleton()->UnregisterInternalPlugin(path);
}
-void PluginServiceImpl::SetPluginListForTesting(
- webkit::npapi::PluginList* plugin_list) {
- plugin_list_ = plugin_list;
+void PluginServiceImpl::GetInternalPlugins(
+ std::vector<webkit::WebPluginInfo>* plugins) {
+ webkit::npapi::PluginList::Singleton()->GetInternalPlugins(plugins);
+}
+
+void PluginServiceImpl::DisablePluginsDiscoveryForTesting() {
+ webkit::npapi::PluginList::Singleton()->DisablePluginsDiscovery();
}
#if defined(OS_MACOSX)
@@ -782,15 +791,4 @@ void PluginServiceImpl::AppActivated() {
}
#endif
-void PluginServiceImpl::RegisterInternalPlugin(
- const webkit::WebPluginInfo& info,
- bool add_at_beginning) {
- plugin_list_->RegisterInternalPlugin(info, add_at_beginning);
-}
-
-void PluginServiceImpl::GetInternalPlugins(
- std::vector<webkit::WebPluginInfo>* plugins) {
- plugin_list_->GetInternalPlugins(plugins);
-}
-
} // namespace content
diff --git a/content/browser/plugin_service_impl.h b/content/browser/plugin_service_impl.h
index c0528f4..b3d928d 100644
--- a/content/browser/plugin_service_impl.h
+++ b/content/browser/plugin_service_impl.h
@@ -101,15 +101,14 @@ class CONTENT_EXPORT PluginServiceImpl
virtual bool IsPluginUnstable(const base::FilePath& plugin_path) OVERRIDE;
virtual void RefreshPlugins() OVERRIDE;
virtual void AddExtraPluginPath(const base::FilePath& path) OVERRIDE;
- virtual void AddExtraPluginDir(const base::FilePath& path) OVERRIDE;
virtual void RemoveExtraPluginPath(const base::FilePath& path) OVERRIDE;
- virtual void UnregisterInternalPlugin(const base::FilePath& path) OVERRIDE;
+ virtual void AddExtraPluginDir(const base::FilePath& path) OVERRIDE;
virtual void RegisterInternalPlugin(
const webkit::WebPluginInfo& info, bool add_at_beginning) OVERRIDE;
+ virtual void UnregisterInternalPlugin(const base::FilePath& path) OVERRIDE;
virtual void GetInternalPlugins(
std::vector<webkit::WebPluginInfo>* plugins) OVERRIDE;
- virtual void SetPluginListForTesting(
- webkit::npapi::PluginList* plugin_list) OVERRIDE;
+ virtual void DisablePluginsDiscoveryForTesting() OVERRIDE;
#if defined(OS_MACOSX)
virtual void AppActivated() OVERRIDE;
#endif
@@ -207,9 +206,6 @@ class CONTENT_EXPORT PluginServiceImpl
const base::FilePath& path);
#endif
- // The plugin list instance.
- webkit::npapi::PluginList* plugin_list_;
-
#if defined(OS_WIN)
// Registry keys for getting notifications when new plugins are installed.
base::win::RegKey hkcu_key_;
diff --git a/content/content_tests.gypi b/content/content_tests.gypi
index 7ecf15f..c8fb74c 100644
--- a/content/content_tests.gypi
+++ b/content/content_tests.gypi
@@ -590,7 +590,6 @@
'../webkit/common/webkit_common.gyp:webkit_common',
'../webkit/glue/webkit_glue_common.gyp:glue_common',
'../webkit/plugins/webkit_plugins.gyp:plugins_common',
- '../webkit/plugins/webkit_plugins.gyp:test_mock_plugin_list',
'../webkit/renderer/webkit_renderer.gyp:webkit_renderer',
'../webkit/storage_browser.gyp:webkit_storage_browser',
'../webkit/storage_common.gyp:webkit_storage_common',
diff --git a/content/public/browser/plugin_service.h b/content/public/browser/plugin_service.h
index d1e9323..eceb628 100644
--- a/content/public/browser/plugin_service.h
+++ b/content/public/browser/plugin_service.h
@@ -20,9 +20,6 @@ class FilePath;
namespace webkit {
struct WebPluginInfo;
-namespace npapi {
-class PluginList;
-}
}
namespace content {
@@ -118,23 +115,37 @@ class PluginService {
// crashed more than a set number of times in a set time period.
virtual bool IsPluginUnstable(const base::FilePath& plugin_path) = 0;
- // The following functions are wrappers around webkit::npapi::PluginList.
- // These must be used instead of those in order to ensure that we have a
- // single global list in the component build and so that we don't
- // accidentally load plugins in the wrong process or thread. Refer to
- // PluginList for further documentation of these functions.
+ // Cause the plugin list to refresh next time they are accessed, regardless
+ // of whether they are already loaded.
virtual void RefreshPlugins() = 0;
+
+ // Add/Remove an extra plugin to load when we actually do the loading. Must
+ // be called before the plugins have been loaded.
virtual void AddExtraPluginPath(const base::FilePath& path) = 0;
- virtual void AddExtraPluginDir(const base::FilePath& path) = 0;
virtual void RemoveExtraPluginPath(const base::FilePath& path) = 0;
- virtual void UnregisterInternalPlugin(const base::FilePath& path) = 0;
+
+ // Same as above, but specifies a directory in which to search for plugins.
+ virtual void AddExtraPluginDir(const base::FilePath& path) = 0;
+
+ // Register an internal plugin with the specified plugin information.
+ // An internal plugin must be registered before it can
+ // be loaded using PluginList::LoadPlugin().
+ // If |add_at_beginning| is true the plugin will be added earlier in
+ // the list so that it can override the MIME types of older registrations.
virtual void RegisterInternalPlugin(const webkit::WebPluginInfo& info,
bool add_at_beginning) = 0;
+
+ // Removes a specified internal plugin from the list. The search will match
+ // on the path from the version info previously registered.
+ virtual void UnregisterInternalPlugin(const base::FilePath& path) = 0;
+
+ // Gets a list of all the registered internal plugins.
virtual void GetInternalPlugins(
std::vector<webkit::WebPluginInfo>* plugins) = 0;
- virtual void SetPluginListForTesting(
- webkit::npapi::PluginList* plugin_list) = 0;
+ // This is equivalent to specifying kDisablePluginsDiscovery, but is useful
+ // for unittests.
+ virtual void DisablePluginsDiscoveryForTesting() = 0;
#if defined(OS_MACOSX)
// Called when the application is made active so that modal plugin windows can
diff --git a/webkit/plugins/npapi/mock_plugin_list.cc b/webkit/plugins/npapi/mock_plugin_list.cc
deleted file mode 100644
index 89206cf..0000000
--- a/webkit/plugins/npapi/mock_plugin_list.cc
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "webkit/plugins/npapi/mock_plugin_list.h"
-
-namespace webkit {
-namespace npapi {
-
-MockPluginList::MockPluginList() {
-}
-
-MockPluginList::~MockPluginList() {
-}
-
-void MockPluginList::AddPluginToLoad(const WebPluginInfo& plugin) {
- plugins_to_load_.push_back(plugin);
-}
-
-void MockPluginList::ClearPluginsToLoad() {
- plugins_to_load_.clear();
-}
-
-bool MockPluginList::GetPluginsNoRefresh(
- std::vector<webkit::WebPluginInfo>* plugins) {
- GetPlugins(plugins);
- return true;
-}
-
-void MockPluginList::LoadPluginsIntoPluginListInternal(
- std::vector<webkit::WebPluginInfo>* plugins) {
- for (size_t i = 0; i < plugins_to_load_.size(); ++i) {
- plugins->push_back(plugins_to_load_[i]);
- }
-}
-
-} // npapi
-} // webkit
diff --git a/webkit/plugins/npapi/mock_plugin_list.h b/webkit/plugins/npapi/mock_plugin_list.h
deleted file mode 100644
index 751d500..0000000
--- a/webkit/plugins/npapi/mock_plugin_list.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef WEBKIT_PLUGINS_NPAPI_MOCK_PLUGIN_LIST_H_
-#define WEBKIT_PLUGINS_NPAPI_MOCK_PLUGIN_LIST_H_
-
-#include "webkit/plugins/npapi/plugin_list.h"
-
-namespace webkit {
-namespace npapi {
-
-// A PluginList for tests that avoids file system IO. There is also no reason
-// to use |lock_| (but it doesn't hurt either).
-class MockPluginList : public PluginList {
- public:
- MockPluginList();
- virtual ~MockPluginList();
-
- void AddPluginToLoad(const WebPluginInfo& plugin);
- void ClearPluginsToLoad();
-
- // PluginList:
- virtual bool GetPluginsNoRefresh(
- std::vector<webkit::WebPluginInfo>* plugins) OVERRIDE;
-
- private:
- std::vector<WebPluginInfo> plugins_to_load_;
-
- // PluginList methods:
-
- virtual void LoadPluginsIntoPluginListInternal(
- std::vector<webkit::WebPluginInfo>* plugins) OVERRIDE;
-};
-
-} // npapi
-} // webkit
-
-#endif // WEBKIT_PLUGINS_NPAPI_MOCK_PLUGIN_LIST_H_
diff --git a/webkit/plugins/npapi/plugin_list.h b/webkit/plugins/npapi/plugin_list.h
index 73bca62..2b800d8 100644
--- a/webkit/plugins/npapi/plugin_list.h
+++ b/webkit/plugins/npapi/plugin_list.h
@@ -99,8 +99,6 @@ class PluginList {
// Removes a specified internal plugin from the list. The search will match
// on the path from the version info previously registered.
- //
- // This is generally only necessary for tests.
void UnregisterInternalPlugin(const base::FilePath& path);
// Gets a list of all the registered internal plugins.
@@ -130,7 +128,7 @@ class PluginList {
// Copies the list of plug-ins into |plugins| without loading them.
// Returns true if the list of plugins is up-to-date.
- virtual bool GetPluginsNoRefresh(
+ bool GetPluginsNoRefresh(
std::vector<webkit::WebPluginInfo>* plugins);
// Returns a list in |info| containing plugins that are found for
@@ -189,11 +187,6 @@ class PluginList {
webkit::WebPluginInfo* info);
#endif
- protected:
- // Constructors are private for singletons but we expose this one
- // for subclasses for test purposes.
- PluginList();
-
private:
enum LoadingState {
LOADING_STATE_NEEDS_REFRESH,
@@ -209,6 +202,8 @@ class PluginList {
friend class PluginListTest;
friend struct base::DefaultLazyInstanceTraits<PluginList>;
+ PluginList();
+
// Implements all IO dependent operations of the LoadPlugins method so that
// test classes can mock these out.
virtual void LoadPluginsIntoPluginListInternal(
diff --git a/webkit/plugins/npapi/plugin_list_unittest.cc b/webkit/plugins/npapi/plugin_list_unittest.cc
index 246f51b..432b90f 100644
--- a/webkit/plugins/npapi/plugin_list_unittest.cc
+++ b/webkit/plugins/npapi/plugin_list_unittest.cc
@@ -7,7 +7,6 @@
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/plugins/npapi/mock_plugin_list.h"
namespace webkit {
namespace npapi {
@@ -31,12 +30,15 @@ bool Contains(const std::vector<WebPluginInfo>& list,
return false;
}
+} // namespace
+
+// Linux Aura doesn't support NPAPI.
+#if !(defined(OS_LINUX) && defined(USE_AURA))
+
base::FilePath::CharType kFooPath[] = FILE_PATH_LITERAL("/plugins/foo.plugin");
base::FilePath::CharType kBarPath[] = FILE_PATH_LITERAL("/plugins/bar.plugin");
const char* kFooName = "Foo Plugin";
-} // namespace
-
class PluginListTest : public testing::Test {
public:
PluginListTest()
@@ -51,12 +53,13 @@ class PluginListTest : public testing::Test {
}
virtual void SetUp() {
- plugin_list_.AddPluginToLoad(bar_plugin_);
- plugin_list_.AddPluginToLoad(foo_plugin_);
+ plugin_list_.DisablePluginsDiscovery();
+ plugin_list_.RegisterInternalPlugin(bar_plugin_, false);
+ plugin_list_.RegisterInternalPlugin(foo_plugin_, false);
}
protected:
- MockPluginList plugin_list_;
+ PluginList plugin_list_;
WebPluginInfo foo_plugin_;
WebPluginInfo bar_plugin_;
};
@@ -74,8 +77,7 @@ TEST_F(PluginListTest, BadPluginDescription) {
base::string16(), base::FilePath(FILE_PATH_LITERAL("/myplugin.3.0.43")),
base::string16(), base::string16());
// Simulate loading of the plugins.
- plugin_list_.ClearPluginsToLoad();
- plugin_list_.AddPluginToLoad(plugin_3043);
+ plugin_list_.RegisterInternalPlugin(plugin_3043, false);
// Now we should have them in the state we specified above.
plugin_list_.RefreshPlugins();
std::vector<WebPluginInfo> plugins;
@@ -83,6 +85,8 @@ TEST_F(PluginListTest, BadPluginDescription) {
ASSERT_TRUE(Contains(plugins, plugin_3043));
}
+#endif
+
#if defined(OS_POSIX) && !defined(OS_MACOSX)
// Test parsing a simple description: Real Audio.
diff --git a/webkit/plugins/webkit_plugins.gyp b/webkit/plugins/webkit_plugins.gyp
index 2f47059..74751ae 100644
--- a/webkit/plugins/webkit_plugins.gyp
+++ b/webkit/plugins/webkit_plugins.gyp
@@ -71,20 +71,6 @@
}],
],
},
- {
- 'target_name': 'test_mock_plugin_list',
- 'type': 'static_library',
- 'dependencies': [
- 'plugins_common'
- ],
- 'include_dirs': [
- '../..',
- ],
- 'sources': [
- 'npapi/mock_plugin_list.cc',
- 'npapi/mock_plugin_list.h',
- ]
- },
],
'conditions': [
['OS!="android" and OS!="ios"', {