summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/cocoa/content_setting_bubble_cocoa.mm5
-rw-r--r--chrome/browser/cocoa/table_model_array_controller_unittest.mm4
-rw-r--r--chrome/browser/gtk/content_setting_bubble_gtk.cc6
-rw-r--r--chrome/browser/mock_plugin_exceptions_table_model.cc6
-rw-r--r--chrome/browser/mock_plugin_exceptions_table_model.h6
-rw-r--r--chrome/browser/plugin_exceptions_table_model.cc10
-rw-r--r--chrome/browser/plugin_exceptions_table_model.h4
-rw-r--r--chrome/browser/plugin_exceptions_table_model_unittest.cc4
-rw-r--r--chrome/browser/plugin_service.cc6
-rw-r--r--chrome/browser/plugin_updater.cc107
-rw-r--r--chrome/browser/plugin_updater.h14
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.cc2
-rw-r--r--chrome/browser/views/content_setting_bubble_contents.cc5
-rw-r--r--chrome/chrome_common.gypi2
-rw-r--r--chrome/chrome_tests.gypi1
-rw-r--r--chrome/renderer/blocked_plugin.cc2
-rw-r--r--chrome/renderer/render_view.cc1
-rw-r--r--webkit/glue/plugins/plugin_group.cc (renamed from chrome/common/plugin_group.cc)12
-rw-r--r--webkit/glue/plugins/plugin_group.h (renamed from chrome/common/plugin_group.h)14
-rw-r--r--webkit/glue/plugins/plugin_group_unittest.cc (renamed from chrome/common/plugin_group_unittest.cc)2
-rw-r--r--webkit/glue/plugins/plugin_list.cc132
-rw-r--r--webkit/glue/plugins/plugin_list.h33
-rw-r--r--webkit/glue/webkit_glue.gypi2
-rw-r--r--webkit/tools/test_shell/test_shell.gypi1
24 files changed, 221 insertions, 160 deletions
diff --git a/chrome/browser/cocoa/content_setting_bubble_cocoa.mm b/chrome/browser/cocoa/content_setting_bubble_cocoa.mm
index de7167c..ea26ebc 100644
--- a/chrome/browser/cocoa/content_setting_bubble_cocoa.mm
+++ b/chrome/browser/cocoa/content_setting_bubble_cocoa.mm
@@ -18,7 +18,6 @@
#include "chrome/browser/host_content_settings_map.h"
#include "chrome/browser/plugin_updater.h"
#include "chrome/common/chrome_switches.h"
-#include "chrome/common/plugin_group.h"
#include "grit/generated_resources.h"
#include "skia/ext/skia_utils_mac.h"
#import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h"
@@ -244,8 +243,8 @@ NSTextField* LabelWithFrame(NSString* text, const NSRect& frame) {
for (std::set<std::string>::iterator it = plugins.begin();
it != plugins.end(); ++it) {
NSString* name;
- PluginUpdater::PluginMap groups;
- PluginUpdater::GetPluginUpdater()->GetPluginGroups(&groups);
+ NPAPI::PluginList::PluginMap groups;
+ NPAPI::PluginList::Singleton()->GetPluginGroups(false, &groups);
if (groups.find(*it) != groups.end())
name = base::SysUTF16ToNSString(groups[*it]->GetGroupName());
else
diff --git a/chrome/browser/cocoa/table_model_array_controller_unittest.mm b/chrome/browser/cocoa/table_model_array_controller_unittest.mm
index 527d3db..f8bff40 100644
--- a/chrome/browser/cocoa/table_model_array_controller_unittest.mm
+++ b/chrome/browser/cocoa/table_model_array_controller_unittest.mm
@@ -11,11 +11,11 @@
#import "chrome/browser/cocoa/cocoa_test_helper.h"
#include "chrome/browser/mock_plugin_exceptions_table_model.h"
#include "chrome/common/chrome_switches.h"
-#include "chrome/common/plugin_group.h"
#include "chrome/test/testing_profile.h"
#include "grit/generated_resources.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/gtest_mac.h"
+#include "webkit/glue/plugins/plugin_list.h"
#include "webkit/glue/plugins/webplugininfo.h"
namespace {
@@ -52,7 +52,7 @@ class TableModelArrayControllerTest : public CocoaTest {
model_.reset(new MockPluginExceptionsTableModel(map, NULL));
- PluginUpdater::PluginMap plugins;
+ NPAPI::PluginList::PluginMap plugins;
WebPluginInfo foo_plugin;
foo_plugin.path = FilePath(FILE_PATH_LITERAL("a-foo"));
foo_plugin.name = ASCIIToUTF16("FooPlugin");
diff --git a/chrome/browser/gtk/content_setting_bubble_gtk.cc b/chrome/browser/gtk/content_setting_bubble_gtk.cc
index 116b3a3..7d4b011 100644
--- a/chrome/browser/gtk/content_setting_bubble_gtk.cc
+++ b/chrome/browser/gtk/content_setting_bubble_gtk.cc
@@ -14,13 +14,11 @@
#include "chrome/browser/gtk/gtk_util.h"
#include "chrome/browser/gtk/options/content_settings_window_gtk.h"
#include "chrome/browser/host_content_settings_map.h"
-#include "chrome/browser/plugin_updater.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/content_settings.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/notification_type.h"
-#include "chrome/common/plugin_group.h"
#include "gfx/gtk_util.h"
#include "grit/app_resources.h"
#include "grit/generated_resources.h"
@@ -90,8 +88,8 @@ void ContentSettingBubbleGtk::BuildBubble() {
for (std::set<std::string>::const_iterator it = plugins.begin();
it != plugins.end(); ++it) {
std::string name;
- PluginUpdater::PluginMap groups;
- PluginUpdater::GetPluginUpdater()->GetPluginGroups(&groups);
+ NPAPI::PluginList::PluginMap groups;
+ NPAPI::PluginList::Singleton()->GetPluginGroups(false, &groups);
if (groups.find(*it) != groups.end())
name = UTF16ToUTF8(groups[*it]->GetGroupName());
else
diff --git a/chrome/browser/mock_plugin_exceptions_table_model.cc b/chrome/browser/mock_plugin_exceptions_table_model.cc
index fe5c904..e2d38a7 100644
--- a/chrome/browser/mock_plugin_exceptions_table_model.cc
+++ b/chrome/browser/mock_plugin_exceptions_table_model.cc
@@ -4,14 +4,12 @@
#include "chrome/browser/mock_plugin_exceptions_table_model.h"
-#include "chrome/common/plugin_group.h"
-
void MockPluginExceptionsTableModel::set_plugins(
- const PluginUpdater::PluginMap& plugins) {
+ const NPAPI::PluginList::PluginMap& plugins) {
plugins_ = plugins;
}
void MockPluginExceptionsTableModel::GetPlugins(
- PluginUpdater::PluginMap* plugins) {
+ NPAPI::PluginList::PluginMap* plugins) {
*plugins = plugins_;
}
diff --git a/chrome/browser/mock_plugin_exceptions_table_model.h b/chrome/browser/mock_plugin_exceptions_table_model.h
index eea5a4d..d1f5da7 100644
--- a/chrome/browser/mock_plugin_exceptions_table_model.h
+++ b/chrome/browser/mock_plugin_exceptions_table_model.h
@@ -17,13 +17,13 @@ class MockPluginExceptionsTableModel : public PluginExceptionsTableModel {
: PluginExceptionsTableModel(map, otr_map) {}
virtual ~MockPluginExceptionsTableModel() {}
- void set_plugins(const PluginUpdater::PluginMap& plugins);
+ void set_plugins(const NPAPI::PluginList::PluginMap& plugins);
protected:
- virtual void GetPlugins(PluginUpdater::PluginMap* plugins);
+ virtual void GetPlugins(NPAPI::PluginList::PluginMap* plugins);
private:
- PluginUpdater::PluginMap plugins_;
+ NPAPI::PluginList::PluginMap plugins_;
};
#endif // CHROME_BROWSER_MOCK_PLUGIN_EXCEPTIONS_TABLE_MODEL_H_
diff --git a/chrome/browser/plugin_exceptions_table_model.cc b/chrome/browser/plugin_exceptions_table_model.cc
index e9abc35..6a655c2 100644
--- a/chrome/browser/plugin_exceptions_table_model.cc
+++ b/chrome/browser/plugin_exceptions_table_model.cc
@@ -10,7 +10,6 @@
#include "base/sys_string_conversions.h"
#include "base/utf_string_conversions.h"
#include "chrome/common/notification_service.h"
-#include "chrome/common/plugin_group.h"
#include "grit/generated_resources.h"
PluginExceptionsTableModel::PluginExceptionsTableModel(
@@ -128,15 +127,16 @@ void PluginExceptionsTableModel::ClearSettings() {
resources_.clear();
}
-void PluginExceptionsTableModel::GetPlugins(PluginUpdater::PluginMap* plugins) {
- PluginUpdater::GetPluginUpdater()->GetPluginGroups(plugins);
+void PluginExceptionsTableModel::GetPlugins(
+ NPAPI::PluginList::PluginMap* plugins) {
+ NPAPI::PluginList::Singleton()->GetPluginGroups(false, plugins);
}
void PluginExceptionsTableModel::LoadSettings() {
int group_id = 0;
- PluginUpdater::PluginMap plugins;
+ NPAPI::PluginList::PluginMap plugins;
GetPlugins(&plugins);
- for (PluginUpdater::PluginMap::iterator it = plugins.begin();
+ for (NPAPI::PluginList::PluginMap::iterator it = plugins.begin();
it != plugins.end(); ++it) {
std::string plugin = it->first;
HostContentSettingsMap::SettingsForOneType settings;
diff --git a/chrome/browser/plugin_exceptions_table_model.h b/chrome/browser/plugin_exceptions_table_model.h
index 491aab1..8a07745 100644
--- a/chrome/browser/plugin_exceptions_table_model.h
+++ b/chrome/browser/plugin_exceptions_table_model.h
@@ -9,9 +9,9 @@
#include <deque>
#include "chrome/browser/host_content_settings_map.h"
-#include "chrome/browser/plugin_updater.h"
#include "chrome/browser/remove_rows_table_model.h"
#include "chrome/common/notification_observer.h"
+#include "webkit/glue/plugins/plugin_list.h"
namespace plugin_test_internal {
class PluginExceptionsTableModelTest;
@@ -49,7 +49,7 @@ class PluginExceptionsTableModel : public RemoveRowsTableModel,
protected:
// Subclasses can override this method for testing.
- virtual void GetPlugins(PluginUpdater::PluginMap* plugins);
+ virtual void GetPlugins(NPAPI::PluginList::PluginMap* plugins);
private:
friend class plugin_test_internal::PluginExceptionsTableModelTest;
diff --git a/chrome/browser/plugin_exceptions_table_model_unittest.cc b/chrome/browser/plugin_exceptions_table_model_unittest.cc
index 6b508c6..1940bde 100644
--- a/chrome/browser/plugin_exceptions_table_model_unittest.cc
+++ b/chrome/browser/plugin_exceptions_table_model_unittest.cc
@@ -8,12 +8,12 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/mock_plugin_exceptions_table_model.h"
#include "chrome/common/chrome_switches.h"
-#include "chrome/common/plugin_group.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/testing_pref_service.h"
#include "chrome/test/testing_profile.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "webkit/glue/plugins/plugin_group.h"
#include "webkit/glue/plugins/webplugininfo.h"
// Can't be an internal namespace because PluginExceptionsTableModel declares
@@ -82,7 +82,7 @@ class PluginExceptionsTableModelTest : public testing::Test {
table_model_.reset(new MockPluginExceptionsTableModel(map, NULL));
- PluginUpdater::PluginMap plugins;
+ NPAPI::PluginList::PluginMap plugins;
WebPluginInfo foo_plugin;
foo_plugin.path = FilePath(FILE_PATH_LITERAL("a-foo"));
foo_plugin.name = ASCIIToUTF16("FooPlugin");
diff --git a/chrome/browser/plugin_service.cc b/chrome/browser/plugin_service.cc
index 7736a9f..6f387e4 100644
--- a/chrome/browser/plugin_service.cc
+++ b/chrome/browser/plugin_service.cc
@@ -68,14 +68,12 @@ void PluginService::InitGlobalInstance(Profile* profile) {
NPAPI::PluginList::Singleton()->SetPluginLoadHook(LoadPluginsFromDiskHook);
- // Code is disabled since plugins shouldn't be loaded on the UI/IO threads.
- // See http://code.google.com/p/chromium/issues/detail?id=57425
// We first group the plugins and then figure out which groups to disable.
- // PluginUpdater::GetPluginUpdater()->DisablePluginGroupsFromPrefs(profile);
+ PluginUpdater::GetPluginUpdater()->DisablePluginGroupsFromPrefs(profile);
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableOutdatedPlugins)) {
- PluginUpdater::GetPluginUpdater()->DisableOutdatedPluginGroups();
+ NPAPI::PluginList::Singleton()->DisableOutdatedPluginGroups();
}
// Have Chrome plugins write their data to the profile directory.
diff --git a/chrome/browser/plugin_updater.cc b/chrome/browser/plugin_updater.cc
index 17ec60a..a119c78 100644
--- a/chrome/browser/plugin_updater.cc
+++ b/chrome/browser/plugin_updater.cc
@@ -10,7 +10,6 @@
#include "base/command_line.h"
#include "base/path_service.h"
#include "base/scoped_ptr.h"
-#include "base/sys_string_conversions.h"
#include "base/values.h"
#include "base/version.h"
#include "chrome/browser/prefs/pref_service.h"
@@ -18,51 +17,14 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/notification_service.h"
-#include "chrome/common/plugin_group.h"
#include "chrome/common/pref_names.h"
+#include "webkit/glue/plugins/plugin_group.h"
#include "webkit/glue/plugins/plugin_list.h"
#include "webkit/glue/plugins/webplugininfo.h"
PluginUpdater::PluginUpdater() : enable_internal_pdf_(true) {
}
-// static
-void PluginUpdater::GetPluginGroups(PluginMap* plugin_groups) {
- DCHECK(plugin_groups);
-
- plugin_groups->clear();
- // Read all plugins and convert them to plugin groups
- std::vector<WebPluginInfo> web_plugins;
- NPAPI::PluginList::Singleton()->GetPlugins(false, &web_plugins);
-
- // We first search for an existing group that matches our name,
- // and only create a new group if we can't find any.
- for (size_t i = 0; i < web_plugins.size(); ++i) {
- const WebPluginInfo& web_plugin = web_plugins[i];
- PluginGroup* group = PluginGroup::FindGroupMatchingPlugin(
- *plugin_groups, web_plugin);
- if (!group) {
- group = PluginGroup::CopyOrCreatePluginGroup(web_plugin);
- std::string identifier = group->identifier();
- // If the identifier is not unique, use the full path. This means that we
- // probably won't be able to search for this group by identifier, but at
- // least it's going to be in the set of plugin groups, and if there
- // is already a plug-in with the same filename, it's probably going to
- // handle the same MIME types (and it has a higher priority), so this one
- // is not going to run anyway.
- if (plugin_groups->find(identifier) != plugin_groups->end())
-#if defined(OS_POSIX)
- identifier = web_plugin.path.value();
-#elif defined(OS_WIN)
- identifier = base::SysWideToUTF8(web_plugin.path.value());
-#endif
- DCHECK(plugin_groups->find(identifier) == plugin_groups->end());
- (*plugin_groups)[identifier] = linked_ptr<PluginGroup>(group);
- }
- group->AddPlugin(web_plugin, i);
- }
-}
-
DictionaryValue* PluginUpdater::CreatePluginFileSummary(
const WebPluginInfo& plugin) {
DictionaryValue* data = new DictionaryValue();
@@ -75,12 +37,12 @@ DictionaryValue* PluginUpdater::CreatePluginFileSummary(
// static
ListValue* PluginUpdater::GetPluginGroupsData() {
- PluginMap plugin_groups;
- GetPluginGroups(&plugin_groups);
+ NPAPI::PluginList::PluginMap plugin_groups;
+ NPAPI::PluginList::Singleton()->GetPluginGroups(true, &plugin_groups);
// Construct DictionaryValues to return to the UI
ListValue* plugin_groups_data = new ListValue();
- for (PluginMap::const_iterator it =
+ for (NPAPI::PluginList::PluginMap::const_iterator it =
plugin_groups.begin();
it != plugin_groups.end();
++it) {
@@ -90,25 +52,13 @@ ListValue* PluginUpdater::GetPluginGroupsData() {
}
void PluginUpdater::EnablePluginGroup(bool enable, const string16& group_name) {
- PluginMap plugin_groups;
- GetPluginGroups(&plugin_groups);
-
- for (PluginMap::const_iterator it =
- plugin_groups.begin();
- it != plugin_groups.end();
- ++it) {
- if (it->second->GetGroupName() == group_name) {
- if (PluginGroup::IsPluginNameDisabledByPolicy(group_name))
- enable = false;
- if (it->second->Enabled() != enable) {
- it->second->Enable(enable);
- NotificationService::current()->Notify(
- NotificationType::PLUGIN_ENABLE_STATUS_CHANGED,
- Source<PluginUpdater>(this),
- NotificationService::NoDetails());
- }
- return;
- }
+ if (PluginGroup::IsPluginNameDisabledByPolicy(group_name))
+ enable = false;
+ if (NPAPI::PluginList::Singleton()->EnableGroup(enable, group_name)) {
+ NotificationService::current()->Notify(
+ NotificationType::PLUGIN_ENABLE_STATUS_CHANGED,
+ Source<PluginUpdater>(this),
+ NotificationService::NoDetails());
}
}
@@ -159,28 +109,6 @@ void PluginUpdater::DisablePluginsFromPolicy(const ListValue* plugin_names) {
}
PluginGroup::SetPolicyDisabledPluginPatterns(policy_disabled_plugin_patterns);
- // Disable all of the plugins and plugin groups that are disabled by policy.
- // There's currenly a bug that makes it impossible to correctly re-enable
- // plugins or plugin-groups to their original, "pre-policy" state, so
- // plugins and grousp are only changed to a more "safe" state after a policy
- // change, i.e. from enabled to disabled. See bug 54681.
- std::vector<WebPluginInfo> plugins;
- NPAPI::PluginList::Singleton()->GetPlugins(false, &plugins);
- for (std::vector<WebPluginInfo>::const_iterator plugin_iter = plugins.begin();
- plugin_iter != plugins.end(); ++plugin_iter) {
- if (PluginGroup::IsPluginNameDisabledByPolicy(plugin_iter->name))
- NPAPI::PluginList::Singleton()->DisablePlugin(plugin_iter->path);
- }
-
- PluginMap plugin_groups;
- GetPluginGroups(&plugin_groups);
- PluginMap::iterator it;
- for (it = plugin_groups.begin(); it != plugin_groups.end(); ++it) {
- string16 current_group_name = it->second->GetGroupName();
- if (PluginGroup::IsPluginNameDisabledByPolicy(current_group_name))
- it->second->Enable(false);
- }
-
NotificationService::current()->Notify(
NotificationType::PLUGIN_ENABLE_STATUS_CHANGED,
Source<PluginUpdater>(this),
@@ -293,13 +221,6 @@ void PluginUpdater::DisablePluginGroupsFromPrefs(Profile* profile) {
UpdatePreferences(profile);
}
-void PluginUpdater::DisableOutdatedPluginGroups() {
- PluginMap groups;
- GetPluginGroups(&groups);
- for (PluginMap::iterator it = groups.begin(); it != groups.end(); ++it)
- it->second->DisableOutdatedPlugins();
-}
-
void PluginUpdater::UpdatePreferences(Profile* profile) {
ListValue* plugins_list = profile->GetPrefs()->GetMutableList(
prefs::kPluginsPluginsList);
@@ -320,9 +241,9 @@ void PluginUpdater::UpdatePreferences(Profile* profile) {
}
// Add the groups as well.
- PluginMap plugin_groups;
- GetPluginGroups(&plugin_groups);
- for (PluginMap::iterator it = plugin_groups.begin();
+ NPAPI::PluginList::PluginMap plugin_groups;
+ NPAPI::PluginList::Singleton()->GetPluginGroups(false, &plugin_groups);
+ for (NPAPI::PluginList::PluginMap::iterator it = plugin_groups.begin();
it != plugin_groups.end(); ++it) {
// Don't save preferences for vulnerable pugins.
if (!CommandLine::ForCurrentProcess()->HasSwitch(
diff --git a/chrome/browser/plugin_updater.h b/chrome/browser/plugin_updater.h
index 74cc286..5ed620b 100644
--- a/chrome/browser/plugin_updater.h
+++ b/chrome/browser/plugin_updater.h
@@ -6,11 +6,8 @@
#define CHROME_BROWSER_PLUGIN_UPDATER_H_
#pragma once
-#include <map>
-
#include "base/basictypes.h"
#include "base/file_path.h"
-#include "base/linked_ptr.h"
#include "base/singleton.h"
#include "chrome/common/notification_observer.h"
@@ -24,11 +21,6 @@ struct WebPluginInfo;
class PluginUpdater : public NotificationObserver {
public:
- typedef std::map<std::string, linked_ptr<PluginGroup> > PluginMap;
-
- // Get a map from identifier to plugin group for all plugin groups.
- static void GetPluginGroups(PluginMap* plugin_groups);
-
// Get a list of all the plugin groups. The caller should take ownership
// of the returned ListValue.
static ListValue* GetPluginGroupsData();
@@ -42,12 +34,6 @@ class PluginUpdater : public NotificationObserver {
// Disable all plugin groups as defined by the user's preference file.
void DisablePluginGroupsFromPrefs(Profile* profile);
- // Disable all plugins groups that are known to be outdated, according to
- // the information hardcoded in PluginGroup, to make sure that they can't
- // be loaded on a web page and instead show a UI to update to the latest
- // version.
- void DisableOutdatedPluginGroups();
-
// Write the enable/disable status to the user's preference file.
void UpdatePreferences(Profile* profile);
diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc
index c1f7d13..2c75bce 100644
--- a/chrome/browser/renderer_host/resource_message_filter.cc
+++ b/chrome/browser/renderer_host/resource_message_filter.cc
@@ -75,7 +75,6 @@
#include "chrome/common/font_loader_mac.h"
#endif
#include "chrome/common/notification_service.h"
-#include "chrome/common/plugin_group.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/render_messages_params.h"
@@ -96,6 +95,7 @@
#include "net/url_request/url_request_context.h"
#include "third_party/WebKit/WebKit/chromium/public/WebNotificationPresenter.h"
#include "webkit/glue/context_menu.h"
+#include "webkit/glue/plugins/plugin_group.h"
#include "webkit/glue/plugins/plugin_list.h"
#include "webkit/glue/plugins/webplugin.h"
#include "webkit/glue/webcookie.h"
diff --git a/chrome/browser/views/content_setting_bubble_contents.cc b/chrome/browser/views/content_setting_bubble_contents.cc
index ef165f8..f285212 100644
--- a/chrome/browser/views/content_setting_bubble_contents.cc
+++ b/chrome/browser/views/content_setting_bubble_contents.cc
@@ -20,7 +20,6 @@
#include "chrome/browser/views/info_bubble.h"
#include "chrome/common/notification_source.h"
#include "chrome/common/notification_type.h"
-#include "chrome/common/plugin_group.h"
#include "grit/generated_resources.h"
#include "views/controls/button/native_button.h"
#include "views/controls/button/radio_button.h"
@@ -209,8 +208,8 @@ void ContentSettingBubbleContents::InitControlLayout() {
for (std::set<std::string>::const_iterator it = plugins.begin();
it != plugins.end(); ++it) {
std::wstring name;
- PluginUpdater::PluginMap groups;
- PluginUpdater::GetPluginUpdater()->GetPluginGroups(&groups);
+ NPAPI::PluginList::PluginMap groups;
+ NPAPI::PluginList::Singleton()->GetPluginGroups(false, &groups);
if (groups.find(*it) != groups.end())
name = UTF16ToWide(groups[*it]->GetGroupName());
else
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index cc9e2c6..e4bc767 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -97,8 +97,6 @@
'common/notification_source.cc',
'common/notification_source.h',
'common/notification_type.h',
- 'common/plugin_group.cc',
- 'common/plugin_group.h',
'common/process_watcher_mac.cc',
'common/process_watcher_posix.cc',
'common/process_watcher_win.cc',
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 2f03cbf..6a04233 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1521,7 +1521,6 @@
'common/net/test_url_fetcher_factory.cc',
'common/net/test_url_fetcher_factory.h',
'common/notification_service_unittest.cc',
- 'common/plugin_group_unittest.cc',
'common/process_watcher_unittest.cc',
'common/property_bag_unittest.cc',
'common/render_messages_unittest.cc',
diff --git a/chrome/renderer/blocked_plugin.cc b/chrome/renderer/blocked_plugin.cc
index 07ff93c..27506d1 100644
--- a/chrome/renderer/blocked_plugin.cc
+++ b/chrome/renderer/blocked_plugin.cc
@@ -10,7 +10,6 @@
#include "base/values.h"
#include "chrome/common/jstemplate_builder.h"
#include "chrome/common/notification_service.h"
-#include "chrome/common/plugin_group.h"
#include "chrome/common/render_messages.h"
#include "chrome/renderer/render_view.h"
#include "grit/generated_resources.h"
@@ -19,6 +18,7 @@
#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h"
#include "third_party/WebKit/WebKit/chromium/public/WebView.h"
+#include "webkit/glue/plugins/plugin_group.h"
#include "webkit/glue/plugins/webview_plugin.h"
#include "webkit/glue/webpreferences.h"
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 9377df5..9d07d18 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -39,7 +39,6 @@
#include "chrome/common/notification_service.h"
#include "chrome/common/page_zoom.h"
#include "chrome/common/pepper_plugin_registry.h"
-#include "chrome/common/plugin_group.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/render_messages_params.h"
#include "chrome/common/renderer_preferences.h"
diff --git a/chrome/common/plugin_group.cc b/webkit/glue/plugins/plugin_group.cc
index a4930146..2639b8f 100644
--- a/chrome/common/plugin_group.cc
+++ b/webkit/glue/plugins/plugin_group.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/common/plugin_group.h"
+#include "webkit/glue/plugins/plugin_group.h"
#include "base/linked_ptr.h"
#include "base/string_util.h"
@@ -414,3 +414,13 @@ void PluginGroup::Enable(bool enable) {
}
}
}
+
+std::vector<FilePath> PluginGroup::GetPaths() const {
+ std::vector<FilePath> rv;
+ for (std::vector<WebPluginInfo>::const_iterator it =
+ web_plugin_infos_.begin();
+ it != web_plugin_infos_.end(); ++it) {
+ rv.push_back(it->path);
+ }
+ return rv;
+}
diff --git a/chrome/common/plugin_group.h b/webkit/glue/plugins/plugin_group.h
index 9691dd7..43640fd 100644
--- a/chrome/common/plugin_group.h
+++ b/webkit/glue/plugins/plugin_group.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_COMMON_PLUGIN_GROUP_H_
-#define CHROME_COMMON_PLUGIN_GROUP_H_
+#ifndef WEBKIT_GLUE_PLUGINS_PLUGIN_GROUP_H_
+#define WEBKIT_GLUE_PLUGINS_PLUGIN_GROUP_H_
#pragma once
#include <map>
@@ -19,6 +19,10 @@ class FilePath;
class Version;
struct WebPluginInfo;
+namespace NPAPI {
+ class PluginList;
+};
+
template <typename T>
class linked_ptr;
@@ -127,6 +131,10 @@ class PluginGroup {
// minimum version.
void DisableOutdatedPlugins();
+ protected:
+ friend class NPAPI::PluginList;
+ std::vector<FilePath> GetPaths() const;
+
private:
FRIEND_TEST_ALL_PREFIXES(PluginGroupTest, PluginGroupDefinition);
@@ -172,4 +180,4 @@ class PluginGroup {
DISALLOW_COPY_AND_ASSIGN(PluginGroup);
};
-#endif // CHROME_COMMON_PLUGIN_GROUP_H_
+#endif // WEBKIT_GLUE_PLUGINS_PLUGIN_GROUP_H_
diff --git a/chrome/common/plugin_group_unittest.cc b/webkit/glue/plugins/plugin_group_unittest.cc
index a42cbaf..a523c73 100644
--- a/chrome/common/plugin_group_unittest.cc
+++ b/webkit/glue/plugins/plugin_group_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/common/plugin_group.h"
+#include "webkit/glue/plugins/plugin_group.h"
#include <string>
#include <vector>
diff --git a/webkit/glue/plugins/plugin_list.cc b/webkit/glue/plugins/plugin_list.cc
index a8d0534..c6ec882 100644
--- a/webkit/glue/plugins/plugin_list.cc
+++ b/webkit/glue/plugins/plugin_list.cc
@@ -11,6 +11,7 @@
#include "base/logging.h"
#include "base/string_split.h"
#include "base/string_util.h"
+#include "base/sys_string_conversions.h"
#include "base/utf_string_conversions.h"
#include "googleurl/src/gurl.h"
#include "net/base/mime_util.h"
@@ -161,7 +162,9 @@ bool PluginList::CreateWebPluginInfo(const PluginVersionInfo& pvi,
}
PluginList::PluginList()
- : plugins_loaded_(false), plugins_need_refresh_(false) {
+ : plugins_loaded_(false),
+ plugins_need_refresh_(false),
+ disable_outdated_plugins_(false) {
PlatformInit();
}
@@ -229,12 +232,43 @@ void PluginList::LoadPlugins(bool refresh) {
// Only update the data now since loading plugins can take a while.
AutoLock lock(lock_);
- // Go through and mark new plugins in the disabled list as, well, disabled.
- for (std::vector<WebPluginInfo>::iterator it = new_plugins.begin();
- it != new_plugins.end();
- ++it) {
- if (disabled_plugins_.find(it->path) != disabled_plugins_.end())
- it->enabled = false;
+ // Mark disabled plugins as such.
+ for (size_t i = 0; i < new_plugins.size(); ++i) {
+ if (disabled_plugins_.count(new_plugins[i].path))
+ new_plugins[i].enabled = false;
+ }
+
+ // Disable all of the plugins and plugin groups that are disabled by policy.
+ // There's currenly a bug that makes it impossible to correctly re-enable
+ // plugins or plugin-groups to their original, "pre-policy" state, so
+ // plugins and groups are only changed to a more "safe" state after a policy
+ // change, i.e. from enabled to disabled. See bug 54681.
+ PluginMap plugin_groups;
+ GetPluginGroups(&new_plugins, &plugin_groups);
+ for (PluginMap::const_iterator it = plugin_groups.begin();
+ it != plugin_groups.end(); ++it) {
+ string16 group_name = it->second->GetGroupName();
+ if (PluginGroup::IsPluginNameDisabledByPolicy(group_name) &&
+ !disabled_groups_.count(group_name)) {
+ disabled_groups_.insert(group_name);
+ }
+
+ if (disabled_groups_.count(group_name)) {
+ // Disable the plugins manually instead of PluginGroup::Enable(false)
+ // since that will need to acquire a lock which we already have.
+ std::vector<FilePath> paths = it->second->GetPaths();
+ for (size_t i = 0; i < paths.size(); ++i) {
+ for (size_t j = 0; j < new_plugins.size(); ++j) {
+ if (new_plugins[j].path == paths[i]) {
+ new_plugins[j].enabled = false;
+ break;
+ }
+ }
+ }
+ }
+
+ if (disable_outdated_plugins_)
+ it->second->DisableOutdatedPlugins();
}
plugins_ = new_plugins;
@@ -420,6 +454,47 @@ bool PluginList::GetPluginInfoByPath(const FilePath& plugin_path,
return false;
}
+void PluginList::GetPluginGroups(bool load_if_necessary,
+ PluginMap* plugin_groups) {
+ if (load_if_necessary)
+ LoadPlugins(false);
+
+ AutoLock lock(lock_);
+ GetPluginGroups(&plugins_, plugin_groups);
+}
+
+// static
+void PluginList::GetPluginGroups(const std::vector<WebPluginInfo>* plugins,
+ PluginMap* plugin_groups) {
+ plugin_groups->clear();
+ // We first search for an existing group that matches our name,
+ // and only create a new group if we can't find any.
+ for (size_t i = 0; i < plugins->size(); ++i) {
+ const WebPluginInfo& web_plugin = (*plugins)[i];
+ PluginGroup* group = PluginGroup::FindGroupMatchingPlugin(
+ *plugin_groups, web_plugin);
+ if (!group) {
+ group = PluginGroup::CopyOrCreatePluginGroup(web_plugin);
+ std::string identifier = group->identifier();
+ // If the identifier is not unique, use the full path. This means that we
+ // probably won't be able to search for this group by identifier, but at
+ // least it's going to be in the set of plugin groups, and if there
+ // is already a plug-in with the same filename, it's probably going to
+ // handle the same MIME types (and it has a higher priority), so this one
+ // is not going to run anyway.
+ if (plugin_groups->find(identifier) != plugin_groups->end())
+#if defined(OS_POSIX)
+ identifier = web_plugin.path.value();
+#elif defined(OS_WIN)
+ identifier = base::SysWideToUTF8(web_plugin.path.value());
+#endif
+ DCHECK(plugin_groups->find(identifier) == plugin_groups->end());
+ (*plugin_groups)[identifier] = linked_ptr<PluginGroup>(group);
+ }
+ group->AddPlugin(web_plugin, i);
+ }
+}
+
bool PluginList::EnablePlugin(const FilePath& filename) {
AutoLock lock(lock_);
@@ -445,9 +520,6 @@ bool PluginList::EnablePlugin(const FilePath& filename) {
return did_enable;
}
-PluginList::~PluginList() {
-}
-
bool PluginList::DisablePlugin(const FilePath& filename) {
AutoLock lock(lock_);
@@ -472,6 +544,46 @@ bool PluginList::DisablePlugin(const FilePath& filename) {
return did_disable;
}
+bool PluginList::EnableGroup(bool enable, const string16& group_name) {
+ bool did_change = false;
+ {
+ AutoLock lock(lock_);
+
+ std::set<string16>::iterator entry = disabled_groups_.find(group_name);
+ if (enable) {
+ if (entry == disabled_groups_.end())
+ return did_change; // Early exit if group not in disabled list.
+ disabled_groups_.erase(entry); // Remove from disabled list.
+ } else {
+ if (entry != disabled_groups_.end())
+ return did_change; // Early exit if group already in disabled list.
+ disabled_groups_.insert(group_name);
+ }
+ }
+
+ PluginMap plugin_groups;
+ GetPluginGroups(false, &plugin_groups);
+ for (PluginMap::const_iterator it = plugin_groups.begin();
+ it != plugin_groups.end(); ++it) {
+ if (it->second->GetGroupName() == group_name) {
+ if (it->second->Enabled() != enable) {
+ it->second->Enable(enable);
+ did_change = true;
+ break;
+ }
+ }
+ }
+
+ return did_change;
+}
+
+void PluginList::DisableOutdatedPluginGroups() {
+ disable_outdated_plugins_ = true;
+}
+
+PluginList::~PluginList() {
+}
+
void PluginList::Shutdown() {
// TODO
}
diff --git a/webkit/glue/plugins/plugin_list.h b/webkit/glue/plugins/plugin_list.h
index c0108ef..a67254f 100644
--- a/webkit/glue/plugins/plugin_list.h
+++ b/webkit/glue/plugins/plugin_list.h
@@ -5,6 +5,7 @@
#ifndef WEBKIT_GLUE_PLUGINS_PLUGIN_LIST_H_
#define WEBKIT_GLUE_PLUGINS_PLUGIN_LIST_H_
+#include <map>
#include <set>
#include <string>
#include <vector>
@@ -12,8 +13,10 @@
#include "base/basictypes.h"
#include "base/file_path.h"
+#include "base/linked_ptr.h"
#include "base/lock.h"
#include "third_party/npapi/bindings/nphostapi.h"
+#include "webkit/glue/plugins/plugin_group.h"
#include "webkit/glue/plugins/webplugininfo.h"
class GURL;
@@ -147,6 +150,14 @@ class PluginList {
bool GetPluginInfoByPath(const FilePath& plugin_path,
WebPluginInfo* info);
+ typedef std::map<std::string, linked_ptr<PluginGroup> > PluginMap;
+
+ // Fill the map from identifier to plugin group for all plugin groups. If
+ // |load_if_necessary| is set, the plugins will be loaded if they haven't
+ // already been loaded, or if Refresh() has been called in the meantime;
+ // otherwise a possibly empty or stale list may be returned.
+ void GetPluginGroups(bool load_if_necessary, PluginMap* plugin_groups);
+
// Load a specific plugin with full path.
void LoadPlugin(const FilePath& filename,
std::vector<WebPluginInfo>* plugins);
@@ -164,6 +175,19 @@ class PluginList {
// will be disabled.
bool DisablePlugin(const FilePath& filename);
+ // Enable/disable a plugin group, specified by group_name. Returns |true| iff
+ // a plugin currently in the plugin list was actually enabled/disabled as a
+ // result; regardless of return value, if a plugin is found in the future with
+ // the given name, it will be enabled/disabled. Note that plugins are enabled
+ // by default as far as |PluginList| is concerned.
+ bool EnableGroup(bool enable, const string16& name);
+
+ // Disable all plugins groups that are known to be outdated, according to
+ // the information hardcoded in PluginGroup, to make sure that they can't
+ // be loaded on a web page and instead show a UI to update to the latest
+ // version.
+ void DisableOutdatedPluginGroups();
+
~PluginList();
private:
@@ -205,6 +229,10 @@ class PluginList {
std::string* actual_mime_type,
WebPluginInfo* info);
+ // Like GetPluginGroups above, but works on a given vector of plugins.
+ static void GetPluginGroups(const std::vector<WebPluginInfo>* plugins,
+ PluginMap* plugin_groups);
+
// Returns true if the given WebPluginInfo supports "mime-type".
// mime_type should be all lower case.
static bool SupportsType(const WebPluginInfo& info,
@@ -268,6 +296,11 @@ class PluginList {
// Path names of plugins to disable (the default is to enable them all).
std::set<FilePath> disabled_plugins_;
+ // Group names disable (the default is to enable them all).
+ std::set<string16> disabled_groups_;
+
+ bool disable_outdated_plugins_;
+
// Need synchronization for the above members since this object can be
// accessed on multiple threads.
Lock lock_;
diff --git a/webkit/glue/webkit_glue.gypi b/webkit/glue/webkit_glue.gypi
index 836ec46..9c1f92e 100644
--- a/webkit/glue/webkit_glue.gypi
+++ b/webkit/glue/webkit_glue.gypi
@@ -251,6 +251,8 @@
'plugins/pepper_widget.cc',
'plugins/pepper_widget.h',
'plugins/plugin_constants_win.h',
+ 'plugins/plugin_group.cc',
+ 'plugins/plugin_group.h',
'plugins/plugin_host.cc',
'plugins/plugin_host.h',
'plugins/plugin_instance.cc',
diff --git a/webkit/tools/test_shell/test_shell.gypi b/webkit/tools/test_shell/test_shell.gypi
index e047d37..d9efb30 100644
--- a/webkit/tools/test_shell/test_shell.gypi
+++ b/webkit/tools/test_shell/test_shell.gypi
@@ -391,6 +391,7 @@
'../../glue/mimetype_unittest.cc',
'../../glue/mock_resource_loader_bridge.h',
'../../glue/multipart_response_delegate_unittest.cc',
+ '../../glue/plugins/plugin_group_unittest.cc',
'../../glue/plugins/plugin_lib_unittest.cc',
'../../glue/plugins/webplugin_impl_unittest.cc',
'../../glue/regular_expression_unittest.cc',