Revert "Fix broken channel icon in chrome://help on CrOS" and try again
[chromium-blink-merge.git] / ppapi / cpp / dev / scriptable_object_deprecated.h
blob7423d2327682b6a26b5e9aa97b361eca47ebf266
1 // Copyright (c) 2010 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_CPP_SCRIPTABLE_OBJECT_DEPRECATED_H_
6 #define PPAPI_CPP_SCRIPTABLE_OBJECT_DEPRECATED_H_
8 #include <vector>
10 struct PPP_Class_Deprecated;
12 namespace pp {
13 class Var;
14 class VarPrivate;
17 namespace pp {
19 namespace deprecated {
21 // This class allows you to implement objects accessible by JavaScript. Derive
22 // from this class and override the virtual functions you support. pp::Var has
23 // a constructor that takes a pointer to a ScriptableObject for when you want
24 // to convert your custom object to a var.
26 // Please see the PPB_Core C interface for more information on how to implement
27 // these functions. These functions are the backend implementation for the
28 // functions in PPB_Var, which contains further information.
30 // Please see:
31 // http://code.google.com/p/ppapi/wiki/InterfacingWithJavaScript
32 // for a general overview of interfacing with JavaScript.
33 class ScriptableObject {
34 public:
35 ScriptableObject() {}
36 virtual ~ScriptableObject() {}
38 // The default implementation returns false.
39 virtual bool HasProperty(const Var& name, Var* exception);
41 // The default implementation returns false.
42 virtual bool HasMethod(const Var& name, Var* exception);
44 // The default implementation sets an exception that the property doesn't
45 // exist.
46 virtual Var GetProperty(const Var& name, Var* exception);
48 // The default implementation returns no properties.
49 virtual void GetAllPropertyNames(std::vector<Var>* properties,
50 Var* exception);
52 // The default implementation sets an exception that the property can not be
53 // set.
54 virtual void SetProperty(const Var& name,
55 const Var& value,
56 Var* exception);
58 // The default implementation sets an exception that the method does not
59 // exist.
60 virtual void RemoveProperty(const Var& name,
61 Var* exception);
63 // TODO(brettw) need native array access here.
65 // method_name is guaranteed to be either a string or an integer.
67 // The default implementation sets an exception that the method does not
68 // exist.
69 virtual Var Call(const Var& method_name,
70 const std::vector<Var>& args,
71 Var* exception);
73 // The default implementation sets an exception that the method does not
74 // exist.
75 virtual Var Construct(const std::vector<Var>& args,
76 Var* exception);
78 private:
79 friend class ::pp::Var;
80 friend class ::pp::VarPrivate;
81 static const PPP_Class_Deprecated* GetClass();
83 // Unimplemented, copy and assignment is not allowed.
84 ScriptableObject(const ScriptableObject& other);
85 ScriptableObject& operator=(const ScriptableObject& other);
88 } // namespace deprecated
90 } // namespace pp
92 #endif // PPAPI_CPP_SCRIPTABLE_OBJECT_DEPRECATED_H_