15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
523730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)#ifndef CONTENT_PUBLIC_COMMON_CHILD_PROCESS_SANDBOX_SUPPORT_LINUX_H_
623730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)#define CONTENT_PUBLIC_COMMON_CHILD_PROCESS_SANDBOX_SUPPORT_LINUX_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <stdint.h>
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string>
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/common/content_export.h"
1223730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)#include "ppapi/c/trusted/ppb_browser_font_trusted.h"
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace content {
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Returns a file descriptor for a shared memory segment.  The
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// executable flag indicates that the caller intends to use mprotect
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// with PROT_EXEC after making a mapping, but not that it intends to
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// mmap with PROT_EXEC in the first place.  (Some systems, such as
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// ChromeOS, disallow PROT_EXEC in mmap on /dev/shm files but do allow
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// PROT_EXEC in mprotect on mappings from such files.  This function
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// can yield an object that has that constraint.)
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)CONTENT_EXPORT int MakeSharedMemorySegmentViaIPC(size_t length,
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                                 bool executable);
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Return a read-only file descriptor to the font which best matches the given
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// properties or -1 on failure.
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//   charset: specifies the language(s) that the font must cover. See
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// render_sandbox_host_linux.cc for more information.
3023730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)// fallback_family: If not set to PP_BROWSERFONT_TRUSTED_FAMILY_DEFAULT, font
3123730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)// selection should fall back to generic Windows font names like Arial and
3223730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)// Times New Roman.
3323730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)CONTENT_EXPORT int MatchFontWithFallback(
3423730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)    const std::string& face,
3523730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)    bool bold,
3623730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)    bool italic,
3723730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)    int charset,
3823730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)    PP_BrowserFont_Trusted_Family fallback_family);
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// GetFontTable loads a specified font table from an open SFNT file.
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//   fd: a file descriptor to the SFNT file. The position doesn't matter.
42c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)//   table_tag: the table tag in *big-endian* format, or 0 for the entire font.
43c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)//   offset: offset into the table or entire font where loading should start.
44c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)//     The offset must be between 0 and 1 GB - 1.
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//   output: a buffer of size output_length that gets the data.  can be 0, in
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//     which case output_length will be set to the required size in bytes.
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//   output_length: size of output, if it's not 0.
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//   returns: true on success.
50c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)CONTENT_EXPORT bool GetFontTable(int fd, uint32_t table_tag, off_t offset,
51c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)                                 uint8_t* output, size_t* output_length);
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
53010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)// Sends a zygote child "ping" message to browser process via socket |fd|.
54010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)// Returns true on success.
55010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)CONTENT_EXPORT bool SendZygoteChildPing(int fd);
56010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};  // namespace content
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5923730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)#endif  // CONTENT_PUBLIC_COMMON_CHILD_PROCESS_SANDBOX_SUPPORT_LINUX_H_
60