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