Chromium Code Reviews| 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); |
|
jln (very slow on Chromium)
2014/06/10 01:52:34
Is it clear on the Blink side of this that this is
Dominik Röttsches
2014/06/10 07:44:52
Yes - that is clear and unfortunately required whe
| |
| 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 } | |
| 343 else { | |
|
piman
2014/06/10 01:30:09
nit: } else {
| |
| 344 reply.WriteString(std::string()); | |
| 345 } | |
| 346 reply.WriteInt(fallbackFont.ttcIndex); | |
| 347 reply.WriteBool(fallbackFont.isBold); | |
| 348 reply.WriteBool(fallbackFont.isItalic); | |
| 342 SendRendererReply(fds, reply, -1); | 349 SendRendererReply(fds, reply, -1); |
| 343 } | 350 } |
| 344 | 351 |
| 345 void SandboxIPCHandler::HandleGetStyleForStrike( | 352 void SandboxIPCHandler::HandleGetStyleForStrike( |
| 346 int fd, | 353 int fd, |
| 347 const Pickle& pickle, | 354 const Pickle& pickle, |
| 348 PickleIterator iter, | 355 PickleIterator iter, |
| 349 const std::vector<base::ScopedFD*>& fds) { | 356 const std::vector<base::ScopedFD*>& fds) { |
| 350 std::string family; | 357 std::string family; |
| 351 int sizeAndStyle; | 358 int sizeAndStyle; |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 635 } | 642 } |
| 636 | 643 |
| 637 void SandboxIPCHandler::EnsureWebKitInitialized() { | 644 void SandboxIPCHandler::EnsureWebKitInitialized() { |
| 638 if (webkit_platform_support_) | 645 if (webkit_platform_support_) |
| 639 return; | 646 return; |
| 640 webkit_platform_support_.reset(new BlinkPlatformImpl); | 647 webkit_platform_support_.reset(new BlinkPlatformImpl); |
| 641 blink::initializeWithoutV8(webkit_platform_support_.get()); | 648 blink::initializeWithoutV8(webkit_platform_support_.get()); |
| 642 } | 649 } |
| 643 | 650 |
| 644 } // namespace content | 651 } // namespace content |
| OLD | NEW |