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 <stdlib.h> | 5 #include <stdlib.h> |
6 #include <string.h> | 6 #include <string.h> |
7 | 7 |
8 #include "ppapi/c/pp_completion_callback.h" | 8 #include "ppapi/c/pp_completion_callback.h" |
9 #include "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
10 #include "ppapi/c/pp_instance.h" | 10 #include "ppapi/c/pp_instance.h" |
11 #include "ppapi/c/pp_module.h" | 11 #include "ppapi/c/pp_module.h" |
12 #include "ppapi/c/pp_size.h" | 12 #include "ppapi/c/pp_size.h" |
13 #include "ppapi/c/pp_var.h" | 13 #include "ppapi/c/pp_var.h" |
14 #include "ppapi/c/ppb.h" | 14 #include "ppapi/c/ppb.h" |
15 #include "ppapi/c/ppb_core.h" | 15 #include "ppapi/c/ppb_core.h" |
16 #include "ppapi/c/ppb_graphics_2d.h" | 16 #include "ppapi/c/ppb_graphics_2d.h" |
17 #include "ppapi/c/ppb_image_data.h" | 17 #include "ppapi/c/ppb_image_data.h" |
18 #include "ppapi/c/ppb_instance.h" | 18 #include "ppapi/c/ppb_instance.h" |
19 #include "ppapi/c/ppp.h" | 19 #include "ppapi/c/ppp.h" |
20 #include "ppapi/c/ppp_instance.h" | 20 #include "ppapi/c/ppp_instance.h" |
21 | 21 |
22 PPB_GetInterface g_get_browser_interface = NULL; | 22 PPB_GetInterface g_get_browser_interface = NULL; |
23 | 23 |
24 const struct PPB_Core* g_core_interface; | 24 const PPB_Core* g_core_interface; |
25 const struct PPB_Graphics2D* g_graphics_2d_interface; | 25 const PPB_Graphics2D* g_graphics_2d_interface; |
26 const struct PPB_ImageData* g_image_data_interface; | 26 const PPB_ImageData* g_image_data_interface; |
27 const struct PPB_Instance* g_instance_interface; | 27 const PPB_Instance* g_instance_interface; |
28 | 28 |
29 /* PPP_Instance implementation -----------------------------------------------*/ | 29 /* PPP_Instance implementation -----------------------------------------------*/ |
30 | 30 |
31 struct InstanceInfo { | 31 struct InstanceInfo { |
32 PP_Instance pp_instance; | 32 PP_Instance pp_instance; |
33 struct PP_Size last_size; | 33 struct PP_Size last_size; |
34 | 34 |
35 struct InstanceInfo* next; | 35 struct InstanceInfo* next; |
36 }; | 36 }; |
37 | 37 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 } | 155 } |
156 | 156 |
157 void Instance_DidChangeFocus(PP_Instance pp_instance, PP_Bool has_focus) { | 157 void Instance_DidChangeFocus(PP_Instance pp_instance, PP_Bool has_focus) { |
158 } | 158 } |
159 | 159 |
160 PP_Bool Instance_HandleDocumentLoad(PP_Instance pp_instance, | 160 PP_Bool Instance_HandleDocumentLoad(PP_Instance pp_instance, |
161 PP_Resource pp_url_loader) { | 161 PP_Resource pp_url_loader) { |
162 return PP_FALSE; | 162 return PP_FALSE; |
163 } | 163 } |
164 | 164 |
165 static struct PPP_Instance instance_interface = { | 165 static PPP_Instance instance_interface = { |
166 &Instance_DidCreate, | 166 &Instance_DidCreate, |
167 &Instance_DidDestroy, | 167 &Instance_DidDestroy, |
168 &Instance_DidChangeView, | 168 &Instance_DidChangeView, |
169 &Instance_DidChangeFocus, | 169 &Instance_DidChangeFocus, |
170 &Instance_HandleDocumentLoad | 170 &Instance_HandleDocumentLoad |
171 }; | 171 }; |
172 | 172 |
173 | 173 |
174 /* Global entrypoints --------------------------------------------------------*/ | 174 /* Global entrypoints --------------------------------------------------------*/ |
175 | 175 |
176 PP_EXPORT int32_t PPP_InitializeModule(PP_Module module, | 176 PP_EXPORT int32_t PPP_InitializeModule(PP_Module module, |
177 PPB_GetInterface get_browser_interface) { | 177 PPB_GetInterface get_browser_interface) { |
178 g_get_browser_interface = get_browser_interface; | 178 g_get_browser_interface = get_browser_interface; |
179 | 179 |
180 g_core_interface = (const struct PPB_Core*) | 180 g_core_interface = (const PPB_Core*) |
181 get_browser_interface(PPB_CORE_INTERFACE); | 181 get_browser_interface(PPB_CORE_INTERFACE); |
182 g_instance_interface = (const struct PPB_Instance*) | 182 g_instance_interface = (const PPB_Instance*) |
183 get_browser_interface(PPB_INSTANCE_INTERFACE); | 183 get_browser_interface(PPB_INSTANCE_INTERFACE); |
184 g_image_data_interface = (const struct PPB_ImageData*) | 184 g_image_data_interface = (const PPB_ImageData*) |
185 get_browser_interface(PPB_IMAGEDATA_INTERFACE); | 185 get_browser_interface(PPB_IMAGEDATA_INTERFACE); |
186 g_graphics_2d_interface = (const struct PPB_Graphics2D*) | 186 g_graphics_2d_interface = (const PPB_Graphics2D*) |
187 get_browser_interface(PPB_GRAPHICS_2D_INTERFACE); | 187 get_browser_interface(PPB_GRAPHICS_2D_INTERFACE); |
188 if (!g_core_interface || !g_instance_interface || !g_image_data_interface || | 188 if (!g_core_interface || !g_instance_interface || !g_image_data_interface || |
189 !g_graphics_2d_interface) | 189 !g_graphics_2d_interface) |
190 return -1; | 190 return -1; |
191 | 191 |
192 return PP_OK; | 192 return PP_OK; |
193 } | 193 } |
194 | 194 |
195 PP_EXPORT void PPP_ShutdownModule() { | 195 PP_EXPORT void PPP_ShutdownModule() { |
196 } | 196 } |
197 | 197 |
198 PP_EXPORT const void* PPP_GetInterface(const char* interface_name) { | 198 PP_EXPORT const void* PPP_GetInterface(const char* interface_name) { |
199 if (strcmp(interface_name, PPP_INSTANCE_INTERFACE) == 0) | 199 if (strcmp(interface_name, PPP_INSTANCE_INTERFACE) == 0) |
200 return &instance_interface; | 200 return &instance_interface; |
201 return NULL; | 201 return NULL; |
202 } | 202 } |
203 | |
OLD | NEW |