interface_list.cc revision 90dce4d38c5ff5333bea97d859d4e484e27edf0c
15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/proxy/interface_list.h"
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/lazy_instance.h"
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/singleton.h"
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/dev/ppb_audio_input_dev.h"
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/dev/ppb_buffer_dev.h"
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/dev/ppb_char_set_dev.h"
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/dev/ppb_crypto_dev.h"
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/dev/ppb_cursor_control_dev.h"
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/dev/ppb_device_ref_dev.h"
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/dev/ppb_font_dev.h"
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/dev/ppb_gles_chromium_texture_mapping_dev.h"
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/dev/ppb_graphics_2d_dev.h"
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/dev/ppb_ime_input_event_dev.h"
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/dev/ppb_keyboard_input_event_dev.h"
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/dev/ppb_memory_dev.h"
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/dev/ppb_opengles2ext_dev.h"
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/dev/ppb_printing_dev.h"
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/dev/ppb_resource_array_dev.h"
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/dev/ppb_testing_dev.h"
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/dev/ppb_text_input_dev.h"
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ppapi/c/dev/ppb_trace_event_dev.h"
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ppapi/c/dev/ppb_truetype_font_dev.h"
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/dev/ppb_url_util_dev.h"
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ppapi/c/dev/ppb_var_array_dev.h"
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/dev/ppb_var_deprecated.h"
312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ppapi/c/dev/ppb_var_dictionary_dev.h"
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/dev/ppb_video_capture_dev.h"
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/dev/ppb_view_dev.h"
34c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "ppapi/c/extensions/dev/ppb_ext_alarms_dev.h"
35c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "ppapi/c/extensions/dev/ppb_ext_socket_dev.h"
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/ppb_audio_config.h"
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/ppb_audio.h"
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ppapi/c/ppb_console.h"
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/ppb_core.h"
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/ppb_file_io.h"
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/ppb_file_ref.h"
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/ppb_file_system.h"
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/ppb_fullscreen.h"
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/ppb_graphics_2d.h"
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/ppb_image_data.h"
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/ppb_input_event.h"
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/ppb_instance.h"
482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ppapi/c/ppb_message_loop.h"
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/ppb_messaging.h"
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/ppb_mouse_lock.h"
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/ppb_opengles2.h"
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/ppb_url_loader.h"
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/ppb_url_request_info.h"
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/ppb_url_response_info.h"
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/ppb_var.h"
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/ppb_var_array_buffer.h"
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/ppb_view.h"
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/pp_errors.h"
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/ppp_instance.h"
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/private/ppb_content_decryptor_private.h"
61b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)#include "ppapi/c/private/ppb_ext_crx_file_system_private.h"
62c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "ppapi/c/private/ppb_file_io_private.h"
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/private/ppb_file_ref_private.h"
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/private/ppb_flash_clipboard.h"
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/private/ppb_flash_file.h"
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/private/ppb_flash_font_file.h"
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/private/ppb_flash_fullscreen.h"
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/private/ppb_flash.h"
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/private/ppb_flash_device_id.h"
7090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "ppapi/c/private/ppb_flash_drm.h"
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/private/ppb_flash_menu.h"
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/private/ppb_flash_message_loop.h"
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/private/ppb_flash_print.h"
742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ppapi/c/private/ppb_host_resolver_private.h"
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/private/ppb_net_address_private.h"
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/private/ppb_network_list_private.h"
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/private/ppb_network_monitor_private.h"
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/private/ppb_pdf.h"
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/private/ppb_talk_private.h"
802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ppapi/c/private/ppb_tcp_server_socket_private.h"
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/private/ppb_tcp_socket_private.h"
825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/private/ppb_udp_socket_private.h"
83c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "ppapi/c/private/ppb_video_destination_private.h"
84c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "ppapi/c/private/ppb_video_source_private.h"
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/private/ppb_x509_certificate_private.h"
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/private/ppp_content_decryptor_private.h"
875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/trusted/ppb_broker_trusted.h"
885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/trusted/ppb_browser_font_trusted.h"
895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/trusted/ppb_char_set_trusted.h"
902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ppapi/c/trusted/ppb_file_chooser_trusted.h"
915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/trusted/ppb_file_io_trusted.h"
925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/trusted/ppb_url_loader_trusted.h"
935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/proxy/interface_proxy.h"
945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/proxy/ppb_audio_proxy.h"
955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/proxy/ppb_broker_proxy.h"
965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/proxy/ppb_buffer_proxy.h"
975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/proxy/ppb_core_proxy.h"
985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/proxy/ppb_file_ref_proxy.h"
995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/proxy/ppb_flash_message_loop_proxy.h"
1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/proxy/ppb_graphics_3d_proxy.h"
1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/proxy/ppb_image_data_proxy.h"
1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/proxy/ppb_instance_proxy.h"
1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/proxy/ppb_message_loop_proxy.h"
1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/proxy/ppb_network_monitor_private_proxy.h"
1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/proxy/ppb_tcp_server_socket_private_proxy.h"
1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/proxy/ppb_tcp_socket_private_proxy.h"
1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/proxy/ppb_testing_proxy.h"
1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/proxy/ppb_var_deprecated_proxy.h"
1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/proxy/ppb_video_decoder_proxy.h"
1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/proxy/ppb_x509_certificate_private_proxy.h"
1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/proxy/ppp_class_proxy.h"
1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/proxy/ppp_content_decryptor_private_proxy.h"
1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/proxy/ppp_graphics_3d_proxy.h"
1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/proxy/ppp_input_event_proxy.h"
1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/proxy/ppp_instance_private_proxy.h"
1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/proxy/ppp_instance_proxy.h"
1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/proxy/ppp_messaging_proxy.h"
1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/proxy/ppp_mouse_lock_proxy.h"
1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/proxy/ppp_printing_proxy.h"
1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/proxy/ppp_text_input_proxy.h"
1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/proxy/ppp_video_decoder_proxy.h"
1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/proxy/resource_creation_proxy.h"
1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/shared_impl/ppb_opengles2_shared.h"
1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/shared_impl/ppb_var_shared.h"
1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/thunk/thunk.h"
1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Helper to get the proxy name PPB_Foo_Proxy given the API name PPB_Foo.
1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PROXY_CLASS_NAME(api_name) api_name##_Proxy
1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Helper to get the interface ID PPB_Foo_Proxy::kApiID given the API
1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// name PPB_Foo.
1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PROXY_API_ID(api_name) PROXY_CLASS_NAME(api_name)::kApiID
1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Helper to get the name of the templatized factory function.
1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PROXY_FACTORY_NAME(api_name) ProxyFactory<PROXY_CLASS_NAME(api_name)>
1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Helper to get the name of the thunk GetPPB_Foo_1_0_Thunk given the interface
1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// struct name PPB_Foo_1_0.
1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define INTERFACE_THUNK_NAME(iface_struct) thunk::Get##iface_struct##_Thunk
1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace ppapi {
1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace proxy {
1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace {
1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// The interface list has interfaces with no ID listed as "NoAPIName" which
1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// means there's no corresponding _Proxy object. Our macros expand this to
1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// NoAPIName_Proxy, and then they look for kApiID inside it.
1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This dummy class provides the correct definition for that interface ID,
1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// which is "NONE".
1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class NoAPIName_Proxy {
1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const ApiID kApiID = API_ID_NONE;
1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)template<typename ProxyClass>
1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)InterfaceProxy* ProxyFactory(Dispatcher* dispatcher) {
1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return new ProxyClass(dispatcher);
1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)base::LazyInstance<PpapiPermissions> g_process_global_permissions;
1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace
1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)InterfaceList::InterfaceList() {
1675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  memset(id_to_factory_, 0, sizeof(id_to_factory_));
1685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Register the API factories for each of the API types. This calls AddProxy
1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // for each InterfaceProxy type we support.
1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  #define PROXIED_API(api_name) \
1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      AddProxy(PROXY_API_ID(api_name), &PROXY_FACTORY_NAME(api_name));
1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Register each proxied interface by calling AddPPB for each supported
1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // interface. Set current_required_permission to the appropriate value for
1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the value you want expanded by this macro.
1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  #define PROXIED_IFACE(api_name, iface_str, iface_struct) \
1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      AddPPB(iface_str, PROXY_API_ID(api_name), \
1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)             INTERFACE_THUNK_NAME(iface_struct)(), \
1805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)             current_required_permission);
1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  {
1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    Permission current_required_permission = PERMISSION_NONE;
1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    #include "ppapi/thunk/interfaces_ppb_private_no_permissions.h"
1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    #include "ppapi/thunk/interfaces_ppb_public_stable.h"
1865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  {
1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    Permission current_required_permission = PERMISSION_DEV;
1905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    #include "ppapi/thunk/interfaces_ppb_public_dev.h"
1915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  {
1935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    Permission current_required_permission = PERMISSION_PRIVATE;
1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    #include "ppapi/thunk/interfaces_ppb_private.h"
1955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
1965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  {
1975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if !defined(OS_NACL)
1985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    Permission current_required_permission = PERMISSION_FLASH;
1995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    #include "ppapi/thunk/interfaces_ppb_private_flash.h"
2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // !defined(OS_NACL)
2015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  #undef PROXIED_API
2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  #undef PROXIED_IFACE
2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Manually add some special proxies. Some of these don't have interfaces
2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // that they support, so aren't covered by the macros above, but have proxies
2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // for message routing. Others have different implementations between the
2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // proxy and the impl and there's no obvious message routing.
2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddProxy(API_ID_RESOURCE_CREATION, &ResourceCreationProxy::Create);
2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddProxy(API_ID_PPP_CLASS, &PPP_Class_Proxy::Create);
2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddPPB(PPB_CORE_INTERFACE_1_0, API_ID_PPB_CORE,
2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)         PPB_Core_Proxy::GetPPB_Core_Interface(), PERMISSION_NONE);
2142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  AddPPB(PPB_MESSAGELOOP_INTERFACE_1_0, API_ID_NONE,
2152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)         PPB_MessageLoop_Proxy::GetInterface(), PERMISSION_NONE);
2165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddPPB(PPB_OPENGLES2_INTERFACE_1_0, API_ID_NONE,
2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)         PPB_OpenGLES2_Shared::GetInterface(), PERMISSION_NONE);
2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddPPB(PPB_OPENGLES2_INSTANCEDARRAYS_INTERFACE_1_0, API_ID_NONE,
2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)         PPB_OpenGLES2_Shared::GetInstancedArraysInterface(), PERMISSION_NONE);
2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddPPB(PPB_OPENGLES2_FRAMEBUFFERBLIT_INTERFACE_1_0, API_ID_NONE,
2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)         PPB_OpenGLES2_Shared::GetFramebufferBlitInterface(), PERMISSION_NONE);
2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddPPB(PPB_OPENGLES2_FRAMEBUFFERMULTISAMPLE_INTERFACE_1_0, API_ID_NONE,
2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)         PPB_OpenGLES2_Shared::GetFramebufferMultisampleInterface(),
2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)         PERMISSION_NONE);
2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddPPB(PPB_OPENGLES2_CHROMIUMENABLEFEATURE_INTERFACE_1_0, API_ID_NONE,
2265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)         PPB_OpenGLES2_Shared::GetChromiumEnableFeatureInterface(),
2275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)         PERMISSION_NONE);
2285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddPPB(PPB_OPENGLES2_CHROMIUMMAPSUB_INTERFACE_1_0, API_ID_NONE,
2295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)         PPB_OpenGLES2_Shared::GetChromiumMapSubInterface(), PERMISSION_NONE);
2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddPPB(PPB_OPENGLES2_CHROMIUMMAPSUB_DEV_INTERFACE_1_0, API_ID_NONE,
2315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)         PPB_OpenGLES2_Shared::GetChromiumMapSubInterface(), PERMISSION_NONE);
2325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddPPB(PPB_OPENGLES2_QUERY_INTERFACE_1_0, API_ID_NONE,
2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)         PPB_OpenGLES2_Shared::GetQueryInterface(), PERMISSION_NONE);
2345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddPPB(PPB_VAR_ARRAY_BUFFER_INTERFACE_1_0, API_ID_NONE,
2355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)         PPB_Var_Shared::GetVarArrayBufferInterface1_0(),
2365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)         PERMISSION_NONE);
2375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddPPB(PPB_VAR_INTERFACE_1_1, API_ID_NONE,
2385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)         PPB_Var_Shared::GetVarInterface1_1(), PERMISSION_NONE);
2395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddPPB(PPB_VAR_INTERFACE_1_0, API_ID_NONE,
2405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)         PPB_Var_Shared::GetVarInterface1_0(), PERMISSION_NONE);
2415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if !defined(OS_NACL)
2435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // PPB (browser) interfaces.
2445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Do not add more stuff here, they should be added to interface_list*.h
2455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // TODO(brettw) remove these.
2465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddPPB(PPB_Instance_Proxy::GetInfoPrivate(), PERMISSION_PRIVATE);
2475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddPPB(PPB_Var_Deprecated_Proxy::GetInfo(), PERMISSION_DEV);
2485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // TODO(tomfinegan): Figure out where to put these once we refactor things
2505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // to load the PPP interface struct from the PPB interface.
2515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddProxy(API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE,
2525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)           &ProxyFactory<PPP_ContentDecryptor_Private_Proxy>);
2535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddPPP(PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE,
2545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)         API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE,
2555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)         PPP_ContentDecryptor_Private_Proxy::GetProxyInterface());
2565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
2575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddPPB(PPB_Testing_Proxy::GetInfo(), PERMISSION_TESTING);
2585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // PPP (plugin) interfaces.
2605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // TODO(brettw) move these to interface_list*.h
2615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddProxy(API_ID_PPP_INSTANCE, &ProxyFactory<PPP_Instance_Proxy>);
2622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  #if !defined(OS_NACL)
2635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddPPP(PPP_INSTANCE_INTERFACE_1_1, API_ID_PPP_INSTANCE,
2645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)         PPP_Instance_Proxy::GetInstanceInterface());
2652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  #endif
2665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddProxy(API_ID_PPP_PRINTING, &ProxyFactory<PPP_Printing_Proxy>);
2675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddPPP(PPP_PRINTING_DEV_INTERFACE, API_ID_PPP_PRINTING,
2685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)         PPP_Printing_Proxy::GetProxyInterface());
2695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddProxy(API_ID_PPP_TEXT_INPUT, &ProxyFactory<PPP_TextInput_Proxy>);
2705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddPPP(PPP_TEXTINPUT_DEV_INTERFACE, API_ID_PPP_TEXT_INPUT,
2715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)         PPP_TextInput_Proxy::GetProxyInterface());
2725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Old-style GetInfo PPP interfaces.
2745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Do not add more stuff here, they should be added to interface_list*.h
2755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // TODO(brettw) remove these.
2765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddPPP(PPP_InputEvent_Proxy::GetInfo());
2775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddPPP(PPP_Messaging_Proxy::GetInfo());
2785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddPPP(PPP_MouseLock_Proxy::GetInfo());
2795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddPPP(PPP_Graphics3D_Proxy::GetInfo());
2805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if !defined(OS_NACL)
2815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddPPP(PPP_Instance_Private_Proxy::GetInfo());
2825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddPPP(PPP_VideoDecoder_Proxy::GetInfo());
2835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
2845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
2855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)InterfaceList::~InterfaceList() {
2875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
2885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// static
2905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)InterfaceList* InterfaceList::GetInstance() {
2915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return Singleton<InterfaceList>::get();
2925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
2935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// static
2955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void InterfaceList::SetProcessGlobalPermissions(
2965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    const PpapiPermissions& permissions) {
2975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  g_process_global_permissions.Get() = permissions;
2985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
2995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)ApiID InterfaceList::GetIDForPPBInterface(const std::string& name) const {
3015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  NameToInterfaceInfoMap::const_iterator found =
3025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      name_to_browser_info_.find(name);
3035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (found == name_to_browser_info_.end())
3045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return API_ID_NONE;
3055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return found->second.id;
3065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
3075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)ApiID InterfaceList::GetIDForPPPInterface(const std::string& name) const {
3095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  NameToInterfaceInfoMap::const_iterator found =
3105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      name_to_plugin_info_.find(name);
3115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (found == name_to_plugin_info_.end())
3125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return API_ID_NONE;
3135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return found->second.id;
3145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
3155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)InterfaceProxy::Factory InterfaceList::GetFactoryForID(ApiID id) const {
3175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int index = static_cast<int>(id);
3185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  COMPILE_ASSERT(API_ID_NONE == 0, none_must_be_zero);
3195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (id <= 0 || id >= API_ID_COUNT)
3205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return NULL;
3215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return id_to_factory_[index];
3225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
3235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const void* InterfaceList::GetInterfaceForPPB(const std::string& name) const {
3255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  NameToInterfaceInfoMap::const_iterator found =
3265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      name_to_browser_info_.find(name);
3275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (found == name_to_browser_info_.end())
3285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return NULL;
3295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (g_process_global_permissions.Get().HasPermission(
3315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)          found->second.required_permission))
3325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return found->second.iface;
3335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return NULL;
3345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
3355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const void* InterfaceList::GetInterfaceForPPP(const std::string& name) const {
3375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  NameToInterfaceInfoMap::const_iterator found =
3385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      name_to_plugin_info_.find(name);
3395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (found == name_to_plugin_info_.end())
3405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return NULL;
3415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return found->second.iface;
3425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
3435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void InterfaceList::AddProxy(ApiID id,
3455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                             InterfaceProxy::Factory factory) {
3465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // For interfaces with no corresponding _Proxy objects, the macros will
3475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // generate calls to this function with API_ID_NONE. This means we
3485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // should just skip adding a factory for these functions.
3495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (id == API_ID_NONE)
3505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
3515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The factory should be an exact dupe of the one we already have if it
3535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // has already been registered before.
3545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int index = static_cast<int>(id);
3555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DCHECK(!id_to_factory_[index] || id_to_factory_[index] == factory);
3565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  id_to_factory_[index] = factory;
3585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
3595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void InterfaceList::AddPPB(const char* name,
3615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                           ApiID id,
3625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                           const void* iface,
3635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                           Permission perm) {
3645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DCHECK(name_to_browser_info_.find(name) == name_to_browser_info_.end());
3655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  name_to_browser_info_[name] = InterfaceInfo(id, iface, perm);
3665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
3675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void InterfaceList::AddPPP(const char* name,
3695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                           ApiID id,
3705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                           const void* iface) {
3715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DCHECK(name_to_plugin_info_.find(name) == name_to_plugin_info_.end());
3725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  name_to_plugin_info_[name] = InterfaceInfo(id, iface, PERMISSION_NONE);
3735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
3745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void InterfaceList::AddPPB(const InterfaceProxy::Info* info, Permission perm) {
3765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddProxy(info->id, info->create_proxy);
3775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddPPB(info->name, info->id, info->interface_ptr, perm);
3785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
3795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void InterfaceList::AddPPP(const InterfaceProxy::Info* info) {
3815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddProxy(info->id, info->create_proxy);
3825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  AddPPP(info->name, info->id, info->interface_ptr);
3835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
3845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace proxy
3865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace ppapi
387