Fix infinite recursion on hiding panel when created during fullscreen mode.
[chromium-blink-merge.git] / ppapi / c / private / ppb_nacl_private.h
blobdd0a04f78978bdb7ca0cb92be96591044806a38b
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 */
6 /* From private/ppb_nacl_private.idl modified Thu Mar 27 10:43:40 2014. */
8 #ifndef PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_
9 #define PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_
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"
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
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. */
28 #include "ppapi/c/private/pp_file_handle.h"
29 #include "ppapi/c/private/ppb_instance_private.h"
31 /**
32 * @addtogroup Enums
33 * @{
35 /** NaCl-specific errors that should be reported to the user.
36 * These error codes are reported via UMA so, if you edit them:
37 * 1) make sure you understand UMA first.
38 * 2) update src/tools/metrics/histograms/histograms.xml
39 * Values are explicitly specified to make sure they don't shift around when
40 * edited, and also to make reading about:histograms easier.
42 typedef enum {
43 PP_NACL_ERROR_LOAD_SUCCESS = 0,
44 PP_NACL_ERROR_LOAD_ABORTED = 1,
45 PP_NACL_ERROR_UNKNOWN = 2,
46 PP_NACL_ERROR_MANIFEST_RESOLVE_URL = 3,
47 PP_NACL_ERROR_MANIFEST_LOAD_URL = 4,
48 PP_NACL_ERROR_MANIFEST_STAT = 5,
49 PP_NACL_ERROR_MANIFEST_TOO_LARGE = 6,
50 PP_NACL_ERROR_MANIFEST_OPEN = 7,
51 PP_NACL_ERROR_MANIFEST_MEMORY_ALLOC = 8,
52 PP_NACL_ERROR_MANIFEST_READ = 9,
53 PP_NACL_ERROR_MANIFEST_PARSING = 10,
54 PP_NACL_ERROR_MANIFEST_SCHEMA_VALIDATE = 11,
55 PP_NACL_ERROR_MANIFEST_GET_NEXE_URL = 12,
56 PP_NACL_ERROR_NEXE_LOAD_URL = 13,
57 PP_NACL_ERROR_NEXE_ORIGIN_PROTOCOL = 14,
58 PP_NACL_ERROR_NEXE_FH_DUP = 15,
59 PP_NACL_ERROR_NEXE_STAT = 16,
60 PP_NACL_ERROR_ELF_CHECK_IO = 17,
61 PP_NACL_ERROR_ELF_CHECK_FAIL = 18,
62 PP_NACL_ERROR_SEL_LDR_INIT = 19,
63 PP_NACL_ERROR_SEL_LDR_CREATE_LAUNCHER = 20,
64 PP_NACL_ERROR_SEL_LDR_FD = 21,
65 PP_NACL_ERROR_SEL_LDR_LAUNCH = 22,
66 /* Deprecated, safe to reuse the value because it's never logged in UMA.
68 PP_NACL_ERROR_SEL_LDR_SEND_NEXE = 24,
69 PP_NACL_ERROR_SEL_LDR_HANDLE_PASSING = 25,
70 PP_NACL_ERROR_SEL_LDR_START_MODULE = 26,
71 PP_NACL_ERROR_SEL_LDR_START_STATUS = 27,
72 PP_NACL_ERROR_SRPC_CONNECTION_FAIL = 28,
73 PP_NACL_ERROR_START_PROXY_CHECK_PPP = 29,
74 PP_NACL_ERROR_START_PROXY_ALLOC = 30,
75 PP_NACL_ERROR_START_PROXY_MODULE = 31,
76 PP_NACL_ERROR_START_PROXY_INSTANCE = 32,
77 PP_NACL_ERROR_SEL_LDR_COMMUNICATION_CMD_CHANNEL = 33,
78 PP_NACL_ERROR_SEL_LDR_COMMUNICATION_REV_SETUP = 34,
79 PP_NACL_ERROR_SEL_LDR_COMMUNICATION_WRAPPER = 35,
80 PP_NACL_ERROR_SEL_LDR_COMMUNICATION_REV_SERVICE = 36,
81 PP_NACL_ERROR_START_PROXY_CRASH = 37,
82 PP_NACL_ERROR_MANIFEST_PROGRAM_MISSING_ARCH = 38,
83 PP_NACL_ERROR_PNACL_CACHE_OPEN_INPROGRESS = 39,
84 PP_NACL_ERROR_PNACL_CACHE_OPEN_NOACCESS = 40,
85 PP_NACL_ERROR_PNACL_CACHE_OPEN_NOQUOTA = 41,
86 PP_NACL_ERROR_PNACL_CACHE_OPEN_NOSPACE = 42,
87 PP_NACL_ERROR_PNACL_CACHE_OPEN_OTHER = 43,
88 PP_NACL_ERROR_PNACL_CACHE_DIRECTORY_CREATE = 44,
89 PP_NACL_ERROR_PNACL_CACHE_FILEOPEN_NOACCESS = 45,
90 PP_NACL_ERROR_PNACL_CACHE_FILEOPEN_NOQUOTA = 46,
91 PP_NACL_ERROR_PNACL_CACHE_FILEOPEN_NOSPACE = 47,
92 PP_NACL_ERROR_PNACL_CACHE_FILEOPEN_NOTAFILE = 48,
93 PP_NACL_ERROR_PNACL_CACHE_FILEOPEN_OTHER = 49,
94 PP_NACL_ERROR_PNACL_CACHE_FETCH_NOACCESS = 50,
95 PP_NACL_ERROR_PNACL_CACHE_FETCH_NOTFOUND = 51,
96 PP_NACL_ERROR_PNACL_CACHE_FETCH_OTHER = 52,
97 PP_NACL_ERROR_PNACL_CACHE_FINALIZE_COPY_NOQUOTA = 53,
98 PP_NACL_ERROR_PNACL_CACHE_FINALIZE_COPY_NOSPACE = 54,
99 PP_NACL_ERROR_PNACL_CACHE_FINALIZE_COPY_OTHER = 55,
100 PP_NACL_ERROR_PNACL_CACHE_FINALIZE_RENAME_NOACCESS = 56,
101 PP_NACL_ERROR_PNACL_CACHE_FINALIZE_RENAME_OTHER = 57,
102 PP_NACL_ERROR_PNACL_RESOURCE_FETCH = 58,
103 PP_NACL_ERROR_PNACL_PEXE_FETCH_ABORTED = 59,
104 PP_NACL_ERROR_PNACL_PEXE_FETCH_NOACCESS = 60,
105 PP_NACL_ERROR_PNACL_PEXE_FETCH_OTHER = 61,
106 PP_NACL_ERROR_PNACL_THREAD_CREATE = 62,
107 PP_NACL_ERROR_PNACL_LLC_SETUP = 63,
108 PP_NACL_ERROR_PNACL_LD_SETUP = 64,
109 PP_NACL_ERROR_PNACL_LLC_INTERNAL = 65,
110 PP_NACL_ERROR_PNACL_LD_INTERNAL = 66,
111 PP_NACL_ERROR_PNACL_CREATE_TEMP = 67,
112 /* This entry is no longer used, but should not be removed, because UMA
114 PP_NACL_ERROR_PNACL_NOT_ENABLED = 68,
115 PP_NACL_ERROR_MANIFEST_NOACCESS_URL = 69,
116 PP_NACL_ERROR_NEXE_NOACCESS_URL = 70,
117 PP_NACL_ERROR_PNACL_CRASH_THROTTLED = 71,
118 /* If you add a code, read the enum comment above on how to update
120 PP_NACL_ERROR_MAX
121 } PP_NaClError;
123 /** Event types that NaCl may use when reporting load progress or errors. */
124 typedef enum {
125 PP_NACL_EVENT_LOADSTART,
126 PP_NACL_EVENT_PROGRESS,
127 PP_NACL_EVENT_ERROR,
128 PP_NACL_EVENT_ABORT,
129 PP_NACL_EVENT_LOAD,
130 PP_NACL_EVENT_LOADEND,
131 PP_NACL_EVENT_CRASH
132 } PP_NaClEventType;
134 typedef enum {
135 PP_SCHEME_CHROME_EXTENSION,
136 PP_SCHEME_DATA,
137 PP_SCHEME_OTHER
138 } PP_UrlSchemeType;
140 typedef enum {
141 /* The trusted plugin begins in this ready state. */
142 PP_NACL_READY_STATE_UNSENT = 0,
143 /* The manifest file has been requested, but not yet received. */
144 PP_NACL_READY_STATE_OPENED = 1,
145 /* The manifest file has been received and the nexe successfully requested. */
146 PP_NACL_READY_STATE_LOADING = 3,
147 /* The nexe has been loaded and the proxy started, so it is ready for
149 PP_NACL_READY_STATE_DONE = 4
150 } PP_NaClReadyState;
152 * @}
156 * @addtogroup Interfaces
157 * @{
159 /* PPB_NaCl_Private */
160 struct PPB_NaCl_Private_1_0 {
161 /* Launches NaCl's sel_ldr process. Returns PP_EXTERNAL_PLUGIN_OK on success
162 * and writes a NaClHandle to imc_handle. Returns PP_EXTERNAL_PLUGIN_FAILED on
163 * failure. The |enable_ppapi_dev| parameter controls whether GetInterface
164 * returns 'Dev' interfaces to the NaCl plugin. The |uses_ppapi| flag
165 * indicates that the nexe run by sel_ldr will use the PPAPI APIs.
166 * This implies that LaunchSelLdr is run from the main thread. If a nexe
167 * does not need PPAPI, then it can run off the main thread.
168 * The |uses_irt| flag indicates whether the IRT should be loaded in this
169 * NaCl process. This is true for ABI stable nexes.
170 * The |uses_nonsfi_mode| flag indicates whether or not nonsfi-mode should
171 * be used with the binary pointed by the url.
172 * The |enable_dyncode_syscalls| flag indicates whether or not the nexe
173 * will be able to use dynamic code system calls (e.g., mmap with PROT_EXEC).
174 * The |enable_exception_handling| flag indicates whether or not the nexe
175 * will be able to use hardware exception handling.
176 * The |enable_crash_throttling| flag indicates whether or not crashes of
177 * the nexe contribute to crash throttling statisics and whether nexe starts
178 * are throttled by crash throttling.
180 void (*LaunchSelLdr)(PP_Instance instance,
181 const char* alleged_url,
182 PP_Bool uses_irt,
183 PP_Bool uses_ppapi,
184 PP_Bool uses_nonsfi_mode,
185 PP_Bool enable_ppapi_dev,
186 PP_Bool enable_dyncode_syscalls,
187 PP_Bool enable_exception_handling,
188 PP_Bool enable_crash_throttling,
189 void* imc_handle,
190 struct PP_Var* error_message,
191 struct PP_CompletionCallback callback);
192 /* This function starts the IPC proxy so the nexe can communicate with the
193 * browser. Returns PP_EXTERNAL_PLUGIN_OK on success, otherwise a result code
194 * indicating the failure. PP_EXTERNAL_PLUGIN_FAILED is returned if
195 * LaunchSelLdr wasn't called with the instance.
196 * PP_EXTERNAL_PLUGIN_ERROR_MODULE is returned if the module can't be
197 * initialized. PP_EXTERNAL_PLUGIN_ERROR_INSTANCE is returned if the instance
198 * can't be initialized.
200 PP_ExternalPluginResult (*StartPpapiProxy)(PP_Instance instance);
201 /* On POSIX systems, this function returns the file descriptor of
202 * /dev/urandom. On non-POSIX systems, this function returns 0.
204 int32_t (*UrandomFD)(void);
205 /* Whether the Pepper 3D interfaces should be disabled in the NaCl PPAPI
206 * proxy. This is so paranoid admins can effectively prevent untrusted shader
207 * code to be processed by the graphics stack.
209 PP_Bool (*Are3DInterfacesDisabled)(void);
210 /* This is Windows-specific. This is a replacement for DuplicateHandle() for
211 * use inside the Windows sandbox. Note that we provide this via dependency
212 * injection only to avoid the linkage problems that occur because the NaCl
213 * plugin is built as a separate DLL/DSO
214 * (see http://code.google.com/p/chromium/issues/detail?id=114439#c8).
216 int32_t (*BrokerDuplicateHandle)(PP_FileHandle source_handle,
217 uint32_t process_id,
218 PP_FileHandle* target_handle,
219 uint32_t desired_access,
220 uint32_t options);
221 /* Returns a read-only file descriptor of a file rooted in the Pnacl
222 * component directory, or an invalid handle on failure.
224 PP_FileHandle (*GetReadonlyPnaclFd)(const char* filename);
225 /* This creates a temporary file that will be deleted by the time
226 * the last handle is closed (or earlier on POSIX systems), and
227 * returns a posix handle to that temporary file.
229 PP_FileHandle (*CreateTemporaryFile)(PP_Instance instance);
230 /* Return the number of processors in the system as reported by the OS */
231 int32_t (*GetNumberOfProcessors)(void);
232 /* Return whether the non-SFI mode is enabled. */
233 PP_Bool (*IsNonSFIModeEnabled)(void);
234 /* Create a temporary file, which will be deleted by the time the
235 * last handle is closed (or earlier on POSIX systems), to use for
236 * the nexe with the cache information given by |pexe_url|,
237 * |abi_version|, |opt_level|, |last_modified|, |etag|, and
238 * |has_no_store_header|. If the nexe is already present in the
239 * cache, |is_hit| is set to PP_TRUE and the contents of the nexe
240 * will be copied into the temporary file. Otherwise |is_hit| is set
241 * to PP_FALSE and the temporary file will be writeable. Currently
242 * the implementation is a stub, which always sets is_hit to false
243 * and calls the implementation of CreateTemporaryFile. In a
244 * subsequent CL it will call into the browser which will remember
245 * the association between the cache key and the fd, and copy the
246 * nexe into the cache after the translation finishes.
248 int32_t (*GetNexeFd)(PP_Instance instance,
249 const char* pexe_url,
250 uint32_t abi_version,
251 uint32_t opt_level,
252 const char* last_modified,
253 const char* etag,
254 PP_Bool has_no_store_header,
255 const char* sandbox_isa,
256 const char* extra_flags,
257 PP_Bool* is_hit,
258 PP_FileHandle* nexe_handle,
259 struct PP_CompletionCallback callback);
260 /* Report to the browser that translation of the pexe for |instance|
261 * has finished, or aborted with an error. If |success| is true, the
262 * browser may then store the translation in the cache. The renderer
263 * must first have called GetNexeFd for the same instance. (The browser is
264 * not guaranteed to store the nexe even if |success| is true; if there is
265 * an error on the browser side, or the file is too big for the cache, or
266 * the browser is in incognito mode, no notification will be delivered to
267 * the plugin.)
269 void (*ReportTranslationFinished)(PP_Instance instance, PP_Bool success);
270 /* Opens a NaCl executable file in the application's extension directory
271 * corresponding to the file URL and returns a file descriptor, or an invalid
272 * handle on failure. |metadata| is left unchanged on failure.
274 PP_FileHandle (*OpenNaClExecutable)(PP_Instance instance,
275 const char* file_url,
276 uint64_t* file_token_lo,
277 uint64_t* file_token_hi);
278 /* Dispatch a progress event on the DOM element where the given instance is
279 * embedded.
281 void (*DispatchEvent)(PP_Instance instance,
282 PP_NaClEventType event_type,
283 const char* resource_url,
284 PP_Bool length_is_computable,
285 uint64_t loaded_bytes,
286 uint64_t total_bytes);
287 /* Sets a read-only property on the <embed> DOM element that corresponds to
288 * the given instance.
290 void (*SetReadOnlyProperty)(PP_Instance instance,
291 struct PP_Var key,
292 struct PP_Var value);
293 /* Report an error that occured while attempting to load a nexe. */
294 void (*ReportLoadError)(PP_Instance instance,
295 PP_NaClError error,
296 const char* error_message,
297 const char* console_message);
298 /* Performs internal setup when an instance is created. */
299 void (*InstanceCreated)(PP_Instance instance);
300 /* Performs internal cleanup when an instance is destroyed. */
301 void (*InstanceDestroyed)(PP_Instance instance);
302 /* Return true if the NaCl debug stub is enabled and the loaded app
303 * will be attached to a debugger.
305 PP_Bool (*NaClDebugStubEnabled)(void);
306 /* Returns the kind of SFI sandbox implemented by NaCl on this
307 * platform.
309 const char* (*GetSandboxArch)(void);
310 /* Returns the scheme type for a given url. */
311 PP_UrlSchemeType (*GetUrlScheme)(struct PP_Var url);
312 /* Logs the message to the console. */
313 void (*LogToConsole)(PP_Instance instance, const char* message);
314 /* Returns PP_TRUE if an error has been reported loading the nexe. */
315 PP_Bool (*GetNexeErrorReported)(PP_Instance instance);
316 /* Sets the nexe error reported state for this instance. */
317 void (*SetNexeErrorReported)(PP_Instance instance, PP_Bool error_reported);
318 /* Returns the NaCl readiness status for this instance. */
319 PP_NaClReadyState (*GetNaClReadyState)(PP_Instance instance);
320 /* Sets the NaCl readiness status for this instance. */
321 void (*SetNaClReadyState)(PP_Instance instance,
322 PP_NaClReadyState ready_state);
323 /* Returns true if the plugin is an installed app. */
324 PP_Bool (*GetIsInstalled)(PP_Instance instance);
325 /* Sets whether the plugin is an installed app. */
326 void (*SetIsInstalled)(PP_Instance instance, PP_Bool is_installed);
329 typedef struct PPB_NaCl_Private_1_0 PPB_NaCl_Private;
331 * @}
334 #endif /* PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_ */