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

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

Issue 10735011: Add permissions buts for Pepper plugins. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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
« no previous file with comments | « chrome/common/chrome_content_client.cc ('k') | content/content_common.gypi » ('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) 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/file_util.h" 8 #include "base/file_util.h"
9 #include "base/native_library.h" 9 #include "base/native_library.h"
10 #include "base/string_split.h" 10 #include "base/string_split.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "content/public/common/content_client.h" 13 #include "content/public/common/content_client.h"
14 #include "content/public/common/content_switches.h" 14 #include "content/public/common/content_switches.h"
15 #include "ppapi/shared_impl/ppapi_permissions.h"
15 #include "webkit/plugins/npapi/plugin_list.h" 16 #include "webkit/plugins/npapi/plugin_list.h"
16 17
17 namespace { 18 namespace {
18 19
19 // Appends any plugins from the command line to the given vector. 20 // Appends any plugins from the command line to the given vector.
20 void ComputePluginsFromCommandLine( 21 void ComputePluginsFromCommandLine(
21 std::vector<content::PepperPluginInfo>* plugins) { 22 std::vector<content::PepperPluginInfo>* plugins) {
22 bool out_of_process = 23 bool out_of_process =
23 CommandLine::ForCurrentProcess()->HasSwitch(switches::kPpapiOutOfProcess); 24 CommandLine::ForCurrentProcess()->HasSwitch(switches::kPpapiOutOfProcess);
24 const std::string value = 25 const std::string value =
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 plugin.description = name_parts[2]; 63 plugin.description = name_parts[2];
63 if (name_parts.size() > 3) 64 if (name_parts.size() > 3)
64 plugin.version = name_parts[3]; 65 plugin.version = name_parts[3];
65 for (size_t j = 1; j < parts.size(); ++j) { 66 for (size_t j = 1; j < parts.size(); ++j) {
66 webkit::WebPluginMimeType mime_type(parts[j], 67 webkit::WebPluginMimeType mime_type(parts[j],
67 std::string(), 68 std::string(),
68 plugin.description); 69 plugin.description);
69 plugin.mime_types.push_back(mime_type); 70 plugin.mime_types.push_back(mime_type);
70 } 71 }
71 72
73 // Command-line plugins get full permissions.
74 plugin.permissions = ppapi::PERMISSION_DEV |
75 ppapi::PERMISSION_PRIVATE |
76 ppapi::PERMISSION_BYPASS_USER_GESTURE;
77
72 plugins->push_back(plugin); 78 plugins->push_back(plugin);
73 } 79 }
74 } 80 }
75 81
76 } // namespace 82 } // namespace
77 83
78 webkit::WebPluginInfo content::PepperPluginInfo::ToWebPluginInfo() const { 84 webkit::WebPluginInfo content::PepperPluginInfo::ToWebPluginInfo() const {
79 webkit::WebPluginInfo info; 85 webkit::WebPluginInfo info;
80 86
81 info.type = is_out_of_process ? 87 info.type = is_out_of_process ?
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 // Note that in each case, AddLiveModule must be called before completing 216 // Note that in each case, AddLiveModule must be called before completing
211 // initialization. If we bail out (in the continue clauses) before saving 217 // initialization. If we bail out (in the continue clauses) before saving
212 // the initialized module, it will still try to unregister itself in its 218 // the initialized module, it will still try to unregister itself in its
213 // destructor. 219 // destructor.
214 for (size_t i = 0; i < plugin_list_.size(); i++) { 220 for (size_t i = 0; i < plugin_list_.size(); i++) {
215 const content::PepperPluginInfo& current = plugin_list_[i]; 221 const content::PepperPluginInfo& current = plugin_list_[i];
216 if (current.is_out_of_process) 222 if (current.is_out_of_process)
217 continue; // Out of process plugins need no special pre-initialization. 223 continue; // Out of process plugins need no special pre-initialization.
218 224
219 scoped_refptr<webkit::ppapi::PluginModule> module = 225 scoped_refptr<webkit::ppapi::PluginModule> module =
220 new webkit::ppapi::PluginModule(current.name, current.path, this); 226 new webkit::ppapi::PluginModule(current.name, current.path, this,
227 ppapi::PpapiPermissions(current.permissions));
221 AddLiveModule(current.path, module); 228 AddLiveModule(current.path, module);
222 if (current.is_internal) { 229 if (current.is_internal) {
223 if (!module->InitAsInternalPlugin(current.internal_entry_points)) { 230 if (!module->InitAsInternalPlugin(current.internal_entry_points)) {
224 DLOG(ERROR) << "Failed to load pepper module: " << current.path.value(); 231 DLOG(ERROR) << "Failed to load pepper module: " << current.path.value();
225 continue; 232 continue;
226 } 233 }
227 } else { 234 } else {
228 // Preload all external plugins we're not running out of process. 235 // Preload all external plugins we're not running out of process.
229 if (!module->InitAsLibrary(current.path)) { 236 if (!module->InitAsLibrary(current.path)) {
230 DLOG(ERROR) << "Failed to load pepper module: " << current.path.value(); 237 DLOG(ERROR) << "Failed to load pepper module: " << current.path.value();
231 continue; 238 continue;
232 } 239 }
233 } 240 }
234 preloaded_modules_[current.path] = module; 241 preloaded_modules_[current.path] = module;
235 } 242 }
236 } 243 }
237 244
OLDNEW
« no previous file with comments | « chrome/common/chrome_content_client.cc ('k') | content/content_common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698