OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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 // This implements the JavaScript class entrypoint for the plugin. | 5 // This implements the JavaScript class entrypoint for the plugin instance. |
6 // The Javascript API is defined as follows. | 6 // The Javascript API is defined as follows. |
7 // | 7 // |
8 // interface ChromotingScriptableObject { | 8 // interface ChromotingScriptableObject { |
9 // // Called when the Chromoting plugin has had a state change such as | 9 // // Called when the Chromoting instance has had a state change such as |
10 // // connection completed. | 10 // // connection completed. |
11 // attribute Function onreadystatechange; | 11 // attribute Function onreadystatechange; |
12 // | 12 // |
13 // // Constants for states, etc. | 13 // // Constants for states, etc. |
14 // const unsigned short NOT_CONNECTED = 0; | 14 // const unsigned short NOT_CONNECTED = 0; |
15 // const unsigned short CONNECTED = 1; | 15 // const unsigned short CONNECTED = 1; |
16 // | 16 // |
17 // // Methods on the object. | 17 // // Methods on the object. |
18 // void connect(string username, string host_jid, string auth_token); | 18 // void connect(string username, string host_jid, string auth_token); |
19 // | 19 // |
(...skipping 11 matching lines...) Expand all Loading... |
31 | 31 |
32 #include <map> | 32 #include <map> |
33 #include <string> | 33 #include <string> |
34 #include <vector> | 34 #include <vector> |
35 | 35 |
36 #include "third_party/ppapi/cpp/scriptable_object.h" | 36 #include "third_party/ppapi/cpp/scriptable_object.h" |
37 #include "third_party/ppapi/cpp/var.h" | 37 #include "third_party/ppapi/cpp/var.h" |
38 | 38 |
39 namespace remoting { | 39 namespace remoting { |
40 | 40 |
41 class ChromotingPlugin; | 41 class ChromotingInstance; |
42 | 42 |
43 class ChromotingScriptableObject : public pp::ScriptableObject { | 43 class ChromotingScriptableObject : public pp::ScriptableObject { |
44 public: | 44 public: |
45 explicit ChromotingScriptableObject(ChromotingPlugin* instance); | 45 explicit ChromotingScriptableObject(ChromotingInstance* instance); |
46 virtual ~ChromotingScriptableObject(); | 46 virtual ~ChromotingScriptableObject(); |
47 | 47 |
48 virtual void Init(); | 48 virtual void Init(); |
49 | 49 |
50 // Override the ScriptableObject functions. | 50 // Override the ScriptableObject functions. |
51 virtual bool HasProperty(const pp::Var& name, pp::Var* exception); | 51 virtual bool HasProperty(const pp::Var& name, pp::Var* exception); |
52 virtual bool HasMethod(const pp::Var& name, pp::Var* exception); | 52 virtual bool HasMethod(const pp::Var& name, pp::Var* exception); |
53 virtual pp::Var GetProperty(const pp::Var& name, pp::Var* exception); | 53 virtual pp::Var GetProperty(const pp::Var& name, pp::Var* exception); |
54 virtual void GetAllPropertyNames(std::vector<pp::Var>* properties, | 54 virtual void GetAllPropertyNames(std::vector<pp::Var>* properties, |
55 pp::Var* exception); | 55 pp::Var* exception); |
(...skipping 29 matching lines...) Expand all Loading... |
85 | 85 |
86 | 86 |
87 void AddAttribute(const std::string& name, pp::Var attribute); | 87 void AddAttribute(const std::string& name, pp::Var attribute); |
88 void AddMethod(const std::string& name, MethodHandler handler); | 88 void AddMethod(const std::string& name, MethodHandler handler); |
89 | 89 |
90 pp::Var DoConnect(const std::vector<pp::Var>& args, pp::Var* exception); | 90 pp::Var DoConnect(const std::vector<pp::Var>& args, pp::Var* exception); |
91 | 91 |
92 PropertyNameMap property_names_; | 92 PropertyNameMap property_names_; |
93 std::vector<PropertyDescriptor> properties_; | 93 std::vector<PropertyDescriptor> properties_; |
94 | 94 |
95 ChromotingPlugin* instance_; | 95 ChromotingInstance* instance_; |
96 }; | 96 }; |
97 | 97 |
98 } // namespace remoting | 98 } // namespace remoting |
99 | 99 |
100 #endif // REMOTING_CLIENT_PLUGIN_CHROMOTING_SCRIPTABLE_OBJECT_H_ | 100 #endif // REMOTING_CLIENT_PLUGIN_CHROMOTING_SCRIPTABLE_OBJECT_H_ |
OLD | NEW |