Chromium Code Reviews| 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 "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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 if (hklm_key.ReadValue(kRegistryPath, &path) == ERROR_SUCCESS) { | 86 if (hklm_key.ReadValue(kRegistryPath, &path) == ERROR_SUCCESS) { |
| 87 *out = base::FilePath(path); | 87 *out = base::FilePath(path); |
| 88 return true; | 88 return true; |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 | 91 |
| 92 return false; | 92 return false; |
| 93 } | 93 } |
| 94 | 94 |
| 95 // Search the registry at the given path and detect plugin directories. | 95 // Search the registry at the given path and detect plugin directories. |
| 96 void GetPluginsInRegistryDirectory( | 96 void GetPluginsInRegistryDirectory(HKEY root_key, |
| 97 HKEY root_key, | 97 const base::string16& registry_folder, |
| 98 const base::string16& registry_folder, | 98 REGSAM wow64_access, |
| 99 std::set<base::FilePath>* plugin_dirs) { | 99 std::set<base::FilePath>* plugin_dirs) { |
| 100 for (base::win::RegistryKeyIterator iter(root_key, registry_folder.c_str()); | 100 for (base::win::RegistryKeyIterator iter( |
| 101 iter.Valid(); ++iter) { | 101 root_key, registry_folder.c_str(), wow64_access); |
| 102 iter.Valid(); | |
| 103 ++iter) { | |
| 102 // Use the registry to gather plugin across the file system. | 104 // Use the registry to gather plugin across the file system. |
| 103 base::string16 reg_path = registry_folder; | 105 base::string16 reg_path = registry_folder; |
| 104 reg_path.append(L"\\"); | 106 reg_path.append(L"\\"); |
| 105 reg_path.append(iter.Name()); | 107 reg_path.append(iter.Name()); |
| 106 base::win::RegKey key(root_key, reg_path.c_str(), KEY_READ); | 108 base::win::RegKey key(root_key, reg_path.c_str(), KEY_READ | wow64_access); |
| 107 | 109 |
| 108 base::string16 path; | 110 base::string16 path; |
| 109 if (key.ReadValue(kRegistryPath, &path) == ERROR_SUCCESS) | 111 if (key.ReadValue(kRegistryPath, &path) == ERROR_SUCCESS) |
| 110 plugin_dirs->insert(base::FilePath(path)); | 112 plugin_dirs->insert(base::FilePath(path)); |
| 111 } | 113 } |
| 112 } | 114 } |
| 113 | 115 |
| 114 // Enumerate through the registry key to find all installed FireFox paths. | 116 // Enumerate through the registry key to find all installed FireFox paths. |
| 115 // FireFox 3 beta and version 2 can coexist. See bug: 1025003 | 117 // FireFox 3 beta and version 2 can coexist. See bug: 1025003 |
| 116 void GetFirefoxInstalledPaths(std::vector<base::FilePath>* out) { | 118 void GetFirefoxInstalledPaths(std::vector<base::FilePath>* out) { |
| 117 base::win::RegistryKeyIterator it(HKEY_LOCAL_MACHINE, | 119 base::win::RegistryKeyIterator it(HKEY_LOCAL_MACHINE, |
| 118 kRegistryFirefoxInstalled); | 120 kRegistryFirefoxInstalled, |
| 121 KEY_WOW64_32KEY); | |
| 119 for (; it.Valid(); ++it) { | 122 for (; it.Valid(); ++it) { |
| 120 base::string16 full_path = base::string16(kRegistryFirefoxInstalled) + | 123 base::string16 full_path = base::string16(kRegistryFirefoxInstalled) + |
| 121 L"\\" + it.Name() + L"\\Main"; | 124 L"\\" + it.Name() + L"\\Main"; |
| 122 base::win::RegKey key(HKEY_LOCAL_MACHINE, full_path.c_str(), KEY_READ); | 125 base::win::RegKey key(HKEY_LOCAL_MACHINE, full_path.c_str(), KEY_READ); |
| 123 base::string16 install_dir; | 126 base::string16 install_dir; |
| 124 if (key.ReadValue(L"Install Directory", &install_dir) != ERROR_SUCCESS) | 127 if (key.ReadValue(L"Install Directory", &install_dir) != ERROR_SUCCESS) |
| 125 continue; | 128 continue; |
| 126 out->push_back(base::FilePath(install_dir)); | 129 out->push_back(base::FilePath(install_dir)); |
| 127 } | 130 } |
| 128 } | 131 } |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 352 FindClose(find_handle); | 355 FindClose(find_handle); |
| 353 } | 356 } |
| 354 | 357 |
| 355 void PluginList::GetPluginPathsFromRegistry( | 358 void PluginList::GetPluginPathsFromRegistry( |
| 356 std::vector<base::FilePath>* plugins) { | 359 std::vector<base::FilePath>* plugins) { |
| 357 if (PluginList::plugins_discovery_disabled_) | 360 if (PluginList::plugins_discovery_disabled_) |
| 358 return; | 361 return; |
| 359 | 362 |
| 360 std::set<base::FilePath> plugin_dirs; | 363 std::set<base::FilePath> plugin_dirs; |
| 361 | 364 |
| 362 GetPluginsInRegistryDirectory( | 365 GetPluginsInRegistryDirectory(HKEY_CURRENT_USER, |
| 363 HKEY_CURRENT_USER, kRegistryMozillaPlugins, &plugin_dirs); | 366 kRegistryMozillaPlugins, |
| 364 GetPluginsInRegistryDirectory( | 367 0, |
| 365 HKEY_LOCAL_MACHINE, kRegistryMozillaPlugins, &plugin_dirs); | 368 &plugin_dirs); |
| 369 GetPluginsInRegistryDirectory(HKEY_LOCAL_MACHINE, | |
|
ananta
2014/10/08 20:36:09
Getting 32 bit plugins from a 64 bit process and v
Will Harris
2014/10/08 20:43:23
it potentially overpopulates the list at this stag
| |
| 370 kRegistryMozillaPlugins, | |
| 371 KEY_WOW64_64KEY, | |
| 372 &plugin_dirs); | |
| 373 GetPluginsInRegistryDirectory(HKEY_LOCAL_MACHINE, | |
| 374 kRegistryMozillaPlugins, | |
| 375 KEY_WOW64_32KEY, | |
| 376 &plugin_dirs); | |
| 366 | 377 |
| 367 for (std::set<base::FilePath>::iterator i = plugin_dirs.begin(); | 378 for (std::set<base::FilePath>::iterator i = plugin_dirs.begin(); |
| 368 i != plugin_dirs.end(); ++i) { | 379 i != plugin_dirs.end(); ++i) { |
| 369 plugins->push_back(*i); | 380 plugins->push_back(*i); |
| 370 } | 381 } |
| 371 } | 382 } |
| 372 | 383 |
| 373 bool PluginList::ShouldLoadPluginUsingPluginList( | 384 bool PluginList::ShouldLoadPluginUsingPluginList( |
| 374 const WebPluginInfo& info, | 385 const WebPluginInfo& info, |
| 375 std::vector<WebPluginInfo>* plugins) { | 386 std::vector<WebPluginInfo>* plugins) { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 470 return false; | 481 return false; |
| 471 #else | 482 #else |
| 472 // The plugin in question could be a 64 bit plugin which we cannot load. | 483 // The plugin in question could be a 64 bit plugin which we cannot load. |
| 473 if (!IsValid32BitImage(base::MakeAbsoluteFilePath(plugin_path))) | 484 if (!IsValid32BitImage(base::MakeAbsoluteFilePath(plugin_path))) |
| 474 return false; | 485 return false; |
| 475 #endif | 486 #endif |
| 476 return true; | 487 return true; |
| 477 } | 488 } |
| 478 | 489 |
| 479 } // namespace content | 490 } // namespace content |
| OLD | NEW |