Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 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 | */ |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 5 | |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 6 | /* From private/ppb_nacl_private.idl modified Tue Aug 6 11:51:26 2013. */ |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 7 | |
| 8 | #ifndef PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_ |
| 9 | #define PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_ |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 10 | |
| 11 | #include "ppapi/c/pp_bool.h" |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 12 | #include "ppapi/c/pp_completion_callback.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 13 | #include "ppapi/c/pp_instance.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 14 | #include "ppapi/c/pp_macros.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 15 | #include "ppapi/c/pp_stdint.h" |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame] | 16 | #include "ppapi/c/pp_var.h" |
Ben Murdoch | a3f7b4e | 2013-07-24 10:36:34 +0100 | [diff] [blame] | 17 | #include "ppapi/c/private/ppb_instance_private.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 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 |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 24 | * This file contains NaCl private interfaces. This interface is not versioned |
| 25 | * and is for internal Chrome use. It may change without notice. */ |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 26 | |
| 27 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 28 | #include "ppapi/c/private/pp_file_handle.h" |
Ben Murdoch | a3f7b4e | 2013-07-24 10:36:34 +0100 | [diff] [blame] | 29 | #include "ppapi/c/private/ppb_instance_private.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 30 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 31 | /** |
| 32 | * @addtogroup Enums |
| 33 | * @{ |
| 34 | */ |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 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 | */ |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 46 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 47 | /** |
| 48 | * @addtogroup Interfaces |
| 49 | * @{ |
| 50 | */ |
| 51 | /* PPB_NaCl_Private */ |
| 52 | struct PPB_NaCl_Private_1_0 { |
Ben Murdoch | 2385ea3 | 2013-08-06 11:01:04 +0100 | [diff] [blame] | 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 |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 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. |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 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). |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 64 | * The |enable_exception_handling| flag indicates whether or not the nexe |
| 65 | * will be able to use hardware exception handling. |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 66 | */ |
Ben Murdoch | a3f7b4e | 2013-07-24 10:36:34 +0100 | [diff] [blame] | 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); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 76 | /* This function starts the IPC proxy so the nexe can communicate with the |
Ben Murdoch | 2385ea3 | 2013-08-06 11:01:04 +0100 | [diff] [blame] | 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. |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 83 | */ |
Ben Murdoch | a3f7b4e | 2013-07-24 10:36:34 +0100 | [diff] [blame] | 84 | PP_ExternalPluginResult (*StartPpapiProxy)(PP_Instance instance); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 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); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 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); |
Ben Murdoch | 2385ea3 | 2013-08-06 11:01:04 +0100 | [diff] [blame] | 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); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 112 | /* Returns a read-only file descriptor of a file rooted in the Pnacl |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 113 | * component directory, or an invalid handle on failure. |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 114 | */ |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 115 | PP_FileHandle (*GetReadonlyPnaclFd)(const char* filename); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 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 | */ |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 120 | PP_FileHandle (*CreateTemporaryFile)(PP_Instance instance); |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 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 |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 123 | * with the cache information given by |pexe_url|, |abi_version|, |opt_level|, |
| 124 | * |last_modified|, and |etag|. If the nexe is already present |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 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, |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 135 | const char* pexe_url, |
| 136 | uint32_t abi_version, |
| 137 | uint32_t opt_level, |
| 138 | const char* last_modified, |
| 139 | const char* etag, |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 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| |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 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.) |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 151 | */ |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 152 | void (*ReportTranslationFinished)(PP_Instance instance, PP_Bool success); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 153 | /* Return true if we are off the record. |
| 154 | */ |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 155 | PP_Bool (*IsOffTheRecord)(void); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 156 | /* Return true if PNaCl is turned on. |
| 157 | */ |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 158 | PP_Bool (*IsPnaclEnabled)(void); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 159 | /* Display a UI message to the user. */ |
Ben Murdoch | a3f7b4e | 2013-07-24 10:36:34 +0100 | [diff] [blame] | 160 | PP_ExternalPluginResult (*ReportNaClError)(PP_Instance instance, |
| 161 | PP_NaClError message_id); |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 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 | */ |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 166 | PP_FileHandle (*OpenNaClExecutable)(PP_Instance instance, |
| 167 | const char* file_url, |
| 168 | uint64_t* file_token_lo, |
| 169 | uint64_t* file_token_hi); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 170 | }; |
| 171 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 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 | |