| 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/pp_errors.h" |
| 8 #include "ppapi/c/ppb_input_event.h" |
| 7 #include "ppapi/c/ppb_instance.h" | 9 #include "ppapi/c/ppb_instance.h" |
| 8 #include "ppapi/c/ppb_messaging.h" | 10 #include "ppapi/c/ppb_messaging.h" |
| 9 #include "ppapi/cpp/common.h" | 11 #include "ppapi/cpp/common.h" |
| 10 #include "ppapi/cpp/dev/surface_3d_dev.h" | 12 #include "ppapi/cpp/dev/surface_3d_dev.h" |
| 11 #include "ppapi/cpp/graphics_2d.h" | 13 #include "ppapi/cpp/graphics_2d.h" |
| 12 #include "ppapi/cpp/image_data.h" | 14 #include "ppapi/cpp/image_data.h" |
| 13 #include "ppapi/cpp/logging.h" | 15 #include "ppapi/cpp/logging.h" |
| 14 #include "ppapi/cpp/module.h" | 16 #include "ppapi/cpp/module.h" |
| 15 #include "ppapi/cpp/module_impl.h" | 17 #include "ppapi/cpp/module_impl.h" |
| 16 #include "ppapi/cpp/point.h" | 18 #include "ppapi/cpp/point.h" |
| 17 #include "ppapi/cpp/resource.h" | 19 #include "ppapi/cpp/resource.h" |
| 18 #include "ppapi/cpp/var.h" | 20 #include "ppapi/cpp/var.h" |
| 19 | 21 |
| 20 namespace pp { | 22 namespace pp { |
| 21 | 23 |
| 22 namespace { | 24 namespace { |
| 23 | 25 |
| 26 template <> const char* interface_name<PPB_InputEvent>() { |
| 27 return PPB_INPUT_EVENT_INTERFACE; |
| 28 } |
| 29 |
| 24 template <> const char* interface_name<PPB_Instance>() { | 30 template <> const char* interface_name<PPB_Instance>() { |
| 25 return PPB_INSTANCE_INTERFACE; | 31 return PPB_INSTANCE_INTERFACE; |
| 26 } | 32 } |
| 27 | 33 |
| 28 template <> const char* interface_name<PPB_Messaging>() { | 34 template <> const char* interface_name<PPB_Messaging>() { |
| 29 return PPB_MESSAGING_INTERFACE; | 35 return PPB_MESSAGING_INTERFACE; |
| 30 } | 36 } |
| 31 | 37 |
| 32 } // namespace | 38 } // namespace |
| 33 | 39 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 58 | 64 |
| 59 | 65 |
| 60 bool Instance::HandleDocumentLoad(const URLLoader& /*url_loader*/) { | 66 bool Instance::HandleDocumentLoad(const URLLoader& /*url_loader*/) { |
| 61 return false; | 67 return false; |
| 62 } | 68 } |
| 63 | 69 |
| 64 bool Instance::HandleInputEvent(const PP_InputEvent& /*event*/) { | 70 bool Instance::HandleInputEvent(const PP_InputEvent& /*event*/) { |
| 65 return false; | 71 return false; |
| 66 } | 72 } |
| 67 | 73 |
| 74 bool Instance::HandleInputEvent(const InputEvent& /*event*/) { |
| 75 return false; |
| 76 } |
| 77 |
| 68 void Instance::HandleMessage(const Var& /*message*/) { | 78 void Instance::HandleMessage(const Var& /*message*/) { |
| 69 return; | 79 return; |
| 70 } | 80 } |
| 71 | 81 |
| 72 #ifndef PPAPI_INSTANCE_REMOVE_SCRIPTING | 82 #ifndef PPAPI_INSTANCE_REMOVE_SCRIPTING |
| 73 Var Instance::GetWindowObject() { | 83 Var Instance::GetWindowObject() { |
| 74 if (!has_interface<PPB_Instance>()) | 84 if (!has_interface<PPB_Instance>()) |
| 75 return Var(); | 85 return Var(); |
| 76 return Var(Var::PassRef(), | 86 return Var(Var::PassRef(), |
| 77 get_interface<PPB_Instance>()->GetWindowObject(pp_instance())); | 87 get_interface<PPB_Instance>()->GetWindowObject(pp_instance())); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 pp_instance(), graphics.pp_resource())); | 124 pp_instance(), graphics.pp_resource())); |
| 115 } | 125 } |
| 116 | 126 |
| 117 bool Instance::IsFullFrame() { | 127 bool Instance::IsFullFrame() { |
| 118 if (!has_interface<PPB_Instance>()) | 128 if (!has_interface<PPB_Instance>()) |
| 119 return false; | 129 return false; |
| 120 return PPBoolToBool(get_interface<PPB_Instance>()->IsFullFrame( | 130 return PPBoolToBool(get_interface<PPB_Instance>()->IsFullFrame( |
| 121 pp_instance())); | 131 pp_instance())); |
| 122 } | 132 } |
| 123 | 133 |
| 134 int32_t Instance::RequestInputEvents(uint32_t event_classes) { |
| 135 if (!has_interface<PPB_InputEvent>()) |
| 136 return PP_ERROR_NOINTERFACE; |
| 137 return get_interface<PPB_InputEvent>()->RequestInputEvents(pp_instance(), |
| 138 event_classes); |
| 139 } |
| 140 |
| 141 int32_t Instance::RequestFilteringInputEvents(uint32_t event_classes) { |
| 142 if (!has_interface<PPB_InputEvent>()) |
| 143 return PP_ERROR_NOINTERFACE; |
| 144 return get_interface<PPB_InputEvent>()->RequestFilteringInputEvents( |
| 145 pp_instance(), event_classes); |
| 146 } |
| 147 |
| 148 void Instance::ClearInputEventRequest(uint32_t event_classes) { |
| 149 if (!has_interface<PPB_InputEvent>()) |
| 150 return; |
| 151 get_interface<PPB_InputEvent>()->ClearInputEventRequest(pp_instance(), |
| 152 event_classes); |
| 153 } |
| 154 |
| 124 void Instance::PostMessage(const Var& message) { | 155 void Instance::PostMessage(const Var& message) { |
| 125 if (!has_interface<PPB_Messaging>()) | 156 if (!has_interface<PPB_Messaging>()) |
| 126 return; | 157 return; |
| 127 get_interface<PPB_Messaging>()->PostMessage(pp_instance(), | 158 get_interface<PPB_Messaging>()->PostMessage(pp_instance(), |
| 128 message.pp_var()); | 159 message.pp_var()); |
| 129 } | 160 } |
| 130 | 161 |
| 131 void Instance::AddPerInstanceObject(const std::string& interface_name, | 162 void Instance::AddPerInstanceObject(const std::string& interface_name, |
| 132 void* object) { | 163 void* object) { |
| 133 // Ensure we're not trying to register more than one object per interface | 164 // Ensure we're not trying to register more than one object per interface |
| (...skipping 28 matching lines...) Expand all Loading... |
| 162 if (!that) | 193 if (!that) |
| 163 return NULL; | 194 return NULL; |
| 164 InterfaceNameToObjectMap::iterator found = | 195 InterfaceNameToObjectMap::iterator found = |
| 165 that->interface_name_to_objects_.find(interface_name); | 196 that->interface_name_to_objects_.find(interface_name); |
| 166 if (found == that->interface_name_to_objects_.end()) | 197 if (found == that->interface_name_to_objects_.end()) |
| 167 return NULL; | 198 return NULL; |
| 168 return found->second; | 199 return found->second; |
| 169 } | 200 } |
| 170 | 201 |
| 171 } // namespace pp | 202 } // namespace pp |
| OLD | NEW |