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

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

Issue 19894003: Move webplugininfo.h to content/public. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/common/pepper_plugin_registry.h" 5 #include "content/common/pepper_plugin_registry.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/native_library.h" 8 #include "base/native_library.h"
9 #include "base/strings/string_split.h" 9 #include "base/strings/string_split.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "content/public/common/content_client.h" 12 #include "content/public/common/content_client.h"
13 #include "content/public/common/content_switches.h" 13 #include "content/public/common/content_switches.h"
14 #include "ppapi/shared_impl/ppapi_permissions.h" 14 #include "ppapi/shared_impl/ppapi_permissions.h"
15 15
16 using webkit::WebPluginInfo;
17
18 namespace content { 16 namespace content {
19 namespace { 17 namespace {
20 18
21 // Appends any plugins from the command line to the given vector. 19 // Appends any plugins from the command line to the given vector.
22 void ComputePluginsFromCommandLine(std::vector<PepperPluginInfo>* plugins) { 20 void ComputePluginsFromCommandLine(std::vector<PepperPluginInfo>* plugins) {
23 bool out_of_process = true; 21 bool out_of_process = true;
24 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kPpapiInProcess)) 22 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kPpapiInProcess))
25 out_of_process = false; 23 out_of_process = false;
26 24
27 const std::string value = 25 const std::string value =
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 #else 57 #else
60 plugin.path = base::FilePath(name_parts[0]); 58 plugin.path = base::FilePath(name_parts[0]);
61 #endif 59 #endif
62 if (name_parts.size() > 1) 60 if (name_parts.size() > 1)
63 plugin.name = name_parts[1]; 61 plugin.name = name_parts[1];
64 if (name_parts.size() > 2) 62 if (name_parts.size() > 2)
65 plugin.description = name_parts[2]; 63 plugin.description = name_parts[2];
66 if (name_parts.size() > 3) 64 if (name_parts.size() > 3)
67 plugin.version = name_parts[3]; 65 plugin.version = name_parts[3];
68 for (size_t j = 1; j < parts.size(); ++j) { 66 for (size_t j = 1; j < parts.size(); ++j) {
69 webkit::WebPluginMimeType mime_type(parts[j], 67 WebPluginMimeType mime_type(parts[j],
70 std::string(), 68 std::string(),
71 plugin.description); 69 plugin.description);
72 plugin.mime_types.push_back(mime_type); 70 plugin.mime_types.push_back(mime_type);
73 } 71 }
74 72
75 // If the plugin name is empty, use the filename. 73 // If the plugin name is empty, use the filename.
76 if (plugin.name.empty()) 74 if (plugin.name.empty())
77 plugin.name = UTF16ToUTF8(plugin.path.BaseName().LossyDisplayName()); 75 plugin.name = UTF16ToUTF8(plugin.path.BaseName().LossyDisplayName());
78 76
79 // Command-line plugins get full permissions. 77 // Command-line plugins get full permissions.
80 plugin.permissions = ppapi::PERMISSION_ALL_BITS; 78 plugin.permissions = ppapi::PERMISSION_ALL_BITS;
81 79
82 plugins->push_back(plugin); 80 plugins->push_back(plugin);
83 } 81 }
84 } 82 }
85 83
86 } // namespace 84 } // namespace
87 85
88 bool MakePepperPluginInfo(const webkit::WebPluginInfo& webplugin_info, 86 bool MakePepperPluginInfo(const WebPluginInfo& webplugin_info,
89 PepperPluginInfo* pepper_info) { 87 PepperPluginInfo* pepper_info) {
90 if (!webplugin_info.is_pepper_plugin()) 88 if (!webplugin_info.is_pepper_plugin())
91 return false; 89 return false;
92 90
93 pepper_info->is_out_of_process = 91 pepper_info->is_out_of_process =
94 webplugin_info.type == WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS || 92 webplugin_info.type == WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS ||
95 webplugin_info.type == WebPluginInfo::PLUGIN_TYPE_PEPPER_UNSANDBOXED; 93 webplugin_info.type == WebPluginInfo::PLUGIN_TYPE_PEPPER_UNSANDBOXED;
96 pepper_info->is_sandboxed = webplugin_info.type != 94 pepper_info->is_sandboxed = webplugin_info.type !=
97 webkit::WebPluginInfo::PLUGIN_TYPE_PEPPER_UNSANDBOXED; 95 WebPluginInfo::PLUGIN_TYPE_PEPPER_UNSANDBOXED;
98 96
99 pepper_info->path = base::FilePath(webplugin_info.path); 97 pepper_info->path = base::FilePath(webplugin_info.path);
100 pepper_info->name = UTF16ToASCII(webplugin_info.name); 98 pepper_info->name = UTF16ToASCII(webplugin_info.name);
101 pepper_info->description = UTF16ToASCII(webplugin_info.desc); 99 pepper_info->description = UTF16ToASCII(webplugin_info.desc);
102 pepper_info->version = UTF16ToASCII(webplugin_info.version); 100 pepper_info->version = UTF16ToASCII(webplugin_info.version);
103 pepper_info->mime_types = webplugin_info.mime_types; 101 pepper_info->mime_types = webplugin_info.mime_types;
104 pepper_info->permissions = webplugin_info.pepper_permissions; 102 pepper_info->permissions = webplugin_info.pepper_permissions;
105 103
106 return true; 104 return true;
107 } 105 }
(...skipping 25 matching lines...) Expand all
133 &error); 131 &error);
134 DLOG_IF(WARNING, !library) << "Unable to load plugin " 132 DLOG_IF(WARNING, !library) << "Unable to load plugin "
135 << plugins[i].path.value() << " " 133 << plugins[i].path.value() << " "
136 << error; 134 << error;
137 (void)library; // Prevent release-mode warning. 135 (void)library; // Prevent release-mode warning.
138 } 136 }
139 } 137 }
140 } 138 }
141 139
142 const PepperPluginInfo* PepperPluginRegistry::GetInfoForPlugin( 140 const PepperPluginInfo* PepperPluginRegistry::GetInfoForPlugin(
143 const webkit::WebPluginInfo& info) { 141 const WebPluginInfo& info) {
144 for (size_t i = 0; i < plugin_list_.size(); ++i) { 142 for (size_t i = 0; i < plugin_list_.size(); ++i) {
145 if (info.path == plugin_list_[i].path) 143 if (info.path == plugin_list_[i].path)
146 return &plugin_list_[i]; 144 return &plugin_list_[i];
147 } 145 }
148 // We did not find the plugin in our list. But wait! the plugin can also 146 // We did not find the plugin in our list. But wait! the plugin can also
149 // be a latecomer, as it happens with pepper flash. This information 147 // be a latecomer, as it happens with pepper flash. This information
150 // is actually in |info| and we can use it to construct it and add it to 148 // is actually in |info| and we can use it to construct it and add it to
151 // the list. This same deal needs to be done in the browser side in 149 // the list. This same deal needs to be done in the browser side in
152 // PluginService. 150 // PluginService.
153 PepperPluginInfo plugin; 151 PepperPluginInfo plugin;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 if (!module->InitAsLibrary(current.path)) { 222 if (!module->InitAsLibrary(current.path)) {
225 DLOG(ERROR) << "Failed to load pepper module: " << current.path.value(); 223 DLOG(ERROR) << "Failed to load pepper module: " << current.path.value();
226 continue; 224 continue;
227 } 225 }
228 } 226 }
229 preloaded_modules_[current.path] = module; 227 preloaded_modules_[current.path] = module;
230 } 228 }
231 } 229 }
232 230
233 } // namespace content 231 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698