| 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 "content/common/plugin_list.h" | 5 #include "content/common/plugin_list.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <dlfcn.h> | 8 #include <dlfcn.h> |
| 9 #if defined(OS_OPENBSD) | 9 #if defined(OS_OPENBSD) |
| 10 #include <sys/exec_elf.h> | 10 #include <sys/exec_elf.h> |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "base/strings/stringprintf.h" | 28 #include "base/strings/stringprintf.h" |
| 29 #include "base/strings/sys_string_conversions.h" | 29 #include "base/strings/sys_string_conversions.h" |
| 30 #include "base/strings/utf_string_conversions.h" | 30 #include "base/strings/utf_string_conversions.h" |
| 31 #include "build/build_config.h" | 31 #include "build/build_config.h" |
| 32 #include "third_party/npapi/bindings/nphostapi.h" | 32 #include "third_party/npapi/bindings/nphostapi.h" |
| 33 | 33 |
| 34 // These headers must be included in this order to make the declaration gods | 34 // These headers must be included in this order to make the declaration gods |
| 35 // happy. | 35 // happy. |
| 36 #include "base/third_party/nspr/prcpucfg_linux.h" | 36 #include "base/third_party/nspr/prcpucfg_linux.h" |
| 37 | 37 |
| 38 using webkit::WebPluginInfo; | |
| 39 using webkit::WebPluginMimeType; | |
| 40 | |
| 41 namespace content { | 38 namespace content { |
| 42 | 39 |
| 43 namespace { | 40 namespace { |
| 44 | 41 |
| 45 // We build up a list of files and mtimes so we can sort them. | 42 // We build up a list of files and mtimes so we can sort them. |
| 46 typedef std::pair<base::FilePath, base::Time> FileAndTime; | 43 typedef std::pair<base::FilePath, base::Time> FileAndTime; |
| 47 typedef std::vector<FileAndTime> FileTimeList; | 44 typedef std::vector<FileAndTime> FileTimeList; |
| 48 | 45 |
| 49 enum PluginQuirk { | 46 enum PluginQuirk { |
| 50 // No quirks - plugin is outright banned. | 47 // No quirks - plugin is outright banned. |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 // Sort the file list by time (and filename). | 554 // Sort the file list by time (and filename). |
| 558 std::sort(files.begin(), files.end(), CompareTime); | 555 std::sort(files.begin(), files.end(), CompareTime); |
| 559 | 556 |
| 560 // Load the files in order. | 557 // Load the files in order. |
| 561 for (FileTimeList::const_iterator i = files.begin(); i != files.end(); ++i) { | 558 for (FileTimeList::const_iterator i = files.begin(); i != files.end(); ++i) { |
| 562 plugins->push_back(i->first); | 559 plugins->push_back(i->first); |
| 563 } | 560 } |
| 564 } | 561 } |
| 565 | 562 |
| 566 bool PluginList::ShouldLoadPluginUsingPluginList( | 563 bool PluginList::ShouldLoadPluginUsingPluginList( |
| 567 const WebPluginInfo& info, std::vector<webkit::WebPluginInfo>* plugins) { | 564 const WebPluginInfo& info, std::vector<WebPluginInfo>* plugins) { |
| 568 LOG_IF(ERROR, PluginList::DebugPluginLoading()) | 565 LOG_IF(ERROR, PluginList::DebugPluginLoading()) |
| 569 << "Considering " << info.path.value() << " (" << info.name << ")"; | 566 << "Considering " << info.path.value() << " (" << info.name << ")"; |
| 570 | 567 |
| 571 if (IsUndesirablePlugin(info)) { | 568 if (IsUndesirablePlugin(info)) { |
| 572 LOG_IF(ERROR, PluginList::DebugPluginLoading()) | 569 LOG_IF(ERROR, PluginList::DebugPluginLoading()) |
| 573 << info.path.value() << " is undesirable."; | 570 << info.path.value() << " is undesirable."; |
| 574 | 571 |
| 575 // See if we have a better version of this plugin. | 572 // See if we have a better version of this plugin. |
| 576 for (size_t j = 0; j < plugins->size(); ++j) { | 573 for (size_t j = 0; j < plugins->size(); ++j) { |
| 577 if ((*plugins)[j].name == info.name && | 574 if ((*plugins)[j].name == info.name && |
| 578 !IsUndesirablePlugin((*plugins)[j])) { | 575 !IsUndesirablePlugin((*plugins)[j])) { |
| 579 // Skip the current undesirable one so we can use the better one | 576 // Skip the current undesirable one so we can use the better one |
| 580 // we just found. | 577 // we just found. |
| 581 LOG_IF(ERROR, PluginList::DebugPluginLoading()) | 578 LOG_IF(ERROR, PluginList::DebugPluginLoading()) |
| 582 << "Skipping " << info.path.value() << ", preferring " | 579 << "Skipping " << info.path.value() << ", preferring " |
| 583 << (*plugins)[j].path.value(); | 580 << (*plugins)[j].path.value(); |
| 584 return false; | 581 return false; |
| 585 } | 582 } |
| 586 } | 583 } |
| 587 } | 584 } |
| 588 | 585 |
| 589 // TODO(evanm): prefer the newest version of flash, etc. here? | 586 // TODO(evanm): prefer the newest version of flash, etc. here? |
| 590 | 587 |
| 591 VLOG_IF(1, PluginList::DebugPluginLoading()) << "Using " << info.path.value(); | 588 VLOG_IF(1, PluginList::DebugPluginLoading()) << "Using " << info.path.value(); |
| 592 | 589 |
| 593 return true; | 590 return true; |
| 594 } | 591 } |
| 595 | 592 |
| 596 } // namespace content | 593 } // namespace content |
| OLD | NEW |