Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Unified Diff: webkit/glue/plugins/plugin_list_linux.cc

Issue 173550: linux: scan more plugin directories, fix bugs (Closed)
Patch Set: fixes Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/native_library_linux.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/plugins/plugin_list_linux.cc
diff --git a/webkit/glue/plugins/plugin_list_linux.cc b/webkit/glue/plugins/plugin_list_linux.cc
index 2a92bbd374c54e251a417e047be54cf175157de2..661c1426b21be13ce90486a9666b3a0aacea10ac 100644
--- a/webkit/glue/plugins/plugin_list_linux.cc
+++ b/webkit/glue/plugins/plugin_list_linux.cc
@@ -7,6 +7,25 @@
#include "base/file_util.h"
#include "base/path_service.h"
+namespace {
+
+// We build up a list of files and mtimes so we can sort them.
+typedef std::pair<FilePath, base::Time> FileAndTime;
+typedef std::vector<FileAndTime> FileTimeList;
+
+// Comparator used to sort by descending mtime then ascending filename.
+bool CompareTime(const FileAndTime& a, const FileAndTime& b) {
+ if (a.second == b.second) {
+ // Fall back on filename sorting, just to make the predicate valid.
+ return a.first < b.first;
+ }
+
+ // Sort by mtime, descending.
+ return a.second > b.second;
+}
+
+}
+
namespace NPAPI {
void PluginList::PlatformInit() {
@@ -38,33 +57,68 @@ void PluginList::GetPluginDirectories(std::vector<FilePath>* plugin_dirs) {
plugin_dirs->push_back(dir.Append("plugins"));
// 4) NS_SYSTEM_PLUGINS_DIR:
- // TODO(evanm): when we support 64-bit platforms, we'll need to fix this
- // to be conditional.
- COMPILE_ASSERT(sizeof(int)==4, fix_system_lib_path);
+ // This varies across different versions of Firefox, so check 'em all.
plugin_dirs->push_back(FilePath("/usr/lib/mozilla/plugins"));
+ plugin_dirs->push_back(FilePath("/usr/lib/firefox/plugins"));
+ plugin_dirs->push_back(FilePath("/usr/lib/xulrunner-addons/plugins"));
}
void PluginList::LoadPluginsFromDir(const FilePath& path,
std::vector<WebPluginInfo>* plugins) {
+ // See ScanPluginsDirectory near
+ // http://mxr.mozilla.org/firefox/source/modules/plugin/base/src/nsPluginHostImpl.cpp#5052
+
+ // Construct and stat a list of all filenames under consideration, for
+ // later sorting by mtime.
+ FileTimeList files;
file_util::FileEnumerator enumerator(path,
false, // not recursive
file_util::FileEnumerator::FILES);
for (FilePath path = enumerator.Next(); !path.value().empty();
path = enumerator.Next()) {
// Skip over Mozilla .xpt files.
- if (!path.MatchesExtension(FILE_PATH_LITERAL(".xpt")))
- LoadPlugin(path, plugins);
+ if (path.MatchesExtension(FILE_PATH_LITERAL(".xpt")))
+ continue;
+
+ // Java doesn't like being loaded through a symlink, since it uses
+ // its path to find dependent data files.
+ // file_util::AbsolutePath calls through to realpath(), which resolves
+ // symlinks.
+ file_util::AbsolutePath(&path);
+
+ // Get mtime.
+ file_util::FileInfo info;
+ if (!file_util::GetFileInfo(path, &info))
+ continue;
+
+ // Skip duplicates of the same file in our list.
+ bool skip = false;
+ for (size_t i = 0; i < plugins->size(); ++i) {
+ if (plugins->at(i).path == path) {
+ skip = true;
+ break;
+ }
+ }
+ if (skip)
+ continue;
+
+ files.push_back(std::make_pair(path, info.last_modified));
+ }
+
+ // Sort the file list by time (and filename).
+ std::sort(files.begin(), files.end(), CompareTime);
+
+ // Load the files in order.
+ for (FileTimeList::const_iterator i = files.begin(); i != files.end(); ++i) {
+ LoadPlugin(i->first, plugins);
}
}
bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info,
std::vector<WebPluginInfo>* plugins) {
- // The equivalent Windows code verifies we haven't loaded a newer version
- // of the same plugin, and then blacklists some known bad plugins.
- // The equivalent Mac code verifies that plugins encountered first in the
- // plugin list clobber later entries.
- // TODO(evanm): figure out which behavior is appropriate for Linux.
- // We don't need either yet as I'm just testing with Flash for now.
+ // TODO(evanm): blacklist nspluginwrapper here?
+ // TODO(evanm): prefer the newest version of flash here?
+
return true;
}
« no previous file with comments | « base/native_library_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698