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

Side by Side Diff: content/common/plugin_list_win.cc

Issue 674073003: Only scan for correct architecture plugin binaries (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tests have a lot of subtle expectations, so leaving the logic exactly the same as before. Created 6 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | 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) 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 "content/common/plugin_list.h" 5 #include "content/common/plugin_list.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/file_version_info.h" 10 #include "base/file_version_info.h"
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 377
378 for (std::set<base::FilePath>::iterator i = plugin_dirs.begin(); 378 for (std::set<base::FilePath>::iterator i = plugin_dirs.begin();
379 i != plugin_dirs.end(); ++i) { 379 i != plugin_dirs.end(); ++i) {
380 plugins->push_back(*i); 380 plugins->push_back(*i);
381 } 381 }
382 } 382 }
383 383
384 bool PluginList::ShouldLoadPluginUsingPluginList( 384 bool PluginList::ShouldLoadPluginUsingPluginList(
385 const WebPluginInfo& info, 385 const WebPluginInfo& info,
386 std::vector<WebPluginInfo>* plugins) { 386 std::vector<WebPluginInfo>* plugins) {
387 bool should_check_version = true; 387 bool wrong_architecture = false;
388 { 388
389 base::AutoLock lock(lock_); 389 if (info.type == WebPluginInfo::PLUGIN_TYPE_NPAPI) {
390 should_check_version = 390 base::FilePath plugin_path(info.path);
391 std::find(extra_plugin_paths_.begin(), extra_plugin_paths_.end(), 391 #if defined(ARCH_CPU_X86_64)
392 info.path) == extra_plugin_paths_.end(); 392 // The plugin in question could be a 32 bit plugin which we cannot load.
393 if (IsValid32BitImage(base::MakeAbsoluteFilePath(plugin_path)))
394 wrong_architecture = true;
395 #else
396 // The plugin in question could be a 64 bit plugin which we cannot load.
397 if (!IsValid32BitImage(base::MakeAbsoluteFilePath(plugin_path)))
398 wrong_architecture = true;
399 #endif
393 } 400 }
394 // Version check for plugins that are not coming from |extra_plugin_paths_|. 401
ananta 2014/11/03 20:28:04 Can we bail if wrong_architecture is true? here?
Bernhard Bauer 2014/11/03 22:24:22 Alternatively: bool should_check_version; if
395 if (should_check_version) { 402 if (!wrong_architecture) {
396 for (size_t j = 0; j < plugins->size(); ++j) { 403 bool should_check_version = true;
397 base::FilePath::StringType plugin1 = 404 {
398 base::StringToLowerASCII((*plugins)[j].path.BaseName().value()); 405 base::AutoLock lock(lock_);
399 base::FilePath::StringType plugin2 = 406 should_check_version =
400 base::StringToLowerASCII(info.path.BaseName().value()); 407 std::find(extra_plugin_paths_.begin(), extra_plugin_paths_.end(),
401 if ((plugin1 == plugin2 && HaveSharedMimeType((*plugins)[j], info)) || 408 info.path) == extra_plugin_paths_.end();
402 (plugin1 == kJavaDeploy1 && plugin2 == kJavaDeploy2) || 409 }
403 (plugin1 == kJavaDeploy2 && plugin2 == kJavaDeploy1)) { 410 // Version check for plugins that are not coming from |extra_plugin_paths_|.
404 if (IsNewerVersion(info.version, (*plugins)[j].version)) 411 if (should_check_version) {
405 return false; // We have loaded a plugin whose version is newer. 412 for (size_t j = 0; j < plugins->size(); ++j) {
406 plugins->erase(plugins->begin() + j); 413 base::FilePath::StringType plugin1 =
407 break; 414 base::StringToLowerASCII((*plugins)[j].path.BaseName().value());
415 base::FilePath::StringType plugin2 =
416 base::StringToLowerASCII(info.path.BaseName().value());
417 if ((plugin1 == plugin2 && HaveSharedMimeType((*plugins)[j], info)) ||
418 (plugin1 == kJavaDeploy1 && plugin2 == kJavaDeploy2) ||
419 (plugin1 == kJavaDeploy2 && plugin2 == kJavaDeploy1)) {
420 if (IsNewerVersion(info.version, (*plugins)[j].version))
421 return false; // We have loaded a plugin whose version is newer.
422 plugins->erase(plugins->begin() + j);
423 break;
424 }
408 } 425 }
409 } 426 }
410 } 427 }
411 428
412 // The checks below only apply to NPAPI plugins. 429 // The checks below only apply to NPAPI plugins.
413 if (info.type != WebPluginInfo::PLUGIN_TYPE_NPAPI) 430 if (info.type != WebPluginInfo::PLUGIN_TYPE_NPAPI)
414 return true; 431 return true;
415 432
416 { 433 {
417 base::AutoLock lock(lock_); 434 base::AutoLock lock(lock_);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 } 484 }
468 } 485 }
469 486
470 } else if (filename == kOldWMPPlugin) { 487 } else if (filename == kOldWMPPlugin) {
471 for (size_t j = 0; j < plugins->size(); ++j) { 488 for (size_t j = 0; j < plugins->size(); ++j) {
472 if ((*plugins)[j].path.BaseName().value() == kNewWMPPlugin) 489 if ((*plugins)[j].path.BaseName().value() == kNewWMPPlugin)
473 return false; 490 return false;
474 } 491 }
475 } 492 }
476 493
477 base::FilePath plugin_path(info.path); 494 if (wrong_architecture)
478 #if defined(ARCH_CPU_X86_64)
479 // The plugin in question could be a 32 bit plugin which we cannot load.
480 if (IsValid32BitImage(base::MakeAbsoluteFilePath(plugin_path)))
481 return false; 495 return false;
482 #else 496
483 // The plugin in question could be a 64 bit plugin which we cannot load.
484 if (!IsValid32BitImage(base::MakeAbsoluteFilePath(plugin_path)))
485 return false;
486 #endif
487 return true; 497 return true;
488 } 498 }
489 499
490 } // namespace content 500 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698