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