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
3 // found in the LICENSE file.
5 #ifndef PPAPI_PROXY_INTERFACE_LIST_H_
6 #define PPAPI_PROXY_INTERFACE_LIST_H_
11 #include "base/basictypes.h"
12 #include "ppapi/proxy/interface_proxy.h"
13 #include "ppapi/proxy/ppapi_proxy_export.h"
14 #include "ppapi/shared_impl/ppapi_permissions.h"
24 static InterfaceList
* GetInstance();
26 // Sets the permissions that the interface list will use to compute
27 // whether an interface is available to the current process. By default,
28 // this will be "no permissions", which will give only access to public
29 // stable interfaces via GetInterface.
31 // IMPORTANT: This is not a security boundary. Malicious plugins can bypass
32 // this check since they run in the same address space as this code in the
33 // plugin process. A real security check is required for all IPC messages.
34 // This check just allows us to return NULL for interfaces you "shouldn't" be
35 // using to keep honest plugins honest.
36 static PPAPI_PROXY_EXPORT
void SetProcessGlobalPermissions(
37 const PpapiPermissions
& permissions
);
39 // Looks up the ID for the given interface name. Returns API_ID_NONE if
40 // the interface string is not found.
41 ApiID
GetIDForPPBInterface(const std::string
& name
) const;
42 ApiID
GetIDForPPPInterface(const std::string
& name
) const;
44 // Looks up the factory function for the given ID. Returns NULL if not
46 InterfaceProxy::Factory
GetFactoryForID(ApiID id
) const;
48 // Returns the interface pointer for the given browser or plugin interface,
49 // or NULL if it's not supported.
50 const void* GetInterfaceForPPB(const std::string
& name
) const;
51 const void* GetInterfaceForPPP(const std::string
& name
) const;
54 struct InterfaceInfo
{
58 required_permission(PERMISSION_NONE
) {
60 InterfaceInfo(ApiID in_id
, const void* in_interface
, Permission in_perm
)
63 required_permission(in_perm
) {
69 // Permission required to return non-null for this interface. This will
70 // be checked with the value set via SetProcessGlobalPermissionBits when
71 // an interface is requested.
72 Permission required_permission
;
75 typedef std::map
<std::string
, InterfaceInfo
> NameToInterfaceInfoMap
;
77 void AddProxy(ApiID id
, InterfaceProxy::Factory factory
);
79 // Permissions is the type of permission required to access the corresponding
80 // interface. Currently this must be just one unique permission (rather than
82 void AddPPB(const char* name
, ApiID id
, const void* iface
,
83 Permission permission
);
84 void AddPPP(const char* name
, ApiID id
, const void* iface
);
86 // Old-style add functions. These should be removed when the rest of the
87 // proxies are converted over to using the new system.
88 void AddPPB(const InterfaceProxy::Info
* info
, Permission perm
);
89 void AddPPP(const InterfaceProxy::Info
* info
);
91 PpapiPermissions permissions_
;
93 NameToInterfaceInfoMap name_to_browser_info_
;
94 NameToInterfaceInfoMap name_to_plugin_info_
;
96 InterfaceProxy::Factory id_to_factory_
[API_ID_COUNT
];
98 DISALLOW_COPY_AND_ASSIGN(InterfaceList
);
104 #endif // PPAPI_PROXY_INTERFACE_LIST_H_