From bcd90b701089e050a74b82f0670cf36ff72bd7d7 Mon Sep 17 00:00:00 2001 From: "jam@chromium.org" Date: Mon, 17 Oct 2011 23:19:57 +0000 Subject: Create a public header with the child_process_sandbox_support_linux functions that are used in chrome. Also move everything to the content namespace, now that we have one. This gets rid of the last content/common includes from chrome/renderer and so I've tightened up the DEPS. Also get rid of the webkit_glue versions of the font functions since they weren't used anymore. BUG=98716 Review URL: http://codereview.chromium.org/8319017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105956 0039d316-1c4b-4281-b951-d872f2087c98 --- content/DEPS | 7 - .../child_process_sandbox_support_impl_linux.cc | 188 +++++++++++++++++++++ .../child_process_sandbox_support_impl_linux.h | 34 ++++ .../common/child_process_sandbox_support_linux.cc | 188 --------------------- .../common/child_process_sandbox_support_linux.h | 62 ------- content/content_common.gypi | 5 +- .../ppapi_webkitplatformsupport_impl.cc | 14 +- .../common/child_process_sandbox_support_linux.h | 42 +++++ content/renderer/renderer_glue.cc | 18 -- .../renderer_webkitplatformsupport_impl.cc | 14 +- content/test/render_view_test.cc | 15 +- content/test/render_view_test.h | 7 +- 12 files changed, 296 insertions(+), 298 deletions(-) create mode 100644 content/common/child_process_sandbox_support_impl_linux.cc create mode 100644 content/common/child_process_sandbox_support_impl_linux.h delete mode 100644 content/common/child_process_sandbox_support_linux.cc delete mode 100644 content/common/child_process_sandbox_support_linux.h create mode 100644 content/public/common/child_process_sandbox_support_linux.h (limited to 'content') diff --git a/content/DEPS b/content/DEPS index 91ac066..aa15b45 100644 --- a/content/DEPS +++ b/content/DEPS @@ -8,13 +8,6 @@ include_rules = [ # make use of it. "+chrome/test", - # The following directories have been refactored, so no new dependencies - # should be added from these directories. - "-chrome/browser/printing", - "-chrome/browser/extensions", - "-chrome/common/extensions", - "-chrome/renderer/extensions", - # The subdirectories in content/ will manually allow their own include # directories in content/ so we disallow all of them. "-content", diff --git a/content/common/child_process_sandbox_support_impl_linux.cc b/content/common/child_process_sandbox_support_impl_linux.cc new file mode 100644 index 0000000..692d4ed --- /dev/null +++ b/content/common/child_process_sandbox_support_impl_linux.cc @@ -0,0 +1,188 @@ +// 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/common/child_process_sandbox_support_impl_linux.h" + +#include + +#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 content { + +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(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(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(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(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 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(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(entry[8]) << 24 | + static_cast(entry[9]) << 16 | + static_cast(entry[10]) << 8 | + static_cast(entry[11]); + length = static_cast(entry[12]) << 24 | + static_cast(entry[13]) << 16 | + static_cast(entry[14]) << 8 | + static_cast(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(length)) + return false; + + return true; +} + +} // namespace content diff --git a/content/common/child_process_sandbox_support_impl_linux.h b/content/common/child_process_sandbox_support_impl_linux.h new file mode 100644 index 0000000..b26634a --- /dev/null +++ b/content/common/child_process_sandbox_support_impl_linux.h @@ -0,0 +1,34 @@ +// 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. + +#ifndef CONTENT_COMMON_CHILD_PROCESS_SANDBOX_SUPPORT_IMPL_LINUX_H_ +#define CONTENT_COMMON_CHILD_PROCESS_SANDBOX_SUPPORT_IMPL_LINUX_H_ +#pragma once + +#include "content/public/common/child_process_sandbox_support_linux.h" + +namespace WebKit { +struct WebFontRenderStyle; +} + +namespace content { + +// 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); + +}; // namespace content + +#endif // CONTENT_COMMON_CHILD_PROCESS_SANDBOX_SUPPORT_IMPL_LINUX_H_ diff --git a/content/common/child_process_sandbox_support_linux.cc b/content/common/child_process_sandbox_support_linux.cc deleted file mode 100644 index 92eea45..0000000 --- a/content/common/child_process_sandbox_support_linux.cc +++ /dev/null @@ -1,188 +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/common/child_process_sandbox_support_linux.h" - -#include - -#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 child_process_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(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(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(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(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 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(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(entry[8]) << 24 | - static_cast(entry[9]) << 16 | - static_cast(entry[10]) << 8 | - static_cast(entry[11]); - length = static_cast(entry[12]) << 24 | - static_cast(entry[13]) << 16 | - static_cast(entry[14]) << 8 | - static_cast(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(length)) - return false; - - return true; -} - -} // namespace child_process_sandbox_support diff --git a/content/common/child_process_sandbox_support_linux.h b/content/common/child_process_sandbox_support_linux.h deleted file mode 100644 index a7537c2..0000000 --- a/content/common/child_process_sandbox_support_linux.h +++ /dev/null @@ -1,62 +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. - -#ifndef CONTENT_COMMON_CHILD_PROCESS_SANDBOX_SUPPORT_LINUX_H_ -#define CONTENT_COMMON_CHILD_PROCESS_SANDBOX_SUPPORT_LINUX_H_ -#pragma once - -#include - -#include - -#include "content/common/content_export.h" - -namespace WebKit { -struct WebFontRenderStyle; -} - -namespace child_process_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. -CONTENT_EXPORT 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. -CONTENT_EXPORT 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. -CONTENT_EXPORT bool GetFontTable(int fd, uint32_t table, uint8_t* output, - size_t* output_length); - -}; // namespace child_process_sandbox_support - -#endif // CONTENT_COMMON_CHILD_PROCESS_SANDBOX_SUPPORT_LINUX_H_ diff --git a/content/content_common.gypi b/content/content_common.gypi index 22ad357..2534708 100644 --- a/content/content_common.gypi +++ b/content/content_common.gypi @@ -29,6 +29,7 @@ ], 'sources': [ 'public/common/bindings_policy.h', + 'public/common/child_process_sandbox_support_linux.h', 'public/common/content_switches.cc', 'public/common/content_switches.h', 'public/common/page_transition_types.cc', @@ -49,8 +50,8 @@ 'common/child_process_info.cc', 'common/child_process_info.h', 'common/child_process_messages.h', - 'common/child_process_sandbox_support_linux.cc', - 'common/child_process_sandbox_support_linux.h', + 'common/child_process_sandbox_support_impl_linux.cc', + 'common/child_process_sandbox_support_impl_linux.h', 'common/child_thread.cc', 'common/child_thread.h', 'common/child_trace_message_filter.cc', diff --git a/content/ppapi_plugin/ppapi_webkitplatformsupport_impl.cc b/content/ppapi_plugin/ppapi_webkitplatformsupport_impl.cc index 82f330c..4733909 100644 --- a/content/ppapi_plugin/ppapi_webkitplatformsupport_impl.cc +++ b/content/ppapi_plugin/ppapi_webkitplatformsupport_impl.cc @@ -18,7 +18,7 @@ #elif defined(OS_MACOSX) #include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebSandboxSupport.h" #elif defined(OS_POSIX) -#include "content/common/child_process_sandbox_support_linux.h" +#include "content/common/child_process_sandbox_support_impl_linux.h" #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebSandboxSupport.h" #endif @@ -92,19 +92,17 @@ PpapiWebKitPlatformSupportImpl::SandboxSupport::getFontFamilyForCharacters( if (iter != unicode_font_families_.end()) return WebString::fromUTF8(iter->second); - const std::string family_name = - child_process_sandbox_support::getFontFamilyForCharacters( - characters, - num_characters, - preferred_locale); + const std::string family_name = content::GetFontFamilyForCharacters( + characters, + num_characters, + preferred_locale); unicode_font_families_.insert(make_pair(key, family_name)); return WebString::fromUTF8(family_name); } void PpapiWebKitPlatformSupportImpl::SandboxSupport::getRenderStyleForStrike( const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out) { - child_process_sandbox_support::getRenderStyleForStrike(family, sizeAndStyle, - out); + content::GetRenderStyleForStrike(family, sizeAndStyle, out); } #endif diff --git a/content/public/common/child_process_sandbox_support_linux.h b/content/public/common/child_process_sandbox_support_linux.h new file mode 100644 index 0000000..c373ba4 --- /dev/null +++ b/content/public/common/child_process_sandbox_support_linux.h @@ -0,0 +1,42 @@ +// 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. + +#ifndef CONTENT_PULIC_COMMON_CHILD_PROCESS_SANDBOX_SUPPORT_LINUX_H_ +#define CONTENT_PULIC_COMMON_CHILD_PROCESS_SANDBOX_SUPPORT_LINUX_H_ +#pragma once + +#include +#include + +#include "content/common/content_export.h" + +namespace content { + +// 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. +CONTENT_EXPORT 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. +CONTENT_EXPORT 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. +CONTENT_EXPORT bool GetFontTable(int fd, uint32_t table, uint8_t* output, + size_t* output_length); + +}; // namespace content + +#endif // CONTENT_PULIC_COMMON_CHILD_PROCESS_SANDBOX_SUPPORT_LINUX_H_ diff --git a/content/renderer/renderer_glue.cc b/content/renderer/renderer_glue.cc index f873993..fb0fbfe 100644 --- a/content/renderer/renderer_glue.cc +++ b/content/renderer/renderer_glue.cc @@ -36,10 +36,6 @@ #include "webkit/glue/webkit_glue.h" #include "webkit/glue/websocketstreamhandle_bridge.h" -#if defined(OS_LINUX) -#include "content/common/child_process_sandbox_support_linux.h" -#endif - // This definition of WriteBitmapFromPixels uses shared memory to communicate // across processes. void ScopedClipboardWriterGlue::WriteBitmapFromPixels(const void* pixels, @@ -205,20 +201,6 @@ WebSocketStreamHandleBridge* WebSocketStreamHandleBridge::Create( return dispatcher->CreateBridge(handle, delegate); } -#if defined(OS_LINUX) -int MatchFontWithFallback(const std::string& face, bool bold, - bool italic, int charset) { - 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 child_process_sandbox_support::GetFontTable( - fd, table, output, output_length); -} -#endif - string16 GetLocalizedString(int message_id) { return content::GetContentClient()->GetLocalizedString(message_id); } diff --git a/content/renderer/renderer_webkitplatformsupport_impl.cc b/content/renderer/renderer_webkitplatformsupport_impl.cc index 6ed042b..0d31ac5 100644 --- a/content/renderer/renderer_webkitplatformsupport_impl.cc +++ b/content/renderer/renderer_webkitplatformsupport_impl.cc @@ -61,7 +61,7 @@ #include #include "base/synchronization/lock.h" -#include "content/common/child_process_sandbox_support_linux.h" +#include "content/common/child_process_sandbox_support_impl_linux.h" #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebSandboxSupport.h" #endif @@ -492,11 +492,10 @@ RendererWebKitPlatformSupportImpl::SandboxSupport::getFontFamilyForCharacters( if (iter != unicode_font_families_.end()) return WebString::fromUTF8(iter->second); - const std::string family_name = - child_process_sandbox_support::getFontFamilyForCharacters( - characters, - num_characters, - preferred_locale); + const std::string family_name = content::GetFontFamilyForCharacters( + characters, + num_characters, + preferred_locale); unicode_font_families_.insert(make_pair(key, family_name)); return WebString::fromUTF8(family_name); } @@ -504,8 +503,7 @@ RendererWebKitPlatformSupportImpl::SandboxSupport::getFontFamilyForCharacters( void RendererWebKitPlatformSupportImpl::SandboxSupport::getRenderStyleForStrike( const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out) { - child_process_sandbox_support::getRenderStyleForStrike(family, sizeAndStyle, - out); + content::GetRenderStyleForStrike(family, sizeAndStyle, out); } #endif diff --git a/content/test/render_view_test.cc b/content/test/render_view_test.cc index 661974b..e47dcaf 100644 --- a/content/test/render_view_test.cc +++ b/content/test/render_view_test.cc @@ -309,14 +309,21 @@ void RenderViewTest::ClearHistory() { impl->history_page_ids_.clear(); } -bool RenderViewTest::OnMessageReceived(const IPC::Message& msg) { +void RenderViewTest::Reload(const GURL& url) { + ViewMsg_Navigate_Params params; + params.url = url; + params.navigation_type = ViewMsg_Navigate_Type::RELOAD; RenderViewImpl* impl = static_cast(view_); - return impl->OnMessageReceived(msg); + impl->OnNavigate(params); +} + +uint32 RenderViewTest::GetNavigationIPCType() { + return ViewHostMsg_FrameNavigate::ID; } -void RenderViewTest::OnNavigate(const ViewMsg_Navigate_Params& params) { +bool RenderViewTest::OnMessageReceived(const IPC::Message& msg) { RenderViewImpl* impl = static_cast(view_); - impl->OnNavigate(params); + return impl->OnMessageReceived(msg); } void RenderViewTest::DidNavigateWithinPage(WebKit::WebFrame* frame, diff --git a/content/test/render_view_test.h b/content/test/render_view_test.h index 7f6ac85..1d3a6a5 100644 --- a/content/test/render_view_test.h +++ b/content/test/render_view_test.h @@ -95,9 +95,14 @@ class RenderViewTest : public testing::Test { // Clears anything associated with the browsing history. void ClearHistory(); + // Simulates a navigation with a type of reload to the given url. + void Reload(const GURL& url); + + // Returns the IPC message ID of the navigation message. + uint32 GetNavigationIPCType(); + // These are all methods from RenderViewImpl that we expose to testing code. bool OnMessageReceived(const IPC::Message& msg); - void OnNavigate(const ViewMsg_Navigate_Params& params); void DidNavigateWithinPage(WebKit::WebFrame* frame, bool is_new_navigation); void SendContentStateImmediately(); WebKit::WebWidget* GetWebWidget(); -- cgit v1.1