| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_COMMON_PEPPER_PLUGIN_REGISTRY_H_ | 5 #ifndef CHROME_COMMON_PEPPER_PLUGIN_REGISTRY_H_ |
| 6 #define CHROME_COMMON_PEPPER_PLUGIN_REGISTRY_H_ | 6 #define CHROME_COMMON_PEPPER_PLUGIN_REGISTRY_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
| 14 #include "webkit/glue/plugins/pepper_plugin_module.h" | 14 #include "webkit/glue/plugins/pepper_plugin_module.h" |
| 15 | 15 |
| 16 struct PepperPluginInfo { | 16 struct PepperPluginInfo { |
| 17 PepperPluginInfo(); // Needed to initialize |is_internal|. | 17 PepperPluginInfo(); |
| 18 ~PepperPluginInfo(); | 18 ~PepperPluginInfo(); |
| 19 | 19 |
| 20 bool is_internal; // Defaults to false (see constructor). | 20 // Indicates internal plugins for which there's not actually a library. |
| 21 // Defaults to false. |
| 22 bool is_internal; |
| 23 |
| 24 // True when this plugin should be run out of process. Defaults to false. |
| 25 bool is_out_of_process; |
| 26 |
| 21 FilePath path; // Internal plugins have "internal-[name]" as path. | 27 FilePath path; // Internal plugins have "internal-[name]" as path. |
| 22 std::vector<std::string> mime_types; | 28 std::vector<std::string> mime_types; |
| 23 std::string name; | 29 std::string name; |
| 24 std::string description; | 30 std::string description; |
| 25 std::string file_extensions; | 31 std::string file_extensions; |
| 26 std::string type_descriptions; | 32 std::string type_descriptions; |
| 27 }; | 33 }; |
| 28 | 34 |
| 29 // This class holds references to all of the known pepper plugin modules. | 35 // This class holds references to all of the known pepper plugin modules. |
| 30 class PepperPluginRegistry { | 36 class PepperPluginRegistry { |
| 31 public: | 37 public: |
| 32 static const char* kPDFPluginName; | 38 static const char* kPDFPluginName; |
| 33 static const char* kPDFPluginMimeType; | 39 static const char* kPDFPluginMimeType; |
| 34 static const char* kPDFPluginExtension; | 40 static const char* kPDFPluginExtension; |
| 35 static const char* kPDFPluginDescription; | 41 static const char* kPDFPluginDescription; |
| 36 | 42 |
| 37 static PepperPluginRegistry* GetInstance(); | 43 static PepperPluginRegistry* GetInstance(); |
| 38 | 44 |
| 39 // Returns the list of known pepper plugins. This method is static so that | 45 // Returns the list of known pepper plugins. This method is static so that |
| 40 // it can be used by the browser process, which has no need to load the | 46 // it can be used by the browser process, which has no need to load the |
| 41 // pepper plugin modules. | 47 // pepper plugin modules. |
| 42 static void GetList(std::vector<PepperPluginInfo>* plugins); | 48 static void GetList(std::vector<PepperPluginInfo>* plugins); |
| 43 | 49 |
| 44 // Loads the (native) libraries but does not initialize them (i.e., does not | 50 // Loads the (native) libraries but does not initialize them (i.e., does not |
| 45 // call PPP_InitializeModule). This is needed by the zygote on Linux to get | 51 // call PPP_InitializeModule). This is needed by the zygote on Linux to get |
| 46 // access to the plugins before entering the sandbox. | 52 // access to the plugins before entering the sandbox. |
| 47 static void PreloadModules(); | 53 static void PreloadModules(); |
| 48 | 54 |
| 55 // Returns true if the given plugin is a pepper plugin that should be run |
| 56 // out of process. |
| 57 bool RunOutOfProcessForPlugin(const FilePath& path) const; |
| 58 |
| 59 // Returns a preloaded module for the given path. This only works for |
| 60 // non-out-of-process plugins since we preload them so they will run in the |
| 61 // sandbox. Returns NULL if the plugin hasn't been preloaded. |
| 49 pepper::PluginModule* GetModule(const FilePath& path) const; | 62 pepper::PluginModule* GetModule(const FilePath& path) const; |
| 50 | 63 |
| 51 ~PepperPluginRegistry(); | 64 ~PepperPluginRegistry(); |
| 52 | 65 |
| 53 private: | 66 private: |
| 54 static void GetPluginInfoFromSwitch(std::vector<PepperPluginInfo>* plugins); | 67 static void GetPluginInfoFromSwitch(std::vector<PepperPluginInfo>* plugins); |
| 55 static void GetExtraPlugins(std::vector<PepperPluginInfo>* plugins); | 68 static void GetExtraPlugins(std::vector<PepperPluginInfo>* plugins); |
| 56 | 69 |
| 57 struct InternalPluginInfo : public PepperPluginInfo { | 70 struct InternalPluginInfo : public PepperPluginInfo { |
| 58 InternalPluginInfo(); // Sets |is_internal|. | 71 InternalPluginInfo(); // Sets |is_internal|. |
| 59 pepper::PluginModule::EntryPoints entry_points; | 72 pepper::PluginModule::EntryPoints entry_points; |
| 60 }; | 73 }; |
| 61 typedef std::vector<InternalPluginInfo> InternalPluginInfoList; | 74 typedef std::vector<InternalPluginInfo> InternalPluginInfoList; |
| 62 static void GetInternalPluginInfo(InternalPluginInfoList* plugin_info); | 75 static void GetInternalPluginInfo(InternalPluginInfoList* plugin_info); |
| 63 | 76 |
| 64 PepperPluginRegistry(); | 77 PepperPluginRegistry(); |
| 65 | 78 |
| 66 typedef scoped_refptr<pepper::PluginModule> ModuleHandle; | 79 typedef scoped_refptr<pepper::PluginModule> ModuleHandle; |
| 67 typedef std::map<FilePath, ModuleHandle> ModuleMap; | 80 typedef std::map<FilePath, ModuleHandle> ModuleMap; |
| 68 ModuleMap modules_; | 81 ModuleMap modules_; |
| 69 }; | 82 }; |
| 70 | 83 |
| 71 #endif // CHROME_COMMON_PEPPER_PLUGIN_REGISTRY_H_ | 84 #endif // CHROME_COMMON_PEPPER_PLUGIN_REGISTRY_H_ |
| OLD | NEW |