Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(415)

Unified Diff: chrome/browser/renderer_host/render_sandbox_host_linux.cc

Issue 132007: Linux: plumb fontconfig call out to the sandbox host. (Closed)
Patch Set: ... Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/message_pump_glib.cc ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « base/message_pump_glib.cc ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698