| Index: webkit/glue/plugins/plugin_list.cc
|
| diff --git a/webkit/glue/plugins/plugin_list.cc b/webkit/glue/plugins/plugin_list.cc
|
| index 84736cbd61f1e4ffcffa646a4b3b40cd6bbd949e..2b2f3fabf707813e31532be6cf7ca8d836b29538 100644
|
| --- a/webkit/glue/plugins/plugin_list.cc
|
| +++ b/webkit/glue/plugins/plugin_list.cc
|
| @@ -157,8 +157,10 @@ bool PluginList::CreateWebPluginInfo(const PluginVersionInfo& pvi,
|
| PluginList::PluginList()
|
| : plugins_loaded_(false),
|
| plugins_need_refresh_(false),
|
| - disable_outdated_plugins_(false) {
|
| + disable_outdated_plugins_(false),
|
| + next_priority_(0) {
|
| PlatformInit();
|
| + AddHardcodedPluginGroups();
|
| }
|
|
|
| bool PluginList::ShouldDisableGroup(const string16& group_name) {
|
| @@ -233,34 +235,26 @@ void PluginList::LoadPlugins(bool refresh) {
|
| // 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) {
|
| - PluginGroup* group = it->second.get();
|
| + for (PluginGroup::PluginMap::iterator it = plugin_groups_.begin();
|
| + it != plugin_groups_.end(); ++it) {
|
| + PluginGroup* group = it->second;
|
| string16 group_name = group->GetGroupName();
|
| if (ShouldDisableGroup(group_name)) {
|
| - it->second->Enable(false);
|
| + group->Enable(false);
|
| }
|
|
|
| if (disable_outdated_plugins_) {
|
| group->DisableOutdatedPlugins();
|
| - if (!group->Enabled()) {
|
| - AutoLock lock(lock_);
|
| - disabled_groups_.insert(group_name);
|
| - }
|
| + }
|
| + if (!group->Enabled()) {
|
| + AutoLock lock(lock_);
|
| + disabled_groups_.insert(group_name);
|
| }
|
| }
|
|
|
| // Only update the data now since loading plugins can take a while.
|
| AutoLock lock(lock_);
|
|
|
| - // 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;
|
| - }
|
| -
|
| plugins_ = new_plugins;
|
| plugins_loaded_ = true;
|
| }
|
| @@ -294,7 +288,16 @@ void PluginList::LoadPlugin(const FilePath& path,
|
| }
|
| }
|
|
|
| + // Mark disabled plugins as such. (This has to happen before calling
|
| + // |AddToPluginGroups(plugin_info)|.)
|
| + if (disabled_plugins_.count(plugin_info.path)) {
|
| + plugin_info.enabled = false;
|
| + } else {
|
| + plugin_info.enabled = true;
|
| + }
|
| +
|
| plugins->push_back(plugin_info);
|
| + AddToPluginGroups(plugin_info);
|
| }
|
|
|
| bool PluginList::SupportsType(const WebPluginInfo& info,
|
| @@ -476,45 +479,75 @@ bool PluginList::GetPluginInfoByPath(const FilePath& plugin_path,
|
| return false;
|
| }
|
|
|
| -void PluginList::GetPluginGroups(bool load_if_necessary,
|
| - PluginMap* plugin_groups) {
|
| +void PluginList::GetPluginGroups(
|
| + bool load_if_necessary,
|
| + std::vector<PluginGroup>* plugin_groups) {
|
| if (load_if_necessary)
|
| LoadPlugins(false);
|
| + plugin_groups->clear();
|
| + for (PluginGroup::PluginMap::const_iterator it = plugin_groups_.begin();
|
| + it != plugin_groups_.end(); ++it) {
|
| + plugin_groups->push_back(*it->second);
|
| + }
|
| +}
|
| +
|
| +const PluginGroup* PluginList::GetPluginGroup(
|
| + const WebPluginInfo& web_plugin_info) {
|
| + return AddToPluginGroups(web_plugin_info);
|
| +}
|
|
|
| +string16 PluginList::GetPluginGroupName(std::string identifier) {
|
| + PluginGroup::PluginMap::iterator it = plugin_groups_.find(identifier);
|
| + if (it == plugin_groups_.end()) {
|
| + return string16();
|
| + }
|
| + return it->second->GetGroupName();
|
| +}
|
| +
|
| +std::string PluginList::GetPluginGroupIdentifier(
|
| + const WebPluginInfo& web_plugin_info) {
|
| + PluginGroup* group = AddToPluginGroups(web_plugin_info);
|
| + return group->identifier();
|
| +}
|
| +
|
| +void PluginList::AddHardcodedPluginGroups() {
|
| AutoLock lock(lock_);
|
| - GetPluginGroups(&plugins_, plugin_groups);
|
| + const PluginGroupDefinition* definitions =
|
| + PluginGroup::GetPluginGroupDefinitions();
|
| + for (size_t i = 0; i < PluginGroup::GetPluginGroupDefinitionsSize(); ++i) {
|
| + PluginGroup* definition_group = PluginGroup::FromPluginGroupDefinition(
|
| + definitions[i]);
|
| + std::string identifier = definition_group->identifier();
|
| + DCHECK(plugin_groups_.find(identifier) == plugin_groups_.end());
|
| + plugin_groups_.insert(std::make_pair(identifier, definition_group));
|
| + }
|
| }
|
|
|
| -// 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);
|
| +PluginGroup* PluginList::AddToPluginGroups(
|
| + const WebPluginInfo& web_plugin_info) {
|
| + AutoLock lock(lock_);
|
| + PluginGroup* group = NULL;
|
| + for (PluginGroup::PluginMap::iterator it = plugin_groups_.begin();
|
| + it != plugin_groups_.end(); ++it) {
|
| + if (it->second->Match(web_plugin_info))
|
| + group = it->second;
|
| + }
|
| + if (!group) {
|
| + group = PluginGroup::FromWebPluginInfo(web_plugin_info);
|
| + 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())
|
| + identifier = PluginGroup::GetLongIdentifier(web_plugin_info);
|
| + DCHECK(plugin_groups_.find(identifier) == plugin_groups_.end());
|
| + plugin_groups_.insert(std::make_pair(identifier, group));
|
| }
|
| + group->AddPlugin(web_plugin_info, next_priority_++);
|
| + return group;
|
| }
|
|
|
| bool PluginList::EnablePlugin(const FilePath& filename) {
|
| @@ -583,10 +616,8 @@ bool PluginList::EnableGroup(bool enable, const string16& group_name) {
|
| }
|
| }
|
|
|
| - PluginMap plugin_groups;
|
| - GetPluginGroups(false, &plugin_groups);
|
| - for (PluginMap::const_iterator it = plugin_groups.begin();
|
| - it != plugin_groups.end(); ++it) {
|
| + for (PluginGroup::PluginMap::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);
|
| @@ -608,6 +639,9 @@ PluginList::~PluginList() {
|
|
|
| void PluginList::Shutdown() {
|
| // TODO
|
| + // Note: plugin_groups_ contains simple pointers of type PluginGroup*, but
|
| + // since this singleton lives until the process is destroyed, no explicit
|
| + // cleanup is necessary.
|
| }
|
|
|
| } // namespace NPAPI
|
|
|