blob: bf2918b257000efacd889216f9ab14b54cffd84e [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 */
5
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +01006/* 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)2a99a7e2013-03-28 15:31:22 +00008
9#inline c
10#include "ppapi/c/private/pp_file_handle.h"
Ben Murdocha3f7b4e2013-07-24 10:36:34 +010011#include "ppapi/c/private/ppb_instance_private.h"
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000012#endinl
13
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000014/** NaCl-specific errors that should be reported to the user */
15enum 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 */
24interface PPB_NaCl_Private {
Ben Murdocha3f7b4e2013-07-24 10:36:34 +010025 /* 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)2a99a7e2013-03-28 15:31:22 +000028 * 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)c2e0dbd2013-05-09 18:35:53 +010034 * 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)7d4cd472013-06-19 11:58:07 +010036 * The |enable_exception_handling| flag indicates whether or not the nexe
37 * will be able to use hardware exception handling.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000038 */
Ben Murdocha3f7b4e2013-07-24 10:36:34 +010039 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)2a99a7e2013-03-28 15:31:22 +000048
49 /* This function starts the IPC proxy so the nexe can communicate with the
Ben Murdocha3f7b4e2013-07-24 10:36:34 +010050 * 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)2a99a7e2013-03-28 15:31:22 +000056 */
Ben Murdocha3f7b4e2013-07-24 10:36:34 +010057 PP_ExternalPluginResult StartPpapiProxy(PP_Instance instance);
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000058
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)2a99a7e2013-03-28 15:31:22 +000070 /* 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 Murdoch2385ea32013-08-06 11:01:04 +010082 /* 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)2a99a7e2013-03-28 15:31:22 +000090 /* Returns a read-only file descriptor of a file rooted in the Pnacl
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010091 * component directory, or an invalid handle on failure.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000092 */
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 Murdocheb525c52013-07-10 11:40:50 +0100101 /* 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 Murdoch7dbb3d52013-07-17 14:55:54 +0100103 * with the cache information given by |pexe_url|, |abi_version|, |opt_level|,
104 * |last_modified|, and |etag|. If the nexe is already present
Ben Murdocheb525c52013-07-10 11:40:50 +0100105 * 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 Murdoch7dbb3d52013-07-17 14:55:54 +0100115 [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 Murdocheb525c52013-07-10 11:40:50 +0100120 [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 Murdochbb1529c2013-08-08 10:24:53 +0100125 * 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 Murdocheb525c52013-07-10 11:40:50 +0100132 */
Ben Murdochbb1529c2013-08-08 10:24:53 +0100133 void ReportTranslationFinished([in] PP_Instance instance,
134 [in] PP_Bool success);
Ben Murdocheb525c52013-07-10 11:40:50 +0100135
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000136 /* 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 Murdocha3f7b4e2013-07-24 10:36:34 +0100145 PP_ExternalPluginResult ReportNaClError([in] PP_Instance instance,
146 [in] PP_NaClError message_id);
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100147
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)90dce4d2013-05-29 14:40:03 +0100154 [out] uint64_t file_token_lo,
155 [out] uint64_t file_token_hi);
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000156};