OLD | NEW |
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 #include "ppapi/cpp/instance.h" | 5 #include "ppapi/cpp/instance.h" |
6 | 6 |
7 #include "ppapi/c/dev/ppp_printing_dev.h" | 7 #include "ppapi/c/dev/ppp_printing_dev.h" |
8 #include "ppapi/c/ppb_instance.h" | 8 #include "ppapi/c/ppb_instance.h" |
9 #include "ppapi/c/ppb_messaging.h" | 9 #include "ppapi/c/ppb_messaging.h" |
10 #include "ppapi/cpp/common.h" | 10 #include "ppapi/cpp/common.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 } | 63 } |
64 | 64 |
65 bool Instance::HandleInputEvent(const PP_InputEvent& /*event*/) { | 65 bool Instance::HandleInputEvent(const PP_InputEvent& /*event*/) { |
66 return false; | 66 return false; |
67 } | 67 } |
68 | 68 |
69 void Instance::HandleMessage(const Var& /*message*/) { | 69 void Instance::HandleMessage(const Var& /*message*/) { |
70 return; | 70 return; |
71 } | 71 } |
72 | 72 |
73 Var Instance::GetInstanceObject() { | |
74 return Var(); | |
75 } | |
76 | |
77 Var Instance::GetSelectedText(bool /* html */) { | 73 Var Instance::GetSelectedText(bool /* html */) { |
78 return Var(); | 74 return Var(); |
79 } | 75 } |
80 | 76 |
| 77 #ifndef PPAPI_INSTANCE_REMOVE_SCRIPTING |
81 Var Instance::GetWindowObject() { | 78 Var Instance::GetWindowObject() { |
82 if (!has_interface<PPB_Instance>()) | 79 if (!has_interface<PPB_Instance>()) |
83 return Var(); | 80 return Var(); |
84 return Var(Var::PassRef(), | 81 return Var(Var::PassRef(), |
85 get_interface<PPB_Instance>()->GetWindowObject(pp_instance())); | 82 get_interface<PPB_Instance>()->GetWindowObject(pp_instance())); |
86 } | 83 } |
87 | 84 |
88 Var Instance::GetOwnerElementObject() { | 85 Var Instance::GetOwnerElementObject() { |
89 if (!has_interface<PPB_Instance>()) | 86 if (!has_interface<PPB_Instance>()) |
90 return Var(); | 87 return Var(); |
91 return Var(Var::PassRef(), | 88 return Var(Var::PassRef(), |
92 get_interface<PPB_Instance>()->GetOwnerElementObject( | 89 get_interface<PPB_Instance>()->GetOwnerElementObject( |
93 pp_instance())); | 90 pp_instance())); |
94 } | 91 } |
95 | 92 |
| 93 Var Instance::ExecuteScript(const Var& script, Var* exception) { |
| 94 if (!has_interface<PPB_Instance>()) |
| 95 return Var(); |
| 96 return Var(Var::PassRef(), |
| 97 get_interface<PPB_Instance>()->ExecuteScript( |
| 98 pp_instance(), |
| 99 script.pp_var(), |
| 100 Var::OutException(exception).get())); |
| 101 } |
| 102 |
| 103 Var Instance::GetInstanceObject() { |
| 104 return Var(); |
| 105 } |
| 106 #endif |
| 107 |
96 bool Instance::BindGraphics(const Graphics2D& graphics) { | 108 bool Instance::BindGraphics(const Graphics2D& graphics) { |
97 if (!has_interface<PPB_Instance>()) | 109 if (!has_interface<PPB_Instance>()) |
98 return false; | 110 return false; |
99 return PPBoolToBool(get_interface<PPB_Instance>()->BindGraphics( | 111 return PPBoolToBool(get_interface<PPB_Instance>()->BindGraphics( |
100 pp_instance(), graphics.pp_resource())); | 112 pp_instance(), graphics.pp_resource())); |
101 } | 113 } |
102 | 114 |
103 bool Instance::BindGraphics(const Surface3D_Dev& graphics) { | 115 bool Instance::BindGraphics(const Surface3D_Dev& graphics) { |
104 if (!has_interface<PPB_Instance>()) | 116 if (!has_interface<PPB_Instance>()) |
105 return false; | 117 return false; |
106 return PPBoolToBool(get_interface<PPB_Instance>()->BindGraphics( | 118 return PPBoolToBool(get_interface<PPB_Instance>()->BindGraphics( |
107 pp_instance(), graphics.pp_resource())); | 119 pp_instance(), graphics.pp_resource())); |
108 } | 120 } |
109 | 121 |
110 bool Instance::IsFullFrame() { | 122 bool Instance::IsFullFrame() { |
111 if (!has_interface<PPB_Instance>()) | 123 if (!has_interface<PPB_Instance>()) |
112 return false; | 124 return false; |
113 return PPBoolToBool(get_interface<PPB_Instance>()->IsFullFrame( | 125 return PPBoolToBool(get_interface<PPB_Instance>()->IsFullFrame( |
114 pp_instance())); | 126 pp_instance())); |
115 } | 127 } |
116 | 128 |
117 Var Instance::ExecuteScript(const Var& script, Var* exception) { | |
118 if (!has_interface<PPB_Instance>()) | |
119 return Var(); | |
120 return Var(Var::PassRef(), | |
121 get_interface<PPB_Instance>()->ExecuteScript( | |
122 pp_instance(), | |
123 script.pp_var(), | |
124 Var::OutException(exception).get())); | |
125 } | |
126 | |
127 void Instance::PostMessage(const Var& message) { | 129 void Instance::PostMessage(const Var& message) { |
128 if (!has_interface<PPB_Messaging>()) | 130 if (!has_interface<PPB_Messaging>()) |
129 return; | 131 return; |
130 get_interface<PPB_Messaging>()->PostMessage(pp_instance(), | 132 get_interface<PPB_Messaging>()->PostMessage(pp_instance(), |
131 message.pp_var()); | 133 message.pp_var()); |
132 } | 134 } |
133 | 135 |
134 void Instance::AddPerInstanceObject(const std::string& interface_name, | 136 void Instance::AddPerInstanceObject(const std::string& interface_name, |
135 void* object) { | 137 void* object) { |
136 // Ensure we're not trying to register more than one object per interface | 138 // Ensure we're not trying to register more than one object per interface |
(...skipping 28 matching lines...) Expand all Loading... |
165 if (!that) | 167 if (!that) |
166 return NULL; | 168 return NULL; |
167 InterfaceNameToObjectMap::iterator found = | 169 InterfaceNameToObjectMap::iterator found = |
168 that->interface_name_to_objects_.find(interface_name); | 170 that->interface_name_to_objects_.find(interface_name); |
169 if (found == that->interface_name_to_objects_.end()) | 171 if (found == that->interface_name_to_objects_.end()) |
170 return NULL; | 172 return NULL; |
171 return found->second; | 173 return found->second; |
172 } | 174 } |
173 | 175 |
174 } // namespace pp | 176 } // namespace pp |
OLD | NEW |