| 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 "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/sha1.h" | 9 #include "base/sha1.h" |
| 10 #include "base/string_split.h" | 10 #include "base/string_split.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 // But a user reported on their Fedora system they are separate. | 157 // But a user reported on their Fedora system they are separate. |
| 158 plugin_dirs->push_back(FilePath("/usr/lib64/browser-plugins")); | 158 plugin_dirs->push_back(FilePath("/usr/lib64/browser-plugins")); |
| 159 plugin_dirs->push_back(FilePath("/usr/lib64/mozilla/plugins")); | 159 plugin_dirs->push_back(FilePath("/usr/lib64/mozilla/plugins")); |
| 160 plugin_dirs->push_back(FilePath("/usr/lib64/firefox/plugins")); | 160 plugin_dirs->push_back(FilePath("/usr/lib64/firefox/plugins")); |
| 161 plugin_dirs->push_back(FilePath("/usr/lib64/xulrunner-addons/plugins")); | 161 plugin_dirs->push_back(FilePath("/usr/lib64/xulrunner-addons/plugins")); |
| 162 #endif // defined(ARCH_CPU_64_BITS) | 162 #endif // defined(ARCH_CPU_64_BITS) |
| 163 #endif // !defined(OS_CHROMEOS) | 163 #endif // !defined(OS_CHROMEOS) |
| 164 } | 164 } |
| 165 | 165 |
| 166 void PluginList::LoadPluginsFromDir(const FilePath& dir_path, | 166 void PluginList::LoadPluginsFromDir(const FilePath& dir_path, |
| 167 std::vector<WebPluginInfo>* plugins, | 167 std::vector<WebPluginInfo*>* plugins, |
| 168 std::set<FilePath>* visited_plugins) { | 168 std::set<FilePath>* visited_plugins) { |
| 169 // See ScanPluginsDirectory near | 169 // See ScanPluginsDirectory near |
| 170 // http://mxr.mozilla.org/firefox/source/modules/plugin/base/src/nsPluginHostI
mpl.cpp#5052 | 170 // http://mxr.mozilla.org/firefox/source/modules/plugin/base/src/nsPluginHostI
mpl.cpp#5052 |
| 171 | 171 |
| 172 // Construct and stat a list of all filenames under consideration, for | 172 // Construct and stat a list of all filenames under consideration, for |
| 173 // later sorting by mtime. | 173 // later sorting by mtime. |
| 174 FileTimeList files; | 174 FileTimeList files; |
| 175 file_util::FileEnumerator enumerator(dir_path, | 175 file_util::FileEnumerator enumerator(dir_path, |
| 176 false, // not recursive | 176 false, // not recursive |
| 177 file_util::FileEnumerator::FILES); | 177 file_util::FileEnumerator::FILES); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 // Sort the file list by time (and filename). | 231 // Sort the file list by time (and filename). |
| 232 std::sort(files.begin(), files.end(), CompareTime); | 232 std::sort(files.begin(), files.end(), CompareTime); |
| 233 | 233 |
| 234 // Load the files in order. | 234 // Load the files in order. |
| 235 for (FileTimeList::const_iterator i = files.begin(); i != files.end(); ++i) { | 235 for (FileTimeList::const_iterator i = files.begin(); i != files.end(); ++i) { |
| 236 LoadPlugin(i->first, plugins); | 236 LoadPlugin(i->first, plugins); |
| 237 } | 237 } |
| 238 } | 238 } |
| 239 | 239 |
| 240 bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info, | 240 bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info, |
| 241 std::vector<WebPluginInfo>* plugins) { | 241 std::vector<WebPluginInfo*>* plugins) { |
| 242 LOG_IF(ERROR, PluginList::DebugPluginLoading()) | 242 LOG_IF(ERROR, PluginList::DebugPluginLoading()) |
| 243 << "Considering " << info.path.value() << " (" << info.name << ")"; | 243 << "Considering " << info.path.value() << " (" << info.name << ")"; |
| 244 | 244 |
| 245 if (IsUndesirablePlugin(info)) { | 245 if (IsUndesirablePlugin(info)) { |
| 246 LOG_IF(ERROR, PluginList::DebugPluginLoading()) | 246 LOG_IF(ERROR, PluginList::DebugPluginLoading()) |
| 247 << info.path.value() << " is undesirable."; | 247 << info.path.value() << " is undesirable."; |
| 248 | 248 |
| 249 // See if we have a better version of this plugin. | 249 // See if we have a better version of this plugin. |
| 250 for (size_t i = 0; i < plugins->size(); ++i) { | 250 for (std::vector<WebPluginInfo*>::iterator it = plugins->begin(); |
| 251 if (plugins->at(i).name == info.name && | 251 it != plugins->end(); |
| 252 !IsUndesirablePlugin(plugins->at(i))) { | 252 ++it) { |
| 253 if ((*it)->name == info.name && |
| 254 !IsUndesirablePlugin(**it)) { |
| 253 // Skip the current undesirable one so we can use the better one | 255 // Skip the current undesirable one so we can use the better one |
| 254 // we just found. | 256 // we just found. |
| 255 LOG_IF(ERROR, PluginList::DebugPluginLoading()) | 257 LOG_IF(ERROR, PluginList::DebugPluginLoading()) |
| 256 << "Skipping " << info.path.value() << ", preferring " | 258 << "Skipping " << info.path.value() << ", preferring " |
| 257 << plugins->at(i).path.value(); | 259 << (*it)->path.value(); |
| 258 return false; | 260 return false; |
| 259 } | 261 } |
| 260 } | 262 } |
| 261 } | 263 } |
| 262 | 264 |
| 263 // TODO(evanm): prefer the newest version of flash, etc. here? | 265 // TODO(evanm): prefer the newest version of flash, etc. here? |
| 264 | 266 |
| 265 VLOG_IF(1, PluginList::DebugPluginLoading()) << "Using " << info.path.value(); | 267 VLOG_IF(1, PluginList::DebugPluginLoading()) << "Using " << info.path.value(); |
| 266 | 268 |
| 267 return true; | 269 return true; |
| 268 } | 270 } |
| 269 | 271 |
| 270 } // namespace NPAPI | 272 } // namespace NPAPI |
| OLD | NEW |