Home | History | Annotate | Download | only in ppapi_test_lib
      1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "native_client/src/shared/platform/nacl_check.h"
      6 
      7 #include "ppapi/c/dev/ppb_font_dev.h"
      8 #include "ppapi/c/dev/ppb_memory_dev.h"
      9 #include "ppapi/c/dev/ppb_var_deprecated.h"
     10 #include "ppapi/c/ppb_audio.h"
     11 #include "ppapi/c/ppb_audio_config.h"
     12 #include "ppapi/c/ppb_core.h"
     13 #include "ppapi/c/ppb_file_io.h"
     14 #include "ppapi/c/ppb_file_ref.h"
     15 #include "ppapi/c/ppb_file_system.h"
     16 #include "ppapi/c/ppb_fullscreen.h"
     17 #include "ppapi/c/ppb_graphics_2d.h"
     18 #include "ppapi/c/ppb_graphics_3d.h"
     19 #include "ppapi/c/ppb_image_data.h"
     20 #include "ppapi/c/ppb_input_event.h"
     21 #include "ppapi/c/ppb_instance.h"
     22 #include "ppapi/c/ppb_messaging.h"
     23 #include "ppapi/c/ppb_mouse_cursor.h"
     24 #include "ppapi/c/ppb_opengles2.h"
     25 #include "ppapi/c/ppb_url_loader.h"
     26 #include "ppapi/c/ppb_url_request_info.h"
     27 #include "ppapi/c/ppb_url_response_info.h"
     28 #include "ppapi/c/ppb_var.h"
     29 #include "ppapi/c/ppb_view.h"
     30 #include "ppapi/c/private/ppb_testing_private.h"
     31 
     32 #include "ppapi/native_client/tests/ppapi_test_lib/get_browser_interface.h"
     33 #include "ppapi/native_client/tests/ppapi_test_lib/internal_utils.h"
     34 
     35 // Use for dev interfaces that might not be present.
     36 const void* GetBrowserInterface(const char* interface_name) {
     37   return (*ppb_get_interface())(interface_name);
     38 }
     39 
     40 // Use for stable interfaces that must always be present.
     41 const void* GetBrowserInterfaceSafe(const char* interface_name) {
     42   const void* ppb_interface = (*ppb_get_interface())(interface_name);
     43   CHECK(ppb_interface != NULL);
     44   return ppb_interface;
     45 }
     46 
     47 // Stable interfaces.
     48 
     49 const PPB_Audio* PPBAudio() {
     50   return reinterpret_cast<const PPB_Audio*>(
     51       GetBrowserInterfaceSafe(PPB_AUDIO_INTERFACE));
     52 }
     53 
     54 const PPB_AudioConfig* PPBAudioConfig() {
     55   return reinterpret_cast<const PPB_AudioConfig*>(
     56       GetBrowserInterfaceSafe(PPB_AUDIO_CONFIG_INTERFACE));
     57 }
     58 
     59 const PPB_Core* PPBCore() {
     60   return reinterpret_cast<const PPB_Core*>(
     61       GetBrowserInterfaceSafe(PPB_CORE_INTERFACE));
     62 }
     63 
     64 const PPB_FileIO* PPBFileIO() {
     65   return reinterpret_cast<const PPB_FileIO*>(
     66       GetBrowserInterfaceSafe(PPB_FILEIO_INTERFACE));
     67 }
     68 
     69 const PPB_FileRef* PPBFileRef() {
     70   return reinterpret_cast<const PPB_FileRef*>(
     71       GetBrowserInterfaceSafe(PPB_FILEREF_INTERFACE));
     72 }
     73 
     74 const PPB_FileSystem* PPBFileSystem() {
     75   return reinterpret_cast<const PPB_FileSystem*>(
     76       GetBrowserInterfaceSafe(PPB_FILESYSTEM_INTERFACE));
     77 }
     78 
     79 const PPB_Fullscreen* PPBFullscreen() {
     80   return reinterpret_cast<const PPB_Fullscreen*>(
     81       GetBrowserInterfaceSafe(PPB_FULLSCREEN_INTERFACE));
     82 }
     83 
     84 const PPB_Graphics2D* PPBGraphics2D() {
     85   return reinterpret_cast<const PPB_Graphics2D*>(
     86       GetBrowserInterfaceSafe(PPB_GRAPHICS_2D_INTERFACE));
     87 }
     88 
     89 const PPB_Graphics3D* PPBGraphics3D() {
     90   return reinterpret_cast<const PPB_Graphics3D*>(
     91       GetBrowserInterfaceSafe(PPB_GRAPHICS_3D_INTERFACE));
     92 }
     93 
     94 const PPB_ImageData* PPBImageData() {
     95   return reinterpret_cast<const PPB_ImageData*>(
     96       GetBrowserInterfaceSafe(PPB_IMAGEDATA_INTERFACE));
     97 }
     98 
     99 const PPB_InputEvent* PPBInputEvent() {
    100   return reinterpret_cast<const PPB_InputEvent*>(
    101       GetBrowserInterfaceSafe(PPB_INPUT_EVENT_INTERFACE));
    102 }
    103 
    104 const PPB_Instance* PPBInstance() {
    105   return reinterpret_cast<const PPB_Instance*>(
    106       GetBrowserInterfaceSafe(PPB_INSTANCE_INTERFACE));
    107 }
    108 
    109 const PPB_KeyboardInputEvent* PPBKeyboardInputEvent() {
    110   return reinterpret_cast<const PPB_KeyboardInputEvent*>(
    111       GetBrowserInterfaceSafe(PPB_KEYBOARD_INPUT_EVENT_INTERFACE));
    112 }
    113 
    114 const PPB_Messaging* PPBMessaging() {
    115   return reinterpret_cast<const PPB_Messaging*>(
    116       GetBrowserInterfaceSafe(PPB_MESSAGING_INTERFACE));
    117 }
    118 
    119 const PPB_MouseCursor_1_0* PPBMouseCursor() {
    120   return reinterpret_cast<const PPB_MouseCursor_1_0*>(
    121       GetBrowserInterfaceSafe(PPB_MOUSECURSOR_INTERFACE_1_0));
    122 }
    123 
    124 const PPB_MouseInputEvent* PPBMouseInputEvent() {
    125   return reinterpret_cast<const PPB_MouseInputEvent*>(
    126       GetBrowserInterfaceSafe(PPB_MOUSE_INPUT_EVENT_INTERFACE));
    127 }
    128 
    129 const PPB_OpenGLES2* PPBOpenGLES2() {
    130   return reinterpret_cast<const PPB_OpenGLES2*>(
    131       GetBrowserInterfaceSafe(PPB_OPENGLES2_INTERFACE));
    132 }
    133 
    134 const PPB_URLLoader* PPBURLLoader() {
    135   return reinterpret_cast<const PPB_URLLoader*>(
    136       GetBrowserInterfaceSafe(PPB_URLLOADER_INTERFACE));
    137 }
    138 
    139 const PPB_URLRequestInfo* PPBURLRequestInfo() {
    140   return reinterpret_cast<const PPB_URLRequestInfo*>(
    141       GetBrowserInterfaceSafe(PPB_URLREQUESTINFO_INTERFACE));
    142 }
    143 
    144 const PPB_URLResponseInfo* PPBURLResponseInfo() {
    145   return reinterpret_cast<const PPB_URLResponseInfo*>(
    146       GetBrowserInterfaceSafe(PPB_URLRESPONSEINFO_INTERFACE));
    147 }
    148 
    149 const PPB_Var* PPBVar() {
    150   return reinterpret_cast<const PPB_Var*>(
    151       GetBrowserInterfaceSafe(PPB_VAR_INTERFACE));
    152 }
    153 
    154 const PPB_WheelInputEvent* PPBWheelInputEvent() {
    155   return reinterpret_cast<const PPB_WheelInputEvent*>(
    156       GetBrowserInterfaceSafe(PPB_WHEEL_INPUT_EVENT_INTERFACE));
    157 }
    158 
    159 
    160 // Dev interfaces.
    161 
    162 const PPB_Font_Dev* PPBFontDev() {
    163   return reinterpret_cast<const PPB_Font_Dev*>(
    164       // Change to GetBrowserInterfaceSafe when moving out of dev.
    165       GetBrowserInterface(PPB_FONT_DEV_INTERFACE));
    166 }
    167 
    168 const PPB_Memory_Dev* PPBMemoryDev() {
    169   return reinterpret_cast<const PPB_Memory_Dev*>(
    170       // Change to GetBrowserInterfaceSafe when moving out of dev.
    171       GetBrowserInterface(PPB_MEMORY_DEV_INTERFACE));
    172 }
    173 
    174 const PPB_Testing_Private* PPBTestingPrivate() {
    175   return reinterpret_cast<const PPB_Testing_Private*>(
    176       GetBrowserInterface(PPB_TESTING_PRIVATE_INTERFACE));
    177 }
    178 
    179 const PPB_View* PPBView() {
    180   return reinterpret_cast<const PPB_View*>(
    181       GetBrowserInterface(PPB_VIEW_INTERFACE));
    182 }
    183