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

Side by Side Diff: ppapi/proxy/interface_list.cc

Issue 112343005: Pepper: Finish support for dev channel APIs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: style nit Created 7 years 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 "ppapi/proxy/interface_list.h" 5 #include "ppapi/proxy/interface_list.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/memory/singleton.h" 8 #include "base/memory/singleton.h"
9 #include "ppapi/c/dev/ppb_alarms_dev.h" 9 #include "ppapi/c/dev/ppb_alarms_dev.h"
10 #include "ppapi/c/dev/ppb_audio_input_dev.h" 10 #include "ppapi/c/dev/ppb_audio_input_dev.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // for each InterfaceProxy type we support. 165 // for each InterfaceProxy type we support.
166 #define PROXIED_API(api_name) \ 166 #define PROXIED_API(api_name) \
167 AddProxy(PROXY_API_ID(api_name), &PROXY_FACTORY_NAME(api_name)); 167 AddProxy(PROXY_API_ID(api_name), &PROXY_FACTORY_NAME(api_name));
168 168
169 // Register each proxied interface by calling AddPPB for each supported 169 // Register each proxied interface by calling AddPPB for each supported
170 // interface. Set current_required_permission to the appropriate value for 170 // interface. Set current_required_permission to the appropriate value for
171 // the value you want expanded by this macro. 171 // the value you want expanded by this macro.
172 #define PROXIED_IFACE(iface_str, iface_struct) \ 172 #define PROXIED_IFACE(iface_str, iface_struct) \
173 AddPPB(iface_str, \ 173 AddPPB(iface_str, \
174 INTERFACE_THUNK_NAME(iface_struct)(), \ 174 INTERFACE_THUNK_NAME(iface_struct)(), \
175 current_required_permission); 175 current_required_permission, \
176 requires_dev_channel);
176 177
177 { 178 {
178 Permission current_required_permission = PERMISSION_NONE; 179 Permission current_required_permission = PERMISSION_NONE;
180 bool requires_dev_channel = false;
179 #include "ppapi/thunk/interfaces_ppb_private_no_permissions.h" 181 #include "ppapi/thunk/interfaces_ppb_private_no_permissions.h"
180 #include "ppapi/thunk/interfaces_ppb_public_stable.h" 182 #include "ppapi/thunk/interfaces_ppb_public_stable.h"
181 } 183 }
182 { 184 {
183 Permission current_required_permission = PERMISSION_DEV; 185 Permission current_required_permission = PERMISSION_DEV;
186 bool requires_dev_channel = false;
184 #include "ppapi/thunk/interfaces_ppb_public_dev.h" 187 #include "ppapi/thunk/interfaces_ppb_public_dev.h"
185 } 188 }
186 { 189 {
187 Permission current_required_permission = PERMISSION_PRIVATE; 190 Permission current_required_permission = PERMISSION_PRIVATE;
191 bool requires_dev_channel = false;
188 #include "ppapi/thunk/interfaces_ppb_private.h" 192 #include "ppapi/thunk/interfaces_ppb_private.h"
189 } 193 }
190 { 194 {
191 #if !defined(OS_NACL) 195 #if !defined(OS_NACL)
192 Permission current_required_permission = PERMISSION_FLASH; 196 Permission current_required_permission = PERMISSION_FLASH;
197 bool requires_dev_channel = false;
193 #include "ppapi/thunk/interfaces_ppb_private_flash.h" 198 #include "ppapi/thunk/interfaces_ppb_private_flash.h"
194 #endif // !defined(OS_NACL) 199 #endif // !defined(OS_NACL)
195 } 200 }
196 201 {
197 // TODO(teravest): Add dev channel interfaces here. 202 // TODO(teravest): These lines should be uncommented when a dev channel
203 // interface is added. They're commented right now because they cause an
204 // unused variable warning.
205 //
206 // Permission current_required_permission = PERMISSION_NONE;
207 // bool requires_dev_channel = true;
208 // #include "ppapi/thunk/interfaces_ppb_public_dev_channel.h"
209 }
198 210
199 #undef PROXIED_API 211 #undef PROXIED_API
200 #undef PROXIED_IFACE 212 #undef PROXIED_IFACE
201 213
202 // Manually add some special proxies. Some of these don't have interfaces 214 // Manually add some special proxies. Some of these don't have interfaces
203 // that they support, so aren't covered by the macros above, but have proxies 215 // that they support, so aren't covered by the macros above, but have proxies
204 // for message routing. Others have different implementations between the 216 // for message routing. Others have different implementations between the
205 // proxy and the impl and there's no obvious message routing. 217 // proxy and the impl and there's no obvious message routing.
206 AddProxy(API_ID_RESOURCE_CREATION, &ResourceCreationProxy::Create); 218 AddProxy(API_ID_RESOURCE_CREATION, &ResourceCreationProxy::Create);
207 AddProxy(API_ID_PPP_CLASS, &PPP_Class_Proxy::Create); 219 AddProxy(API_ID_PPP_CLASS, &PPP_Class_Proxy::Create);
208 AddPPB(PPB_CORE_INTERFACE_1_0, 220 AddPPB(PPB_CORE_INTERFACE_1_0,
209 PPB_Core_Proxy::GetPPB_Core_Interface(), PERMISSION_NONE); 221 PPB_Core_Proxy::GetPPB_Core_Interface(), PERMISSION_NONE, false);
210 AddPPB(PPB_MESSAGELOOP_INTERFACE_1_0, 222 AddPPB(PPB_MESSAGELOOP_INTERFACE_1_0,
211 PPB_MessageLoop_Proxy::GetInterface(), PERMISSION_NONE); 223 PPB_MessageLoop_Proxy::GetInterface(), PERMISSION_NONE, false);
212 AddPPB(PPB_OPENGLES2_INTERFACE_1_0, 224 AddPPB(PPB_OPENGLES2_INTERFACE_1_0,
213 PPB_OpenGLES2_Shared::GetInterface(), PERMISSION_NONE); 225 PPB_OpenGLES2_Shared::GetInterface(), PERMISSION_NONE, false);
214 AddPPB(PPB_OPENGLES2_INSTANCEDARRAYS_INTERFACE_1_0, 226 AddPPB(PPB_OPENGLES2_INSTANCEDARRAYS_INTERFACE_1_0,
215 PPB_OpenGLES2_Shared::GetInstancedArraysInterface(), PERMISSION_NONE); 227 PPB_OpenGLES2_Shared::GetInstancedArraysInterface(),
228 PERMISSION_NONE, false);
216 AddPPB(PPB_OPENGLES2_FRAMEBUFFERBLIT_INTERFACE_1_0, 229 AddPPB(PPB_OPENGLES2_FRAMEBUFFERBLIT_INTERFACE_1_0,
217 PPB_OpenGLES2_Shared::GetFramebufferBlitInterface(), PERMISSION_NONE); 230 PPB_OpenGLES2_Shared::GetFramebufferBlitInterface(),
231 PERMISSION_NONE, false);
218 AddPPB(PPB_OPENGLES2_FRAMEBUFFERMULTISAMPLE_INTERFACE_1_0, 232 AddPPB(PPB_OPENGLES2_FRAMEBUFFERMULTISAMPLE_INTERFACE_1_0,
219 PPB_OpenGLES2_Shared::GetFramebufferMultisampleInterface(), 233 PPB_OpenGLES2_Shared::GetFramebufferMultisampleInterface(),
220 PERMISSION_NONE); 234 PERMISSION_NONE, false);
221 AddPPB(PPB_OPENGLES2_CHROMIUMENABLEFEATURE_INTERFACE_1_0, 235 AddPPB(PPB_OPENGLES2_CHROMIUMENABLEFEATURE_INTERFACE_1_0,
222 PPB_OpenGLES2_Shared::GetChromiumEnableFeatureInterface(), 236 PPB_OpenGLES2_Shared::GetChromiumEnableFeatureInterface(),
223 PERMISSION_NONE); 237 PERMISSION_NONE, false);
224 AddPPB(PPB_OPENGLES2_CHROMIUMMAPSUB_INTERFACE_1_0, 238 AddPPB(PPB_OPENGLES2_CHROMIUMMAPSUB_INTERFACE_1_0,
225 PPB_OpenGLES2_Shared::GetChromiumMapSubInterface(), PERMISSION_NONE); 239 PPB_OpenGLES2_Shared::GetChromiumMapSubInterface(),
240 PERMISSION_NONE, false);
226 AddPPB(PPB_OPENGLES2_CHROMIUMMAPSUB_DEV_INTERFACE_1_0, 241 AddPPB(PPB_OPENGLES2_CHROMIUMMAPSUB_DEV_INTERFACE_1_0,
227 PPB_OpenGLES2_Shared::GetChromiumMapSubInterface(), PERMISSION_NONE); 242 PPB_OpenGLES2_Shared::GetChromiumMapSubInterface(),
243 PERMISSION_NONE, false);
228 AddPPB(PPB_OPENGLES2_QUERY_INTERFACE_1_0, 244 AddPPB(PPB_OPENGLES2_QUERY_INTERFACE_1_0,
229 PPB_OpenGLES2_Shared::GetQueryInterface(), PERMISSION_NONE); 245 PPB_OpenGLES2_Shared::GetQueryInterface(), PERMISSION_NONE, false);
230 AddPPB(PPB_VAR_ARRAY_BUFFER_INTERFACE_1_0, 246 AddPPB(PPB_VAR_ARRAY_BUFFER_INTERFACE_1_0,
231 PPB_Var_Shared::GetVarArrayBufferInterface1_0(), 247 PPB_Var_Shared::GetVarArrayBufferInterface1_0(),
232 PERMISSION_NONE); 248 PERMISSION_NONE, false);
233 AddPPB(PPB_VAR_INTERFACE_1_1, 249 AddPPB(PPB_VAR_INTERFACE_1_1,
234 PPB_Var_Shared::GetVarInterface1_1(), PERMISSION_NONE); 250 PPB_Var_Shared::GetVarInterface1_1(), PERMISSION_NONE, false);
235 AddPPB(PPB_VAR_INTERFACE_1_0, 251 AddPPB(PPB_VAR_INTERFACE_1_0,
236 PPB_Var_Shared::GetVarInterface1_0(), PERMISSION_NONE); 252 PPB_Var_Shared::GetVarInterface1_0(), PERMISSION_NONE, false);
237 253
238 #if !defined(OS_NACL) 254 #if !defined(OS_NACL)
239 // PPB (browser) interfaces. 255 // PPB (browser) interfaces.
240 // Do not add more stuff here, they should be added to interface_list*.h 256 // Do not add more stuff here, they should be added to interface_list*.h
241 // TODO(brettw) remove these. 257 // TODO(brettw) remove these.
242 AddProxy(API_ID_PPB_INSTANCE_PRIVATE, &ProxyFactory<PPB_Instance_Proxy>); 258 AddProxy(API_ID_PPB_INSTANCE_PRIVATE, &ProxyFactory<PPB_Instance_Proxy>);
243 AddPPB(PPB_INSTANCE_PRIVATE_INTERFACE_0_1, 259 AddPPB(PPB_INSTANCE_PRIVATE_INTERFACE_0_1,
244 thunk::GetPPB_Instance_Private_0_1_Thunk(), 260 thunk::GetPPB_Instance_Private_0_1_Thunk(),
245 PERMISSION_PRIVATE); 261 PERMISSION_PRIVATE, false);
246 262
247 AddProxy(API_ID_PPB_VAR_DEPRECATED, &ProxyFactory<PPB_Var_Deprecated_Proxy>); 263 AddProxy(API_ID_PPB_VAR_DEPRECATED, &ProxyFactory<PPB_Var_Deprecated_Proxy>);
248 AddPPB(PPB_VAR_DEPRECATED_INTERFACE, 264 AddPPB(PPB_VAR_DEPRECATED_INTERFACE,
249 PPB_Var_Deprecated_Proxy::GetProxyInterface(), PERMISSION_DEV); 265 PPB_Var_Deprecated_Proxy::GetProxyInterface(), PERMISSION_DEV, false);
250 266
251 // TODO(tomfinegan): Figure out where to put these once we refactor things 267 // TODO(tomfinegan): Figure out where to put these once we refactor things
252 // to load the PPP interface struct from the PPB interface. 268 // to load the PPP interface struct from the PPB interface.
253 AddProxy(API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, 269 AddProxy(API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE,
254 &ProxyFactory<PPP_ContentDecryptor_Private_Proxy>); 270 &ProxyFactory<PPP_ContentDecryptor_Private_Proxy>);
255 AddPPP(PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE, 271 AddPPP(PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE,
256 PPP_ContentDecryptor_Private_Proxy::GetProxyInterface()); 272 PPP_ContentDecryptor_Private_Proxy::GetProxyInterface());
257 #endif 273 #endif
258 AddProxy(API_ID_PPB_TESTING, &ProxyFactory<PPB_Testing_Proxy>); 274 AddProxy(API_ID_PPB_TESTING, &ProxyFactory<PPB_Testing_Proxy>);
259 AddPPB(PPB_TESTING_PRIVATE_INTERFACE, 275 AddPPB(PPB_TESTING_PRIVATE_INTERFACE,
260 PPB_Testing_Proxy::GetProxyInterface(), PERMISSION_TESTING); 276 PPB_Testing_Proxy::GetProxyInterface(), PERMISSION_TESTING, false);
261 277
262 // PPP (plugin) interfaces. 278 // PPP (plugin) interfaces.
263 // TODO(brettw) move these to interface_list*.h 279 // TODO(brettw) move these to interface_list*.h
264 AddProxy(API_ID_PPP_GRAPHICS_3D, &ProxyFactory<PPP_Graphics3D_Proxy>); 280 AddProxy(API_ID_PPP_GRAPHICS_3D, &ProxyFactory<PPP_Graphics3D_Proxy>);
265 AddPPP(PPP_GRAPHICS_3D_INTERFACE, PPP_Graphics3D_Proxy::GetProxyInterface()); 281 AddPPP(PPP_GRAPHICS_3D_INTERFACE, PPP_Graphics3D_Proxy::GetProxyInterface());
266 AddProxy(API_ID_PPP_INPUT_EVENT, &ProxyFactory<PPP_InputEvent_Proxy>); 282 AddProxy(API_ID_PPP_INPUT_EVENT, &ProxyFactory<PPP_InputEvent_Proxy>);
267 AddPPP(PPP_INPUT_EVENT_INTERFACE, PPP_InputEvent_Proxy::GetProxyInterface()); 283 AddPPP(PPP_INPUT_EVENT_INTERFACE, PPP_InputEvent_Proxy::GetProxyInterface());
268 AddProxy(API_ID_PPP_INSTANCE, &ProxyFactory<PPP_Instance_Proxy>); 284 AddProxy(API_ID_PPP_INSTANCE, &ProxyFactory<PPP_Instance_Proxy>);
269 #if !defined(OS_NACL) 285 #if !defined(OS_NACL)
270 AddPPP(PPP_INSTANCE_INTERFACE_1_1, 286 AddPPP(PPP_INSTANCE_INTERFACE_1_1,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 return NULL; 332 return NULL;
317 return id_to_factory_[index]; 333 return id_to_factory_[index];
318 } 334 }
319 335
320 const void* InterfaceList::GetInterfaceForPPB(const std::string& name) const { 336 const void* InterfaceList::GetInterfaceForPPB(const std::string& name) const {
321 NameToInterfaceInfoMap::const_iterator found = 337 NameToInterfaceInfoMap::const_iterator found =
322 name_to_browser_info_.find(name); 338 name_to_browser_info_.find(name);
323 if (found == name_to_browser_info_.end()) 339 if (found == name_to_browser_info_.end())
324 return NULL; 340 return NULL;
325 341
326 // Dev channel checking goes here. 342 if (found->second.requires_dev_channel && !g_supports_dev_channel.Get())
343 return NULL;
327 344
328 if (g_process_global_permissions.Get().HasPermission( 345 if (g_process_global_permissions.Get().HasPermission(
329 found->second.required_permission)) 346 found->second.required_permission))
330 return found->second.iface; 347 return found->second.iface;
331 return NULL; 348 return NULL;
332 } 349 }
333 350
334 const void* InterfaceList::GetInterfaceForPPP(const std::string& name) const { 351 const void* InterfaceList::GetInterfaceForPPP(const std::string& name) const {
335 NameToInterfaceInfoMap::const_iterator found = 352 NameToInterfaceInfoMap::const_iterator found =
336 name_to_plugin_info_.find(name); 353 name_to_plugin_info_.find(name);
(...skipping 13 matching lines...) Expand all
350 // The factory should be an exact dupe of the one we already have if it 367 // The factory should be an exact dupe of the one we already have if it
351 // has already been registered before. 368 // has already been registered before.
352 int index = static_cast<int>(id); 369 int index = static_cast<int>(id);
353 DCHECK(!id_to_factory_[index] || id_to_factory_[index] == factory); 370 DCHECK(!id_to_factory_[index] || id_to_factory_[index] == factory);
354 371
355 id_to_factory_[index] = factory; 372 id_to_factory_[index] = factory;
356 } 373 }
357 374
358 void InterfaceList::AddPPB(const char* name, 375 void InterfaceList::AddPPB(const char* name,
359 const void* iface, 376 const void* iface,
360 Permission perm) { 377 Permission perm,
378 bool requires_dev_channel) {
361 DCHECK(name_to_browser_info_.find(name) == name_to_browser_info_.end()); 379 DCHECK(name_to_browser_info_.find(name) == name_to_browser_info_.end());
362 name_to_browser_info_[name] = InterfaceInfo(iface, perm); 380 name_to_browser_info_[name] =
381 InterfaceInfo(iface, perm, requires_dev_channel);
363 } 382 }
364 383
365 void InterfaceList::AddPPP(const char* name, 384 void InterfaceList::AddPPP(const char* name,
366 const void* iface) { 385 const void* iface) {
367 DCHECK(name_to_plugin_info_.find(name) == name_to_plugin_info_.end()); 386 DCHECK(name_to_plugin_info_.find(name) == name_to_plugin_info_.end());
368 name_to_plugin_info_[name] = InterfaceInfo(iface, PERMISSION_NONE); 387 name_to_plugin_info_[name] = InterfaceInfo(iface, PERMISSION_NONE, false);
369 } 388 }
370 389
371 } // namespace proxy 390 } // namespace proxy
372 } // namespace ppapi 391 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698