| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/pickle.h" | 11 #include "base/pickle.h" |
| 12 #include "base/posix/eintr_wrapper.h" | 12 #include "base/posix/eintr_wrapper.h" |
| 13 #include "base/posix/unix_domain_socket_linux.h" | 13 #include "base/posix/unix_domain_socket_linux.h" |
| 14 #include "base/safe_numerics.h" | 14 #include "base/safe_numerics.h" |
| 15 #include "base/sys_byteorder.h" | 15 #include "base/sys_byteorder.h" |
| 16 #include "content/common/sandbox_linux.h" | 16 #include "content/common/sandbox_linux.h" |
| 17 #include "third_party/WebKit/public/platform/linux/WebFontFamily.h" | 17 #include "third_party/WebKit/public/platform/linux/WebFontFamily.h" |
| 18 #include "third_party/WebKit/public/platform/linux/WebFontRenderStyle.h" | 18 #include "third_party/WebKit/public/platform/linux/WebFontRenderStyle.h" |
| 19 | 19 |
| 20 namespace content { | 20 namespace content { |
| 21 | 21 |
| 22 void GetFontFamilyForCharacter(int32_t character, | 22 void GetFontFamilyForCharacter(int32_t character, |
| 23 const char* preferred_locale, | 23 const char* preferred_locale, |
| 24 WebKit::WebFontFamily* family) { | 24 blink::WebFontFamily* family) { |
| 25 TRACE_EVENT0("sandbox_ipc", "GetFontFamilyForCharacter"); | 25 TRACE_EVENT0("sandbox_ipc", "GetFontFamilyForCharacter"); |
| 26 | 26 |
| 27 Pickle request; | 27 Pickle request; |
| 28 request.WriteInt(LinuxSandbox::METHOD_GET_FONT_FAMILY_FOR_CHAR); | 28 request.WriteInt(LinuxSandbox::METHOD_GET_FONT_FAMILY_FOR_CHAR); |
| 29 request.WriteInt(character); | 29 request.WriteInt(character); |
| 30 request.WriteString(preferred_locale); | 30 request.WriteString(preferred_locale); |
| 31 | 31 |
| 32 uint8_t buf[512]; | 32 uint8_t buf[512]; |
| 33 const ssize_t n = UnixDomainSocket::SendRecvMsg(GetSandboxFD(), buf, | 33 const ssize_t n = UnixDomainSocket::SendRecvMsg(GetSandboxFD(), buf, |
| 34 sizeof(buf), NULL, request); | 34 sizeof(buf), NULL, request); |
| 35 | 35 |
| 36 std::string family_name; | 36 std::string family_name; |
| 37 bool isBold = false; | 37 bool isBold = false; |
| 38 bool isItalic = false; | 38 bool isItalic = false; |
| 39 if (n != -1) { | 39 if (n != -1) { |
| 40 Pickle reply(reinterpret_cast<char*>(buf), n); | 40 Pickle reply(reinterpret_cast<char*>(buf), n); |
| 41 PickleIterator pickle_iter(reply); | 41 PickleIterator pickle_iter(reply); |
| 42 if (reply.ReadString(&pickle_iter, &family_name) && | 42 if (reply.ReadString(&pickle_iter, &family_name) && |
| 43 reply.ReadBool(&pickle_iter, &isBold) && | 43 reply.ReadBool(&pickle_iter, &isBold) && |
| 44 reply.ReadBool(&pickle_iter, &isItalic)) { | 44 reply.ReadBool(&pickle_iter, &isItalic)) { |
| 45 family->name = family_name; | 45 family->name = family_name; |
| 46 family->isBold = isBold; | 46 family->isBold = isBold; |
| 47 family->isItalic = isItalic; | 47 family->isItalic = isItalic; |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 | 51 |
| 52 void GetRenderStyleForStrike(const char* family, int sizeAndStyle, | 52 void GetRenderStyleForStrike(const char* family, int sizeAndStyle, |
| 53 WebKit::WebFontRenderStyle* out) { | 53 blink::WebFontRenderStyle* out) { |
| 54 TRACE_EVENT0("sandbox_ipc", "GetRenderStyleForStrike"); | 54 TRACE_EVENT0("sandbox_ipc", "GetRenderStyleForStrike"); |
| 55 | 55 |
| 56 Pickle request; | 56 Pickle request; |
| 57 request.WriteInt(LinuxSandbox::METHOD_GET_STYLE_FOR_STRIKE); | 57 request.WriteInt(LinuxSandbox::METHOD_GET_STYLE_FOR_STRIKE); |
| 58 request.WriteString(family); | 58 request.WriteString(family); |
| 59 request.WriteInt(sizeAndStyle); | 59 request.WriteInt(sizeAndStyle); |
| 60 | 60 |
| 61 uint8_t buf[512]; | 61 uint8_t buf[512]; |
| 62 const ssize_t n = UnixDomainSocket::SendRecvMsg(GetSandboxFD(), buf, | 62 const ssize_t n = UnixDomainSocket::SendRecvMsg(GetSandboxFD(), buf, |
| 63 sizeof(buf), NULL, request); | 63 sizeof(buf), NULL, request); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 ssize_t n = HANDLE_EINTR(pread(fd, output, data_length, data_offset)); | 171 ssize_t n = HANDLE_EINTR(pread(fd, output, data_length, data_offset)); |
| 172 if (n != base::checked_numeric_cast<ssize_t>(data_length)) | 172 if (n != base::checked_numeric_cast<ssize_t>(data_length)) |
| 173 return false; | 173 return false; |
| 174 } | 174 } |
| 175 *output_length = data_length; | 175 *output_length = data_length; |
| 176 | 176 |
| 177 return true; | 177 return true; |
| 178 } | 178 } |
| 179 | 179 |
| 180 } // namespace content | 180 } // namespace content |
| OLD | NEW |