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

Side by Side Diff: webkit/plugins/npapi/plugin_list_win.cc

Issue 5699005: Policy: Re-enabled plugin still disabled (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Whitespace fixes only. Trybot happiness still applies. Created 9 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/plugins/npapi/plugin_list_unittest.cc ('k') | webkit/plugins/npapi/webplugininfo.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/plugins/npapi/plugin_list.h" 5 #include "webkit/plugins/npapi/plugin_list.h"
6 6
7 #include <tchar.h> 7 #include <tchar.h>
8 8
9 #include <set> 9 #include <set>
10 10
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 // the plugins are found. We are going to copy this as well. 243 // the plugins are found. We are going to copy this as well.
244 GetAcrobatDirectory(&dirs); 244 GetAcrobatDirectory(&dirs);
245 GetQuicktimeDirectory(&dirs); 245 GetQuicktimeDirectory(&dirs);
246 GetWindowsMediaDirectory(&dirs); 246 GetWindowsMediaDirectory(&dirs);
247 247
248 for (std::set<FilePath>::iterator i = dirs.begin(); i != dirs.end(); ++i) 248 for (std::set<FilePath>::iterator i = dirs.begin(); i != dirs.end(); ++i)
249 plugin_dirs->push_back(*i); 249 plugin_dirs->push_back(*i);
250 } 250 }
251 251
252 void PluginList::LoadPluginsFromDir(const FilePath &path, 252 void PluginList::LoadPluginsFromDir(const FilePath &path,
253 std::vector<WebPluginInfo>* plugins, 253 ScopedVector<PluginGroup>* plugin_groups,
254 std::set<FilePath>* visited_plugins) { 254 std::set<FilePath>* visited_plugins) {
255 WIN32_FIND_DATA find_file_data; 255 WIN32_FIND_DATA find_file_data;
256 HANDLE find_handle; 256 HANDLE find_handle;
257 257
258 std::wstring dir = path.value(); 258 std::wstring dir = path.value();
259 // FindFirstFile requires that you specify a wildcard for directories. 259 // FindFirstFile requires that you specify a wildcard for directories.
260 dir.append(L"\\NP*.DLL"); 260 dir.append(L"\\NP*.DLL");
261 261
262 find_handle = FindFirstFile(dir.c_str(), &find_file_data); 262 find_handle = FindFirstFile(dir.c_str(), &find_file_data);
263 if (find_handle == INVALID_HANDLE_VALUE) 263 if (find_handle == INVALID_HANDLE_VALUE)
264 return; 264 return;
265 265
266 do { 266 do {
267 if (!(find_file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { 267 if (!(find_file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
268 FilePath filename = path.Append(find_file_data.cFileName); 268 FilePath filename = path.Append(find_file_data.cFileName);
269 LoadPlugin(filename, plugins); 269 LoadPlugin(filename, plugin_groups);
270 visited_plugins->insert(filename); 270 visited_plugins->insert(filename);
271 } 271 }
272 } while (FindNextFile(find_handle, &find_file_data) != 0); 272 } while (FindNextFile(find_handle, &find_file_data) != 0);
273 273
274 DCHECK(GetLastError() == ERROR_NO_MORE_FILES); 274 DCHECK(GetLastError() == ERROR_NO_MORE_FILES);
275 FindClose(find_handle); 275 FindClose(find_handle);
276 } 276 }
277 277
278 void PluginList::LoadPluginsFromRegistry( 278 void PluginList::LoadPluginsFromRegistry(
279 std::vector<WebPluginInfo>* plugins, 279 ScopedVector<PluginGroup>* plugin_groups,
280 std::set<FilePath>* visited_plugins) { 280 std::set<FilePath>* visited_plugins) {
281 std::set<FilePath> plugin_dirs; 281 std::set<FilePath> plugin_dirs;
282 282
283 GetPluginsInRegistryDirectory( 283 GetPluginsInRegistryDirectory(
284 HKEY_CURRENT_USER, kRegistryMozillaPlugins, &plugin_dirs); 284 HKEY_CURRENT_USER, kRegistryMozillaPlugins, &plugin_dirs);
285 GetPluginsInRegistryDirectory( 285 GetPluginsInRegistryDirectory(
286 HKEY_LOCAL_MACHINE, kRegistryMozillaPlugins, &plugin_dirs); 286 HKEY_LOCAL_MACHINE, kRegistryMozillaPlugins, &plugin_dirs);
287 287
288 for (std::set<FilePath>::iterator i = plugin_dirs.begin(); 288 for (std::set<FilePath>::iterator i = plugin_dirs.begin();
289 i != plugin_dirs.end(); ++i) { 289 i != plugin_dirs.end(); ++i) {
290 LoadPlugin(*i, plugins); 290 LoadPlugin(*i, plugin_groups);
291 visited_plugins->insert(*i); 291 visited_plugins->insert(*i);
292 } 292 }
293 } 293 }
294 294
295 // Returns true if the given plugins share at least one mime type. This is used 295 // Returns true if the given plugins share at least one mime type. This is used
296 // to differentiate newer versions of a plugin vs two plugins which happen to 296 // to differentiate newer versions of a plugin vs two plugins which happen to
297 // have the same filename. 297 // have the same filename.
298 bool HaveSharedMimeType(const WebPluginInfo& plugin1, 298 bool HaveSharedMimeType(const WebPluginInfo& plugin1,
299 const WebPluginInfo& plugin2) { 299 const WebPluginInfo& plugin2) {
300 for (size_t i = 0; i < plugin1.mime_types.size(); ++i) { 300 for (size_t i = 0; i < plugin1.mime_types.size(); ++i) {
(...skipping 27 matching lines...) Expand all
328 328
329 if (cur_a > cur_b) 329 if (cur_a > cur_b)
330 return false; 330 return false;
331 if (cur_a < cur_b) 331 if (cur_a < cur_b)
332 return true; 332 return true;
333 } 333 }
334 return false; 334 return false;
335 } 335 }
336 336
337 bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info, 337 bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info,
338 std::vector<WebPluginInfo>* plugins) { 338 ScopedVector<PluginGroup>* plugin_groups) {
339 // Version check 339 // Version check
340 340
341 for (size_t i = 0; i < plugins->size(); ++i) { 341 for (size_t i = 0; i < plugin_groups->size(); ++i) {
342 std::wstring plugin1 = 342 const std::vector<WebPluginInfo>& plugins =
343 StringToLowerASCII((*plugins)[i].path.BaseName().ToWStringHack()); 343 (*plugin_groups)[i]->web_plugins_info();
344 std::wstring plugin2 = 344 for (size_t j = 0; j < plugins.size(); ++j) {
345 StringToLowerASCII(info.path.BaseName().ToWStringHack()); 345 std::wstring plugin1 =
346 if ((plugin1 == plugin2 && HaveSharedMimeType((*plugins)[i], info)) || 346 StringToLowerASCII(plugins[j].path.BaseName().ToWStringHack());
347 (plugin1 == kJavaDeploy1 && plugin2 == kJavaDeploy2) || 347 std::wstring plugin2 =
348 (plugin1 == kJavaDeploy2 && plugin2 == kJavaDeploy1)) { 348 StringToLowerASCII(info.path.BaseName().ToWStringHack());
349 if (!IsNewerVersion((*plugins)[i].version, info.version)) 349 if ((plugin1 == plugin2 && HaveSharedMimeType(plugins[j], info)) ||
350 return false; // We have loaded a plugin whose version is newer. 350 (plugin1 == kJavaDeploy1 && plugin2 == kJavaDeploy2) ||
351 (plugin1 == kJavaDeploy2 && plugin2 == kJavaDeploy1)) {
352 if (!IsNewerVersion(plugins[j].version, info.version))
353 return false; // We have loaded a plugin whose version is newer.
351 354
352 plugins->erase(plugins->begin() + i); 355 (*plugin_groups)[i]->RemovePlugin(plugins[j].path);
353 break; 356 break;
357 }
354 } 358 }
355 } 359 }
356 360
357 // Troublemakers 361 // Troublemakers
358 362
359 std::wstring filename = StringToLowerASCII(info.path.BaseName().value()); 363 std::wstring filename = StringToLowerASCII(info.path.BaseName().value());
360 // Depends on XPCOM. 364 // Depends on XPCOM.
361 if (filename == kMozillaActiveXPlugin) 365 if (filename == kMozillaActiveXPlugin)
362 return false; 366 return false;
363 367
(...skipping 25 matching lines...) Expand all
389 } 393 }
390 } 394 }
391 395
392 // Special WMP handling 396 // Special WMP handling
393 397
394 // If both the new and old WMP plugins exist, only load the new one. 398 // If both the new and old WMP plugins exist, only load the new one.
395 if (filename == kNewWMPPlugin) { 399 if (filename == kNewWMPPlugin) {
396 if (dont_load_new_wmp_) 400 if (dont_load_new_wmp_)
397 return false; 401 return false;
398 402
399 for (size_t i = 0; i < plugins->size(); ++i) { 403 for (size_t i = 0; i < plugin_groups->size(); ++i) {
400 if ((*plugins)[i].path.BaseName().value() == kOldWMPPlugin) { 404 const std::vector<WebPluginInfo>& plugins =
401 plugins->erase(plugins->begin() + i); 405 (*plugin_groups)[i]->web_plugins_info();
402 break; 406 for (size_t j = 0; j < plugins.size(); ++j) {
407 if (plugins[j].path.BaseName().value() == kOldWMPPlugin) {
408 (*plugin_groups)[i]->RemovePlugin(plugins[j].path);
409 break;
410 }
403 } 411 }
404 } 412 }
405 } else if (filename == kOldWMPPlugin) { 413 } else if (filename == kOldWMPPlugin) {
406 for (size_t i = 0; i < plugins->size(); ++i) { 414 for (size_t i = 0; i < plugin_groups->size(); ++i) {
407 if ((*plugins)[i].path.BaseName().value() == kNewWMPPlugin) 415 const std::vector<WebPluginInfo>& plugins =
408 return false; 416 (*plugin_groups)[i]->web_plugins_info();
417 for (size_t j = 0; j < plugins.size(); ++j) {
418 if (plugins[j].path.BaseName().value() == kNewWMPPlugin)
419 return false;
420 }
409 } 421 }
410 } 422 }
411 423
412 return true; 424 return true;
413 } 425 }
414 426
415 } // namespace npapi 427 } // namespace npapi
416 } // namespace webkit 428 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/npapi/plugin_list_unittest.cc ('k') | webkit/plugins/npapi/webplugininfo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698