Index: chrome/browser/renderer_host/render_sandbox_host_linux.cc |
diff --git a/chrome/browser/renderer_host/render_sandbox_host_linux.cc b/chrome/browser/renderer_host/render_sandbox_host_linux.cc |
index dcd20d9158d5849109aa95e2ff4931b697239638..e657af4088367f70bb9521243d9b44ff13d47372 100644 |
--- a/chrome/browser/renderer_host/render_sandbox_host_linux.cc |
+++ b/chrome/browser/renderer_host/render_sandbox_host_linux.cc |
@@ -15,11 +15,18 @@ |
#include "base/logging.h" |
#include "base/message_loop.h" |
#include "base/pickle.h" |
+#include "base/string_util.h" |
#include "base/unix_domain_socket_posix.h" |
+#include "chrome/common/sandbox_methods_linux.h" |
+#include "webkit/api/public/gtk/WebFontInfo.h" |
#include "SkFontHost_fontconfig_direct.h" |
#include "SkFontHost_fontconfig_ipc.h" |
+using WebKit::WebFontInfo; |
+using WebKit::WebString; |
+using WebKit::WebUChar; |
+ |
// http://code.google.com/p/chromium/wiki/LinuxSandboxIPC |
// BEWARE: code in this file run across *processes* (not just threads). |
@@ -101,6 +108,8 @@ class SandboxIPCProcess { |
HandleFontMatchRequest(fd, pickle, iter, fds); |
} else if (kind == FontConfigIPC::METHOD_OPEN) { |
HandleFontOpenRequest(fd, pickle, iter, fds); |
+ } else if (kind == LinuxSandbox::METHOD_GET_FONT_FAMILY_FOR_CHARS) { |
+ HandleGetFontFamilyForChars(fd, pickle, iter, fds); |
} |
error: |
@@ -166,6 +175,43 @@ class SandboxIPCProcess { |
SendRendererReply(fds, reply, result_fd); |
} |
+ void HandleGetFontFamilyForChars(int fd, Pickle& pickle, void* iter, |
+ std::vector<int>& fds) { |
+ // The other side of this call is |
+ // chrome/renderer/renderer_sandbox_support_linux.cc |
+ |
+ int num_chars; |
+ if (!pickle.ReadInt(&iter, &num_chars)) |
+ return; |
+ |
+ // We don't want a corrupt renderer asking too much of us, it might |
+ // overflow later in the code. |
+ static const int kMaxChars = 4096; |
+ if (num_chars < 1 || num_chars > kMaxChars) { |
+ LOG(WARNING) << "HandleGetFontFamilyForChars: too many chars: " |
+ << num_chars; |
+ return; |
+ } |
+ |
+ scoped_array<WebUChar> chars(new WebUChar[num_chars]); |
+ |
+ for (int i = 0; i < num_chars; ++i) { |
+ uint32_t c; |
+ if (!pickle.ReadUInt32(&iter, &c)) { |
+ return; |
+ } |
+ |
+ chars[i] = c; |
+ } |
+ |
+ const WebString family = WebFontInfo::familyForChars(chars.get(), num_chars); |
+ const std::string family_utf8 = UTF16ToUTF8(family); |
+ |
+ Pickle reply; |
+ reply.WriteString(family_utf8); |
+ SendRendererReply(fds, reply, -1); |
+ } |
+ |
void SendRendererReply(const std::vector<int>& fds, const Pickle& reply, |
int reply_fd) { |
struct msghdr msg; |