summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/api/plugins/plugins_handler.h
blob: 231541232b8bfcc9f67007acb0e378fe8827e3da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_COMMON_EXTENSIONS_API_PLUGINS_PLUGINS_HANDLER_H_
#define CHROME_COMMON_EXTENSIONS_API_PLUGINS_PLUGINS_HANDLER_H_

#include <string>

#include "base/memory/scoped_ptr.h"
#include "chrome/common/extensions/extension.h"
#include "extensions/common/manifest_handler.h"

namespace extensions {

// An NPAPI plugin included in the extension.
struct PluginInfo {
  typedef std::vector<PluginInfo> PluginVector;

  PluginInfo(const base::FilePath& plugin_path, bool plugin_is_public);
  ~PluginInfo();

  base::FilePath path;  // Path to the plugin.
  bool is_public;  // False if only this extension can load this plugin.

  // Return the plugins for a given |extensions|, or NULL if none exist.
  static const PluginVector* GetPlugins(const Extension* extension);

  // Return true if the given |extension| has plugins, and false otherwise.
  static bool HasPlugins(const Extension* extension);
};

// Parses the "plugins" manifest key.
class PluginsHandler : public ManifestHandler {
 public:
  PluginsHandler();
  virtual ~PluginsHandler();

  virtual bool Parse(Extension* extension, string16* error) OVERRIDE;
  virtual bool Validate(const Extension* extension,
                        std::string* error,
                        std::vector<InstallWarning>* warnings) const OVERRIDE;

 private:
  virtual const std::vector<std::string> Keys() const OVERRIDE;

  DISALLOW_COPY_AND_ASSIGN(PluginsHandler);
};

}  // namespace extensions

#endif  // CHROME_COMMON_EXTENSIONS_API_PLUGINS_PLUGINS_HANDLER_H_