| OLD | NEW |
| 1 // Copyright (c) 2011 The Native Client Authors. All rights reserved. | 1 // Copyright (c) 2011 The Native Client 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 // PPAPI-based implementation of the interface for a scriptable object. | 5 // PPAPI-based implementation of the interface for a scriptable object. |
| 6 | 6 |
| 7 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PPAPI_SCRIPTABLE_HANDLE_PPAPI_H_ | 7 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PPAPI_SCRIPTABLE_HANDLE_PPAPI_H_ |
| 8 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PPAPI_SCRIPTABLE_HANDLE_PPAPI_H_ | 8 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PPAPI_SCRIPTABLE_HANDLE_PPAPI_H_ |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 // Encapsulates a browser scriptable object for a PPAPI NaCl plugin. | 23 // Encapsulates a browser scriptable object for a PPAPI NaCl plugin. |
| 24 class ScriptableHandlePpapi : public pp::deprecated::ScriptableObject, | 24 class ScriptableHandlePpapi : public pp::deprecated::ScriptableObject, |
| 25 public ScriptableHandle { | 25 public ScriptableHandle { |
| 26 public: | 26 public: |
| 27 // Factory method for creation. | 27 // Factory method for creation. |
| 28 static ScriptableHandlePpapi* New(PortableHandle* handle); | 28 static ScriptableHandlePpapi* New(PortableHandle* handle); |
| 29 | 29 |
| 30 // If not NULL, this var should be reused to pass this object to the browser. | 30 // If not NULL, this var should be reused to pass this object to the browser. |
| 31 pp::VarPrivate* var() { return var_; } | 31 pp::VarPrivate* var() { return var_; } |
| 32 | 32 |
| 33 // Turn off the ability to set a proxy if we're removing scripting. In this | |
| 34 // case, the ScriptableHandle can only refer to the NaCl plugin. | |
| 35 // TODO(dmichael): Clean up all traces of scripting proxying. | |
| 36 #ifndef PPAPI_INSTANCE_REMOVE_SCRIPTING | |
| 37 // If this scriptable handle corresponds to the NaCl plugin itself and the | |
| 38 // plugin has successfully loaded the NaCl module and started proxied | |
| 39 // execution, scripting should be redirected via this proxy. | |
| 40 void set_scriptable_proxy(const pp::VarPrivate& proxy) { | |
| 41 scriptable_proxy_ = proxy; | |
| 42 } | |
| 43 #endif | |
| 44 | |
| 45 // ------ Methods inherited from pp::deprecated::ScriptableObject: | 33 // ------ Methods inherited from pp::deprecated::ScriptableObject: |
| 46 | 34 |
| 47 // Returns true for preloaded NaCl Plugin properties. | 35 // Returns true for preloaded NaCl Plugin properties. |
| 48 // Does not set |exception|. | 36 // Does not set |exception|. |
| 49 virtual bool HasProperty(const pp::Var& name, pp::Var* exception); | 37 virtual bool HasProperty(const pp::Var& name, pp::Var* exception); |
| 50 // Returns true for preloaded NaCl Plugin methods and SRPC methods exported | 38 // Returns true for preloaded NaCl Plugin methods and SRPC methods exported |
| 51 // from a NaCl module. Does not set |exception|. | 39 // from a NaCl module. Does not set |exception|. |
| 52 virtual bool HasMethod(const pp::Var& name, pp::Var* exception); | 40 virtual bool HasMethod(const pp::Var& name, pp::Var* exception); |
| 53 | 41 |
| 54 // Gets the value of a preloaded NaCl Plugin property. | 42 // Gets the value of a preloaded NaCl Plugin property. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 // This is never set for objects that are not shared with the browser nor for | 101 // This is never set for objects that are not shared with the browser nor for |
| 114 // objects created during SRPC calls as they are taken over by the browser on | 102 // objects created during SRPC calls as they are taken over by the browser on |
| 115 // return. | 103 // return. |
| 116 pp::VarPrivate* var_; | 104 pp::VarPrivate* var_; |
| 117 | 105 |
| 118 // We should have no more than one internal plugin owner for this object, | 106 // We should have no more than one internal plugin owner for this object, |
| 119 // and only that owner should call Unref(). To CHECK for that keep a counter. | 107 // and only that owner should call Unref(). To CHECK for that keep a counter. |
| 120 int num_unref_calls_; | 108 int num_unref_calls_; |
| 121 | 109 |
| 122 bool handle_is_plugin_; // Whether (portable) handle() is a plugin. | 110 bool handle_is_plugin_; // Whether (portable) handle() is a plugin. |
| 123 | |
| 124 #ifdef PPAPI_INSTANCE_REMOVE_SCRIPTING | |
| 125 // If untrusted scripting is disabled, make this a VarPrivate just so that | |
| 126 // it has all the methods it needs to compile. This is a hack to avoid having | |
| 127 // conditional compilation at every call-site for things like HasProperty, | |
| 128 // HasMethod, etc. We turn off untrusted scripting above by removing the | |
| 129 // setter for scriptable_proxy_, so it's always invalid. | |
| 130 // TODO(dmichael): Remove scriptable_proxy_ and all other traces of untrusted | |
| 131 // scripting. | |
| 132 pp::VarPrivate scriptable_proxy_; | |
| 133 #else | |
| 134 pp::Var scriptable_proxy_; // Proxy for NaCl module's scripting interface. | |
| 135 #endif | |
| 136 }; | 111 }; |
| 137 | 112 |
| 138 } // namespace plugin | 113 } // namespace plugin |
| 139 | 114 |
| 140 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PPAPI_SCRIPTABLE_HANDLE_PPAPI_H_ | 115 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PPAPI_SCRIPTABLE_HANDLE_PPAPI_H_ |
| OLD | NEW |