| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "webkit/glue/plugins/plugin_list.h" | 5 #include "webkit/glue/plugins/plugin_list.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 for (std::vector<WebPluginInfo*>::const_iterator it = plugins_.begin(); | 463 for (std::vector<WebPluginInfo*>::const_iterator it = plugins_.begin(); |
| 464 it != plugins_.end(); | 464 it != plugins_.end(); |
| 465 ++it) { | 465 ++it) { |
| 466 plugins->push_back(**it); | 466 plugins->push_back(**it); |
| 467 } | 467 } |
| 468 } | 468 } |
| 469 | 469 |
| 470 void PluginList::GetEnabledPlugins(bool refresh, | 470 void PluginList::GetEnabledPlugins(bool refresh, |
| 471 std::vector<WebPluginInfo>* plugins) { | 471 std::vector<WebPluginInfo>* plugins) { |
| 472 LoadPlugins(refresh); | 472 LoadPlugins(refresh); |
| 473 | |
| 474 plugins->clear(); | 473 plugins->clear(); |
| 475 AutoLock lock(lock_); | 474 AutoLock lock(lock_); |
| 476 for (std::vector<WebPluginInfo*>::const_iterator it = plugins_.begin(); | 475 for (std::vector<WebPluginInfo*>::const_iterator it = plugins_.begin(); |
| 477 it != plugins_.end(); | 476 it != plugins_.end(); |
| 478 ++it) { | 477 ++it) { |
| 479 if ((*it)->enabled) | 478 if ((*it)->enabled) |
| 480 plugins->push_back(**it); | 479 plugins->push_back(**it); |
| 481 } | 480 } |
| 482 } | 481 } |
| 483 | 482 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 } | 602 } |
| 604 | 603 |
| 605 void PluginList::GetPluginGroups( | 604 void PluginList::GetPluginGroups( |
| 606 bool load_if_necessary, | 605 bool load_if_necessary, |
| 607 std::vector<PluginGroup>* plugin_groups) { | 606 std::vector<PluginGroup>* plugin_groups) { |
| 608 if (load_if_necessary) | 607 if (load_if_necessary) |
| 609 LoadPlugins(false); | 608 LoadPlugins(false); |
| 610 plugin_groups->clear(); | 609 plugin_groups->clear(); |
| 611 for (PluginGroup::PluginMap::const_iterator it = plugin_groups_.begin(); | 610 for (PluginGroup::PluginMap::const_iterator it = plugin_groups_.begin(); |
| 612 it != plugin_groups_.end(); ++it) { | 611 it != plugin_groups_.end(); ++it) { |
| 613 plugin_groups->push_back(*it->second); | 612 if (!it->second->IsEmpty()) |
| 613 plugin_groups->push_back(*it->second); |
| 614 } | 614 } |
| 615 } | 615 } |
| 616 | 616 |
| 617 const PluginGroup* PluginList::GetPluginGroup( | 617 const PluginGroup* PluginList::GetPluginGroup( |
| 618 const WebPluginInfo& web_plugin_info) { | 618 const WebPluginInfo& web_plugin_info) { |
| 619 AutoLock lock(lock_); | 619 AutoLock lock(lock_); |
| 620 return AddToPluginGroups(web_plugin_info); | 620 return AddToPluginGroups(web_plugin_info); |
| 621 } | 621 } |
| 622 | 622 |
| 623 string16 PluginList::GetPluginGroupName(std::string identifier) { | 623 string16 PluginList::GetPluginGroupName(std::string identifier) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 634 PluginGroup* group = AddToPluginGroups(web_plugin_info); | 634 PluginGroup* group = AddToPluginGroups(web_plugin_info); |
| 635 return group->identifier(); | 635 return group->identifier(); |
| 636 } | 636 } |
| 637 | 637 |
| 638 void PluginList::AddHardcodedPluginGroups() { | 638 void PluginList::AddHardcodedPluginGroups() { |
| 639 AutoLock lock(lock_); | 639 AutoLock lock(lock_); |
| 640 const PluginGroupDefinition* definitions = GetPluginGroupDefinitions(); | 640 const PluginGroupDefinition* definitions = GetPluginGroupDefinitions(); |
| 641 for (size_t i = 0; i < GetPluginGroupDefinitionsSize(); ++i) { | 641 for (size_t i = 0; i < GetPluginGroupDefinitionsSize(); ++i) { |
| 642 PluginGroup* definition_group = PluginGroup::FromPluginGroupDefinition( | 642 PluginGroup* definition_group = PluginGroup::FromPluginGroupDefinition( |
| 643 definitions[i]); | 643 definitions[i]); |
| 644 PostInitPluginGroup(definition_group); |
| 644 std::string identifier = definition_group->identifier(); | 645 std::string identifier = definition_group->identifier(); |
| 645 DCHECK(plugin_groups_.find(identifier) == plugin_groups_.end()); | 646 DCHECK(plugin_groups_.find(identifier) == plugin_groups_.end()); |
| 646 plugin_groups_.insert(std::make_pair(identifier, definition_group)); | 647 plugin_groups_.insert(std::make_pair(identifier, definition_group)); |
| 647 } | 648 } |
| 648 } | 649 } |
| 649 | 650 |
| 650 PluginGroup* PluginList::AddToPluginGroups( | 651 PluginGroup* PluginList::AddToPluginGroups( |
| 651 const WebPluginInfo& web_plugin_info) { | 652 const WebPluginInfo& web_plugin_info) { |
| 652 PluginGroup* group = NULL; | 653 PluginGroup* group = NULL; |
| 653 for (PluginGroup::PluginMap::iterator it = plugin_groups_.begin(); | 654 for (PluginGroup::PluginMap::iterator it = plugin_groups_.begin(); |
| 654 it != plugin_groups_.end(); ++it) { | 655 it != plugin_groups_.end(); ++it) { |
| 655 if (it->second->Match(web_plugin_info)) | 656 if (it->second->Match(web_plugin_info)) |
| 656 group = it->second; | 657 group = it->second; |
| 657 } | 658 } |
| 658 if (!group) { | 659 if (!group) { |
| 659 group = PluginGroup::FromWebPluginInfo(web_plugin_info); | 660 group = PluginGroup::FromWebPluginInfo(web_plugin_info); |
| 661 PostInitPluginGroup(group); |
| 660 std::string identifier = group->identifier(); | 662 std::string identifier = group->identifier(); |
| 661 // If the identifier is not unique, use the full path. This means that we | 663 // If the identifier is not unique, use the full path. This means that we |
| 662 // probably won't be able to search for this group by identifier, but at | 664 // probably won't be able to search for this group by identifier, but at |
| 663 // least it's going to be in the set of plugin groups, and if there | 665 // least it's going to be in the set of plugin groups, and if there |
| 664 // is already a plug-in with the same filename, it's probably going to | 666 // is already a plug-in with the same filename, it's probably going to |
| 665 // handle the same MIME types (and it has a higher priority), so this one | 667 // handle the same MIME types (and it has a higher priority), so this one |
| 666 // is not going to run anyway. | 668 // is not going to run anyway. |
| 667 if (plugin_groups_.find(identifier) != plugin_groups_.end()) | 669 if (plugin_groups_.find(identifier) != plugin_groups_.end()) |
| 668 identifier = PluginGroup::GetLongIdentifier(web_plugin_info); | 670 identifier = PluginGroup::GetLongIdentifier(web_plugin_info); |
| 669 DCHECK(plugin_groups_.find(identifier) == plugin_groups_.end()); | 671 DCHECK(plugin_groups_.find(identifier) == plugin_groups_.end()); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 // memory tree green. | 829 // memory tree green. |
| 828 #if defined(OS_POSIX) | 830 #if defined(OS_POSIX) |
| 829 if (RUNNING_ON_VALGRIND) { | 831 if (RUNNING_ON_VALGRIND) { |
| 830 STLDeleteContainerPairSecondPointers(plugin_groups_.begin(), | 832 STLDeleteContainerPairSecondPointers(plugin_groups_.begin(), |
| 831 plugin_groups_.end()); | 833 plugin_groups_.end()); |
| 832 } | 834 } |
| 833 #endif | 835 #endif |
| 834 } | 836 } |
| 835 | 837 |
| 836 } // namespace NPAPI | 838 } // namespace NPAPI |
| OLD | NEW |