Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: chrome/common/pepper_plugin_registry.cc

Issue 2834021: Revert 50667 - Add in support for internal pepper plugins into the PepperPlug... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/pepper_plugin_registry.h ('k') | remoting/client/plugin/chromoting_plugin.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "chrome/common/pepper_plugin_registry.h" 5 #include "chrome/common/pepper_plugin_registry.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "chrome/common/chrome_switches.h" 9 #include "chrome/common/chrome_switches.h"
10 #include "remoting/client/plugin/pepper_entrypoints.h"
11 10
12 // static 11 // static
13 PepperPluginRegistry* PepperPluginRegistry::GetInstance() { 12 PepperPluginRegistry* PepperPluginRegistry::GetInstance() {
14 static PepperPluginRegistry registry; 13 static PepperPluginRegistry registry;
15 return &registry; 14 return &registry;
16 } 15 }
17 16
18 // static 17 // static
19 void PepperPluginRegistry::GetList(std::vector<PepperPluginInfo>* plugins) { 18 void PepperPluginRegistry::GetList(std::vector<PepperPluginInfo>* plugins) {
20 InternalPluginInfoList internal_plugin_info;
21 GetInternalPluginInfo(&internal_plugin_info);
22 for (InternalPluginInfoList::const_iterator it =
23 internal_plugin_info.begin();
24 it != internal_plugin_info.end();
25 ++it) {
26 plugins->push_back(*it);
27 }
28
29 GetPluginInfoFromSwitch(plugins);
30 }
31
32 // static
33 void PepperPluginRegistry::GetPluginInfoFromSwitch(
34 std::vector<PepperPluginInfo>* plugins) {
35 const std::wstring& value = CommandLine::ForCurrentProcess()->GetSwitchValue( 19 const std::wstring& value = CommandLine::ForCurrentProcess()->GetSwitchValue(
36 switches::kRegisterPepperPlugins); 20 switches::kRegisterPepperPlugins);
37 if (value.empty()) 21 if (value.empty())
38 return; 22 return;
39 23
40 // FORMAT: 24 // FORMAT:
41 // command-line = <plugin-entry> + *( LWS + "," + LWS + <plugin-entry> ) 25 // command-line = <plugin-entry> + *( LWS + "," + LWS + <plugin-entry> )
42 // plugin-entry = <file-path> + *1( LWS + ";" + LWS + <mime-type> ) 26 // plugin-entry = <file-path> + *1( LWS + ";" + LWS + <mime-type> )
43 27
44 std::vector<std::wstring> modules; 28 std::vector<std::wstring> modules;
45 SplitString(value, ',', &modules); 29 SplitString(value, ',', &modules);
46 for (size_t i = 0; i < modules.size(); ++i) { 30 for (size_t i = 0; i < modules.size(); ++i) {
47 std::vector<std::wstring> parts; 31 std::vector<std::wstring> parts;
48 SplitString(modules[i], ';', &parts); 32 SplitString(modules[i], ';', &parts);
49 if (parts.size() < 2) { 33 if (parts.size() < 2) {
50 DLOG(ERROR) << "Required mime-type not found"; 34 DLOG(ERROR) << "Required mime-type not found";
51 continue; 35 continue;
52 } 36 }
53 37
54 PepperPluginInfo plugin; 38 PepperPluginInfo plugin;
55 plugin.path = FilePath::FromWStringHack(parts[0]); 39 plugin.path = FilePath::FromWStringHack(parts[0]);
56 for (size_t j = 1; j < parts.size(); ++j) 40 for (size_t j = 1; j < parts.size(); ++j)
57 plugin.mime_types.push_back(WideToASCII(parts[j])); 41 plugin.mime_types.push_back(WideToASCII(parts[j]));
58 42
59 plugins->push_back(plugin); 43 plugins->push_back(plugin);
60 } 44 }
61 } 45 }
62 46
63 // static
64 void PepperPluginRegistry::GetInternalPluginInfo(
65 InternalPluginInfoList* plugin_info) {
66 // Currently, to centralize the internal plugin registration logic, we
67 // hardcode the list of plugins, mimetypes, and registration information
68 // in this function. This is gross, but because the GetList() function is
69 // called from both the renderer and browser the other option is to force a
70 // special register function for each plugin to be called by both
71 // RendererMain() and BrowserMain(). This seemed like the better tradeoff.
72 //
73 // TODO(ajwong): Think up a better way to maintain the plugin registration
74 // information. Pehraps by construction of a singly linked list of
75 // plugin initializers that is built with static initializers?
76
77 #if defined(ENABLE_REMOTING)
78 InternalPluginInfo info;
79 // Add the chromoting plugin.
80 info.path =
81 FilePath(FILE_PATH_LITERAL("internal-chromoting"));
82 info.mime_types.push_back("pepper-application/x-chromoting");
83 info.entry_points.get_interface = remoting::PPP_GetInterface;
84 info.entry_points.initialize_module = remoting::PPP_InitializeModule;
85 info.entry_points.shutdown_module = remoting::PPP_ShutdownModule;
86
87 plugin_info->push_back(info);
88 #endif
89
90 }
91
92 pepper::PluginModule* PepperPluginRegistry::GetModule( 47 pepper::PluginModule* PepperPluginRegistry::GetModule(
93 const FilePath& path) const { 48 const FilePath& path) const {
94 ModuleMap::const_iterator it = modules_.find(path); 49 ModuleMap::const_iterator it = modules_.find(path);
95 if (it == modules_.end()) 50 if (it == modules_.end())
96 return NULL; 51 return NULL;
97 return it->second; 52 return it->second;
98 } 53 }
99 54
100 PepperPluginRegistry::PepperPluginRegistry() { 55 PepperPluginRegistry::PepperPluginRegistry() {
101 InternalPluginInfoList internal_plugin_info;
102 GetInternalPluginInfo(&internal_plugin_info);
103 // Register modules for these suckers.
104 for (InternalPluginInfoList::const_iterator it =
105 internal_plugin_info.begin();
106 it != internal_plugin_info.end();
107 ++it) {
108 const FilePath& path = it->path;
109 ModuleHandle module =
110 pepper::PluginModule::CreateInternalModule(it->entry_points);
111 if (!module) {
112 DLOG(ERROR) << "Failed to load pepper module: " << path.value();
113 continue;
114 }
115 modules_[path] = module;
116 }
117
118 // Add the modules specified on the command line last so that they can
119 // override the internal plugins.
120 std::vector<PepperPluginInfo> plugins; 56 std::vector<PepperPluginInfo> plugins;
121 GetPluginInfoFromSwitch(&plugins); 57 GetList(&plugins);
122 for (size_t i = 0; i < plugins.size(); ++i) { 58 for (size_t i = 0; i < plugins.size(); ++i) {
123 const FilePath& path = plugins[i].path; 59 const FilePath& path = plugins[i].path;
124 ModuleHandle module = pepper::PluginModule::CreateModule(path); 60 ModuleHandle module = pepper::PluginModule::CreateModule(path);
125 if (!module) { 61 if (!module) {
126 DLOG(ERROR) << "Failed to load pepper module: " << path.value(); 62 DLOG(ERROR) << "Failed to load pepper module: " << path.value();
127 continue; 63 continue;
128 } 64 }
129 modules_[path] = module; 65 modules_[path] = module;
130 } 66 }
131 } 67 }
OLDNEW
« no previous file with comments | « chrome/common/pepper_plugin_registry.h ('k') | remoting/client/plugin/chromoting_plugin.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698