| 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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 // Firefox hard-codes the paths of some popular plugins to ensure that | 260 // Firefox hard-codes the paths of some popular plugins to ensure that |
| 261 // the plugins are found. We are going to copy this as well. | 261 // the plugins are found. We are going to copy this as well. |
| 262 GetAcrobatDirectory(&dirs); | 262 GetAcrobatDirectory(&dirs); |
| 263 GetQuicktimeDirectory(&dirs); | 263 GetQuicktimeDirectory(&dirs); |
| 264 GetWindowsMediaDirectory(&dirs); | 264 GetWindowsMediaDirectory(&dirs); |
| 265 | 265 |
| 266 for (std::set<FilePath>::iterator i = dirs.begin(); i != dirs.end(); ++i) | 266 for (std::set<FilePath>::iterator i = dirs.begin(); i != dirs.end(); ++i) |
| 267 plugin_dirs->push_back(*i); | 267 plugin_dirs->push_back(*i); |
| 268 } | 268 } |
| 269 | 269 |
| 270 void PluginList::LoadPluginsFromDir(const FilePath &path, | 270 void PluginList::GetPluginsInDir( |
| 271 ScopedVector<PluginGroup>* plugin_groups, | 271 const FilePath& path, std::vector<FilePath>* plugins) { |
| 272 std::set<FilePath>* visited_plugins) { | |
| 273 WIN32_FIND_DATA find_file_data; | 272 WIN32_FIND_DATA find_file_data; |
| 274 HANDLE find_handle; | 273 HANDLE find_handle; |
| 275 | 274 |
| 276 std::wstring dir = path.value(); | 275 std::wstring dir = path.value(); |
| 277 // FindFirstFile requires that you specify a wildcard for directories. | 276 // FindFirstFile requires that you specify a wildcard for directories. |
| 278 dir.append(L"\\NP*.DLL"); | 277 dir.append(L"\\NP*.DLL"); |
| 279 | 278 |
| 280 find_handle = FindFirstFile(dir.c_str(), &find_file_data); | 279 find_handle = FindFirstFile(dir.c_str(), &find_file_data); |
| 281 if (find_handle == INVALID_HANDLE_VALUE) | 280 if (find_handle == INVALID_HANDLE_VALUE) |
| 282 return; | 281 return; |
| 283 | 282 |
| 284 do { | 283 do { |
| 285 if (!(find_file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { | 284 if (!(find_file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { |
| 286 FilePath filename = path.Append(find_file_data.cFileName); | 285 FilePath filename = path.Append(find_file_data.cFileName); |
| 287 LoadPlugin(filename, plugin_groups); | 286 plugins->push_back(filename); |
| 288 visited_plugins->insert(filename); | |
| 289 } | 287 } |
| 290 } while (FindNextFile(find_handle, &find_file_data) != 0); | 288 } while (FindNextFile(find_handle, &find_file_data) != 0); |
| 291 | 289 |
| 292 DCHECK(GetLastError() == ERROR_NO_MORE_FILES); | 290 DCHECK(GetLastError() == ERROR_NO_MORE_FILES); |
| 293 FindClose(find_handle); | 291 FindClose(find_handle); |
| 294 } | 292 } |
| 295 | 293 |
| 296 void PluginList::LoadPluginsFromRegistry( | 294 void PluginList::GetPluginPathsFromRegistry(std::vector<FilePath>* plugins) { |
| 297 ScopedVector<PluginGroup>* plugin_groups, | |
| 298 std::set<FilePath>* visited_plugins) { | |
| 299 std::set<FilePath> plugin_dirs; | 295 std::set<FilePath> plugin_dirs; |
| 300 | 296 |
| 301 GetPluginsInRegistryDirectory( | 297 GetPluginsInRegistryDirectory( |
| 302 HKEY_CURRENT_USER, kRegistryMozillaPlugins, &plugin_dirs); | 298 HKEY_CURRENT_USER, kRegistryMozillaPlugins, &plugin_dirs); |
| 303 GetPluginsInRegistryDirectory( | 299 GetPluginsInRegistryDirectory( |
| 304 HKEY_LOCAL_MACHINE, kRegistryMozillaPlugins, &plugin_dirs); | 300 HKEY_LOCAL_MACHINE, kRegistryMozillaPlugins, &plugin_dirs); |
| 305 | 301 |
| 306 for (std::set<FilePath>::iterator i = plugin_dirs.begin(); | 302 for (std::set<FilePath>::iterator i = plugin_dirs.begin(); |
| 307 i != plugin_dirs.end(); ++i) { | 303 i != plugin_dirs.end(); ++i) { |
| 308 LoadPlugin(*i, plugin_groups); | 304 plugins->push_back(*i); |
| 309 visited_plugins->insert(*i); | |
| 310 } | 305 } |
| 311 } | 306 } |
| 312 | 307 |
| 313 // Returns true if the given plugins share at least one mime type. This is used | 308 // 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 | 309 // to differentiate newer versions of a plugin vs two plugins which happen to |
| 315 // have the same filename. | 310 // have the same filename. |
| 316 bool HaveSharedMimeType(const webkit::WebPluginInfo& plugin1, | 311 bool HaveSharedMimeType(const webkit::WebPluginInfo& plugin1, |
| 317 const webkit::WebPluginInfo& plugin2) { | 312 const webkit::WebPluginInfo& plugin2) { |
| 318 for (size_t i = 0; i < plugin1.mime_types.size(); ++i) { | 313 for (size_t i = 0; i < plugin1.mime_types.size(); ++i) { |
| 319 for (size_t j = 0; j < plugin2.mime_types.size(); ++j) { | 314 for (size_t j = 0; j < plugin2.mime_types.size(); ++j) { |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 | 444 |
| 450 if (file_util::PathExists(info.path) && (!IsValid32BitImage(info.path))) | 445 if (file_util::PathExists(info.path) && (!IsValid32BitImage(info.path))) |
| 451 load_plugin = false; | 446 load_plugin = false; |
| 452 break; | 447 break; |
| 453 } | 448 } |
| 454 return load_plugin; | 449 return load_plugin; |
| 455 } | 450 } |
| 456 | 451 |
| 457 } // namespace npapi | 452 } // namespace npapi |
| 458 } // namespace webkit | 453 } // namespace webkit |
| OLD | NEW |