| 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 #ifndef WEBKIT_PLUGINS_NPAPI_PLUGIN_LIST_H_ |    5 #ifndef WEBKIT_PLUGINS_NPAPI_PLUGIN_LIST_H_ | 
|    6 #define WEBKIT_PLUGINS_NPAPI_PLUGIN_LIST_H_ |    6 #define WEBKIT_PLUGINS_NPAPI_PLUGIN_LIST_H_ | 
|    7  |    7  | 
|    8 #include <set> |    8 #include <set> | 
|    9 #include <string> |    9 #include <string> | 
|   10 #include <utility> |   10 #include <utility> | 
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   64   static bool SupportsType(const webkit::WebPluginInfo& plugin, |   64   static bool SupportsType(const webkit::WebPluginInfo& plugin, | 
|   65                            const std::string& mime_type, |   65                            const std::string& mime_type, | 
|   66                            bool allow_wildcard); |   66                            bool allow_wildcard); | 
|   67  |   67  | 
|   68   // Cause the plugin list to refresh next time they are accessed, regardless |   68   // Cause the plugin list to refresh next time they are accessed, regardless | 
|   69   // of whether they are already loaded. |   69   // of whether they are already loaded. | 
|   70   void RefreshPlugins(); |   70   void RefreshPlugins(); | 
|   71  |   71  | 
|   72   // Add/Remove an extra plugin to load when we actually do the loading.  Must |   72   // Add/Remove an extra plugin to load when we actually do the loading.  Must | 
|   73   // be called before the plugins have been loaded. |   73   // be called before the plugins have been loaded. | 
|   74   void AddExtraPluginPath(const FilePath& plugin_path); |   74   void AddExtraPluginPath(const base::FilePath& plugin_path); | 
|   75   void RemoveExtraPluginPath(const FilePath& plugin_path); |   75   void RemoveExtraPluginPath(const base::FilePath& plugin_path); | 
|   76  |   76  | 
|   77   // Same as above, but specifies a directory in which to search for plugins. |   77   // Same as above, but specifies a directory in which to search for plugins. | 
|   78   void AddExtraPluginDir(const FilePath& plugin_dir); |   78   void AddExtraPluginDir(const base::FilePath& plugin_dir); | 
|   79  |   79  | 
|   80   // Get the ordered list of directories from which to load plugins |   80   // Get the ordered list of directories from which to load plugins | 
|   81   void GetPluginDirectories(std::vector<FilePath>* plugin_dirs); |   81   void GetPluginDirectories(std::vector<base::FilePath>* plugin_dirs); | 
|   82  |   82  | 
|   83   // Register an internal plugin with the specified plugin information. |   83   // Register an internal plugin with the specified plugin information. | 
|   84   // An internal plugin must be registered before it can |   84   // An internal plugin must be registered before it can | 
|   85   // be loaded using PluginList::LoadPlugin(). |   85   // be loaded using PluginList::LoadPlugin(). | 
|   86   // If |add_at_beginning| is true the plugin will be added earlier in |   86   // If |add_at_beginning| is true the plugin will be added earlier in | 
|   87   // the list so that it can override the MIME types of older registrations. |   87   // the list so that it can override the MIME types of older registrations. | 
|   88   void RegisterInternalPlugin(const webkit::WebPluginInfo& info, |   88   void RegisterInternalPlugin(const webkit::WebPluginInfo& info, | 
|   89                               bool add_at_beginning); |   89                               bool add_at_beginning); | 
|   90  |   90  | 
|   91   // This second version is for "plugins" that have been compiled directly into |   91   // This second version is for "plugins" that have been compiled directly into | 
|   92   // the binary -- callers must provide the plugin information and the entry |   92   // the binary -- callers must provide the plugin information and the entry | 
|   93   // points. |   93   // points. | 
|   94   void RegisterInternalPluginWithEntryPoints( |   94   void RegisterInternalPluginWithEntryPoints( | 
|   95       const webkit::WebPluginInfo& info, |   95       const webkit::WebPluginInfo& info, | 
|   96       bool add_at_beginning, |   96       bool add_at_beginning, | 
|   97       const PluginEntryPoints& entry_points); |   97       const PluginEntryPoints& entry_points); | 
|   98  |   98  | 
|   99   // Removes a specified internal plugin from the list. The search will match |   99   // Removes a specified internal plugin from the list. The search will match | 
|  100   // on the path from the version info previously registered. |  100   // on the path from the version info previously registered. | 
|  101   // |  101   // | 
|  102   // This is generally only necessary for tests. |  102   // This is generally only necessary for tests. | 
|  103   void UnregisterInternalPlugin(const FilePath& path); |  103   void UnregisterInternalPlugin(const base::FilePath& path); | 
|  104  |  104  | 
|  105   // Gets a list of all the registered internal plugins. |  105   // Gets a list of all the registered internal plugins. | 
|  106   void GetInternalPlugins(std::vector<webkit::WebPluginInfo>* plugins); |  106   void GetInternalPlugins(std::vector<webkit::WebPluginInfo>* plugins); | 
|  107  |  107  | 
|  108   // Creates a WebPluginInfo structure given a plugin's path.  On success |  108   // Creates a WebPluginInfo structure given a plugin's path.  On success | 
|  109   // returns true, with the information being put into "info".  If it's an |  109   // returns true, with the information being put into "info".  If it's an | 
|  110   // internal plugin, "entry_points" is filled in as well with a |  110   // internal plugin, "entry_points" is filled in as well with a | 
|  111   // internally-owned PluginEntryPoints pointer. |  111   // internally-owned PluginEntryPoints pointer. | 
|  112   // Returns false if the library couldn't be found, or if it's not a plugin. |  112   // Returns false if the library couldn't be found, or if it's not a plugin. | 
|  113   bool ReadPluginInfo(const FilePath& filename, |  113   bool ReadPluginInfo(const base::FilePath& filename, | 
|  114                       webkit::WebPluginInfo* info, |  114                       webkit::WebPluginInfo* info, | 
|  115                       const PluginEntryPoints** entry_points); |  115                       const PluginEntryPoints** entry_points); | 
|  116  |  116  | 
|  117   // In Windows plugins, the mime types are passed as a specially formatted list |  117   // In Windows plugins, the mime types are passed as a specially formatted list | 
|  118   // of strings. This function parses those strings into a WebPluginMimeType |  118   // of strings. This function parses those strings into a WebPluginMimeType | 
|  119   // vector. |  119   // vector. | 
|  120   // TODO(evan): move this code into plugin_list_win. |  120   // TODO(evan): move this code into plugin_list_win. | 
|  121   static bool ParseMimeTypes( |  121   static bool ParseMimeTypes( | 
|  122       const std::string& mime_types, |  122       const std::string& mime_types, | 
|  123       const std::string& file_extensions, |  123       const std::string& file_extensions, | 
| (...skipping 22 matching lines...) Expand all  Loading... | 
|  146   // will be true iff the plug-in list was stale. |  146   // will be true iff the plug-in list was stale. | 
|  147   void GetPluginInfoArray(const GURL& url, |  147   void GetPluginInfoArray(const GURL& url, | 
|  148                           const std::string& mime_type, |  148                           const std::string& mime_type, | 
|  149                           bool allow_wildcard, |  149                           bool allow_wildcard, | 
|  150                           bool* use_stale, |  150                           bool* use_stale, | 
|  151                           std::vector<webkit::WebPluginInfo>* info, |  151                           std::vector<webkit::WebPluginInfo>* info, | 
|  152                           std::vector<std::string>* actual_mime_types); |  152                           std::vector<std::string>* actual_mime_types); | 
|  153  |  153  | 
|  154   // Load a specific plugin with full path. Return true iff loading the plug-in |  154   // Load a specific plugin with full path. Return true iff loading the plug-in | 
|  155   // was successful. |  155   // was successful. | 
|  156   bool LoadPluginIntoPluginList(const FilePath& filename, |  156   bool LoadPluginIntoPluginList(const base::FilePath& filename, | 
|  157                                 std::vector<webkit::WebPluginInfo>* plugins, |  157                                 std::vector<webkit::WebPluginInfo>* plugins, | 
|  158                                 webkit::WebPluginInfo* plugin_info); |  158                                 webkit::WebPluginInfo* plugin_info); | 
|  159  |  159  | 
|  160   // The following functions are used to support probing for WebPluginInfo |  160   // The following functions are used to support probing for WebPluginInfo | 
|  161   // using a different instance of this class. |  161   // using a different instance of this class. | 
|  162  |  162  | 
|  163   // Computes a list of all plugins to potentially load from all sources. |  163   // Computes a list of all plugins to potentially load from all sources. | 
|  164   void GetPluginPathsToLoad(std::vector<FilePath>* plugin_paths); |  164   void GetPluginPathsToLoad(std::vector<base::FilePath>* plugin_paths); | 
|  165  |  165  | 
|  166   // Clears the internal list of Plugins and copies them from the vector. |  166   // Clears the internal list of Plugins and copies them from the vector. | 
|  167   void SetPlugins(const std::vector<webkit::WebPluginInfo>& plugins); |  167   void SetPlugins(const std::vector<webkit::WebPluginInfo>& plugins); | 
|  168  |  168  | 
|  169   void set_will_load_plugins_callback(const base::Closure& callback); |  169   void set_will_load_plugins_callback(const base::Closure& callback); | 
|  170  |  170  | 
|  171   virtual ~PluginList(); |  171   virtual ~PluginList(); | 
|  172  |  172  | 
|  173  protected: |  173  protected: | 
|  174   // Constructors are private for singletons but we expose this one |  174   // Constructors are private for singletons but we expose this one | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
|  193   // Implements all IO dependent operations of the LoadPlugins method so that |  193   // Implements all IO dependent operations of the LoadPlugins method so that | 
|  194   // test classes can mock these out. |  194   // test classes can mock these out. | 
|  195   virtual void LoadPluginsIntoPluginListInternal( |  195   virtual void LoadPluginsIntoPluginListInternal( | 
|  196       std::vector<webkit::WebPluginInfo>* plugins); |  196       std::vector<webkit::WebPluginInfo>* plugins); | 
|  197  |  197  | 
|  198   // Load all plugins from the default plugins directory. |  198   // Load all plugins from the default plugins directory. | 
|  199   void LoadPlugins(); |  199   void LoadPlugins(); | 
|  200  |  200  | 
|  201   // Walks a directory and produces a list of all the plugins to potentially |  201   // Walks a directory and produces a list of all the plugins to potentially | 
|  202   // load in that directory. |  202   // load in that directory. | 
|  203   void GetPluginsInDir(const FilePath& path, std::vector<FilePath>* plugins); |  203   void GetPluginsInDir(const base::FilePath& path, | 
 |  204                        std::vector<base::FilePath>* plugins); | 
|  204  |  205  | 
|  205   // Returns true if we should load the given plugin, or false otherwise. |  206   // Returns true if we should load the given plugin, or false otherwise. | 
|  206   // |plugins| is the list of plugins we have crawled in the current plugin |  207   // |plugins| is the list of plugins we have crawled in the current plugin | 
|  207   // loading run. |  208   // loading run. | 
|  208   bool ShouldLoadPluginUsingPluginList( |  209   bool ShouldLoadPluginUsingPluginList( | 
|  209       const webkit::WebPluginInfo& info, |  210       const webkit::WebPluginInfo& info, | 
|  210       std::vector<webkit::WebPluginInfo>* plugins); |  211       std::vector<webkit::WebPluginInfo>* plugins); | 
|  211  |  212  | 
|  212   // Returns true if the given plugin supports a given file extension. |  213   // Returns true if the given plugin supports a given file extension. | 
|  213   // |extension| should be all lower case. If |mime_type| is not NULL, it will |  214   // |extension| should be all lower case. If |mime_type| is not NULL, it will | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
|  227   // |  228   // | 
|  228   // Command-line switches |  229   // Command-line switches | 
|  229   // |  230   // | 
|  230  |  231  | 
|  231 #if defined(OS_WIN) |  232 #if defined(OS_WIN) | 
|  232   // true if we shouldn't load the new WMP plugin. |  233   // true if we shouldn't load the new WMP plugin. | 
|  233   bool dont_load_new_wmp_; |  234   bool dont_load_new_wmp_; | 
|  234  |  235  | 
|  235   // Gets plugin paths registered under HKCU\Software\MozillaPlugins and |  236   // Gets plugin paths registered under HKCU\Software\MozillaPlugins and | 
|  236   // HKLM\Software\MozillaPlugins. |  237   // HKLM\Software\MozillaPlugins. | 
|  237   void GetPluginPathsFromRegistry(std::vector<FilePath>* plugins); |  238   void GetPluginPathsFromRegistry(std::vector<base::FilePath>* plugins); | 
|  238 #endif |  239 #endif | 
|  239  |  240  | 
|  240   // |  241   // | 
|  241   // Internals |  242   // Internals | 
|  242   // |  243   // | 
|  243  |  244  | 
|  244   // States whether we will load the plug-in list the next time we try to access |  245   // States whether we will load the plug-in list the next time we try to access | 
|  245   // it, whether we are currently in the process of loading it, or whether we |  246   // it, whether we are currently in the process of loading it, or whether we | 
|  246   // consider it up-to-date. |  247   // consider it up-to-date. | 
|  247   LoadingState loading_state_; |  248   LoadingState loading_state_; | 
|  248  |  249  | 
|  249   // Extra plugin paths that we want to search when loading. |  250   // Extra plugin paths that we want to search when loading. | 
|  250   std::vector<FilePath> extra_plugin_paths_; |  251   std::vector<base::FilePath> extra_plugin_paths_; | 
|  251  |  252  | 
|  252   // Extra plugin directories that we want to search when loading. |  253   // Extra plugin directories that we want to search when loading. | 
|  253   std::vector<FilePath> extra_plugin_dirs_; |  254   std::vector<base::FilePath> extra_plugin_dirs_; | 
|  254  |  255  | 
|  255   // Holds information about internal plugins. |  256   // Holds information about internal plugins. | 
|  256   std::vector<InternalPlugin> internal_plugins_; |  257   std::vector<InternalPlugin> internal_plugins_; | 
|  257  |  258  | 
|  258   // A list holding all plug-ins. |  259   // A list holding all plug-ins. | 
|  259   std::vector<webkit::WebPluginInfo> plugins_list_; |  260   std::vector<webkit::WebPluginInfo> plugins_list_; | 
|  260  |  261  | 
|  261   // Callback that is invoked whenever the PluginList will reload the plugins. |  262   // Callback that is invoked whenever the PluginList will reload the plugins. | 
|  262   base::Closure will_load_plugins_callback_; |  263   base::Closure will_load_plugins_callback_; | 
|  263  |  264  | 
|  264   // Need synchronization for the above members since this object can be |  265   // Need synchronization for the above members since this object can be | 
|  265   // accessed on multiple threads. |  266   // accessed on multiple threads. | 
|  266   base::Lock lock_; |  267   base::Lock lock_; | 
|  267  |  268  | 
|  268   DISALLOW_COPY_AND_ASSIGN(PluginList); |  269   DISALLOW_COPY_AND_ASSIGN(PluginList); | 
|  269 }; |  270 }; | 
|  270  |  271  | 
|  271 }  // namespace npapi |  272 }  // namespace npapi | 
|  272 }  // namespace webkit |  273 }  // namespace webkit | 
|  273  |  274  | 
|  274 #endif  // WEBKIT_PLUGINS_NPAPI_PLUGIN_LIST_H_ |  275 #endif  // WEBKIT_PLUGINS_NPAPI_PLUGIN_LIST_H_ | 
| OLD | NEW |