OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/renderer/renderer_sandbox_support_linux.h" | 5 #include "chrome/renderer/renderer_sandbox_support_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/pickle.h" | 11 #include "base/pickle.h" |
12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
13 #include "chrome/common/chrome_descriptors.h" | 13 #include "chrome/common/chrome_descriptors.h" |
14 #include "chrome/common/sandbox_methods_linux.h" | 14 #include "chrome/common/sandbox_methods_linux.h" |
15 #include "chrome/common/unix_domain_socket_posix.h" | 15 #include "chrome/common/unix_domain_socket_posix.h" |
16 | 16 |
17 #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" |
18 | 18 |
19 static int GetSandboxFD() { | 19 static int GetSandboxFD() { |
20 return kSandboxIPCChannel + base::GlobalDescriptors::kBaseDescriptor; | 20 return kSandboxIPCChannel + base::GlobalDescriptors::kBaseDescriptor; |
21 } | 21 } |
22 | 22 |
23 namespace renderer_sandbox_support { | 23 namespace renderer_sandbox_support { |
24 | 24 |
25 std::string getFontFamilyForCharacters(const uint16_t* utf16, | 25 std::string getFontFamilyForCharacters(const uint16_t* utf16, |
26 size_t num_utf16) { | 26 size_t num_utf16, |
| 27 const char* preferred_locale) { |
27 Pickle request; | 28 Pickle request; |
28 request.WriteInt(LinuxSandbox::METHOD_GET_FONT_FAMILY_FOR_CHARS); | 29 request.WriteInt(LinuxSandbox::METHOD_GET_FONT_FAMILY_FOR_CHARS); |
29 request.WriteInt(num_utf16); | 30 request.WriteInt(num_utf16); |
30 for (size_t i = 0; i < num_utf16; ++i) | 31 for (size_t i = 0; i < num_utf16; ++i) |
31 request.WriteUInt32(utf16[i]); | 32 request.WriteUInt32(utf16[i]); |
| 33 request.WriteString(preferred_locale); |
32 | 34 |
33 uint8_t buf[512]; | 35 uint8_t buf[512]; |
34 const ssize_t n = UnixDomainSocket::SendRecvMsg(GetSandboxFD(), buf, | 36 const ssize_t n = UnixDomainSocket::SendRecvMsg(GetSandboxFD(), buf, |
35 sizeof(buf), NULL, request); | 37 sizeof(buf), NULL, request); |
36 | 38 |
37 std::string family_name; | 39 std::string family_name; |
38 if (n != -1) { | 40 if (n != -1) { |
39 Pickle reply(reinterpret_cast<char*>(buf), n); | 41 Pickle reply(reinterpret_cast<char*>(buf), n); |
40 void* pickle_iter = NULL; | 42 void* pickle_iter = NULL; |
41 reply.ReadString(&pickle_iter, &family_name); | 43 reply.ReadString(&pickle_iter, &family_name); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 180 |
179 *output_length = length; | 181 *output_length = length; |
180 n = HANDLE_EINTR(pread(fd, output, length, offset)); | 182 n = HANDLE_EINTR(pread(fd, output, length, offset)); |
181 if (n != static_cast<ssize_t>(length)) | 183 if (n != static_cast<ssize_t>(length)) |
182 return false; | 184 return false; |
183 | 185 |
184 return true; | 186 return true; |
185 } | 187 } |
186 | 188 |
187 } // namespace render_sandbox_support | 189 } // namespace render_sandbox_support |
OLD | NEW |