| 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/global_descriptors_posix.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/pickle.h" | 12 #include "base/pickle.h" |
| 13 #include "content/common/chrome_descriptors.h" | 13 #include "content/common/chrome_descriptors.h" |
| 14 #include "content/common/sandbox_methods_linux.h" | 14 #include "content/common/sandbox_methods_linux.h" |
| 15 #include "content/common/unix_domain_socket_posix.h" | 15 #include "content/common/unix_domain_socket_posix.h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebFontFamily.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 |
| 18 static int GetSandboxFD() { | 19 static int GetSandboxFD() { |
| 19 return kSandboxIPCChannel + base::GlobalDescriptors::kBaseDescriptor; | 20 return kSandboxIPCChannel + base::GlobalDescriptors::kBaseDescriptor; |
| 20 } | 21 } |
| 21 | 22 |
| 22 namespace content { | 23 namespace content { |
| 23 | 24 |
| 24 std::string GetFontFamilyForCharacters(const uint16_t* utf16, | 25 void GetFontFamilyForCharacters(const uint16_t* utf16, |
| 25 size_t num_utf16, | 26 size_t num_utf16, |
| 26 const char* preferred_locale) { | 27 const char* preferred_locale, |
| 28 WebKit::WebFontFamily* family) { |
| 27 Pickle request; | 29 Pickle request; |
| 28 request.WriteInt(LinuxSandbox::METHOD_GET_FONT_FAMILY_FOR_CHARS); | 30 request.WriteInt(LinuxSandbox::METHOD_GET_FONT_FAMILY_FOR_CHARS); |
| 29 request.WriteInt(num_utf16); | 31 request.WriteInt(num_utf16); |
| 30 for (size_t i = 0; i < num_utf16; ++i) | 32 for (size_t i = 0; i < num_utf16; ++i) |
| 31 request.WriteUInt32(utf16[i]); | 33 request.WriteUInt32(utf16[i]); |
| 32 request.WriteString(preferred_locale); | 34 request.WriteString(preferred_locale); |
| 33 | 35 |
| 34 uint8_t buf[512]; | 36 uint8_t buf[512]; |
| 35 const ssize_t n = UnixDomainSocket::SendRecvMsg(GetSandboxFD(), buf, | 37 const ssize_t n = UnixDomainSocket::SendRecvMsg(GetSandboxFD(), buf, |
| 36 sizeof(buf), NULL, request); | 38 sizeof(buf), NULL, request); |
| 37 | 39 |
| 38 std::string family_name; | 40 std::string family_name; |
| 41 bool isBold = false; |
| 42 bool isItalic = false; |
| 39 if (n != -1) { | 43 if (n != -1) { |
| 40 Pickle reply(reinterpret_cast<char*>(buf), n); | 44 Pickle reply(reinterpret_cast<char*>(buf), n); |
| 41 void* pickle_iter = NULL; | 45 void* pickle_iter = NULL; |
| 42 reply.ReadString(&pickle_iter, &family_name); | 46 if (reply.ReadString(&pickle_iter, &family_name) && |
| 47 reply.ReadBool(&pickle_iter, &isBold) && |
| 48 reply.ReadBool(&pickle_iter, &isItalic)) { |
| 49 family->name = family_name; |
| 50 family->isBold = isBold; |
| 51 family->isItalic = isItalic; |
| 52 } |
| 43 } | 53 } |
| 44 | |
| 45 return family_name; | |
| 46 } | 54 } |
| 47 | 55 |
| 48 void GetRenderStyleForStrike(const char* family, int sizeAndStyle, | 56 void GetRenderStyleForStrike(const char* family, int sizeAndStyle, |
| 49 WebKit::WebFontRenderStyle* out) { | 57 WebKit::WebFontRenderStyle* out) { |
| 50 Pickle request; | 58 Pickle request; |
| 51 request.WriteInt(LinuxSandbox::METHOD_GET_STYLE_FOR_STRIKE); | 59 request.WriteInt(LinuxSandbox::METHOD_GET_STYLE_FOR_STRIKE); |
| 52 request.WriteString(family); | 60 request.WriteString(family); |
| 53 request.WriteInt(sizeAndStyle); | 61 request.WriteInt(sizeAndStyle); |
| 54 | 62 |
| 55 uint8_t buf[512]; | 63 uint8_t buf[512]; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 | 187 |
| 180 *output_length = length; | 188 *output_length = length; |
| 181 n = HANDLE_EINTR(pread(fd, output, length, offset)); | 189 n = HANDLE_EINTR(pread(fd, output, length, offset)); |
| 182 if (n != static_cast<ssize_t>(length)) | 190 if (n != static_cast<ssize_t>(length)) |
| 183 return false; | 191 return false; |
| 184 | 192 |
| 185 return true; | 193 return true; |
| 186 } | 194 } |
| 187 | 195 |
| 188 } // namespace content | 196 } // namespace content |
| OLD | NEW |