Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(430)

Side by Side Diff: ppapi/cpp/var.h

Issue 7362012: Remove untrusted scripting support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/cpp/private/instance_private.cc ('k') | ppapi/cpp/var.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_CPP_VAR_H_ 5 #ifndef PPAPI_CPP_VAR_H_
6 #define PPAPI_CPP_VAR_H_ 6 #define PPAPI_CPP_VAR_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "ppapi/c/pp_module.h" 11 #include "ppapi/c/pp_module.h"
12 #include "ppapi/c/pp_var.h" 12 #include "ppapi/c/pp_var.h"
13 13
14 namespace pp { 14 namespace pp {
15 15
16 class Instance; 16 class Instance;
17 17
18 #ifndef PPAPI_VAR_REMOVE_SCRIPTING
19 namespace deprecated {
20 class ScriptableObject;
21 }
22 #endif
23
24 class Var { 18 class Var {
25 public: 19 public:
26 struct Null {}; // Special value passed to constructor to make NULL. 20 struct Null {}; // Special value passed to constructor to make NULL.
27 21
28 Var(); // PP_Var of type Undefined. 22 Var(); // PP_Var of type Undefined.
29 Var(Null); // PP_Var of type Null. 23 Var(Null); // PP_Var of type Null.
30 Var(bool b); 24 Var(bool b);
31 Var(int32_t i); 25 Var(int32_t i);
32 Var(double d); 26 Var(double d);
33 Var(const char* utf8_str); // Must be encoded in UTF-8. 27 Var(const char* utf8_str); // Must be encoded in UTF-8.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 // 87 //
94 // These functions will assert in debug mode and return 0 if the internal 88 // These functions will assert in debug mode and return 0 if the internal
95 // representation is not IsNumber(). 89 // representation is not IsNumber().
96 int32_t AsInt() const; 90 int32_t AsInt() const;
97 double AsDouble() const; 91 double AsDouble() const;
98 92
99 // This assumes the object is of type string. If it's not, it will assert 93 // This assumes the object is of type string. If it's not, it will assert
100 // in debug mode, and return an empty string. 94 // in debug mode, and return an empty string.
101 std::string AsString() const; 95 std::string AsString() const;
102 96
103 #ifndef PPAPI_VAR_REMOVE_SCRIPTING
104 // Takes ownership of the given pointer.
105 Var(Instance* instance, deprecated::ScriptableObject* object);
106
107 // This assumes the object is of type object. If it's not, it will assert in
108 // debug mode. If it is not an object or not a ScriptableObject type, returns
109 // NULL.
110 deprecated::ScriptableObject* AsScriptableObject() const;
111
112 bool HasProperty(const Var& name, Var* exception = NULL) const;
113 bool HasMethod(const Var& name, Var* exception = NULL) const;
114 Var GetProperty(const Var& name, Var* exception = NULL) const;
115 void GetAllPropertyNames(std::vector<Var>* properties,
116 Var* exception = NULL) const;
117 void SetProperty(const Var& name, const Var& value, Var* exception = NULL);
118 void RemoveProperty(const Var& name, Var* exception = NULL);
119 Var Call(const Var& method_name, uint32_t argc, Var* argv,
120 Var* exception = NULL);
121 Var Construct(uint32_t argc, Var* argv, Var* exception = NULL) const;
122
123 // Convenience functions for calling functions with small # of args.
124 Var Call(const Var& method_name, Var* exception = NULL);
125 Var Call(const Var& method_name, const Var& arg1, Var* exception = NULL);
126 Var Call(const Var& method_name, const Var& arg1, const Var& arg2,
127 Var* exception = NULL);
128 Var Call(const Var& method_name, const Var& arg1, const Var& arg2,
129 const Var& arg3, Var* exception = NULL);
130 Var Call(const Var& method_name, const Var& arg1, const Var& arg2,
131 const Var& arg3, const Var& arg4, Var* exception = NULL);
132 #endif // ifndef PPAPI_VAR_REMOVE_SCRIPTING
133
134 // Returns a const reference to the PP_Var managed by this Var object. 97 // Returns a const reference to the PP_Var managed by this Var object.
135 const PP_Var& pp_var() const { 98 const PP_Var& pp_var() const {
136 return var_; 99 return var_;
137 } 100 }
138 101
139 // Detaches from the internal PP_Var of this object, keeping the reference 102 // Detaches from the internal PP_Var of this object, keeping the reference
140 // count the same. This is used when returning a PP_Var from an API function 103 // count the same. This is used when returning a PP_Var from an API function
141 // where the caller expects the return value to be AddRef'ed for it. 104 // where the caller expects the return value to be AddRef'ed for it.
142 PP_Var Detach() { 105 PP_Var Detach() {
143 PP_Var ret = var_; 106 PP_Var ret = var_;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 // Prevent an arbitrary pointer argument from being implicitly converted to 172 // Prevent an arbitrary pointer argument from being implicitly converted to
210 // a bool at Var construction. If somebody makes such a mistake, (s)he will 173 // a bool at Var construction. If somebody makes such a mistake, (s)he will
211 // get a compilation error. 174 // get a compilation error.
212 Var(void* non_scriptable_object_pointer); 175 Var(void* non_scriptable_object_pointer);
213 176
214 }; 177 };
215 178
216 } // namespace pp 179 } // namespace pp
217 180
218 #endif // PPAPI_CPP_VAR_H_ 181 #endif // PPAPI_CPP_VAR_H_
OLDNEW
« no previous file with comments | « ppapi/cpp/private/instance_private.cc ('k') | ppapi/cpp/var.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698