| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/plugins/npapi/plugin_list.h" | 5 #include "webkit/plugins/npapi/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 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 // In some unit tests we can get confronted with empty groups but in real | 528 // In some unit tests we can get confronted with empty groups but in real |
| 529 // world code this if should never be false here. | 529 // world code this if should never be false here. |
| 530 if (!plugin_groups_[i]->IsEmpty()) | 530 if (!plugin_groups_[i]->IsEmpty()) |
| 531 plugin_groups->push_back(*plugin_groups_[i]); | 531 plugin_groups->push_back(*plugin_groups_[i]); |
| 532 } | 532 } |
| 533 } | 533 } |
| 534 | 534 |
| 535 PluginGroup* PluginList::GetPluginGroup( | 535 PluginGroup* PluginList::GetPluginGroup( |
| 536 const webkit::WebPluginInfo& web_plugin_info) { | 536 const webkit::WebPluginInfo& web_plugin_info) { |
| 537 base::AutoLock lock(lock_); | 537 base::AutoLock lock(lock_); |
| 538 for (size_t i = 0; i < plugin_groups_->size(); ++i) { | 538 for (size_t i = 0; i < plugin_groups_.size(); ++i) { |
| 539 const std::vector<webkit::WebPluginInfo>& plugins = | 539 const std::vector<webkit::WebPluginInfo>& plugins = |
| 540 plugin_groups_[i]->web_plugin_infos(); | 540 plugin_groups_[i]->web_plugin_infos(); |
| 541 for (size_t j = 0; j < plugins.size(); ++j) { | 541 for (size_t j = 0; j < plugins.size(); ++j) { |
| 542 if (plugins[j].path == web_plugin_info.path) { | 542 if (plugins[j].path == web_plugin_info.path) { |
| 543 return new PluginGroup(*plugin_groups_[i]); | 543 return new PluginGroup(*plugin_groups_[i]); |
| 544 } | 544 } |
| 545 } | 545 } |
| 546 } | 546 } |
| 547 PluginGroup* group = CreatePluginGroup(web_plugin_info); | 547 PluginGroup* group = CreatePluginGroup(web_plugin_info); |
| 548 group->AddPlugin(web_plugin_info); | 548 group->AddPlugin(web_plugin_info); |
| 549 return group; | 549 return group; |
| 550 } | 550 } |
| 551 | 551 |
| 552 string16 PluginList::GetPluginGroupName(const std::string& identifier) { | 552 string16 PluginList::GetPluginGroupName(const std::string& identifier) { |
| 553 for (size_t i = 0; i < plugin_groups_.size(); ++i) { | 553 for (size_t i = 0; i < plugin_groups_.size(); ++i) { |
| 554 if (plugin_groups_[i]->identifier() == identifier) | 554 if (plugin_groups_[i]->identifier() == identifier) |
| 555 return plugin_groups_[i]->GetGroupName(); | 555 return plugin_groups_[i]->GetGroupName(); |
| 556 } | 556 } |
| 557 return string16(); | 557 return string16(); |
| 558 } | 558 } |
| 559 | 559 |
| 560 void PluginList::AddHardcodedPluginGroups( | 560 void PluginList::AddHardcodedPluginGroups( |
| 561 const PluginGroupDefinition* group_definitions, | 561 const PluginGroupDefinition* group_definitions, |
| 562 size_t num_group_definitions) { | 562 size_t num_group_definitions) { |
| 563 for (size_t i = 0; i < num_group_definitions; ++i) { | 563 for (size_t i = 0; i < num_group_definitions; ++i) { |
| 564 hardcoded_plugin_groups_->push_back( | 564 hardcoded_plugin_groups_.push_back( |
| 565 PluginGroup::FromPluginGroupDefinition(group_definitions[i])); | 565 PluginGroup::FromPluginGroupDefinition(group_definitions[i])); |
| 566 } | 566 } |
| 567 } | 567 } |
| 568 | 568 |
| 569 PluginGroup* PluginList::AddToPluginGroups( | 569 PluginGroup* PluginList::AddToPluginGroups( |
| 570 const webkit::WebPluginInfo& web_plugin_info, | 570 const webkit::WebPluginInfo& web_plugin_info, |
| 571 ScopedVector<PluginGroup>* plugin_groups) { | 571 ScopedVector<PluginGroup>* plugin_groups) { |
| 572 PluginGroup* group = NULL; | 572 PluginGroup* group = NULL; |
| 573 for (size_t i = 0; i < plugin_groups->size(); ++i) { | 573 for (size_t i = 0; i < plugin_groups->size(); ++i) { |
| 574 if ((*plugin_groups)[i]->Match(web_plugin_info)) { | 574 if ((*plugin_groups)[i]->Match(web_plugin_info)) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 } | 630 } |
| 631 return false; | 631 return false; |
| 632 } | 632 } |
| 633 | 633 |
| 634 PluginList::~PluginList() { | 634 PluginList::~PluginList() { |
| 635 } | 635 } |
| 636 | 636 |
| 637 | 637 |
| 638 } // namespace npapi | 638 } // namespace npapi |
| 639 } // namespace webkit | 639 } // namespace webkit |
| OLD | NEW |