blob: 8be28293386a928db07279a716b00108a8b41e59 [file] [log] [blame]
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +00001/* 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)58218062012-11-14 11:43:16 +00005
Ben Murdochbb1529c2013-08-08 10:24:53 +01006/* From private/ppb_nacl_private.idl modified Tue Aug 6 11:51:26 2013. */
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +00007
8#ifndef PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_
9#define PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_
Torne (Richard Coles)58218062012-11-14 11:43:16 +000010
11#include "ppapi/c/pp_bool.h"
Ben Murdocheb525c52013-07-10 11:40:50 +010012#include "ppapi/c/pp_completion_callback.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +000013#include "ppapi/c/pp_instance.h"
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000014#include "ppapi/c/pp_macros.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +000015#include "ppapi/c/pp_stdint.h"
Ben Murdochca12bfa2013-07-23 11:17:05 +010016#include "ppapi/c/pp_var.h"
Ben Murdocha3f7b4e2013-07-24 10:36:34 +010017#include "ppapi/c/private/ppb_instance_private.h"
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000018
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)c2e0dbd2013-05-09 18:35:53 +010024 * 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)2a99a7e2013-03-28 15:31:22 +000026
27
Torne (Richard Coles)58218062012-11-14 11:43:16 +000028#include "ppapi/c/private/pp_file_handle.h"
Ben Murdocha3f7b4e2013-07-24 10:36:34 +010029#include "ppapi/c/private/ppb_instance_private.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +000030
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000031/**
32 * @addtogroup Enums
33 * @{
34 */
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000035/** NaCl-specific errors that should be reported to the user */
36typedef 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)58218062012-11-14 11:43:16 +000046
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000047/**
48 * @addtogroup Interfaces
49 * @{
50 */
51/* PPB_NaCl_Private */
52struct PPB_NaCl_Private_1_0 {
Ben Murdoch2385ea32013-08-06 11:01:04 +010053 /* 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)2a99a7e2013-03-28 15:31:22 +000056 * 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)c2e0dbd2013-05-09 18:35:53 +010062 * 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)7d4cd472013-06-19 11:58:07 +010064 * The |enable_exception_handling| flag indicates whether or not the nexe
65 * will be able to use hardware exception handling.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000066 */
Ben Murdocha3f7b4e2013-07-24 10:36:34 +010067 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)2a99a7e2013-03-28 15:31:22 +000076 /* This function starts the IPC proxy so the nexe can communicate with the
Ben Murdoch2385ea32013-08-06 11:01:04 +010077 * 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)2a99a7e2013-03-28 15:31:22 +000083 */
Ben Murdocha3f7b4e2013-07-24 10:36:34 +010084 PP_ExternalPluginResult (*StartPpapiProxy)(PP_Instance instance);
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000085 /* 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)2a99a7e2013-03-28 15:31:22 +000094 /* 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 Murdoch2385ea32013-08-06 11:01:04 +0100105 /* 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)2a99a7e2013-03-28 15:31:22 +0000112 /* Returns a read-only file descriptor of a file rooted in the Pnacl
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100113 * component directory, or an invalid handle on failure.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000114 */
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000115 PP_FileHandle (*GetReadonlyPnaclFd)(const char* filename);
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000116 /* 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)58218062012-11-14 11:43:16 +0000120 PP_FileHandle (*CreateTemporaryFile)(PP_Instance instance);
Ben Murdocheb525c52013-07-10 11:40:50 +0100121 /* 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 Murdoch7dbb3d52013-07-17 14:55:54 +0100123 * with the cache information given by |pexe_url|, |abi_version|, |opt_level|,
124 * |last_modified|, and |etag|. If the nexe is already present
Ben Murdocheb525c52013-07-10 11:40:50 +0100125 * 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 Murdoch7dbb3d52013-07-17 14:55:54 +0100135 const char* pexe_url,
136 uint32_t abi_version,
137 uint32_t opt_level,
138 const char* last_modified,
139 const char* etag,
Ben Murdocheb525c52013-07-10 11:40:50 +0100140 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 Murdochbb1529c2013-08-08 10:24:53 +0100144 * 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 Murdocheb525c52013-07-10 11:40:50 +0100151 */
Ben Murdochbb1529c2013-08-08 10:24:53 +0100152 void (*ReportTranslationFinished)(PP_Instance instance, PP_Bool success);
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000153 /* Return true if we are off the record.
154 */
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000155 PP_Bool (*IsOffTheRecord)(void);
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000156 /* Return true if PNaCl is turned on.
157 */
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000158 PP_Bool (*IsPnaclEnabled)(void);
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000159 /* Display a UI message to the user. */
Ben Murdocha3f7b4e2013-07-24 10:36:34 +0100160 PP_ExternalPluginResult (*ReportNaClError)(PP_Instance instance,
161 PP_NaClError message_id);
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100162 /* 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)90dce4d2013-05-29 14:40:03 +0100166 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)58218062012-11-14 11:43:16 +0000170};
171
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000172typedef struct PPB_NaCl_Private_1_0 PPB_NaCl_Private;
173/**
174 * @}
175 */
176
177#endif /* PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_ */
178