#ifndef PPAPI_PROXY_INTERFACE_LIST_H_
#define PPAPI_PROXY_INTERFACE_LIST_H_
#include <map>
#include <string>
#include "base/basictypes.h"
#include "ppapi/proxy/interface_proxy.h"
#include "ppapi/proxy/ppapi_proxy_export.h"
#include "ppapi/shared_impl/ppapi_permissions.h"
namespace ppapi {
namespace proxy {
class PPAPI_PROXY_EXPORT InterfaceList {
public:
InterfaceList();
~InterfaceList();
static InterfaceList* GetInstance();
static void SetProcessGlobalPermissions(const PpapiPermissions& permissions);
InterfaceProxy::Factory GetFactoryForID(ApiID id) const;
const void* GetInterfaceForPPB(const std::string& name);
const void* GetInterfaceForPPP(const std::string& name) const;
private:
friend class InterfaceListTest;
struct InterfaceInfo {
InterfaceInfo()
: iface(NULL),
required_permission(PERMISSION_NONE),
interface_logged(false) {
}
InterfaceInfo(const void* in_interface, Permission in_perm)
: iface(in_interface),
required_permission(in_perm),
interface_logged(false) {
}
const void* iface;
Permission required_permission;
bool interface_logged;
};
typedef std::map<std::string, InterfaceInfo> NameToInterfaceInfoMap;
void AddProxy(ApiID id, InterfaceProxy::Factory factory);
void AddPPB(const char* name, const void* iface, Permission permission);
void AddPPP(const char* name, const void* iface);
static int HashInterfaceName(const std::string& name);
PpapiPermissions permissions_;
NameToInterfaceInfoMap name_to_browser_info_;
NameToInterfaceInfoMap name_to_plugin_info_;
InterfaceProxy::Factory id_to_factory_[API_ID_COUNT];
DISALLOW_COPY_AND_ASSIGN(InterfaceList);
};
}
}
#endif