| OLD | NEW |
| 1 // Copyright (c) 2011 The Native Client Authors. All rights reserved. | 1 // Copyright (c) 2011 The Native Client 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 required interfaces for representing a plugin module | 5 // This implements the required interfaces for representing a plugin module |
| 6 // instance in browser interactions and provides a way to register custom | 6 // instance in browser interactions and provides a way to register custom |
| 7 // plugin interfaces. | 7 // plugin interfaces. |
| 8 // | 8 // |
| 9 | 9 |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 CHECK(ppb_get_interface() != NULL); | 81 CHECK(ppb_get_interface() != NULL); |
| 82 CHECK(PPBCore() != NULL); | 82 CHECK(PPBCore() != NULL); |
| 83 CHECK(PPBGraphics2D() != NULL); | 83 CHECK(PPBGraphics2D() != NULL); |
| 84 CHECK(PPBImageData() != NULL); | 84 CHECK(PPBImageData() != NULL); |
| 85 CHECK(PPBInstance() != NULL); | 85 CHECK(PPBInstance() != NULL); |
| 86 CHECK(PPBMessaging() != NULL); | 86 CHECK(PPBMessaging() != NULL); |
| 87 CHECK(PPBURLLoader() != NULL); | 87 CHECK(PPBURLLoader() != NULL); |
| 88 CHECK(PPBURLRequestInfo() != NULL); | 88 CHECK(PPBURLRequestInfo() != NULL); |
| 89 CHECK(PPBURLResponseInfo() != NULL); | 89 CHECK(PPBURLResponseInfo() != NULL); |
| 90 CHECK(PPBVar() != NULL); | 90 CHECK(PPBVar() != NULL); |
| 91 CHECK(PPBVarDeprecated() != NULL); | |
| 92 | 91 |
| 93 set_pp_instance(instance); | 92 set_pp_instance(instance); |
| 94 SetupTests(); | 93 SetupTests(); |
| 95 | 94 |
| 96 return PP_TRUE; | 95 return PP_TRUE; |
| 97 } | 96 } |
| 98 | 97 |
| 99 void DidDestroy(PP_Instance /*instance*/) { | 98 void DidDestroy(PP_Instance /*instance*/) { |
| 100 } | 99 } |
| 101 | 100 |
| 102 void DidChangeView(PP_Instance /*instance*/, | 101 void DidChangeView(PP_Instance /*instance*/, |
| 103 const struct PP_Rect* /*position*/, | 102 const struct PP_Rect* /*position*/, |
| 104 const struct PP_Rect* /*clip*/) { | 103 const struct PP_Rect* /*clip*/) { |
| 105 } | 104 } |
| 106 | 105 |
| 107 void DidChangeFocus(PP_Instance /*instance*/, | 106 void DidChangeFocus(PP_Instance /*instance*/, |
| 108 PP_Bool /*has_focus*/) { | 107 PP_Bool /*has_focus*/) { |
| 109 } | 108 } |
| 110 | 109 |
| 111 PP_Bool HandleInputEvent(PP_Instance /*instance*/, | 110 PP_Bool HandleInputEvent(PP_Instance /*instance*/, |
| 112 const struct PP_InputEvent* /*event*/) { | 111 const struct PP_InputEvent* /*event*/) { |
| 113 return PP_TRUE; | 112 return PP_TRUE; |
| 114 } | 113 } |
| 115 | 114 |
| 116 PP_Bool HandleDocumentLoad(PP_Instance instance, | 115 PP_Bool HandleDocumentLoad(PP_Instance instance, |
| 117 PP_Resource url_loader) { | 116 PP_Resource url_loader) { |
| 118 return PP_TRUE; | 117 return PP_TRUE; |
| 119 } | 118 } |
| 120 | 119 |
| 121 PP_Var GetInstanceObject(PP_Instance instance) { | |
| 122 return GetScriptableObject(instance); | |
| 123 } | |
| 124 | |
| 125 const PPP_Instance ppp_instance_interface = { | 120 const PPP_Instance ppp_instance_interface = { |
| 126 DidCreate, | 121 DidCreate, |
| 127 DidDestroy, | 122 DidDestroy, |
| 128 DidChangeView, | 123 DidChangeView, |
| 129 DidChangeFocus, | 124 DidChangeFocus, |
| 130 HandleInputEvent, | 125 HandleInputEvent, |
| 131 HandleDocumentLoad | 126 HandleDocumentLoad |
| 132 #ifndef PPAPI_INSTANCE_REMOVE_SCRIPTING | |
| 133 , GetInstanceObject | |
| 134 #endif | |
| 135 }; | 127 }; |
| 136 | 128 |
| 137 /////////////////////////////////////////////////////////////////////////////// | 129 /////////////////////////////////////////////////////////////////////////////// |
| 138 // PPP_Messaging implementation | 130 // PPP_Messaging implementation |
| 139 /////////////////////////////////////////////////////////////////////////////// | 131 /////////////////////////////////////////////////////////////////////////////// |
| 140 | 132 |
| 141 void HandleMessage(PP_Instance instance, PP_Var message) { | 133 void HandleMessage(PP_Instance instance, PP_Var message) { |
| 142 if (message.type != PP_VARTYPE_STRING) | 134 if (message.type != PP_VARTYPE_STRING) |
| 143 return; | 135 return; |
| 144 uint32_t len = 0; | 136 uint32_t len = 0; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 174 return &ppp_instance_interface; | 166 return &ppp_instance_interface; |
| 175 } | 167 } |
| 176 // The PPP_Messaging interface is required for the test set-up. | 168 // The PPP_Messaging interface is required for the test set-up. |
| 177 if (0 == strncmp(PPP_MESSAGING_INTERFACE, interface_name, | 169 if (0 == strncmp(PPP_MESSAGING_INTERFACE, interface_name, |
| 178 strlen(PPP_MESSAGING_INTERFACE))) { | 170 strlen(PPP_MESSAGING_INTERFACE))) { |
| 179 return &ppp_messaging_interface; | 171 return &ppp_messaging_interface; |
| 180 } | 172 } |
| 181 // All other interfaces are to be optionally supplied by the tester. | 173 // All other interfaces are to be optionally supplied by the tester. |
| 182 return PluginInterfaceTable::Get()->GetInterface(interface_name); | 174 return PluginInterfaceTable::Get()->GetInterface(interface_name); |
| 183 } | 175 } |
| OLD | NEW |