summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-10 02:53:47 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-10 02:53:47 +0000
commitddd8d5e5cf7f916268e9429ebe3cf5be65268630 (patch)
tree933df07c4805e8ff7db44d8de13cbd0ff6be370a
parent59cfa77428e0458a2d46784cb618fb2ec757038e (diff)
downloadchromium_src-ddd8d5e5cf7f916268e9429ebe3cf5be65268630.zip
chromium_src-ddd8d5e5cf7f916268e9429ebe3cf5be65268630.tar.gz
chromium_src-ddd8d5e5cf7f916268e9429ebe3cf5be65268630.tar.bz2
Linux: open shared memory in browser rather than renderer (like on mac).
BUG=40448 TEST=copy image into gimp from sandboxed chrome. also, gtk_clipboard_dump shows image data on clipboard Review URL: http://codereview.chromium.org/1517029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44179 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.cc7
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.h5
-rw-r--r--chrome/common/render_messages_internal.h3
-rw-r--r--chrome/renderer/renderer_glue.cc8
4 files changed, 15 insertions, 8 deletions
diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc
index 39706a9..6119c18 100644
--- a/chrome/browser/renderer_host/resource_message_filter.cc
+++ b/chrome/browser/renderer_host/resource_message_filter.cc
@@ -501,9 +501,12 @@ bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& msg) {
#if defined(OS_MACOSX)
IPC_MESSAGE_HANDLER(ViewHostMsg_AllocatePDFTransport,
OnAllocateSharedMemoryBuffer)
+#endif
+#if defined(OS_POSIX)
IPC_MESSAGE_HANDLER(ViewHostMsg_AllocateSharedMemoryBuffer,
OnAllocateSharedMemoryBuffer)
-#elif defined(OS_POSIX)
+#endif
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_AllocateTempFileForPrinting,
OnAllocateTempFileForPrinting)
IPC_MESSAGE_HANDLER(ViewHostMsg_TempFileForPrintingWritten,
@@ -971,7 +974,7 @@ void ResourceMessageFilter::OnDuplicateSection(
}
#endif
-#if defined(OS_MACOSX)
+#if defined(OS_POSIX)
void ResourceMessageFilter::OnAllocateSharedMemoryBuffer(
uint32 buffer_size,
base::SharedMemoryHandle* handle) {
diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h
index 77b8eb7..549110a 100644
--- a/chrome/browser/renderer_host/resource_message_filter.h
+++ b/chrome/browser/renderer_host/resource_message_filter.h
@@ -251,10 +251,11 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
void OnAllocateTempFileForPrinting(IPC::Message* reply_msg);
void OnTempFileForPrintingWritten(int fd_in_browser);
#endif
-#if defined(OS_MACOSX)
+
+#if defined(OS_POSIX)
// Used to ask the browser to allocate a block of shared memory for the
// renderer to send back data in, since shared memory can't be created
- // in the renderer on OS X due to the sandbox.
+ // in the renderer on POSIX due to the sandbox.
void OnAllocateSharedMemoryBuffer(uint32 buffer_size,
base::SharedMemoryHandle* handle);
#endif
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 24cda62..a1028b2 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -1716,6 +1716,9 @@ IPC_BEGIN_MESSAGES(ViewHost)
IPC_SYNC_MESSAGE_ROUTED1_1(ViewHostMsg_AllocatePDFTransport,
uint32 /* buffer size */,
base::SharedMemoryHandle /* browser handle */)
+#endif
+
+#if defined(OS_POSIX)
// Asks the browser to create a block of shared memory for the renderer to
// fill in and pass back to the browser.
IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_AllocateSharedMemoryBuffer,
diff --git a/chrome/renderer/renderer_glue.cc b/chrome/renderer/renderer_glue.cc
index e4f8dd9..bf879be18 100644
--- a/chrome/renderer/renderer_glue.cc
+++ b/chrome/renderer/renderer_glue.cc
@@ -93,8 +93,8 @@ void ScopedClipboardWriterGlue::WriteBitmapFromPixels(const void* pixels,
uint32 buf_size = 4 * size.width() * size.height();
// Allocate a shared memory buffer to hold the bitmap bits.
-#if defined(OS_MACOSX)
- // On OS X, we need to ask the browser to create the shared memory for us,
+#if defined(OS_POSIX)
+ // On POSIX, we need to ask the browser to create the shared memory for us,
// since this is blocked by the sandbox.
base::SharedMemoryHandle shared_mem_handle;
ViewHostMsg_AllocateSharedMemoryBuffer *msg =
@@ -115,7 +115,7 @@ void ScopedClipboardWriterGlue::WriteBitmapFromPixels(const void* pixels,
NOTREACHED() << "Browser allocation request message failed";
return;
}
-#else
+#else // !OS_POSIX
shared_buf_ = new base::SharedMemory;
const bool created = shared_buf_ && shared_buf_->Create(
L"", false /* read write */, true /* open existing */, buf_size);
@@ -123,7 +123,7 @@ void ScopedClipboardWriterGlue::WriteBitmapFromPixels(const void* pixels,
NOTREACHED();
return;
}
-#endif // !OS_MACOSX
+#endif
// Copy the bits into shared memory
memcpy(shared_buf_->memory(), pixels, buf_size);