Home | History | Annotate | Download | only in common
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef CONTENT_PUBLIC_COMMON_WEBPLUGININFO_H_
      6 #define CONTENT_PUBLIC_COMMON_WEBPLUGININFO_H_
      7 
      8 #include <string>
      9 #include <vector>
     10 
     11 #include "base/basictypes.h"
     12 #include "base/files/file_path.h"
     13 #include "content/common/content_export.h"
     14 
     15 namespace base {
     16 class Version;
     17 }
     18 
     19 namespace content {
     20 
     21 struct CONTENT_EXPORT WebPluginMimeType {
     22   WebPluginMimeType();
     23   // A constructor for the common case of a single file extension and an ASCII
     24   // description.
     25   WebPluginMimeType(const std::string& m,
     26                     const std::string& f,
     27                     const std::string& d);
     28   ~WebPluginMimeType();
     29 
     30   // The name of the mime type (e.g., "application/x-shockwave-flash").
     31   std::string mime_type;
     32 
     33   // A list of all the file extensions for this mime type.
     34   std::vector<std::string> file_extensions;
     35 
     36   // Description of the mime type.
     37   base::string16 description;
     38 
     39   // Extra parameters to include when instantiating the plugin.
     40   std::vector<base::string16> additional_param_names;
     41   std::vector<base::string16> additional_param_values;
     42 };
     43 
     44 // Describes an available NPAPI or Pepper plugin.
     45 struct CONTENT_EXPORT WebPluginInfo {
     46   enum PluginType {
     47     PLUGIN_TYPE_NPAPI,
     48     PLUGIN_TYPE_PEPPER_IN_PROCESS,
     49     PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS,
     50     PLUGIN_TYPE_PEPPER_UNSANDBOXED
     51   };
     52 
     53   WebPluginInfo();
     54   WebPluginInfo(const WebPluginInfo& rhs);
     55   ~WebPluginInfo();
     56   WebPluginInfo& operator=(const WebPluginInfo& rhs);
     57 
     58   // Special constructor only used during unit testing:
     59   WebPluginInfo(const base::string16& fake_name,
     60                 const base::FilePath& fake_path,
     61                 const base::string16& fake_version,
     62                 const base::string16& fake_desc);
     63 
     64   bool is_pepper_plugin() const {
     65     return ((type == PLUGIN_TYPE_PEPPER_IN_PROCESS ) ||
     66           (type == PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS) ||
     67           (type == PLUGIN_TYPE_PEPPER_UNSANDBOXED));
     68   }
     69 
     70   // Parse a version string as used by a plug-in. This method is more lenient
     71   // in accepting weird version strings than base::Version::GetFromString()
     72   static void CreateVersionFromString(const base::string16& version_string,
     73                                       base::Version* parsed_version);
     74 
     75   // The name of the plugin (i.e. Flash).
     76   base::string16 name;
     77 
     78   // The path to the plugin file (DLL/bundle/library).
     79   base::FilePath path;
     80 
     81   // The version number of the plugin file (may be OS-specific)
     82   base::string16 version;
     83 
     84   // A description of the plugin that we get from its version info.
     85   base::string16 desc;
     86 
     87   // A list of all the mime types that this plugin supports.
     88   std::vector<WebPluginMimeType> mime_types;
     89 
     90   // Plugin type. See the PluginType enum.
     91   int type;
     92 
     93   // When type is PLUGIN_TYPE_PEPPER_* this indicates the permission bits.
     94   int32 pepper_permissions;
     95 };
     96 
     97 }  // namespace content
     98 
     99 #endif  // CONTENT_PUBLIC_COMMON_WEBPLUGININFO_H_
    100