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 6 /* From private/ppb_nacl_private.idl modified Tue Aug 6 11:51:26 2013. */ 7 8 #ifndef PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_ 9 #define PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_ 10 11 #include "ppapi/c/pp_bool.h" 12 #include "ppapi/c/pp_completion_callback.h" 13 #include "ppapi/c/pp_instance.h" 14 #include "ppapi/c/pp_macros.h" 15 #include "ppapi/c/pp_stdint.h" 16 #include "ppapi/c/pp_var.h" 17 #include "ppapi/c/private/ppb_instance_private.h" 18 19 #define PPB_NACL_PRIVATE_INTERFACE_1_0 "PPB_NaCl_Private;1.0" 20 #define PPB_NACL_PRIVATE_INTERFACE PPB_NACL_PRIVATE_INTERFACE_1_0 21 22 /** 23 * @file 24 * This file contains NaCl private interfaces. This interface is not versioned 25 * and is for internal Chrome use. It may change without notice. */ 26 27 28 #include "ppapi/c/private/pp_file_handle.h" 29 #include "ppapi/c/private/ppb_instance_private.h" 30 31 /** 32 * @addtogroup Enums 33 * @{ 34 */ 35 /** NaCl-specific errors that should be reported to the user */ 36 typedef enum { 37 /** 38 * The manifest program element does not contain a program usable on the 39 * user's architecture 40 */ 41 PP_NACL_MANIFEST_MISSING_ARCH = 0 42 } PP_NaClError; 43 /** 44 * @} 45 */ 46 47 /** 48 * @addtogroup Interfaces 49 * @{ 50 */ 51 /* PPB_NaCl_Private */ 52 struct PPB_NaCl_Private_1_0 { 53 /* Launches NaCl's sel_ldr process. Returns PP_EXTERNAL_PLUGIN_OK on success 54 * and writes a NaClHandle to imc_handle. Returns PP_EXTERNAL_PLUGIN_FAILED on 55 * failure. The |enable_ppapi_dev| parameter controls whether GetInterface 56 * returns 'Dev' interfaces to the NaCl plugin. The |uses_ppapi| flag 57 * indicates that the nexe run by sel_ldr will use the PPAPI APIs. 58 * This implies that LaunchSelLdr is run from the main thread. If a nexe 59 * does not need PPAPI, then it can run off the main thread. 60 * The |uses_irt| flag indicates whether the IRT should be loaded in this 61 * NaCl process. This is true for ABI stable nexes. 62 * The |enable_dyncode_syscalls| flag indicates whether or not the nexe 63 * will be able to use dynamic code system calls (e.g., mmap with PROT_EXEC). 64 * The |enable_exception_handling| flag indicates whether or not the nexe 65 * will be able to use hardware exception handling. 66 */ 67 PP_ExternalPluginResult (*LaunchSelLdr)(PP_Instance instance, 68 const char* alleged_url, 69 PP_Bool uses_irt, 70 PP_Bool uses_ppapi, 71 PP_Bool enable_ppapi_dev, 72 PP_Bool enable_dyncode_syscalls, 73 PP_Bool enable_exception_handling, 74 void* imc_handle, 75 struct PP_Var* error_message); 76 /* This function starts the IPC proxy so the nexe can communicate with the 77 * browser. Returns PP_EXTERNAL_PLUGIN_OK on success, otherwise a result code 78 * indicating the failure. PP_EXTERNAL_PLUGIN_FAILED is returned if 79 * LaunchSelLdr wasn't called with the instance. 80 * PP_EXTERNAL_PLUGIN_ERROR_MODULE is returned if the module can't be 81 * initialized. PP_EXTERNAL_PLUGIN_ERROR_INSTANCE is returned if the instance 82 * can't be initialized. 83 */ 84 PP_ExternalPluginResult (*StartPpapiProxy)(PP_Instance instance); 85 /* On POSIX systems, this function returns the file descriptor of 86 * /dev/urandom. On non-POSIX systems, this function returns 0. 87 */ 88 int32_t (*UrandomFD)(void); 89 /* Whether the Pepper 3D interfaces should be disabled in the NaCl PPAPI 90 * proxy. This is so paranoid admins can effectively prevent untrusted shader 91 * code to be processed by the graphics stack. 92 */ 93 PP_Bool (*Are3DInterfacesDisabled)(void); 94 /* This is Windows-specific. This is a replacement for DuplicateHandle() for 95 * use inside the Windows sandbox. Note that we provide this via dependency 96 * injection only to avoid the linkage problems that occur because the NaCl 97 * plugin is built as a separate DLL/DSO 98 * (see http://code.google.com/p/chromium/issues/detail?id=114439#c8). 99 */ 100 int32_t (*BrokerDuplicateHandle)(PP_FileHandle source_handle, 101 uint32_t process_id, 102 PP_FileHandle* target_handle, 103 uint32_t desired_access, 104 uint32_t options); 105 /* Check if PNaCl is installed and attempt to install if necessary. 106 * Callback is called when the check is done and PNaCl is already installed, 107 * or after an on-demand install is attempted. Called back with PP_OK if 108 * PNaCl is available. Called back with an error otherwise. 109 */ 110 int32_t (*EnsurePnaclInstalled)(PP_Instance instance, 111 struct PP_CompletionCallback callback); 112 /* Returns a read-only file descriptor of a file rooted in the Pnacl 113 * component directory, or an invalid handle on failure. 114 */ 115 PP_FileHandle (*GetReadonlyPnaclFd)(const char* filename); 116 /* This creates a temporary file that will be deleted by the time 117 * the last handle is closed (or earlier on POSIX systems), and 118 * returns a posix handle to that temporary file. 119 */ 120 PP_FileHandle (*CreateTemporaryFile)(PP_Instance instance); 121 /* Create a temporary file, which will be deleted by the time the last 122 * handle is closed (or earlier on POSIX systems), to use for the nexe 123 * with the cache information given by |pexe_url|, |abi_version|, |opt_level|, 124 * |last_modified|, and |etag|. If the nexe is already present 125 * in the cache, |is_hit| is set to PP_TRUE and the contents of the nexe 126 * will be copied into the temporary file. Otherwise |is_hit| is set to 127 * PP_FALSE and the temporary file will be writeable. 128 * Currently the implementation is a stub, which always sets is_hit to false 129 * and calls the implementation of CreateTemporaryFile. In a subsequent CL 130 * it will call into the browser which will remember the association between 131 * the cache key and the fd, and copy the nexe into the cache after the 132 * translation finishes. 133 */ 134 int32_t (*GetNexeFd)(PP_Instance instance, 135 const char* pexe_url, 136 uint32_t abi_version, 137 uint32_t opt_level, 138 const char* last_modified, 139 const char* etag, 140 PP_Bool* is_hit, 141 PP_FileHandle* nexe_handle, 142 struct PP_CompletionCallback callback); 143 /* Report to the browser that translation of the pexe for |instance| 144 * has finished, or aborted with an error. If |success| is true, the 145 * browser may then store the translation in the cache. The renderer 146 * must first have called GetNexeFd for the same instance. (The browser is 147 * not guaranteed to store the nexe even if |success| is true; if there is 148 * an error on the browser side, or the file is too big for the cache, or 149 * the browser is in incognito mode, no notification will be delivered to 150 * the plugin.) 151 */ 152 void (*ReportTranslationFinished)(PP_Instance instance, PP_Bool success); 153 /* Return true if we are off the record. 154 */ 155 PP_Bool (*IsOffTheRecord)(void); 156 /* Return true if PNaCl is turned on. 157 */ 158 PP_Bool (*IsPnaclEnabled)(void); 159 /* Display a UI message to the user. */ 160 PP_ExternalPluginResult (*ReportNaClError)(PP_Instance instance, 161 PP_NaClError message_id); 162 /* Opens a NaCl executable file in the application's extension directory 163 * corresponding to the file URL and returns a file descriptor, or an invalid 164 * handle on failure. |metadata| is left unchanged on failure. 165 */ 166 PP_FileHandle (*OpenNaClExecutable)(PP_Instance instance, 167 const char* file_url, 168 uint64_t* file_token_lo, 169 uint64_t* file_token_hi); 170 }; 171 172 typedef struct PPB_NaCl_Private_1_0 PPB_NaCl_Private; 173 /** 174 * @} 175 */ 176 177 #endif /* PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_ */ 178 179