OLD | NEW |
---|---|
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 #ifndef PPAPI_PROXY_INTERFACE_LIST_H_ | 5 #ifndef PPAPI_PROXY_INTERFACE_LIST_H_ |
6 #define PPAPI_PROXY_INTERFACE_LIST_H_ | 6 #define PPAPI_PROXY_INTERFACE_LIST_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "ppapi/proxy/interface_proxy.h" | 12 #include "ppapi/proxy/interface_proxy.h" |
13 #include "ppapi/proxy/ppapi_proxy_export.h" | 13 #include "ppapi/proxy/ppapi_proxy_export.h" |
14 #include "ppapi/shared_impl/ppapi_permissions.h" | 14 #include "ppapi/shared_impl/ppapi_permissions.h" |
15 | 15 |
16 namespace ppapi { | 16 namespace ppapi { |
17 namespace proxy { | 17 namespace proxy { |
18 | 18 |
19 class InterfaceList { | 19 class PPAPI_PROXY_EXPORT InterfaceList { |
20 public: | 20 public: |
21 InterfaceList(); | 21 InterfaceList(); |
22 ~InterfaceList(); | 22 ~InterfaceList(); |
23 | 23 |
24 static InterfaceList* GetInstance(); | 24 static InterfaceList* GetInstance(); |
25 | 25 |
26 // Sets the permissions that the interface list will use to compute | 26 // Sets the permissions that the interface list will use to compute |
27 // whether an interface is available to the current process. By default, | 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 | 28 // this will be "no permissions", which will give only access to public |
29 // stable interfaces via GetInterface. | 29 // stable interfaces via GetInterface. |
30 // | 30 // |
31 // IMPORTANT: This is not a security boundary. Malicious plugins can bypass | 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 | 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. | 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 | 34 // This check just allows us to return NULL for interfaces you "shouldn't" be |
35 // using to keep honest plugins honest. | 35 // using to keep honest plugins honest. |
36 static PPAPI_PROXY_EXPORT void SetProcessGlobalPermissions( | 36 static void SetProcessGlobalPermissions(const PpapiPermissions& permissions); |
37 const PpapiPermissions& permissions); | 37 static void SetSupportsDevChannel(bool supports_dev_channel); |
38 static PPAPI_PROXY_EXPORT void SetSupportsDevChannel( | |
39 bool supports_dev_channel); | |
40 | 38 |
41 // Looks up the factory function for the given ID. Returns NULL if not | 39 // Looks up the factory function for the given ID. Returns NULL if not |
42 // supported. | 40 // supported. |
43 InterfaceProxy::Factory GetFactoryForID(ApiID id) const; | 41 InterfaceProxy::Factory GetFactoryForID(ApiID id) const; |
44 | 42 |
45 // Returns the interface pointer for the given browser or plugin interface, | 43 // Returns the interface pointer for the given browser or plugin interface, |
46 // or NULL if it's not supported. | 44 // or NULL if it's not supported. |
47 const void* GetInterfaceForPPB(const std::string& name) const; | 45 const void* GetInterfaceForPPB(const std::string& name) const; |
48 const void* GetInterfaceForPPP(const std::string& name) const; | 46 const void* GetInterfaceForPPP(const std::string& name) const; |
49 | 47 |
50 private: | 48 private: |
49 friend class InterfaceListTest; | |
50 | |
51 struct InterfaceInfo { | 51 struct InterfaceInfo { |
52 InterfaceInfo() | 52 InterfaceInfo() |
53 : iface(NULL), | 53 : iface(NULL), |
54 required_permission(PERMISSION_NONE) { | 54 required_permission(PERMISSION_NONE) { |
55 } | 55 } |
56 InterfaceInfo(const void* in_interface, Permission in_perm) | 56 InterfaceInfo(const void* in_interface, Permission in_perm, |
57 bool in_requires_dev_channel) | |
dmichael (off chromium)
2013/12/18 18:42:38
Is there a reason this can't be one of the values
| |
57 : iface(in_interface), | 58 : iface(in_interface), |
58 required_permission(in_perm) { | 59 required_permission(in_perm), |
60 requires_dev_channel(in_requires_dev_channel) { | |
59 } | 61 } |
60 | 62 |
61 const void* iface; | 63 const void* iface; |
62 | 64 |
63 // Permission required to return non-null for this interface. This will | 65 // Permission required to return non-null for this interface. This will |
64 // be checked with the value set via SetProcessGlobalPermissionBits when | 66 // be checked with the value set via SetProcessGlobalPermissionBits when |
65 // an interface is requested. | 67 // an interface is requested. |
66 Permission required_permission; | 68 Permission required_permission; |
69 | |
70 bool requires_dev_channel; | |
67 }; | 71 }; |
68 | 72 |
69 typedef std::map<std::string, InterfaceInfo> NameToInterfaceInfoMap; | 73 typedef std::map<std::string, InterfaceInfo> NameToInterfaceInfoMap; |
70 | 74 |
71 void AddProxy(ApiID id, InterfaceProxy::Factory factory); | 75 void AddProxy(ApiID id, InterfaceProxy::Factory factory); |
72 | 76 |
73 // Permissions is the type of permission required to access the corresponding | 77 // Permissions is the type of permission required to access the corresponding |
74 // interface. Currently this must be just one unique permission (rather than | 78 // interface. Currently this must be just one unique permission (rather than |
75 // a bitfield). | 79 // a bitfield). |
76 void AddPPB(const char* name, const void* iface, Permission permission); | 80 void AddPPB(const char* name, const void* iface, Permission permission, |
81 bool requires_dev_channel); | |
77 void AddPPP(const char* name, const void* iface); | 82 void AddPPP(const char* name, const void* iface); |
78 | 83 |
79 PpapiPermissions permissions_; | 84 PpapiPermissions permissions_; |
80 | 85 |
81 NameToInterfaceInfoMap name_to_browser_info_; | 86 NameToInterfaceInfoMap name_to_browser_info_; |
82 NameToInterfaceInfoMap name_to_plugin_info_; | 87 NameToInterfaceInfoMap name_to_plugin_info_; |
83 | 88 |
84 InterfaceProxy::Factory id_to_factory_[API_ID_COUNT]; | 89 InterfaceProxy::Factory id_to_factory_[API_ID_COUNT]; |
85 | 90 |
86 DISALLOW_COPY_AND_ASSIGN(InterfaceList); | 91 DISALLOW_COPY_AND_ASSIGN(InterfaceList); |
87 }; | 92 }; |
88 | 93 |
89 } // namespace proxy | 94 } // namespace proxy |
90 } // namespace ppapi | 95 } // namespace ppapi |
91 | 96 |
92 #endif // PPAPI_PROXY_INTERFACE_LIST_H_ | 97 #endif // PPAPI_PROXY_INTERFACE_LIST_H_ |
93 | 98 |
OLD | NEW |