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, | |
168 std::set<FilePath>* visited_plugins) { | 167 std::set<FilePath>* visited_plugins) { |
169 // See ScanPluginsDirectory near | 168 // See ScanPluginsDirectory near |
170 // http://mxr.mozilla.org/firefox/source/modules/plugin/base/src/nsPluginHostI mpl.cpp#5052 | 169 // http://mxr.mozilla.org/firefox/source/modules/plugin/base/src/nsPluginHostI mpl.cpp#5052 |
171 | 170 |
172 // Construct and stat a list of all filenames under consideration, for | 171 // Construct and stat a list of all filenames under consideration, for |
173 // later sorting by mtime. | 172 // later sorting by mtime. |
174 FileTimeList files; | 173 FileTimeList files; |
175 file_util::FileEnumerator enumerator(dir_path, | 174 file_util::FileEnumerator enumerator(dir_path, |
176 false, // not recursive | 175 false, // not recursive |
177 file_util::FileEnumerator::FILES); | 176 file_util::FileEnumerator::FILES); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
226 continue; | 225 continue; |
227 | 226 |
228 files.push_back(std::make_pair(path, info.last_modified)); | 227 files.push_back(std::make_pair(path, info.last_modified)); |
229 } | 228 } |
230 | 229 |
231 // Sort the file list by time (and filename). | 230 // Sort the file list by time (and filename). |
232 std::sort(files.begin(), files.end(), CompareTime); | 231 std::sort(files.begin(), files.end(), CompareTime); |
233 | 232 |
234 // Load the files in order. | 233 // Load the files in order. |
235 for (FileTimeList::const_iterator i = files.begin(); i != files.end(); ++i) { | 234 for (FileTimeList::const_iterator i = files.begin(); i != files.end(); ++i) { |
236 LoadPlugin(i->first, plugins); | 235 LoadPlugin(i->first); |
237 } | 236 } |
238 } | 237 } |
239 | 238 |
240 bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info, | 239 bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info) { |
241 std::vector<WebPluginInfo>* plugins) { | |
242 LOG_IF(ERROR, PluginList::DebugPluginLoading()) | 240 LOG_IF(ERROR, PluginList::DebugPluginLoading()) |
243 << "Considering " << info.path.value() << " (" << info.name << ")"; | 241 << "Considering " << info.path.value() << " (" << info.name << ")"; |
244 | 242 |
245 if (IsUndesirablePlugin(info)) { | 243 if (IsUndesirablePlugin(info)) { |
246 LOG_IF(ERROR, PluginList::DebugPluginLoading()) | 244 LOG_IF(ERROR, PluginList::DebugPluginLoading()) |
247 << info.path.value() << " is undesirable."; | 245 << info.path.value() << " is undesirable."; |
248 | 246 |
249 // See if we have a better version of this plugin. | 247 // See if we have a better version of this plugin. |
250 for (size_t i = 0; i < plugins->size(); ++i) { | 248 std::vector<WebPluginInfo*> new_plugins; |
251 if (plugins->at(i).name == info.name && | 249 for (PluginGroup::PluginMap::iterator it = plugin_groups_.begin(); |
danno
2010/12/14 09:43:39
now that you have two iterators, you probably want
pastarmovj
2010/12/15 14:44:51
Done. I guess current_curent meant to be current_g
| |
252 !IsUndesirablePlugin(plugins->at(i))) { | 250 it != plugin_groups_.end(); ++it) { |
253 // Skip the current undesirable one so we can use the better one | 251 std::vector<WebPluginInfo>& group_plugins = it->second->GetPlugins(); |
254 // we just found. | 252 for (std::vector<WebPluginInfo>::iterator itp = group_plugins.begin(); |
255 LOG_IF(ERROR, PluginList::DebugPluginLoading()) | 253 itp != group_plugins.end(); |
256 << "Skipping " << info.path.value() << ", preferring " | 254 ++itp) { |
257 << plugins->at(i).path.value(); | 255 if (itp->name == info.name && |
258 return false; | 256 !IsUndesirablePlugin(*itp)) { |
257 // Skip the current undesirable one so we can use the better one | |
258 // we just found. | |
259 LOG_IF(ERROR, PluginList::DebugPluginLoading()) | |
260 << "Skipping " << info.path.value() << ", preferring " | |
261 << itp->path.value(); | |
262 return false; | |
263 } | |
259 } | 264 } |
260 } | 265 } |
261 } | 266 } |
262 | 267 |
263 // TODO(evanm): prefer the newest version of flash, etc. here? | 268 // TODO(evanm): prefer the newest version of flash, etc. here? |
264 | 269 |
265 VLOG_IF(1, PluginList::DebugPluginLoading()) << "Using " << info.path.value(); | 270 VLOG_IF(1, PluginList::DebugPluginLoading()) << "Using " << info.path.value(); |
266 | 271 |
267 return true; | 272 return true; |
268 } | 273 } |
269 | 274 |
270 } // namespace NPAPI | 275 } // namespace NPAPI |
OLD | NEW |