summaryrefslogtreecommitdiffstats
path: root/content/renderer
diff options
context:
space:
mode:
Diffstat (limited to 'content/renderer')
-rw-r--r--content/renderer/render_process_impl.cc4
-rw-r--r--content/renderer/renderer_glue.cc6
-rw-r--r--content/renderer/renderer_sandbox_support_linux.cc189
-rw-r--r--content/renderer/renderer_sandbox_support_linux.h59
-rw-r--r--content/renderer/renderer_webkitclient_impl.cc21
5 files changed, 14 insertions, 265 deletions
diff --git a/content/renderer/render_process_impl.cc b/content/renderer/render_process_impl.cc
index c03878e..1ded505 100644
--- a/content/renderer/render_process_impl.cc
+++ b/content/renderer/render_process_impl.cc
@@ -37,10 +37,6 @@
#include "base/mac/mac_util.h"
#endif
-#if defined(OS_LINUX)
-#include "content/renderer/renderer_sandbox_support_linux.h"
-#endif
-
RenderProcessImpl::RenderProcessImpl()
: ALLOW_THIS_IN_INITIALIZER_LIST(shared_mem_cache_cleaner_(
base::TimeDelta::FromSeconds(5),
diff --git a/content/renderer/renderer_glue.cc b/content/renderer/renderer_glue.cc
index 5ad03fd..8c78846 100644
--- a/content/renderer/renderer_glue.cc
+++ b/content/renderer/renderer_glue.cc
@@ -35,7 +35,7 @@
#include "webkit/glue/websocketstreamhandle_bridge.h"
#if defined(OS_LINUX)
-#include "content/renderer/renderer_sandbox_support_linux.h"
+#include "content/common/child_process_sandbox_support_linux.h"
#endif
// This definition of WriteBitmapFromPixels uses shared memory to communicate
@@ -262,13 +262,13 @@ void EnableSpdy(bool enable) {
#if defined(OS_LINUX)
int MatchFontWithFallback(const std::string& face, bool bold,
bool italic, int charset) {
- return renderer_sandbox_support::MatchFontWithFallback(
+ return child_process_sandbox_support::MatchFontWithFallback(
face, bold, italic, charset);
}
bool GetFontTable(int fd, uint32_t table, uint8_t* output,
size_t* output_length) {
- return renderer_sandbox_support::GetFontTable(
+ return child_process_sandbox_support::GetFontTable(
fd, table, output, output_length);
}
#endif
diff --git a/content/renderer/renderer_sandbox_support_linux.cc b/content/renderer/renderer_sandbox_support_linux.cc
deleted file mode 100644
index 11d27a6..0000000
--- a/content/renderer/renderer_sandbox_support_linux.cc
+++ /dev/null
@@ -1,189 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/renderer/renderer_sandbox_support_linux.h"
-
-#include <sys/stat.h>
-
-#include "base/eintr_wrapper.h"
-#include "base/global_descriptors_posix.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/pickle.h"
-#include "content/common/chrome_descriptors.h"
-#include "content/common/sandbox_methods_linux.h"
-#include "content/common/unix_domain_socket_posix.h"
-
-#include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebFontRenderStyle.h"
-
-static int GetSandboxFD() {
- return kSandboxIPCChannel + base::GlobalDescriptors::kBaseDescriptor;
-}
-
-namespace renderer_sandbox_support {
-
-std::string getFontFamilyForCharacters(const uint16_t* utf16,
- size_t num_utf16,
- const char* preferred_locale) {
- Pickle request;
- request.WriteInt(LinuxSandbox::METHOD_GET_FONT_FAMILY_FOR_CHARS);
- request.WriteInt(num_utf16);
- for (size_t i = 0; i < num_utf16; ++i)
- request.WriteUInt32(utf16[i]);
- request.WriteString(preferred_locale);
-
- uint8_t buf[512];
- const ssize_t n = UnixDomainSocket::SendRecvMsg(GetSandboxFD(), buf,
- sizeof(buf), NULL, request);
-
- std::string family_name;
- if (n != -1) {
- Pickle reply(reinterpret_cast<char*>(buf), n);
- void* pickle_iter = NULL;
- reply.ReadString(&pickle_iter, &family_name);
- }
-
- return family_name;
-}
-
-void getRenderStyleForStrike(const char* family, int sizeAndStyle,
- WebKit::WebFontRenderStyle* out) {
- Pickle request;
- request.WriteInt(LinuxSandbox::METHOD_GET_STYLE_FOR_STRIKE);
- request.WriteString(family);
- request.WriteInt(sizeAndStyle);
-
- uint8_t buf[512];
- const ssize_t n = UnixDomainSocket::SendRecvMsg(GetSandboxFD(), buf,
- sizeof(buf), NULL, request);
-
- out->setDefaults();
- if (n == -1) {
- return;
- }
-
- Pickle reply(reinterpret_cast<char*>(buf), n);
- void* pickle_iter = NULL;
- int useBitmaps, useAutoHint, useHinting, hintStyle, useAntiAlias, useSubpixel;
- if (reply.ReadInt(&pickle_iter, &useBitmaps) &&
- reply.ReadInt(&pickle_iter, &useAutoHint) &&
- reply.ReadInt(&pickle_iter, &useHinting) &&
- reply.ReadInt(&pickle_iter, &hintStyle) &&
- reply.ReadInt(&pickle_iter, &useAntiAlias) &&
- reply.ReadInt(&pickle_iter, &useSubpixel)) {
- out->useBitmaps = useBitmaps;
- out->useAutoHint = useAutoHint;
- out->useHinting = useHinting;
- out->hintStyle = hintStyle;
- out->useAntiAlias = useAntiAlias;
- out->useSubpixel = useSubpixel;
- }
-}
-
-int MakeSharedMemorySegmentViaIPC(size_t length, bool executable) {
- Pickle request;
- request.WriteInt(LinuxSandbox::METHOD_MAKE_SHARED_MEMORY_SEGMENT);
- request.WriteUInt32(length);
- uint8_t reply_buf[10];
- int result_fd;
- ssize_t result = UnixDomainSocket::SendRecvMsg(GetSandboxFD(),
- reply_buf, sizeof(reply_buf),
- &result_fd, request);
- if (result == -1)
- return -1;
- return result_fd;
-}
-
-int MatchFontWithFallback(const std::string& face, bool bold,
- bool italic, int charset) {
- Pickle request;
- request.WriteInt(LinuxSandbox::METHOD_MATCH_WITH_FALLBACK);
- request.WriteString(face);
- request.WriteBool(bold);
- request.WriteBool(italic);
- request.WriteUInt32(charset);
- uint8_t reply_buf[64];
- int fd = -1;
- UnixDomainSocket::SendRecvMsg(GetSandboxFD(), reply_buf, sizeof(reply_buf),
- &fd, request);
- return fd;
-}
-
-bool GetFontTable(int fd, uint32_t table, uint8_t* output,
- size_t* output_length) {
- if (table == 0) {
- struct stat st;
- if (fstat(fd, &st) < 0)
- return false;
- size_t length = st.st_size;
- if (!output) {
- *output_length = length;
- return true;
- }
- if (*output_length < length)
- return false;
- *output_length = length;
- ssize_t n = HANDLE_EINTR(pread(fd, output, length, 0));
- if (n != static_cast<ssize_t>(length))
- return false;
- return true;
- }
-
- unsigned num_tables;
- uint8_t num_tables_buf[2];
-
- ssize_t n = HANDLE_EINTR(pread(fd, &num_tables_buf, sizeof(num_tables_buf),
- 4 /* skip the font type */));
- if (n != sizeof(num_tables_buf))
- return false;
-
- num_tables = static_cast<unsigned>(num_tables_buf[0]) << 8 |
- num_tables_buf[1];
-
- // The size in bytes of an entry in the table directory.
- static const unsigned kTableEntrySize = 16;
- scoped_array<uint8_t> table_entries(
- new uint8_t[num_tables * kTableEntrySize]);
- n = HANDLE_EINTR(pread(fd, table_entries.get(), num_tables * kTableEntrySize,
- 12 /* skip the SFNT header */));
- if (n != static_cast<ssize_t>(num_tables * kTableEntrySize))
- return false;
-
- size_t offset;
- size_t length = 0;
- for (unsigned i = 0; i < num_tables; i++) {
- const uint8_t* entry = table_entries.get() + i * kTableEntrySize;
- if (memcmp(entry, &table, sizeof(table)) == 0) {
- offset = static_cast<size_t>(entry[8]) << 24 |
- static_cast<size_t>(entry[9]) << 16 |
- static_cast<size_t>(entry[10]) << 8 |
- static_cast<size_t>(entry[11]);
- length = static_cast<size_t>(entry[12]) << 24 |
- static_cast<size_t>(entry[13]) << 16 |
- static_cast<size_t>(entry[14]) << 8 |
- static_cast<size_t>(entry[15]);
-
- break;
- }
- }
-
- if (!length)
- return false;
-
- if (!output) {
- *output_length = length;
- return true;
- }
-
- if (*output_length < length)
- return false;
-
- *output_length = length;
- n = HANDLE_EINTR(pread(fd, output, length, offset));
- if (n != static_cast<ssize_t>(length))
- return false;
-
- return true;
-}
-
-} // namespace render_sandbox_support
diff --git a/content/renderer/renderer_sandbox_support_linux.h b/content/renderer/renderer_sandbox_support_linux.h
deleted file mode 100644
index bc482bd..0000000
--- a/content/renderer/renderer_sandbox_support_linux.h
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CONTENT_RENDERER_RENDERER_SANDBOX_SUPPORT_LINUX_H_
-#define CONTENT_RENDERER_RENDERER_SANDBOX_SUPPORT_LINUX_H_
-#pragma once
-
-#include <stdint.h>
-
-#include <string>
-
-namespace WebKit {
-struct WebFontRenderStyle;
-}
-
-namespace renderer_sandbox_support {
-
-// Return a font family which provides glyphs for the Unicode code points
-// specified by |utf16|
-// utf16: a native-endian UTF16 string
-// num_utf16: the number of 16-bit words in |utf16|
-// preferred_locale: preferred locale identifier for the |utf16|
-//
-// Returns: the font family or an empty string if the request could not be
-// satisfied.
-std::string getFontFamilyForCharacters(const uint16_t* utf16,
- size_t num_utf16,
- const char* preferred_locale);
-
-void getRenderStyleForStrike(const char* family, int sizeAndStyle,
- WebKit::WebFontRenderStyle* out);
-
-// Returns a file descriptor for a shared memory segment.
-// The second argument is ignored because SHM segments are always
-// mappable with PROT_EXEC on Linux.
-int MakeSharedMemorySegmentViaIPC(size_t length, bool executable);
-
-// Return a read-only file descriptor to the font which best matches the given
-// properties or -1 on failure.
-// charset: specifies the language(s) that the font must cover. See
-// render_sandbox_host_linux.cc for more information.
-int MatchFontWithFallback(const std::string& face, bool bold,
- bool italic, int charset);
-
-// GetFontTable loads a specified font table from an open SFNT file.
-// fd: a file descriptor to the SFNT file. The position doesn't matter.
-// table: the table in *big-endian* format, or 0 for the whole font file.
-// output: a buffer of size output_length that gets the data. can be 0, in
-// which case output_length will be set to the required size in bytes.
-// output_length: size of output, if it's not 0.
-//
-// returns: true on success.
-bool GetFontTable(int fd, uint32_t table, uint8_t* output,
- size_t* output_length);
-
-}; // namespace render_sandbox_support
-
-#endif // CONTENT_RENDERER_RENDERER_SANDBOX_SUPPORT_LINUX_H_
diff --git a/content/renderer/renderer_webkitclient_impl.cc b/content/renderer/renderer_webkitclient_impl.cc
index 99746c9..c68cc58 100644
--- a/content/renderer/renderer_webkitclient_impl.cc
+++ b/content/renderer/renderer_webkitclient_impl.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -61,7 +61,7 @@
#include <map>
#include "base/synchronization/lock.h"
-#include "content/renderer/renderer_sandbox_support_linux.h"
+#include "content/common/child_process_sandbox_support_linux.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebSandboxSupport.h"
#endif
@@ -128,7 +128,7 @@ class RendererWebKitClientImpl::SandboxSupport
// here. The key in this map is an array of 16-bit UTF16 values from WebKit.
// The value is a string containing the correct font family.
base::Lock unicode_font_families_mutex_;
- std::map<std::string, std::string> unicode_font_families_;
+ std::map<string16, std::string> unicode_font_families_;
#endif
};
@@ -440,24 +440,25 @@ WebString RendererWebKitClientImpl::SandboxSupport::getFontFamilyForCharacters(
size_t num_characters,
const char* preferred_locale) {
base::AutoLock lock(unicode_font_families_mutex_);
- const std::string key(reinterpret_cast<const char*>(characters),
- num_characters * sizeof(characters[0]));
- const std::map<std::string, std::string>::const_iterator iter =
+ const string16 key(characters, num_characters);
+ const std::map<string16, std::string>::const_iterator iter =
unicode_font_families_.find(key);
if (iter != unicode_font_families_.end())
return WebString::fromUTF8(iter->second);
const std::string family_name =
- renderer_sandbox_support::getFontFamilyForCharacters(characters,
- num_characters,
- preferred_locale);
+ child_process_sandbox_support::getFontFamilyForCharacters(
+ characters,
+ num_characters,
+ preferred_locale);
unicode_font_families_.insert(make_pair(key, family_name));
return WebString::fromUTF8(family_name);
}
void RendererWebKitClientImpl::SandboxSupport::getRenderStyleForStrike(
const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out) {
- renderer_sandbox_support::getRenderStyleForStrike(family, sizeAndStyle, out);
+ child_process_sandbox_support::getRenderStyleForStrike(family, sizeAndStyle,
+ out);
}
#elif defined(OS_MACOSX)