OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 base::StringToInt(b_ver[i], &cur_b); | 328 base::StringToInt(b_ver[i], &cur_b); |
329 | 329 |
330 if (cur_a > cur_b) | 330 if (cur_a > cur_b) |
331 return false; | 331 return false; |
332 if (cur_a < cur_b) | 332 if (cur_a < cur_b) |
333 return true; | 333 return true; |
334 } | 334 } |
335 return false; | 335 return false; |
336 } | 336 } |
337 | 337 |
338 bool PluginList::ShouldLoadPlugin(const webkit::WebPluginInfo& info, | 338 // TODO(ibraaaa): DELETE |
339 ScopedVector<PluginGroup>* plugin_groups) { | 339 bool PluginList::ShouldLoadPluginUsingPluginList( |
| 340 const webkit::WebPluginInfo& info, |
| 341 ScopedVector<PluginGroup>* plugin_groups) { |
340 // Version check | 342 // Version check |
341 | 343 |
342 for (size_t i = 0; i < plugin_groups->size(); ++i) { | 344 for (size_t i = 0; i < plugin_groups->size(); ++i) { |
343 const std::vector<webkit::WebPluginInfo>& plugins = | 345 const std::vector<webkit::WebPluginInfo>& plugins = |
344 (*plugin_groups)[i]->web_plugin_infos(); | 346 (*plugin_groups)[i]->web_plugin_infos(); |
345 for (size_t j = 0; j < plugins.size(); ++j) { | 347 for (size_t j = 0; j < plugins.size(); ++j) { |
346 std::wstring plugin1 = | 348 std::wstring plugin1 = |
347 StringToLowerASCII(plugins[j].path.BaseName().value()); | 349 StringToLowerASCII(plugins[j].path.BaseName().value()); |
348 std::wstring plugin2 = | 350 std::wstring plugin2 = |
349 StringToLowerASCII(info.path.BaseName().value()); | 351 StringToLowerASCII(info.path.BaseName().value()); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 if (info.path == internal_plugins_[i].info.path) | 437 if (info.path == internal_plugins_[i].info.path) |
436 continue; | 438 continue; |
437 | 439 |
438 if (file_util::PathExists(info.path) && (!IsValid32BitImage(info.path))) | 440 if (file_util::PathExists(info.path) && (!IsValid32BitImage(info.path))) |
439 load_plugin = false; | 441 load_plugin = false; |
440 break; | 442 break; |
441 } | 443 } |
442 return load_plugin; | 444 return load_plugin; |
443 } | 445 } |
444 | 446 |
| 447 bool PluginList::ShouldLoadPlugin( |
| 448 const webkit::WebPluginInfo& info, |
| 449 std::vector<webkit::WebPluginInfo>* plugins) { |
| 450 // Version check |
| 451 for (size_t j = 0; j < plugins->size(); ++j) { |
| 452 FilePath::StringType plugin1 = |
| 453 StringToLowerASCII((*plugins[j]).path.BaseName().value()); |
| 454 FilePath::StringType plugin2 = |
| 455 StringToLowerASCII(info.path.BaseName().value()); |
| 456 if ((plugin1 == plugin2 && HaveSharedMimeType((*plugins)[j], info)) || |
| 457 (plugin1 == kJavaDeploy1 && plugin2 == kJavaDeploy2) || |
| 458 (plugin1 == kJavaDeploy2 && plugin2 == kJavaDeploy1)) { |
| 459 if (!IsNewerVersion((*plugins)[j].version, info.version)) |
| 460 return false; // We have loaded a plugin whose version is newer. |
| 461 PluginList::RemovePlugin((*plugins)[j].path, plugins); |
| 462 break; |
| 463 } |
| 464 } |
| 465 |
| 466 // Troublemakers |
| 467 |
| 468 std::wstring filename = StringToLowerASCII(info.path.BaseName().value()); |
| 469 // Depends on XPCOM. |
| 470 if (filename == kMozillaActiveXPlugin) |
| 471 return false; |
| 472 |
| 473 // Disable the Yahoo Application State plugin as it crashes the plugin |
| 474 // process on return from NPObjectStub::OnInvoke. Please refer to |
| 475 // http://b/issue?id=1372124 for more information. |
| 476 if (filename == kYahooApplicationStatePlugin) |
| 477 return false; |
| 478 |
| 479 // Disable the WangWang protocol handler plugin (npww.dll) as it crashes |
| 480 // chrome during shutdown. Firefox also disables this plugin. |
| 481 // Please refer to http://code.google.com/p/chromium/issues/detail?id=3953 |
| 482 // for more information. |
| 483 if (filename == kWanWangProtocolHandlerPlugin) |
| 484 return false; |
| 485 |
| 486 // We only work with newer versions of the Java plugin which use NPAPI only |
| 487 // and don't depend on XPCOM. |
| 488 if (filename == kJavaPlugin1 || filename == kJavaPlugin2) { |
| 489 std::vector<std::wstring> ver; |
| 490 base::SplitString(info.version, '.', &ver); |
| 491 int major, minor, update; |
| 492 if (ver.size() == 4 && |
| 493 base::StringToInt(ver[0], &major) && |
| 494 base::StringToInt(ver[1], &minor) && |
| 495 base::StringToInt(ver[2], &update)) { |
| 496 if (major == 6 && minor == 0 && update < 120) |
| 497 return false; // Java SE6 Update 11 or older. |
| 498 } |
| 499 } |
| 500 |
| 501 if (base::win::IsMetroProcess()) { |
| 502 // In metro mode we only allow pepper plugins. |
| 503 if (info.type == WebPluginInfo::PLUGIN_TYPE_NPAPI) |
| 504 return false; |
| 505 } |
| 506 |
| 507 // Special WMP handling |
| 508 |
| 509 // If both the new and old WMP plugins exist, only load the new one. |
| 510 if (filename == kNewWMPPlugin) { |
| 511 if (dont_load_new_wmp_) |
| 512 return false; |
| 513 |
| 514 for (size_t j = 0; j < plugins->size(); ++j) { |
| 515 if (plugins[j].path.BaseName().value() == kOldWMPPlugin) { |
| 516 PluginList::RemovePlugin((*plugins)[j].path, plugins); |
| 517 break; |
| 518 } |
| 519 } |
| 520 |
| 521 } else if (filename == kOldWMPPlugin) { |
| 522 for (size_t j = 0; j < plugins->size(); ++j) { |
| 523 if ((*plugins)[j].path.BaseName().value() == kNewWMPPlugin) |
| 524 return false; |
| 525 } |
| 526 } |
| 527 |
| 528 HMODULE plugin_dll = NULL; |
| 529 bool load_plugin = true; |
| 530 |
| 531 // The plugin list could contain a 64 bit plugin which we cannot load. |
| 532 for (size_t i = 0; i < internal_plugins_.size(); ++i) { |
| 533 if (info.path == internal_plugins_[i].info.path) |
| 534 continue; |
| 535 |
| 536 if (file_util::PathExists(info.path) && (!IsValid32BitImage(info.path))) |
| 537 load_plugin = false; |
| 538 break; |
| 539 } |
| 540 return load_plugin; |
| 541 } |
| 542 |
| 543 |
445 } // namespace npapi | 544 } // namespace npapi |
446 } // namespace webkit | 545 } // namespace webkit |
OLD | NEW |