OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/browser/renderer_host/sandbox_ipc_linux.h" | 5 #include "content/browser/renderer_host/sandbox_ipc_linux.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <fontconfig/fontconfig.h> | 8 #include <fontconfig/fontconfig.h> |
9 #include <sys/poll.h> | 9 #include <sys/poll.h> |
10 #include <sys/socket.h> | 10 #include <sys/socket.h> |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 PickleIterator iter(pickle); | 212 PickleIterator iter(pickle); |
213 | 213 |
214 int kind; | 214 int kind; |
215 if (!pickle.ReadInt(&iter, &kind)) | 215 if (!pickle.ReadInt(&iter, &kind)) |
216 return; | 216 return; |
217 | 217 |
218 if (kind == FontConfigIPC::METHOD_MATCH) { | 218 if (kind == FontConfigIPC::METHOD_MATCH) { |
219 HandleFontMatchRequest(fd, pickle, iter, fds.get()); | 219 HandleFontMatchRequest(fd, pickle, iter, fds.get()); |
220 } else if (kind == FontConfigIPC::METHOD_OPEN) { | 220 } else if (kind == FontConfigIPC::METHOD_OPEN) { |
221 HandleFontOpenRequest(fd, pickle, iter, fds.get()); | 221 HandleFontOpenRequest(fd, pickle, iter, fds.get()); |
222 } else if (kind == LinuxSandbox::METHOD_GET_FONT_FAMILY_FOR_CHAR) { | 222 } else if (kind == LinuxSandbox::METHOD_GET_FALLBACK_FONT_FOR_CHAR) { |
223 HandleGetFontFamilyForChar(fd, pickle, iter, fds.get()); | 223 HandleGetFallbackFontForChar(fd, pickle, iter, fds.get()); |
224 } else if (kind == LinuxSandbox::METHOD_LOCALTIME) { | 224 } else if (kind == LinuxSandbox::METHOD_LOCALTIME) { |
225 HandleLocaltime(fd, pickle, iter, fds.get()); | 225 HandleLocaltime(fd, pickle, iter, fds.get()); |
226 } else if (kind == LinuxSandbox::METHOD_GET_STYLE_FOR_STRIKE) { | 226 } else if (kind == LinuxSandbox::METHOD_GET_STYLE_FOR_STRIKE) { |
227 HandleGetStyleForStrike(fd, pickle, iter, fds.get()); | 227 HandleGetStyleForStrike(fd, pickle, iter, fds.get()); |
228 } else if (kind == LinuxSandbox::METHOD_MAKE_SHARED_MEMORY_SEGMENT) { | 228 } else if (kind == LinuxSandbox::METHOD_MAKE_SHARED_MEMORY_SEGMENT) { |
229 HandleMakeSharedMemorySegment(fd, pickle, iter, fds.get()); | 229 HandleMakeSharedMemorySegment(fd, pickle, iter, fds.get()); |
230 } else if (kind == LinuxSandbox::METHOD_MATCH_WITH_FALLBACK) { | 230 } else if (kind == LinuxSandbox::METHOD_MATCH_WITH_FALLBACK) { |
231 HandleMatchWithFallback(fd, pickle, iter, fds.get()); | 231 HandleMatchWithFallback(fd, pickle, iter, fds.get()); |
232 } | 232 } |
233 } | 233 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 // The receiver will have its own access to the file, so we will close it | 304 // The receiver will have its own access to the file, so we will close it |
305 // after this send. | 305 // after this send. |
306 SendRendererReply(fds, reply, result_fd); | 306 SendRendererReply(fds, reply, result_fd); |
307 | 307 |
308 if (result_fd >= 0) { | 308 if (result_fd >= 0) { |
309 int err = IGNORE_EINTR(close(result_fd)); | 309 int err = IGNORE_EINTR(close(result_fd)); |
310 DCHECK(!err); | 310 DCHECK(!err); |
311 } | 311 } |
312 } | 312 } |
313 | 313 |
314 void SandboxIPCHandler::HandleGetFontFamilyForChar( | 314 void SandboxIPCHandler::HandleGetFallbackFontForChar( |
315 int fd, | 315 int fd, |
316 const Pickle& pickle, | 316 const Pickle& pickle, |
317 PickleIterator iter, | 317 PickleIterator iter, |
318 const std::vector<base::ScopedFD*>& fds) { | 318 const std::vector<base::ScopedFD*>& fds) { |
319 // The other side of this call is | 319 // The other side of this call is |
320 // content/common/child_process_sandbox_support_impl_linux.cc | 320 // content/common/child_process_sandbox_support_impl_linux.cc |
321 | 321 |
322 EnsureWebKitInitialized(); | 322 EnsureWebKitInitialized(); |
323 WebUChar32 c; | 323 WebUChar32 c; |
324 if (!pickle.ReadInt(&iter, &c)) | 324 if (!pickle.ReadInt(&iter, &c)) |
325 return; | 325 return; |
326 | 326 |
327 std::string preferred_locale; | 327 std::string preferred_locale; |
328 if (!pickle.ReadString(&iter, &preferred_locale)) | 328 if (!pickle.ReadString(&iter, &preferred_locale)) |
329 return; | 329 return; |
330 | 330 |
331 blink::WebFontFamily family; | 331 blink::WebFallbackFont fallbackFont; |
332 WebFontInfo::familyForChar(c, preferred_locale.c_str(), &family); | 332 WebFontInfo::fallbackFontForChar(c, preferred_locale.c_str(), &fallbackFont); |
333 | 333 |
334 Pickle reply; | 334 Pickle reply; |
335 if (family.name.data()) { | 335 if (fallbackFont.name.data()) { |
336 reply.WriteString(family.name.data()); | 336 reply.WriteString(fallbackFont.name.data()); |
337 } else { | 337 } else { |
338 reply.WriteString(std::string()); | 338 reply.WriteString(std::string()); |
339 } | 339 } |
340 reply.WriteBool(family.isBold); | 340 if (fallbackFont.filename.data()) { |
341 reply.WriteBool(family.isItalic); | 341 reply.WriteString(fallbackFont.filename.data()); |
| 342 } else { |
| 343 reply.WriteString(std::string()); |
| 344 } |
| 345 reply.WriteInt(fallbackFont.ttcIndex); |
| 346 reply.WriteBool(fallbackFont.isBold); |
| 347 reply.WriteBool(fallbackFont.isItalic); |
342 SendRendererReply(fds, reply, -1); | 348 SendRendererReply(fds, reply, -1); |
343 } | 349 } |
344 | 350 |
345 void SandboxIPCHandler::HandleGetStyleForStrike( | 351 void SandboxIPCHandler::HandleGetStyleForStrike( |
346 int fd, | 352 int fd, |
347 const Pickle& pickle, | 353 const Pickle& pickle, |
348 PickleIterator iter, | 354 PickleIterator iter, |
349 const std::vector<base::ScopedFD*>& fds) { | 355 const std::vector<base::ScopedFD*>& fds) { |
350 std::string family; | 356 std::string family; |
351 int sizeAndStyle; | 357 int sizeAndStyle; |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 } | 641 } |
636 | 642 |
637 void SandboxIPCHandler::EnsureWebKitInitialized() { | 643 void SandboxIPCHandler::EnsureWebKitInitialized() { |
638 if (webkit_platform_support_) | 644 if (webkit_platform_support_) |
639 return; | 645 return; |
640 webkit_platform_support_.reset(new BlinkPlatformImpl); | 646 webkit_platform_support_.reset(new BlinkPlatformImpl); |
641 blink::initializeWithoutV8(webkit_platform_support_.get()); | 647 blink::initializeWithoutV8(webkit_platform_support_.get()); |
642 } | 648 } |
643 | 649 |
644 } // namespace content | 650 } // namespace content |
OLD | NEW |