| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 FilePath filename = path.Append(find_file_data.cFileName); | 265 FilePath filename = path.Append(find_file_data.cFileName); |
| 266 LoadPlugin(filename, plugins); | 266 LoadPlugin(filename, plugins); |
| 267 visited_plugins->insert(filename); | 267 visited_plugins->insert(filename); |
| 268 } | 268 } |
| 269 } while (FindNextFile(find_handle, &find_file_data) != 0); | 269 } while (FindNextFile(find_handle, &find_file_data) != 0); |
| 270 | 270 |
| 271 DCHECK(GetLastError() == ERROR_NO_MORE_FILES); | 271 DCHECK(GetLastError() == ERROR_NO_MORE_FILES); |
| 272 FindClose(find_handle); | 272 FindClose(find_handle); |
| 273 } | 273 } |
| 274 | 274 |
| 275 void PluginList::LoadPluginsFromRegistry( | 275 void PluginList::LoadPluginsFromRegistry(std::vector<WebPluginInfo>* plugins, |
| 276 std::vector<WebPluginInfo>* plugins, | 276 std::set<FilePath>* visited_plugins) { |
| 277 std::set<FilePath>* visited_plugins) { | |
| 278 std::set<FilePath> plugin_dirs; | 277 std::set<FilePath> plugin_dirs; |
| 279 | 278 |
| 280 GetPluginsInRegistryDirectory( | 279 GetPluginsInRegistryDirectory( |
| 281 HKEY_CURRENT_USER, kRegistryMozillaPlugins, &plugin_dirs); | 280 HKEY_CURRENT_USER, kRegistryMozillaPlugins, &plugin_dirs); |
| 282 GetPluginsInRegistryDirectory( | 281 GetPluginsInRegistryDirectory( |
| 283 HKEY_LOCAL_MACHINE, kRegistryMozillaPlugins, &plugin_dirs); | 282 HKEY_LOCAL_MACHINE, kRegistryMozillaPlugins, &plugin_dirs); |
| 284 | 283 |
| 285 for (std::set<FilePath>::iterator i = plugin_dirs.begin(); | 284 for (std::set<FilePath>::iterator i = plugin_dirs.begin(); |
| 286 i != plugin_dirs.end(); ++i) { | 285 i != plugin_dirs.end(); ++i) { |
| 287 LoadPlugin(*i, plugins); | 286 LoadPlugin(*i, plugins); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 } | 329 } |
| 331 return false; | 330 return false; |
| 332 } | 331 } |
| 333 | 332 |
| 334 bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info, | 333 bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info, |
| 335 std::vector<WebPluginInfo>* plugins) { | 334 std::vector<WebPluginInfo>* plugins) { |
| 336 // Version check | 335 // Version check |
| 337 | 336 |
| 338 for (size_t i = 0; i < plugins->size(); ++i) { | 337 for (size_t i = 0; i < plugins->size(); ++i) { |
| 339 std::wstring plugin1 = | 338 std::wstring plugin1 = |
| 340 StringToLowerASCII((*plugins)[i].path.BaseName().ToWStringHack()); | 339 StringToLowerASCII(plugins->at(i).path.BaseName().ToWStringHack()); |
| 341 std::wstring plugin2 = | 340 std::wstring plugin2 = |
| 342 StringToLowerASCII(info.path.BaseName().ToWStringHack()); | 341 StringToLowerASCII(info.path.BaseName().ToWStringHack()); |
| 343 if ((plugin1 == plugin2 && HaveSharedMimeType((*plugins)[i], info)) || | 342 if ((plugin1 == plugin2 && HaveSharedMimeType(plugins->at(i), info)) || |
| 344 (plugin1 == kJavaDeploy1 && plugin2 == kJavaDeploy2) || | 343 (plugin1 == kJavaDeploy1 && plugin2 == kJavaDeploy2) || |
| 345 (plugin1 == kJavaDeploy2 && plugin2 == kJavaDeploy1)) { | 344 (plugin1 == kJavaDeploy2 && plugin2 == kJavaDeploy1)) { |
| 346 if (!IsNewerVersion((*plugins)[i].version, info.version)) | 345 if (!IsNewerVersion(plugins->at(i).version, info.version)) |
| 347 return false; // We have loaded a plugin whose version is newer. | 346 return false; // We have loaded a plugin whose version is newer. |
| 348 | 347 |
| 349 plugins->erase(plugins->begin() + i); | 348 plugins->erase(plugins->begin() + i); |
| 350 break; | 349 break; |
| 351 } | 350 } |
| 352 } | 351 } |
| 353 | 352 |
| 354 // Troublemakers | 353 // Troublemakers |
| 355 | 354 |
| 356 std::wstring filename = StringToLowerASCII(info.path.BaseName().value()); | 355 std::wstring filename = StringToLowerASCII(info.path.BaseName().value()); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 387 } | 386 } |
| 388 | 387 |
| 389 // Special WMP handling | 388 // Special WMP handling |
| 390 | 389 |
| 391 // If both the new and old WMP plugins exist, only load the new one. | 390 // If both the new and old WMP plugins exist, only load the new one. |
| 392 if (filename == kNewWMPPlugin) { | 391 if (filename == kNewWMPPlugin) { |
| 393 if (dont_load_new_wmp_) | 392 if (dont_load_new_wmp_) |
| 394 return false; | 393 return false; |
| 395 | 394 |
| 396 for (size_t i = 0; i < plugins->size(); ++i) { | 395 for (size_t i = 0; i < plugins->size(); ++i) { |
| 397 if ((*plugins)[i].path.BaseName().value() == kOldWMPPlugin) { | 396 if (plugins->at(i).path.BaseName().value() == kOldWMPPlugin) { |
| 398 plugins->erase(plugins->begin() + i); | 397 plugins->erase(plugins->begin() + i); |
| 399 break; | 398 break; |
| 400 } | 399 } |
| 401 } | 400 } |
| 402 } else if (filename == kOldWMPPlugin) { | 401 } else if (filename == kOldWMPPlugin) { |
| 403 for (size_t i = 0; i < plugins->size(); ++i) { | 402 for (size_t i = 0; i < plugins->size(); ++i) { |
| 404 if ((*plugins)[i].path.BaseName().value() == kNewWMPPlugin) | 403 if (plugins->at(i).path.BaseName().value() == kNewWMPPlugin) |
| 405 return false; | 404 return false; |
| 406 } | 405 } |
| 407 } | 406 } |
| 408 | 407 |
| 409 return true; | 408 return true; |
| 410 } | 409 } |
| 411 | 410 |
| 412 } // namespace npapi | 411 } // namespace npapi |
| 413 } // namespace webkit | 412 } // namespace webkit |
| OLD | NEW |