OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 for (std::set<FilePath>::iterator i = plugin_dirs.begin(); | 306 for (std::set<FilePath>::iterator i = plugin_dirs.begin(); |
307 i != plugin_dirs.end(); ++i) { | 307 i != plugin_dirs.end(); ++i) { |
308 LoadPlugin(*i, plugin_groups); | 308 LoadPlugin(*i, plugin_groups); |
309 visited_plugins->insert(*i); | 309 visited_plugins->insert(*i); |
310 } | 310 } |
311 } | 311 } |
312 | 312 |
313 // Returns true if the given plugins share at least one mime type. This is used | 313 // Returns true if the given plugins share at least one mime type. This is used |
314 // to differentiate newer versions of a plugin vs two plugins which happen to | 314 // to differentiate newer versions of a plugin vs two plugins which happen to |
315 // have the same filename. | 315 // have the same filename. |
316 bool HaveSharedMimeType(const WebPluginInfo& plugin1, | 316 bool HaveSharedMimeType(const webkit::WebPluginInfo& plugin1, |
317 const WebPluginInfo& plugin2) { | 317 const webkit::WebPluginInfo& plugin2) { |
318 for (size_t i = 0; i < plugin1.mime_types.size(); ++i) { | 318 for (size_t i = 0; i < plugin1.mime_types.size(); ++i) { |
319 for (size_t j = 0; j < plugin2.mime_types.size(); ++j) { | 319 for (size_t j = 0; j < plugin2.mime_types.size(); ++j) { |
320 if (plugin1.mime_types[i].mime_type == plugin2.mime_types[j].mime_type) | 320 if (plugin1.mime_types[i].mime_type == plugin2.mime_types[j].mime_type) |
321 return true; | 321 return true; |
322 } | 322 } |
323 } | 323 } |
324 | 324 |
325 return false; | 325 return false; |
326 } | 326 } |
327 | 327 |
(...skipping 17 matching lines...) Expand all Loading... |
345 base::StringToInt(b_ver[i], &cur_b); | 345 base::StringToInt(b_ver[i], &cur_b); |
346 | 346 |
347 if (cur_a > cur_b) | 347 if (cur_a > cur_b) |
348 return false; | 348 return false; |
349 if (cur_a < cur_b) | 349 if (cur_a < cur_b) |
350 return true; | 350 return true; |
351 } | 351 } |
352 return false; | 352 return false; |
353 } | 353 } |
354 | 354 |
355 bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info, | 355 bool PluginList::ShouldLoadPlugin(const webkit::WebPluginInfo& info, |
356 ScopedVector<PluginGroup>* plugin_groups) { | 356 ScopedVector<PluginGroup>* plugin_groups) { |
357 // Version check | 357 // Version check |
358 | 358 |
359 for (size_t i = 0; i < plugin_groups->size(); ++i) { | 359 for (size_t i = 0; i < plugin_groups->size(); ++i) { |
360 const std::vector<WebPluginInfo>& plugins = | 360 const std::vector<webkit::WebPluginInfo>& plugins = |
361 (*plugin_groups)[i]->web_plugins_info(); | 361 (*plugin_groups)[i]->web_plugins_info(); |
362 for (size_t j = 0; j < plugins.size(); ++j) { | 362 for (size_t j = 0; j < plugins.size(); ++j) { |
363 std::wstring plugin1 = | 363 std::wstring plugin1 = |
364 StringToLowerASCII(plugins[j].path.BaseName().value()); | 364 StringToLowerASCII(plugins[j].path.BaseName().value()); |
365 std::wstring plugin2 = | 365 std::wstring plugin2 = |
366 StringToLowerASCII(info.path.BaseName().value()); | 366 StringToLowerASCII(info.path.BaseName().value()); |
367 if ((plugin1 == plugin2 && HaveSharedMimeType(plugins[j], info)) || | 367 if ((plugin1 == plugin2 && HaveSharedMimeType(plugins[j], info)) || |
368 (plugin1 == kJavaDeploy1 && plugin2 == kJavaDeploy2) || | 368 (plugin1 == kJavaDeploy1 && plugin2 == kJavaDeploy2) || |
369 (plugin1 == kJavaDeploy2 && plugin2 == kJavaDeploy1)) { | 369 (plugin1 == kJavaDeploy2 && plugin2 == kJavaDeploy1)) { |
370 if (!IsNewerVersion(plugins[j].version, info.version)) | 370 if (!IsNewerVersion(plugins[j].version, info.version)) |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 } | 412 } |
413 | 413 |
414 // Special WMP handling | 414 // Special WMP handling |
415 | 415 |
416 // If both the new and old WMP plugins exist, only load the new one. | 416 // If both the new and old WMP plugins exist, only load the new one. |
417 if (filename == kNewWMPPlugin) { | 417 if (filename == kNewWMPPlugin) { |
418 if (dont_load_new_wmp_) | 418 if (dont_load_new_wmp_) |
419 return false; | 419 return false; |
420 | 420 |
421 for (size_t i = 0; i < plugin_groups->size(); ++i) { | 421 for (size_t i = 0; i < plugin_groups->size(); ++i) { |
422 const std::vector<WebPluginInfo>& plugins = | 422 const std::vector<webkit::WebPluginInfo>& plugins = |
423 (*plugin_groups)[i]->web_plugins_info(); | 423 (*plugin_groups)[i]->web_plugins_info(); |
424 for (size_t j = 0; j < plugins.size(); ++j) { | 424 for (size_t j = 0; j < plugins.size(); ++j) { |
425 if (plugins[j].path.BaseName().value() == kOldWMPPlugin) { | 425 if (plugins[j].path.BaseName().value() == kOldWMPPlugin) { |
426 (*plugin_groups)[i]->RemovePlugin(plugins[j].path); | 426 (*plugin_groups)[i]->RemovePlugin(plugins[j].path); |
427 break; | 427 break; |
428 } | 428 } |
429 } | 429 } |
430 } | 430 } |
431 } else if (filename == kOldWMPPlugin) { | 431 } else if (filename == kOldWMPPlugin) { |
432 for (size_t i = 0; i < plugin_groups->size(); ++i) { | 432 for (size_t i = 0; i < plugin_groups->size(); ++i) { |
433 const std::vector<WebPluginInfo>& plugins = | 433 const std::vector<webkit::WebPluginInfo>& plugins = |
434 (*plugin_groups)[i]->web_plugins_info(); | 434 (*plugin_groups)[i]->web_plugins_info(); |
435 for (size_t j = 0; j < plugins.size(); ++j) { | 435 for (size_t j = 0; j < plugins.size(); ++j) { |
436 if (plugins[j].path.BaseName().value() == kNewWMPPlugin) | 436 if (plugins[j].path.BaseName().value() == kNewWMPPlugin) |
437 return false; | 437 return false; |
438 } | 438 } |
439 } | 439 } |
440 } | 440 } |
441 | 441 |
442 HMODULE plugin_dll = NULL; | 442 HMODULE plugin_dll = NULL; |
443 bool load_plugin = true; | 443 bool load_plugin = true; |
444 | 444 |
445 // The plugin list could contain a 64 bit plugin which we cannot load. | 445 // The plugin list could contain a 64 bit plugin which we cannot load. |
446 for (size_t i = 0; i < internal_plugins_.size(); ++i) { | 446 for (size_t i = 0; i < internal_plugins_.size(); ++i) { |
447 if (info.path == internal_plugins_[i].info.path) | 447 if (info.path == internal_plugins_[i].info.path) |
448 continue; | 448 continue; |
449 | 449 |
450 if (file_util::PathExists(info.path) && (!IsValid32BitImage(info.path))) | 450 if (file_util::PathExists(info.path) && (!IsValid32BitImage(info.path))) |
451 load_plugin = false; | 451 load_plugin = false; |
452 break; | 452 break; |
453 } | 453 } |
454 return load_plugin; | 454 return load_plugin; |
455 } | 455 } |
456 | 456 |
457 } // namespace npapi | 457 } // namespace npapi |
458 } // namespace webkit | 458 } // namespace webkit |
OLD | NEW |