summaryrefslogtreecommitdiffstats
path: root/chrome/browser/plugin_updater.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/plugin_updater.cc')
-rw-r--r--chrome/browser/plugin_updater.cc107
1 files changed, 14 insertions, 93 deletions
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(