summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/chromeos/gview_request_interceptor_unittest.cc3
-rw-r--r--chrome/browser/extensions/extension_service_unittest.cc11
-rw-r--r--chrome/browser/plugin_prefs.cc36
-rw-r--r--chrome/browser/plugin_prefs.h11
-rw-r--r--chrome/browser/plugin_prefs_unittest.cc18
-rw-r--r--content/browser/plugin_loader_posix_unittest.cc7
-rw-r--r--content/browser/plugin_service.cc4
-rw-r--r--content/browser/plugin_service.h2
8 files changed, 61 insertions, 31 deletions
diff --git a/chrome/browser/chromeos/gview_request_interceptor_unittest.cc b/chrome/browser/chromeos/gview_request_interceptor_unittest.cc
index 9c5aed1..ea119a9 100644
--- a/chrome/browser/chromeos/gview_request_interceptor_unittest.cc
+++ b/chrome/browser/chromeos/gview_request_interceptor_unittest.cc
@@ -5,6 +5,7 @@
#include <string>
#include <vector>
+#include "base/at_exit.h"
#include "base/bind.h"
#include "base/message_loop.h"
#include "chrome/browser/chrome_plugin_service_filter.h"
@@ -115,6 +116,7 @@ class GViewRequestInterceptorTest : public testing::Test {
handler_ = new content::DummyResourceHandler();
+ PluginService::GetInstance()->Init();
PluginService::GetInstance()->RefreshPlugins();
PluginService::GetInstance()->GetPlugins(base::Bind(&QuitMessageLoop));
MessageLoop::current()->RunAllPending();
@@ -200,6 +202,7 @@ class GViewRequestInterceptorTest : public testing::Test {
}
protected:
+ base::ShadowingAtExitManager at_exit_manager_; // Deletes PluginService.
MessageLoopForIO message_loop_;
content::TestBrowserThread ui_thread_;
content::TestBrowserThread file_thread_;
diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc
index 914271b..17160bf 100644
--- a/chrome/browser/extensions/extension_service_unittest.cc
+++ b/chrome/browser/extensions/extension_service_unittest.cc
@@ -8,6 +8,7 @@
#include <set>
#include <vector>
+#include "base/at_exit.h"
#include "base/basictypes.h"
#include "base/bind.h"
#include "base/command_line.h"
@@ -60,6 +61,7 @@
#include "content/browser/file_system/browser_file_system_helper.h"
#include "content/browser/in_process_webkit/dom_storage_context.h"
#include "content/browser/in_process_webkit/webkit_context.h"
+#include "content/browser/plugin_service.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_service.h"
#include "content/test/test_browser_thread.h"
@@ -982,6 +984,9 @@ void PackExtensionTestClient::OnPackFailure(const std::string& error_message) {
// Test loading good extensions from the profile directory.
TEST_F(ExtensionServiceTest, LoadAllExtensionsFromDirectorySuccess) {
+ base::ShadowingAtExitManager at_exit_manager;
+ PluginService::GetInstance()->Init();
+
// Initialize the test dir with a good Preferences/extensions.
FilePath source_install_dir = data_dir_
.AppendASCII("good")
@@ -1119,6 +1124,9 @@ TEST_F(ExtensionServiceTest, LoadAllExtensionsFromDirectoryFail) {
// Test that partially deleted extensions are cleaned up during startup
// Test loading bad extensions from the profile directory.
TEST_F(ExtensionServiceTest, CleanupOnStartup) {
+ base::ShadowingAtExitManager at_exit_manager;
+ PluginService::GetInstance()->Init();
+
FilePath source_install_dir = data_dir_
.AppendASCII("good")
.AppendASCII("Extensions");
@@ -1452,6 +1460,9 @@ TEST_F(ExtensionServiceTest, GrantedPermissions) {
// an extension contains an NPAPI plugin. Don't run this test on Chrome OS
// since they don't support plugins.
TEST_F(ExtensionServiceTest, GrantedFullAccessPermissions) {
+ base::ShadowingAtExitManager at_exit_manager;
+ PluginService::GetInstance()->Init();
+
InitializeEmptyExtensionService();
FilePath path = data_dir_
diff --git a/chrome/browser/plugin_prefs.cc b/chrome/browser/plugin_prefs.cc
index 94ecb6e..f4923f1 100644
--- a/chrome/browser/plugin_prefs.cc
+++ b/chrome/browser/plugin_prefs.cc
@@ -73,17 +73,15 @@ void PluginPrefs::SetPluginListForTesting(
}
void PluginPrefs::EnablePluginGroup(bool enabled, const string16& group_name) {
- if (!BrowserThread::CurrentlyOn(BrowserThread::FILE)) {
- BrowserThread::PostTask(
- BrowserThread::FILE, FROM_HERE,
- base::Bind(&PluginPrefs::EnablePluginGroup, this, enabled, group_name));
- return;
- }
-
- webkit::npapi::PluginList* plugin_list = GetPluginList();
- std::vector<webkit::npapi::PluginGroup> groups;
- plugin_list->GetPluginGroups(true, &groups);
+ PluginService::GetInstance()->GetPluginGroups(
+ base::Bind(&PluginPrefs::EnablePluginGroupInternal,
+ this, enabled, group_name));
+}
+void PluginPrefs::EnablePluginGroupInternal(
+ bool enabled,
+ const string16& group_name,
+ const std::vector<webkit::npapi::PluginGroup>& groups) {
base::AutoLock auto_lock(lock_);
// Set the desired state for the group.
@@ -124,27 +122,21 @@ bool PluginPrefs::EnablePlugin(bool enabled, const FilePath& path) {
}
}
- if (BrowserThread::CurrentlyOn(BrowserThread::FILE)) {
- EnablePluginInternal(enabled, path);
- } else {
- BrowserThread::PostTask(
- BrowserThread::FILE, FROM_HERE,
- base::Bind(&PluginPrefs::EnablePluginInternal, this, enabled, path));
- }
+ PluginService::GetInstance()->GetPluginGroups(
+ base::Bind(&PluginPrefs::EnablePluginInternal, this, enabled, path));
return true;
}
-void PluginPrefs::EnablePluginInternal(bool enabled, const FilePath& path) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+void PluginPrefs::EnablePluginInternal(
+ bool enabled,
+ const FilePath& path,
+ const std::vector<webkit::npapi::PluginGroup>& groups) {
{
// Set the desired state for the plug-in.
base::AutoLock auto_lock(lock_);
plugin_state_[path] = enabled;
}
- std::vector<webkit::npapi::PluginGroup> groups;
- GetPluginList()->GetPluginGroups(true, &groups);
-
bool found_group = false;
for (size_t i = 0; i < groups.size(); ++i) {
bool all_disabled = true;
diff --git a/chrome/browser/plugin_prefs.h b/chrome/browser/plugin_prefs.h
index e6afa45..3792dfd 100644
--- a/chrome/browser/plugin_prefs.h
+++ b/chrome/browser/plugin_prefs.h
@@ -117,8 +117,15 @@ class PluginPrefs : public base::RefCountedThreadSafe<PluginPrefs>,
// Returns the plugin list to use, either the singleton or the override.
webkit::npapi::PluginList* GetPluginList();
- // Called on the file thread to update the plug-in state.
- void EnablePluginInternal(bool enabled, const FilePath& path);
+ // Callback for after the plugin groups have been loaded.
+ void EnablePluginGroupInternal(
+ bool enabled,
+ const string16& group_name,
+ const std::vector<webkit::npapi::PluginGroup>& groups);
+ void EnablePluginInternal(
+ bool enabled,
+ const FilePath& path,
+ const std::vector<webkit::npapi::PluginGroup>& groups);
// Called on the file thread to get the data necessary to update the saved
// preferences.
diff --git a/chrome/browser/plugin_prefs_unittest.cc b/chrome/browser/plugin_prefs_unittest.cc
index 20acd5e..e045a16 100644
--- a/chrome/browser/plugin_prefs_unittest.cc
+++ b/chrome/browser/plugin_prefs_unittest.cc
@@ -4,10 +4,14 @@
#include "chrome/browser/plugin_prefs.h"
+#include "base/at_exit.h"
+#include "base/bind.h"
+#include "base/message_loop.h"
#include "base/utf_string_conversions.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
+#include "content/browser/plugin_service.h"
#include "content/test/test_browser_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webkit/plugins/npapi/mock_plugin_list.cc"
@@ -134,10 +138,16 @@ TEST_F(PluginPrefsTest, EnabledAndDisabledByPolicy) {
}
TEST_F(PluginPrefsTest, DisableGlobally) {
+ base::ShadowingAtExitManager at_exit_manager_; // Destroys the PluginService.
+
MessageLoop message_loop;
content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop);
content::TestBrowserThread file_thread(BrowserThread::FILE, &message_loop);
+ webkit::npapi::MockPluginList plugin_list(NULL, 0);
+ PluginService::GetInstance()->SetPluginListForTesting(&plugin_list);
+ PluginService::GetInstance()->Init();
+
TestingBrowserProcess* browser_process =
static_cast<TestingBrowserProcess*>(g_browser_process);
TestingProfileManager profile_manager(browser_process);
@@ -147,16 +157,17 @@ TEST_F(PluginPrefsTest, DisableGlobally) {
profile_manager.CreateTestingProfile("Profile 1");
PluginPrefs* plugin_prefs = PluginPrefs::GetForTestingProfile(profile_1);
ASSERT_TRUE(plugin_prefs);
+ plugin_prefs->SetPluginListForTesting(&plugin_list);
webkit::WebPluginInfo plugin(ASCIIToUTF16("Foo"),
FilePath(FILE_PATH_LITERAL("/path/too/foo")),
ASCIIToUTF16("1.0.0"),
ASCIIToUTF16("Foo plug-in"));
- webkit::npapi::MockPluginList plugin_list(NULL, 0);
plugin_list.AddPluginToLoad(plugin);
- plugin_prefs->SetPluginListForTesting(&plugin_list);
EXPECT_TRUE(PluginPrefs::EnablePluginGlobally(false, plugin.path));
+ message_loop.RunAllPending();
+
EXPECT_FALSE(plugin_prefs->IsPluginEnabled(plugin));
TestingProfile* profile_2 =
@@ -165,4 +176,7 @@ TEST_F(PluginPrefsTest, DisableGlobally) {
ASSERT_TRUE(plugin_prefs);
plugin_prefs_2->SetPluginListForTesting(&plugin_list);
EXPECT_FALSE(plugin_prefs_2->IsPluginEnabled(plugin));
+
+ profile_manager.DeleteTestingProfile("Profile 1");
+ profile_manager.DeleteTestingProfile("Profile 2");
}
diff --git a/content/browser/plugin_loader_posix_unittest.cc b/content/browser/plugin_loader_posix_unittest.cc
index 5111f58..b9cbfac 100644
--- a/content/browser/plugin_loader_posix_unittest.cc
+++ b/content/browser/plugin_loader_posix_unittest.cc
@@ -4,6 +4,7 @@
#include "content/browser/plugin_loader_posix.h"
+#include "base/at_exit.h"
#include "base/bind.h"
#include "base/file_path.h"
#include "base/memory/ref_counted.h"
@@ -72,6 +73,10 @@ class PluginLoaderPosixTest : public testing::Test {
plugin_loader_(new MockPluginLoaderPosix) {
}
+ virtual void SetUp() OVERRIDE {
+ PluginService::GetInstance()->Init();
+ }
+
MessageLoop* message_loop() { return &message_loop_; }
MockPluginLoaderPosix* plugin_loader() { return plugin_loader_.get(); }
@@ -88,6 +93,8 @@ class PluginLoaderPosixTest : public testing::Test {
webkit::WebPluginInfo plugin3_;
private:
+ base::ShadowingAtExitManager at_exit_manager_; // Destroys PluginService.
+
MessageLoopForIO message_loop_;
BrowserThreadImpl file_thread_;
BrowserThreadImpl io_thread_;
diff --git a/content/browser/plugin_service.cc b/content/browser/plugin_service.cc
index b0cbb7f..eb82c1f 100644
--- a/content/browser/plugin_service.cc
+++ b/content/browser/plugin_service.cc
@@ -643,10 +643,6 @@ void PluginService::UnregisterInternalPlugin(const FilePath& path) {
plugin_list()->UnregisterInternalPlugin(path);
}
-webkit::npapi::PluginList* PluginService::plugin_list() {
- return webkit::npapi::PluginList::Singleton();
-}
-
void PluginService::SetPluginListForTesting(
webkit::npapi::PluginList* plugin_list) {
plugin_list_ = plugin_list;
diff --git a/content/browser/plugin_service.h b/content/browser/plugin_service.h
index c2a3733..2dae647 100644
--- a/content/browser/plugin_service.h
+++ b/content/browser/plugin_service.h
@@ -189,7 +189,7 @@ class CONTENT_EXPORT PluginService
string16 GetPluginGroupName(const std::string& plugin_name);
// TODO(dpranke): This should be private.
- webkit::npapi::PluginList* plugin_list();
+ webkit::npapi::PluginList* plugin_list() { return plugin_list_; }
void SetPluginListForTesting(webkit::npapi::PluginList* plugin_list);