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

Side by Side Diff: webkit/glue/plugins/plugin_list_posix.cc

Issue 5699005: Policy: Re-enabled plugin still disabled (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed PluginGroup::DisableOutdatedPlugins Created 10 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 PluginGroup::PluginMap::iterator current_group = plugin_groups_.begin();
252 !IsUndesirablePlugin(plugins->at(i))) { 250 for (; current_group != plugin_groups_.end(); ++current_group) {
253 // Skip the current undesirable one so we can use the better one 251 std::list<WebPluginInfo>& group_plugins =
254 // we just found. 252 current_group->second->GetPlugins();
255 LOG_IF(ERROR, PluginList::DebugPluginLoading()) 253 for (std::list<WebPluginInfo>::iterator it = group_plugins.begin();
256 << "Skipping " << info.path.value() << ", preferring " 254 it != group_plugins.end();
257 << plugins->at(i).path.value(); 255 ++it) {
258 return false; 256 if (it->name == info.name &&
257 !IsUndesirablePlugin(*it)) {
258 // Skip the current undesirable one so we can use the better one
259 // we just found.
260 LOG_IF(ERROR, PluginList::DebugPluginLoading())
261 << "Skipping " << info.path.value() << ", preferring "
262 << it->path.value();
263 return false;
264 }
259 } 265 }
260 } 266 }
261 } 267 }
262 268
263 // TODO(evanm): prefer the newest version of flash, etc. here? 269 // TODO(evanm): prefer the newest version of flash, etc. here?
264 270
265 VLOG_IF(1, PluginList::DebugPluginLoading()) << "Using " << info.path.value(); 271 VLOG_IF(1, PluginList::DebugPluginLoading()) << "Using " << info.path.value();
266 272
267 return true; 273 return true;
268 } 274 }
269 275
270 } // namespace NPAPI 276 } // namespace NPAPI
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698