Changeset 69790 in webkit


Ignore:
Timestamp:
Oct 14, 2010 12:22:27 PM (14 years ago)
Author:
Adam Roben
Message:

Make sure WebKit2 only loads each plugin once

Fixes <http://webkit.org/b/47677> <rdar://problem/8552178> WebKit2 can
load the same plugin multiple times

Reviewed by Sam Weinig.

  • UIProcess/Plugins/PluginInfoStore.cpp:

(WebKit::addFromVector): Helper function that adds all the elements
from a Vector to a HashSet.
(WebKit::PluginInfoStore::loadPluginsIfNecessary): Put all the plugin
paths into a HashSet, then load the plugins specified in the HashSet.
On Windows, the HashSet is case-insensitive, just like the file
system.

  • UIProcess/Plugins/PluginInfoStore.h: Removed loadPluginsInDirectory,

which is no longer used.

  • UIProcess/Plugins/win/PluginInfoStoreWin.cpp:

(WebKit::addPluginPathsFromRegistry):
(WebKit::PluginInfoStore::individualPluginPaths):
Changed to store the paths in a Vector instead of a HashSet now that
loadPluginsIfNecessary will handle duplicates for us.

Location:
trunk/WebKit2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit2/ChangeLog

    r69789 r69790  
     12010-10-14  Adam Roben  <aroben@apple.com>
     2
     3        Make sure WebKit2 only loads each plugin once
     4
     5        Fixes <http://webkit.org/b/47677> <rdar://problem/8552178> WebKit2 can
     6        load the same plugin multiple times
     7
     8        Reviewed by Sam Weinig.
     9
     10        * UIProcess/Plugins/PluginInfoStore.cpp:
     11        (WebKit::addFromVector): Helper function that adds all the elements
     12        from a Vector to a HashSet.
     13        (WebKit::PluginInfoStore::loadPluginsIfNecessary): Put all the plugin
     14        paths into a HashSet, then load the plugins specified in the HashSet.
     15        On Windows, the HashSet is case-insensitive, just like the file
     16        system.
     17
     18        * UIProcess/Plugins/PluginInfoStore.h: Removed loadPluginsInDirectory,
     19        which is no longer used.
     20
     21        * UIProcess/Plugins/win/PluginInfoStoreWin.cpp:
     22        (WebKit::addPluginPathsFromRegistry):
     23        (WebKit::PluginInfoStore::individualPluginPaths):
     24        Changed to store the paths in a Vector instead of a HashSet now that
     25        loadPluginsIfNecessary will handle duplicates for us.
     26
    1272010-10-14  Adam Roben  <aroben@apple.com>
    228
  • trunk/WebKit2/UIProcess/Plugins/PluginInfoStore.cpp

    r69789 r69790  
    5252}
    5353
     54template <typename T, typename U, typename V, typename W>
     55static void addFromVector(HashSet<T, U, V>& hashSet, const W& vector)
     56{
     57    for (size_t i = 0; i < vector.size(); ++i)
     58        hashSet.add(vector[i]);
     59}
     60
     61#if OS(WINDOWS)
     62typedef HashSet<String, CaseFoldingHash> PathHashSet;
     63#else
     64typedef HashSet<String> PathHashSet;
     65#endif
     66
    5467void PluginInfoStore::loadPluginsIfNecessary()
    5568{
     
    5972    m_plugins.clear();
    6073
     74    PathHashSet uniquePluginPaths;
     75
    6176    // First, load plug-ins from the additional plug-ins directories specified.
    6277    for (size_t i = 0; i < m_additionalPluginsDirectories.size(); ++i)
    63         loadPluginsInDirectory(m_additionalPluginsDirectories[i]);
     78        addFromVector(uniquePluginPaths, pluginPathsInDirectory(m_additionalPluginsDirectories[i]));
    6479
    6580    // Then load plug-ins from the standard plug-ins directories.
    6681    Vector<String> directories = pluginsDirectories();
    6782    for (size_t i = 0; i < directories.size(); ++i)
    68         loadPluginsInDirectory(directories[i]);
     83        addFromVector(uniquePluginPaths, pluginPathsInDirectory(directories[i]));
    6984
    7085    // Then load plug-ins that are not in the standard plug-ins directories.
    71     Vector<String> paths = individualPluginPaths();
    72     for (size_t i = 0; i < paths.size(); ++i)
    73         loadPlugin(paths[i]);
     86    addFromVector(uniquePluginPaths, individualPluginPaths());
     87
     88    PathHashSet::const_iterator end = uniquePluginPaths.end();
     89    for (PathHashSet::const_iterator it = uniquePluginPaths.begin(); it != end; ++it)
     90        loadPlugin(*it);
    7491
    7592    m_pluginListIsUpToDate = true;
    76 }
    77 
    78 void PluginInfoStore::loadPluginsInDirectory(const String& directory)
    79 {
    80     Vector<String> pluginPaths = pluginPathsInDirectory(directory);
    81     for (size_t i = 0; i < pluginPaths.size(); ++i)
    82         loadPlugin(pluginPaths[i]);
    8393}
    8494
  • trunk/WebKit2/UIProcess/Plugins/PluginInfoStore.h

    r69789 r69790  
    6969
    7070    void loadPluginsIfNecessary();
    71     void loadPluginsInDirectory(const String& directory);
    7271    void loadPlugin(const String& pluginPath);
    7372   
  • trunk/WebKit2/UIProcess/Plugins/win/PluginInfoStoreWin.cpp

    r69789 r69790  
    3030#include <WebCore/FileSystem.h>
    3131#include <shlwapi.h>
    32 #include <wtf/HashSet.h>
    3332#include <wtf/OwnArrayPtr.h>
    34 #include <wtf/text/StringHash.h>
    3533
    3634using namespace WebCore;
     
    306304}
    307305
    308 static void addPluginPathsFromRegistry(HKEY rootKey, HashSet<String, CaseFoldingHash>& paths)
     306static void addPluginPathsFromRegistry(HKEY rootKey, Vector<String>& paths)
    309307{
    310308    HKEY key;
     
    327325            continue;
    328326
    329         paths.add(path);
     327        paths.append(path);
    330328    }
    331329
     
    335333Vector<String> PluginInfoStore::individualPluginPaths()
    336334{
    337     HashSet<String, CaseFoldingHash> paths;
     335    Vector<String> paths;
    338336
    339337    addPluginPathsFromRegistry(HKEY_LOCAL_MACHINE, paths);
    340338    addPluginPathsFromRegistry(HKEY_CURRENT_USER, paths);
    341339
    342     Vector<String> result;
    343     copyToVector(paths, result);
    344     return result;
     340    return paths;
    345341}
    346342
Note: See TracChangeset for help on using the changeset viewer.