Home | History | Annotate | Download | only in plugins
      1 // Copyright (c) 2013 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 CHROME_COMMON_EXTENSIONS_API_PLUGINS_PLUGINS_HANDLER_H_
      6 #define CHROME_COMMON_EXTENSIONS_API_PLUGINS_PLUGINS_HANDLER_H_
      7 
      8 #include <string>
      9 
     10 #include "base/memory/scoped_ptr.h"
     11 #include "extensions/common/extension.h"
     12 #include "extensions/common/manifest_handler.h"
     13 
     14 namespace extensions {
     15 
     16 // An NPAPI plugin included in the extension.
     17 struct PluginInfo {
     18   typedef std::vector<PluginInfo> PluginVector;
     19 
     20   PluginInfo(const base::FilePath& plugin_path, bool plugin_is_public);
     21   ~PluginInfo();
     22 
     23   base::FilePath path;  // Path to the plugin.
     24   bool is_public;  // False if only this extension can load this plugin.
     25 
     26   // Return the plugins for a given |extensions|, or NULL if none exist.
     27   static const PluginVector* GetPlugins(const Extension* extension);
     28 
     29   // Return true if the given |extension| has plugins, and false otherwise.
     30   static bool HasPlugins(const Extension* extension);
     31 };
     32 
     33 // Parses the "plugins" manifest key.
     34 class PluginsHandler : public ManifestHandler {
     35  public:
     36   PluginsHandler();
     37   virtual ~PluginsHandler();
     38 
     39   virtual bool Parse(Extension* extension, base::string16* error) OVERRIDE;
     40   virtual bool Validate(const Extension* extension,
     41                         std::string* error,
     42                         std::vector<InstallWarning>* warnings) const OVERRIDE;
     43 
     44  private:
     45   virtual const std::vector<std::string> Keys() const OVERRIDE;
     46 
     47   DISALLOW_COPY_AND_ASSIGN(PluginsHandler);
     48 };
     49 
     50 }  // namespace extensions
     51 
     52 #endif  // CHROME_COMMON_EXTENSIONS_API_PLUGINS_PLUGINS_HANDLER_H_
     53