diff options
author | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-08 14:37:48 +0000 |
---|---|---|
committer | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-08 14:37:48 +0000 |
commit | 60c671ca9dc52bb7c6a0bac0773d526d9060e87a (patch) | |
tree | 24885879abfe576ff8fa1f1b70a3cee3a8b69623 /chrome/browser | |
parent | fb630c1cdb74e955d343272a1c9b6ac2968e3a0c (diff) | |
download | chromium_src-60c671ca9dc52bb7c6a0bac0773d526d9060e87a.zip chromium_src-60c671ca9dc52bb7c6a0bac0773d526d9060e87a.tar.gz chromium_src-60c671ca9dc52bb7c6a0bac0773d526d9060e87a.tar.bz2 |
Pass printing result to the browser.
The resulting PDF file will now be passed to the browser and be saved as "chromium_printing_test.pdf" under current directory.
BUG=9847
TEST=printing on linux should now generate chromium_printing_test.pdf in download directory. Printing on Windows should still work.
Patch contributed by minyu.huang@gmail.com
Review URL: http://codereview.chromium.org/172115
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25615 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/renderer_host/resource_message_filter.cc | 31 | ||||
-rw-r--r-- | chrome/browser/renderer_host/resource_message_filter.h | 20 |
2 files changed, 47 insertions, 4 deletions
diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc index b460814..059f2af 100644 --- a/chrome/browser/renderer_host/resource_message_filter.cc +++ b/chrome/browser/renderer_host/resource_message_filter.cc @@ -323,7 +323,13 @@ bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& msg) { OnGetPreferredExtensionForMimeType) IPC_MESSAGE_HANDLER(ViewHostMsg_GetCPBrowsingContext, OnGetCPBrowsingContext) +#if defined(OS_WIN) IPC_MESSAGE_HANDLER(ViewHostMsg_DuplicateSection, OnDuplicateSection) +#endif +#if defined(OS_LINUX) + IPC_MESSAGE_HANDLER(ViewHostMsg_AllocateShareMemory, + OnAllocateShareMemory) +#endif IPC_MESSAGE_HANDLER(ViewHostMsg_ResourceTypeStats, OnResourceTypeStats) IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_ResolveProxy, OnResolveProxy) IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetDefaultPrintSettings, @@ -675,6 +681,7 @@ void ResourceMessageFilter::OnGetCPBrowsingContext(uint32* context) { CPBrowsingContextManager::Instance()->Allocate(request_context_.get()); } +#if defined(OS_WIN) void ResourceMessageFilter::OnDuplicateSection( base::SharedMemoryHandle renderer_handle, base::SharedMemoryHandle* browser_handle) { @@ -683,6 +690,30 @@ void ResourceMessageFilter::OnDuplicateSection( base::SharedMemory shared_buf(renderer_handle, true, handle()); shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), browser_handle); } +#endif + +#if defined(OS_LINUX) +void ResourceMessageFilter::OnAllocateShareMemory( + size_t buffer_size, + base::SharedMemoryHandle* browser_handle) { + // We don't want to allocate a super big chunk of memory. + // 32MB should be large enough for printing on Linux. + if (buffer_size > 32 * 1024 * 1024) { + *browser_handle = base::SharedMemory::NULLHandle(); + NOTREACHED() << "Buffer too large: " << buffer_size; + return; + } + base::SharedMemory shared_buf; + shared_buf.Create(L"", false, false, buffer_size); + if (shared_buf.Map(buffer_size)) { + shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), browser_handle); + } else { + *browser_handle = base::SharedMemory::NULLHandle(); + NOTREACHED() << "Cannot map buffer"; + return; + } +} +#endif void ResourceMessageFilter::OnResourceTypeStats( const WebCache::ResourceTypeStats& stats) { diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h index 825422b..7fd7979 100644 --- a/chrome/browser/renderer_host/resource_message_filter.h +++ b/chrome/browser/renderer_host/resource_message_filter.h @@ -5,6 +5,10 @@ #ifndef CHROME_BROWSER_RENDERER_HOST_RESOURCE_MSG_FILTER_H_ #define CHROME_BROWSER_RENDERER_HOST_RESOURCE_MSG_FILTER_H_ +#if defined(OS_WIN) +#include <windows.h> +#endif + #include <string> #include <vector> @@ -26,10 +30,6 @@ #include "ipc/ipc_channel_proxy.h" #include "webkit/api/public/WebCache.h" -#if defined(OS_WIN) -#include <windows.h> -#endif - class AppCacheDispatcherHost; class AudioRendererHost; class Clipboard; @@ -190,8 +190,20 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter, void OnGetPreferredExtensionForMimeType(const std::string& mime_type, FilePath::StringType* ext); void OnGetCPBrowsingContext(uint32* context); + +#if defined(OS_WIN) + // Used to pass resulting EMF from renderer to browser in printing. void OnDuplicateSection(base::SharedMemoryHandle renderer_handle, base::SharedMemoryHandle* browser_handle); +#endif + +#if defined(OS_LINUX) + // Used to ask the browser allocate a block of shared memory for the renderer + // to fill in resulting PDF in renderer. + void OnAllocateShareMemory(size_t buffer_size, + base::SharedMemoryHandle* browser_handle); +#endif + void OnResourceTypeStats(const WebKit::WebCache::ResourceTypeStats& stats); void OnResolveProxy(const GURL& url, IPC::Message* reply_msg); |