OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 LoadPlugins(); | 512 LoadPlugins(); |
513 base::AutoLock lock(lock_); | 513 base::AutoLock lock(lock_); |
514 if (use_stale) | 514 if (use_stale) |
515 *use_stale = plugins_need_refresh_; | 515 *use_stale = plugins_need_refresh_; |
516 info->clear(); | 516 info->clear(); |
517 if (actual_mime_types) | 517 if (actual_mime_types) |
518 actual_mime_types->clear(); | 518 actual_mime_types->clear(); |
519 | 519 |
520 std::set<FilePath> visited_plugins; | 520 std::set<FilePath> visited_plugins; |
521 | 521 |
522 // Add in enabled plugins by mime type. | 522 // Add in plugins by mime type. |
523 for (size_t i = 0; i < plugin_groups_.size(); ++i) { | 523 for (size_t i = 0; i < plugin_groups_.size(); ++i) { |
524 const std::vector<webkit::WebPluginInfo>& plugins = | 524 const std::vector<webkit::WebPluginInfo>& plugins = |
525 plugin_groups_[i]->web_plugins_info(); | 525 plugin_groups_[i]->web_plugins_info(); |
526 for (size_t i = 0; i < plugins.size(); ++i) { | 526 for (size_t i = 0; i < plugins.size(); ++i) { |
527 if (IsPluginEnabled(plugins[i]) && SupportsType(plugins[i], | 527 if (SupportsType(plugins[i], mime_type, allow_wildcard)) { |
528 mime_type, allow_wildcard)) { | |
529 FilePath path = plugins[i].path; | 528 FilePath path = plugins[i].path; |
530 if (path.value() != kDefaultPluginLibraryName && | 529 if (path.value() != kDefaultPluginLibraryName && |
531 visited_plugins.insert(path).second) { | 530 visited_plugins.insert(path).second) { |
532 info->push_back(plugins[i]); | 531 info->push_back(plugins[i]); |
533 if (actual_mime_types) | 532 if (actual_mime_types) |
534 actual_mime_types->push_back(mime_type); | 533 actual_mime_types->push_back(mime_type); |
535 } | 534 } |
536 } | 535 } |
537 } | 536 } |
538 } | 537 } |
539 | 538 |
540 // Add in enabled plugins by url. | 539 // Add in plugins by url. |
541 std::string path = url.path(); | 540 std::string path = url.path(); |
542 std::string::size_type last_dot = path.rfind('.'); | 541 std::string::size_type last_dot = path.rfind('.'); |
543 if (last_dot != std::string::npos) { | 542 if (last_dot != std::string::npos) { |
544 std::string extension = StringToLowerASCII(std::string(path, last_dot+1)); | 543 std::string extension = StringToLowerASCII(std::string(path, last_dot+1)); |
545 std::string actual_mime_type; | 544 std::string actual_mime_type; |
546 for (size_t i = 0; i < plugin_groups_.size(); ++i) { | 545 for (size_t i = 0; i < plugin_groups_.size(); ++i) { |
547 const std::vector<webkit::WebPluginInfo>& plugins = | 546 const std::vector<webkit::WebPluginInfo>& plugins = |
548 plugin_groups_[i]->web_plugins_info(); | 547 plugin_groups_[i]->web_plugins_info(); |
549 for (size_t i = 0; i < plugins.size(); ++i) { | 548 for (size_t i = 0; i < plugins.size(); ++i) { |
550 if (IsPluginEnabled(plugins[i]) && | 549 if (SupportsExtension(plugins[i], extension, &actual_mime_type)) { |
551 SupportsExtension(plugins[i], extension, &actual_mime_type)) { | |
552 FilePath path = plugins[i].path; | 550 FilePath path = plugins[i].path; |
553 if (path.value() != kDefaultPluginLibraryName && | 551 if (path.value() != kDefaultPluginLibraryName && |
554 visited_plugins.insert(path).second) { | 552 visited_plugins.insert(path).second) { |
555 info->push_back(plugins[i]); | 553 info->push_back(plugins[i]); |
556 if (actual_mime_types) | 554 if (actual_mime_types) |
557 actual_mime_types->push_back(actual_mime_type); | 555 actual_mime_types->push_back(actual_mime_type); |
558 } | 556 } |
559 } | 557 } |
560 } | 558 } |
561 } | 559 } |
562 } | 560 } |
563 | 561 |
564 // Add in disabled plugins by mime type. | |
565 for (size_t i = 0; i < plugin_groups_.size(); ++i) { | |
566 const std::vector<webkit::WebPluginInfo>& plugins = | |
567 plugin_groups_[i]->web_plugins_info(); | |
568 for (size_t i = 0; i < plugins.size(); ++i) { | |
569 if (!IsPluginEnabled(plugins[i]) && | |
570 SupportsType(plugins[i], mime_type, allow_wildcard)) { | |
571 FilePath path = plugins[i].path; | |
572 if (path.value() != kDefaultPluginLibraryName && | |
573 visited_plugins.insert(path).second) { | |
574 info->push_back(plugins[i]); | |
575 if (actual_mime_types) | |
576 actual_mime_types->push_back(mime_type); | |
577 } | |
578 } | |
579 } | |
580 } | |
581 | |
582 // Add the default plugin at the end if it supports the mime type given, | 562 // Add the default plugin at the end if it supports the mime type given, |
583 // and the default plugin is enabled. | 563 // and the default plugin is enabled. |
584 for (size_t i = 0; i < plugin_groups_.size(); ++i) { | 564 for (size_t i = 0; i < plugin_groups_.size(); ++i) { |
585 #if defined(OS_WIN) | 565 #if defined(OS_WIN) |
586 if (plugin_groups_[i]->identifier().compare( | 566 if (plugin_groups_[i]->identifier().compare( |
587 WideToUTF8(kDefaultPluginLibraryName)) == 0) { | 567 WideToUTF8(kDefaultPluginLibraryName)) == 0) { |
588 #else | 568 #else |
589 if (plugin_groups_[i]->identifier().compare( | 569 if (plugin_groups_[i]->identifier().compare( |
590 kDefaultPluginLibraryName) == 0) { | 570 kDefaultPluginLibraryName) == 0) { |
591 #endif | 571 #endif |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 } | 757 } |
778 return false; | 758 return false; |
779 } | 759 } |
780 | 760 |
781 PluginList::~PluginList() { | 761 PluginList::~PluginList() { |
782 } | 762 } |
783 | 763 |
784 | 764 |
785 } // namespace npapi | 765 } // namespace npapi |
786 } // namespace webkit | 766 } // namespace webkit |
OLD | NEW |