| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/common/child_process_sandbox_support_impl_linux.h" | 5 #include "content/common/child_process_sandbox_support_impl_linux.h" |
| 6 | 6 |
| 7 #include <sys/stat.h> | 7 #include <sys/stat.h> |
| 8 | 8 |
| 9 #include "base/eintr_wrapper.h" | 9 #include "base/eintr_wrapper.h" |
| 10 #include "base/global_descriptors_posix.h" |
| 10 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/pickle.h" | 12 #include "base/pickle.h" |
| 12 #include "content/common/child_process_sandbox_support_impl_linux.h" | 13 #include "content/common/chrome_descriptors.h" |
| 13 #include "content/common/sandbox_methods_linux.h" | 14 #include "content/common/sandbox_methods_linux.h" |
| 14 #include "content/common/unix_domain_socket_posix.h" | 15 #include "content/common/unix_domain_socket_posix.h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/linux/WebFon
tFamily.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/linux/WebFon
tFamily.h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebFontRenderSt
yle.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebFontRenderSt
yle.h" |
| 17 | 18 |
| 19 static int GetSandboxFD() { |
| 20 return kSandboxIPCChannel + base::GlobalDescriptors::kBaseDescriptor; |
| 21 } |
| 22 |
| 18 namespace content { | 23 namespace content { |
| 19 | 24 |
| 20 void GetFontFamilyForCharacters(const uint16_t* utf16, | 25 void GetFontFamilyForCharacters(const uint16_t* utf16, |
| 21 size_t num_utf16, | 26 size_t num_utf16, |
| 22 const char* preferred_locale, | 27 const char* preferred_locale, |
| 23 WebKit::WebFontFamily* family) { | 28 WebKit::WebFontFamily* family) { |
| 24 Pickle request; | 29 Pickle request; |
| 25 request.WriteInt(LinuxSandbox::METHOD_GET_FONT_FAMILY_FOR_CHARS); | 30 request.WriteInt(LinuxSandbox::METHOD_GET_FONT_FAMILY_FOR_CHARS); |
| 26 request.WriteInt(num_utf16); | 31 request.WriteInt(num_utf16); |
| 27 for (size_t i = 0; i < num_utf16; ++i) | 32 for (size_t i = 0; i < num_utf16; ++i) |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 reply.ReadInt(&pickle_iter, &useSubpixel)) { | 80 reply.ReadInt(&pickle_iter, &useSubpixel)) { |
| 76 out->useBitmaps = useBitmaps; | 81 out->useBitmaps = useBitmaps; |
| 77 out->useAutoHint = useAutoHint; | 82 out->useAutoHint = useAutoHint; |
| 78 out->useHinting = useHinting; | 83 out->useHinting = useHinting; |
| 79 out->hintStyle = hintStyle; | 84 out->hintStyle = hintStyle; |
| 80 out->useAntiAlias = useAntiAlias; | 85 out->useAntiAlias = useAntiAlias; |
| 81 out->useSubpixel = useSubpixel; | 86 out->useSubpixel = useSubpixel; |
| 82 } | 87 } |
| 83 } | 88 } |
| 84 | 89 |
| 90 int MakeSharedMemorySegmentViaIPC(size_t length, bool executable) { |
| 91 Pickle request; |
| 92 request.WriteInt(LinuxSandbox::METHOD_MAKE_SHARED_MEMORY_SEGMENT); |
| 93 request.WriteUInt32(length); |
| 94 request.WriteBool(executable); |
| 95 uint8_t reply_buf[10]; |
| 96 int result_fd; |
| 97 ssize_t result = UnixDomainSocket::SendRecvMsg(GetSandboxFD(), |
| 98 reply_buf, sizeof(reply_buf), |
| 99 &result_fd, request); |
| 100 if (result == -1) |
| 101 return -1; |
| 102 return result_fd; |
| 103 } |
| 104 |
| 85 int MatchFontWithFallback(const std::string& face, bool bold, | 105 int MatchFontWithFallback(const std::string& face, bool bold, |
| 86 bool italic, int charset) { | 106 bool italic, int charset) { |
| 87 Pickle request; | 107 Pickle request; |
| 88 request.WriteInt(LinuxSandbox::METHOD_MATCH_WITH_FALLBACK); | 108 request.WriteInt(LinuxSandbox::METHOD_MATCH_WITH_FALLBACK); |
| 89 request.WriteString(face); | 109 request.WriteString(face); |
| 90 request.WriteBool(bold); | 110 request.WriteBool(bold); |
| 91 request.WriteBool(italic); | 111 request.WriteBool(italic); |
| 92 request.WriteUInt32(charset); | 112 request.WriteUInt32(charset); |
| 93 uint8_t reply_buf[64]; | 113 uint8_t reply_buf[64]; |
| 94 int fd = -1; | 114 int fd = -1; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 188 |
| 169 *output_length = length; | 189 *output_length = length; |
| 170 n = HANDLE_EINTR(pread(fd, output, length, offset)); | 190 n = HANDLE_EINTR(pread(fd, output, length, offset)); |
| 171 if (n != static_cast<ssize_t>(length)) | 191 if (n != static_cast<ssize_t>(length)) |
| 172 return false; | 192 return false; |
| 173 | 193 |
| 174 return true; | 194 return true; |
| 175 } | 195 } |
| 176 | 196 |
| 177 } // namespace content | 197 } // namespace content |
| OLD | NEW |