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

Side by Side Diff: components/printing/renderer/print_web_view_helper.cc

Issue 1714643002: printing: Sandboxed processes must ask the browser to allocate shared memory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile error. Created 4 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/printing/renderer/print_web_view_helper.h" 5 #include "components/printing/renderer/print_web_view_helper.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 1793 matching lines...) Expand 10 before | Expand all | Expand 10 after
1804 } 1804 }
1805 #endif // !defined(OS_MACOSX) 1805 #endif // !defined(OS_MACOSX)
1806 1806
1807 bool PrintWebViewHelper::CopyMetafileDataToSharedMem( 1807 bool PrintWebViewHelper::CopyMetafileDataToSharedMem(
1808 const PdfMetafileSkia& metafile, 1808 const PdfMetafileSkia& metafile,
1809 base::SharedMemoryHandle* shared_mem_handle) { 1809 base::SharedMemoryHandle* shared_mem_handle) {
1810 uint32_t buf_size = metafile.GetDataSize(); 1810 uint32_t buf_size = metafile.GetDataSize();
1811 if (buf_size == 0) 1811 if (buf_size == 0)
1812 return false; 1812 return false;
1813 1813
1814 #if defined(OS_WIN)
1815 base::SharedMemory shared_buf;
1816 // Allocate a shared memory buffer to hold the generated metafile data.
1817 if (!shared_buf.CreateAndMapAnonymous(buf_size))
1818 return false;
1819
1820 // Copy the bits into shared memory.
1821 if (!metafile.GetData(shared_buf.memory(), buf_size))
1822 return false;
1823
1824 *shared_mem_handle = base::SharedMemory::DuplicateHandle(shared_buf.handle());
1825 return true;
1826 #else
1827 scoped_ptr<base::SharedMemory> shared_buf( 1814 scoped_ptr<base::SharedMemory> shared_buf(
1828 content::RenderThread::Get()->HostAllocateSharedMemoryBuffer(buf_size)); 1815 content::RenderThread::Get()->HostAllocateSharedMemoryBuffer(buf_size));
1829 if (!shared_buf) 1816 if (!shared_buf)
1830 return false; 1817 return false;
1831 1818
1832 if (!shared_buf->Map(buf_size)) 1819 if (!shared_buf->Map(buf_size))
1833 return false; 1820 return false;
1834 1821
1835 if (!metafile.GetData(shared_buf->memory(), buf_size)) 1822 if (!metafile.GetData(shared_buf->memory(), buf_size))
1836 return false; 1823 return false;
1837 1824
1838 return shared_buf->GiveToProcess(base::GetCurrentProcessHandle(), 1825 *shared_mem_handle =
1839 shared_mem_handle); 1826 base::SharedMemory::DuplicateHandle(shared_buf->handle());
1840 #endif // defined(OS_WIN) 1827 return true;
1841 } 1828 }
1842 1829
1843 #if defined(ENABLE_PRINT_PREVIEW) 1830 #if defined(ENABLE_PRINT_PREVIEW)
1844 void PrintWebViewHelper::ShowScriptedPrintPreview() { 1831 void PrintWebViewHelper::ShowScriptedPrintPreview() {
1845 if (is_scripted_preview_delayed_) { 1832 if (is_scripted_preview_delayed_) {
1846 is_scripted_preview_delayed_ = false; 1833 is_scripted_preview_delayed_ = false;
1847 Send(new PrintHostMsg_ShowScriptedPrintPreview( 1834 Send(new PrintHostMsg_ShowScriptedPrintPreview(
1848 routing_id(), print_preview_context_.IsModifiable())); 1835 routing_id(), print_preview_context_.IsModifiable()));
1849 } 1836 }
1850 } 1837 }
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
2253 blink::WebConsoleMessage::LevelWarning, message)); 2240 blink::WebConsoleMessage::LevelWarning, message));
2254 return false; 2241 return false;
2255 } 2242 }
2256 2243
2257 void PrintWebViewHelper::ScriptingThrottler::Reset() { 2244 void PrintWebViewHelper::ScriptingThrottler::Reset() {
2258 // Reset counter on successful print. 2245 // Reset counter on successful print.
2259 count_ = 0; 2246 count_ = 0;
2260 } 2247 }
2261 2248
2262 } // namespace printing 2249 } // namespace printing
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698