Bug 47677

Summary: WebKit2 can load the same plugin multiple times
Product: WebKit Reporter: Adam Roben (:aroben) <aroben>
Component: Plug-insAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: andersca, jhoneycutt, sam
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
See Also: https://bugs.webkit.org/show_bug.cgi?id=164103
Attachments:
Description Flags
Make sure WebKit2 only loads each plugin once sam: review+

Description Adam Roben (:aroben) 2010-10-14 11:21:01 PDT
It's possible for WebKit2 to load the same plugin multiple times. This can happen, e.g., if a client application passes the path to a standard plugin directory to _WKContextSetAdditionalPluginsDirectory, or if a plugin in one of the standard plugin directories on Windows is also listed in the MozillaPlugins registry key.
Comment 1 Adam Roben (:aroben) 2010-10-14 11:21:53 PDT
We could change how we load plugins to:

1) Collect all plugin paths from all directories
2) Put all the paths in a HashSet to get rid of duplicates
3) Load plugins specified in the HashSet

On Windows, we'd probably want to use a case-insensitive HashSet.
Comment 2 Adam Roben (:aroben) 2010-10-14 11:22:13 PDT
<rdar://problem/8552178>
Comment 3 Adam Roben (:aroben) 2010-10-14 11:55:13 PDT
Created attachment 70763 [details]
Make sure WebKit2 only loads each plugin once
Comment 4 Sam Weinig 2010-10-14 12:08:26 PDT
Comment on attachment 70763 [details]
Make sure WebKit2 only loads each plugin once

View in context: https://bugs.webkit.org/attachment.cgi?id=70763&action=review

> WebKit2/UIProcess/Plugins/PluginInfoStore.cpp:59
> +template <typename T, typename U, typename V, typename W>
> +static void addFromVector(HashSet<T, U, V>& hashSet, const W& vector)
> +{
> +    for (size_t i = 0; i < vector.size(); ++i)
> +        hashSet.add(vector[i]);
> +}

Should this be in HashSet.h?
Comment 5 Adam Roben (:aroben) 2010-10-14 12:09:52 PDT
Comment on attachment 70763 [details]
Make sure WebKit2 only loads each plugin once

View in context: https://bugs.webkit.org/attachment.cgi?id=70763&action=review

>> WebKit2/UIProcess/Plugins/PluginInfoStore.cpp:59
>> +}
> 
> Should this be in HashSet.h?

If we find it to be more generally useful we could put it there.

Thanks for reviewing!
Comment 6 Adam Roben (:aroben) 2010-10-14 12:33:35 PDT
Committed r69790: <http://trac.webkit.org/changeset/69790>