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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 } | 599 } |
601 | 600 |
602 return false; | 601 return false; |
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); |
| 609 AutoLock lock(lock_); |
610 plugin_groups->clear(); | 610 plugin_groups->clear(); |
611 for (PluginGroup::PluginMap::const_iterator it = plugin_groups_.begin(); | 611 for (PluginGroup::PluginMap::const_iterator it = plugin_groups_.begin(); |
612 it != plugin_groups_.end(); ++it) { | 612 it != plugin_groups_.end(); ++it) { |
613 plugin_groups->push_back(*it->second); | 613 if (!it->second->IsEmpty()) |
| 614 plugin_groups->push_back(*it->second); |
614 } | 615 } |
615 } | 616 } |
616 | 617 |
617 const PluginGroup* PluginList::GetPluginGroup( | 618 const PluginGroup* PluginList::GetPluginGroup( |
618 const WebPluginInfo& web_plugin_info) { | 619 const WebPluginInfo& web_plugin_info) { |
619 AutoLock lock(lock_); | 620 AutoLock lock(lock_); |
620 return AddToPluginGroups(web_plugin_info); | 621 return AddToPluginGroups(web_plugin_info); |
621 } | 622 } |
622 | 623 |
623 string16 PluginList::GetPluginGroupName(std::string identifier) { | 624 string16 PluginList::GetPluginGroupName(std::string identifier) { |
(...skipping 10 matching lines...) Expand all Loading... |
634 PluginGroup* group = AddToPluginGroups(web_plugin_info); | 635 PluginGroup* group = AddToPluginGroups(web_plugin_info); |
635 return group->identifier(); | 636 return group->identifier(); |
636 } | 637 } |
637 | 638 |
638 void PluginList::AddHardcodedPluginGroups() { | 639 void PluginList::AddHardcodedPluginGroups() { |
639 AutoLock lock(lock_); | 640 AutoLock lock(lock_); |
640 const PluginGroupDefinition* definitions = GetPluginGroupDefinitions(); | 641 const PluginGroupDefinition* definitions = GetPluginGroupDefinitions(); |
641 for (size_t i = 0; i < GetPluginGroupDefinitionsSize(); ++i) { | 642 for (size_t i = 0; i < GetPluginGroupDefinitionsSize(); ++i) { |
642 PluginGroup* definition_group = PluginGroup::FromPluginGroupDefinition( | 643 PluginGroup* definition_group = PluginGroup::FromPluginGroupDefinition( |
643 definitions[i]); | 644 definitions[i]); |
| 645 PostInitPluginGroup(definition_group); |
644 std::string identifier = definition_group->identifier(); | 646 std::string identifier = definition_group->identifier(); |
645 DCHECK(plugin_groups_.find(identifier) == plugin_groups_.end()); | 647 DCHECK(plugin_groups_.find(identifier) == plugin_groups_.end()); |
646 plugin_groups_.insert(std::make_pair(identifier, definition_group)); | 648 plugin_groups_.insert(std::make_pair(identifier, definition_group)); |
647 } | 649 } |
648 } | 650 } |
649 | 651 |
650 PluginGroup* PluginList::AddToPluginGroups( | 652 PluginGroup* PluginList::AddToPluginGroups( |
651 const WebPluginInfo& web_plugin_info) { | 653 const WebPluginInfo& web_plugin_info) { |
652 PluginGroup* group = NULL; | 654 PluginGroup* group = NULL; |
653 for (PluginGroup::PluginMap::iterator it = plugin_groups_.begin(); | 655 for (PluginGroup::PluginMap::iterator it = plugin_groups_.begin(); |
654 it != plugin_groups_.end(); ++it) { | 656 it != plugin_groups_.end(); ++it) { |
655 if (it->second->Match(web_plugin_info)) | 657 if (it->second->Match(web_plugin_info)) |
656 group = it->second; | 658 group = it->second; |
657 } | 659 } |
658 if (!group) { | 660 if (!group) { |
659 group = PluginGroup::FromWebPluginInfo(web_plugin_info); | 661 group = PluginGroup::FromWebPluginInfo(web_plugin_info); |
| 662 PostInitPluginGroup(group); |
660 std::string identifier = group->identifier(); | 663 std::string identifier = group->identifier(); |
661 // If the identifier is not unique, use the full path. This means that we | 664 // 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 | 665 // 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 | 666 // 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 | 667 // 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 | 668 // handle the same MIME types (and it has a higher priority), so this one |
666 // is not going to run anyway. | 669 // is not going to run anyway. |
667 if (plugin_groups_.find(identifier) != plugin_groups_.end()) | 670 if (plugin_groups_.find(identifier) != plugin_groups_.end()) |
668 identifier = PluginGroup::GetLongIdentifier(web_plugin_info); | 671 identifier = PluginGroup::GetLongIdentifier(web_plugin_info); |
669 DCHECK(plugin_groups_.find(identifier) == plugin_groups_.end()); | 672 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. | 830 // memory tree green. |
828 #if defined(OS_POSIX) | 831 #if defined(OS_POSIX) |
829 if (RUNNING_ON_VALGRIND) { | 832 if (RUNNING_ON_VALGRIND) { |
830 STLDeleteContainerPairSecondPointers(plugin_groups_.begin(), | 833 STLDeleteContainerPairSecondPointers(plugin_groups_.begin(), |
831 plugin_groups_.end()); | 834 plugin_groups_.end()); |
832 } | 835 } |
833 #endif | 836 #endif |
834 } | 837 } |
835 | 838 |
836 } // namespace NPAPI | 839 } // namespace NPAPI |
OLD | NEW |