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/numerics/safe_conversions.h" | 11 #include "base/numerics/safe_conversions.h" |
12 #include "base/pickle.h" | 12 #include "base/pickle.h" |
13 #include "base/posix/eintr_wrapper.h" | 13 #include "base/posix/eintr_wrapper.h" |
14 #include "base/posix/unix_domain_socket_linux.h" | 14 #include "base/posix/unix_domain_socket_linux.h" |
15 #include "base/sys_byteorder.h" | 15 #include "base/sys_byteorder.h" |
16 #include "content/common/sandbox_linux/sandbox_linux.h" | 16 #include "content/common/sandbox_linux/sandbox_linux.h" |
17 #include "content/common/zygote_commands_linux.h" | 17 #include "content/common/zygote_commands_linux.h" |
18 #include "third_party/WebKit/public/platform/linux/WebFontFamily.h" | 18 #include "third_party/WebKit/public/platform/linux/WebFallbackFont.h" |
19 #include "third_party/WebKit/public/platform/linux/WebFontRenderStyle.h" | 19 #include "third_party/WebKit/public/platform/linux/WebFontRenderStyle.h" |
20 | 20 |
21 namespace content { | 21 namespace content { |
22 | 22 |
23 void GetFontFamilyForCharacter(int32_t character, | 23 void GetFallbackFontForCharacter(int32_t character, |
24 const char* preferred_locale, | 24 const char* preferred_locale, |
25 blink::WebFontFamily* family) { | 25 blink::WebFallbackFont* fallbackFont) { |
26 TRACE_EVENT0("sandbox_ipc", "GetFontFamilyForCharacter"); | 26 TRACE_EVENT0("sandbox_ipc", "GetFontFamilyForCharacter"); |
27 | 27 |
28 Pickle request; | 28 Pickle request; |
29 request.WriteInt(LinuxSandbox::METHOD_GET_FONT_FAMILY_FOR_CHAR); | 29 request.WriteInt(LinuxSandbox::METHOD_GET_FALLBACK_FONT_FOR_CHAR); |
30 request.WriteInt(character); | 30 request.WriteInt(character); |
31 request.WriteString(preferred_locale); | 31 request.WriteString(preferred_locale); |
32 | 32 |
33 uint8_t buf[512]; | 33 uint8_t buf[512]; |
34 const ssize_t n = UnixDomainSocket::SendRecvMsg(GetSandboxFD(), buf, | 34 const ssize_t n = UnixDomainSocket::SendRecvMsg(GetSandboxFD(), buf, |
35 sizeof(buf), NULL, request); | 35 sizeof(buf), NULL, request); |
36 | 36 |
37 std::string family_name; | 37 std::string family_name; |
| 38 std::string filename; |
| 39 int ttcIndex = 0; |
38 bool isBold = false; | 40 bool isBold = false; |
39 bool isItalic = false; | 41 bool isItalic = false; |
40 if (n != -1) { | 42 if (n != -1) { |
41 Pickle reply(reinterpret_cast<char*>(buf), n); | 43 Pickle reply(reinterpret_cast<char*>(buf), n); |
42 PickleIterator pickle_iter(reply); | 44 PickleIterator pickle_iter(reply); |
43 if (reply.ReadString(&pickle_iter, &family_name) && | 45 if (reply.ReadString(&pickle_iter, &family_name) && |
| 46 reply.ReadString(&pickle_iter, &filename) && |
| 47 reply.ReadInt(&pickle_iter, &ttcIndex) && |
44 reply.ReadBool(&pickle_iter, &isBold) && | 48 reply.ReadBool(&pickle_iter, &isBold) && |
45 reply.ReadBool(&pickle_iter, &isItalic)) { | 49 reply.ReadBool(&pickle_iter, &isItalic)) { |
46 family->name = family_name; | 50 fallbackFont->name = family_name; |
47 family->isBold = isBold; | 51 fallbackFont->filename = filename; |
48 family->isItalic = isItalic; | 52 fallbackFont->ttcIndex = ttcIndex; |
| 53 fallbackFont->isBold = isBold; |
| 54 fallbackFont->isItalic = isItalic; |
49 } | 55 } |
50 } | 56 } |
51 } | 57 } |
52 | 58 |
53 void GetRenderStyleForStrike(const char* family, int sizeAndStyle, | 59 void GetRenderStyleForStrike(const char* family, int sizeAndStyle, |
54 blink::WebFontRenderStyle* out) { | 60 blink::WebFontRenderStyle* out) { |
55 TRACE_EVENT0("sandbox_ipc", "GetRenderStyleForStrike"); | 61 TRACE_EVENT0("sandbox_ipc", "GetRenderStyleForStrike"); |
56 | 62 |
57 Pickle request; | 63 Pickle request; |
58 request.WriteInt(LinuxSandbox::METHOD_GET_STYLE_FOR_STRIKE); | 64 request.WriteInt(LinuxSandbox::METHOD_GET_STYLE_FOR_STRIKE); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 } | 189 } |
184 | 190 |
185 bool SendZygoteChildPing(int fd) { | 191 bool SendZygoteChildPing(int fd) { |
186 return UnixDomainSocket::SendMsg(fd, | 192 return UnixDomainSocket::SendMsg(fd, |
187 kZygoteChildPingMessage, | 193 kZygoteChildPingMessage, |
188 sizeof(kZygoteChildPingMessage), | 194 sizeof(kZygoteChildPingMessage), |
189 std::vector<int>()); | 195 std::vector<int>()); |
190 } | 196 } |
191 | 197 |
192 } // namespace content | 198 } // namespace content |
OLD | NEW |