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

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

Issue 7982026: Add GetPluginPath() to npobject_util to avoid content/plugin/ include from npobject_stub.cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/npobject_util.h" 5 #include "content/common/npobject_util.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "content/common/np_channel_base.h" 8 #include "content/common/np_channel_base.h"
9 #include "content/common/npobject_proxy.h" 9 #include "content/common/npobject_proxy.h"
10 #include "content/common/plugin_messages.h" 10 #include "content/common/plugin_messages.h"
11 #include "third_party/npapi/bindings/nphostapi.h" 11 #include "third_party/npapi/bindings/nphostapi.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h"
13 #include "webkit/plugins/npapi/plugin_host.h" 13 #include "webkit/plugins/npapi/plugin_host.h"
14 #include "webkit/glue/webkit_glue.h" 14 #include "webkit/glue/webkit_glue.h"
15 15
16 using WebKit::WebBindings; 16 using WebKit::WebBindings;
17 17
18 // true if the current process is a plugin process, false if it's a renderer 18 // true if the current process is a plugin process, false otherwise.
19 static bool g_plugin_process;
20 // The path of the plugin file that this process hosts, if this is a plugin
19 // process. 21 // process.
20 static bool g_plugin_process; 22 static FilePath* g_plugin_path = NULL;
21 23
22 namespace { 24 namespace {
23 // The next 7 functions are called by the plugin code when it's using the 25 // The next 7 functions are called by the plugin code when it's using the
24 // NPObject. Plugins always ignore the functions in NPClass (except allocate 26 // NPObject. Plugins always ignore the functions in NPClass (except allocate
25 // and deallocate), and instead just use the function pointers that were 27 // and deallocate), and instead just use the function pointers that were
26 // passed in NPInitialize. 28 // passed in NPInitialize.
27 // When the renderer interacts with an NPObject from the plugin, it of course 29 // When the renderer interacts with an NPObject from the plugin, it of course
28 // uses the function pointers in its NPClass structure. 30 // uses the function pointers in its NPClass structure.
29 static bool NPN_HasMethodPatch(NPP npp, 31 static bool NPN_HasMethodPatch(NPP npp,
30 NPObject *npobj, 32 NPObject *npobj,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 host_funcs.hasmethod = NPN_HasMethodPatch; 120 host_funcs.hasmethod = NPN_HasMethodPatch;
119 host_funcs.setexception = NPN_SetExceptionPatch; 121 host_funcs.setexception = NPN_SetExceptionPatch;
120 host_funcs.enumerate = NPN_EnumeratePatch; 122 host_funcs.enumerate = NPN_EnumeratePatch;
121 123
122 init = true; 124 init = true;
123 return &host_funcs; 125 return &host_funcs;
124 } 126 }
125 127
126 } 128 }
127 129
128 void PatchNPNFunctions() { 130 void PatchNPNFunctions(const FilePath& plugin_path) {
129 g_plugin_process = true; 131 g_plugin_process = true;
132 DCHECK(!g_plugin_path);
133 g_plugin_path = new FilePath(plugin_path);
130 NPNetscapeFuncs* funcs = GetHostFunctions(); 134 NPNetscapeFuncs* funcs = GetHostFunctions();
131 webkit::npapi::PluginHost::Singleton()->PatchNPNetscapeFuncs(funcs); 135 webkit::npapi::PluginHost::Singleton()->PatchNPNetscapeFuncs(funcs);
132 } 136 }
133 137
134 bool IsPluginProcess() { 138 bool IsPluginProcess() {
135 return g_plugin_process; 139 return g_plugin_process;
136 } 140 }
137 141
142 const FilePath& GetPluginPath() {
143 DCHECK(g_plugin_process);
144 return *g_plugin_path;
145 }
146
138 void CreateNPIdentifierParam(NPIdentifier id, NPIdentifier_Param* param) { 147 void CreateNPIdentifierParam(NPIdentifier id, NPIdentifier_Param* param) {
139 param->identifier = id; 148 param->identifier = id;
140 } 149 }
141 150
142 NPIdentifier CreateNPIdentifier(const NPIdentifier_Param& param) { 151 NPIdentifier CreateNPIdentifier(const NPIdentifier_Param& param) {
143 return param.identifier; 152 return param.identifier;
144 } 153 }
145 154
146 void CreateNPVariantParam(const NPVariant& variant, 155 void CreateNPVariantParam(const NPVariant& variant,
147 NPChannelBase* channel, 156 NPChannelBase* channel,
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 result->type = NPVariantType_Object; 289 result->type = NPVariantType_Object;
281 result->value.objectValue = npobject_base->GetUnderlyingNPObject(); 290 result->value.objectValue = npobject_base->GetUnderlyingNPObject();
282 WebBindings::retainObject(result->value.objectValue); 291 WebBindings::retainObject(result->value.objectValue);
283 break; 292 break;
284 } 293 }
285 default: 294 default:
286 NOTREACHED(); 295 NOTREACHED();
287 } 296 }
288 return true; 297 return true;
289 } 298 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698