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

Side by Side Diff: chrome/renderer/mock_render_thread.cc

Issue 6516022: Linux: Refactor printing to be more like Windows/Mac.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix mac build Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/renderer/mock_render_thread.h" 5 #include "chrome/renderer/mock_render_thread.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/process_util.h" 10 #include "base/process_util.h"
11 #include "chrome/common/render_messages.h" 11 #include "chrome/common/render_messages.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 OnDidGetPrintedPagesCount) 113 OnDidGetPrintedPagesCount)
114 IPC_MESSAGE_HANDLER(ViewHostMsg_DidPrintPage, OnDidPrintPage) 114 IPC_MESSAGE_HANDLER(ViewHostMsg_DidPrintPage, OnDidPrintPage)
115 #endif 115 #endif
116 #if defined(OS_WIN) 116 #if defined(OS_WIN)
117 IPC_MESSAGE_HANDLER(ViewHostMsg_DuplicateSection, OnDuplicateSection) 117 IPC_MESSAGE_HANDLER(ViewHostMsg_DuplicateSection, OnDuplicateSection)
118 #endif 118 #endif
119 #if defined(OS_POSIX) 119 #if defined(OS_POSIX)
120 IPC_MESSAGE_HANDLER(ViewHostMsg_AllocateSharedMemoryBuffer, 120 IPC_MESSAGE_HANDLER(ViewHostMsg_AllocateSharedMemoryBuffer,
121 OnAllocateSharedMemoryBuffer) 121 OnAllocateSharedMemoryBuffer)
122 #endif 122 #endif
123 #if defined(OS_LINUX) 123 #if defined(OS_CHROMEOS)
124 IPC_MESSAGE_HANDLER(ViewHostMsg_AllocateTempFileForPrinting, 124 IPC_MESSAGE_HANDLER(ViewHostMsg_AllocateTempFileForPrinting,
125 OnAllocateTempFileForPrinting) 125 OnAllocateTempFileForPrinting)
126 IPC_MESSAGE_HANDLER(ViewHostMsg_TempFileForPrintingWritten, 126 IPC_MESSAGE_HANDLER(ViewHostMsg_TempFileForPrintingWritten,
127 OnTempFileForPrintingWritten) 127 OnTempFileForPrintingWritten)
128 #endif 128 #endif
129 IPC_MESSAGE_UNHANDLED(handled = false) 129 IPC_MESSAGE_UNHANDLED(handled = false)
130 IPC_END_MESSAGE_MAP_EX() 130 IPC_END_MESSAGE_MAP_EX()
131 return handled; 131 return handled;
132 } 132 }
133 133
(...skipping 28 matching lines...) Expand all
162 base::SharedMemory shared_buf; 162 base::SharedMemory shared_buf;
163 if (!shared_buf.CreateAndMapAnonymous(buffer_size)) { 163 if (!shared_buf.CreateAndMapAnonymous(buffer_size)) {
164 *handle = base::SharedMemory::NULLHandle(); 164 *handle = base::SharedMemory::NULLHandle();
165 NOTREACHED() << "Cannot map shared memory buffer"; 165 NOTREACHED() << "Cannot map shared memory buffer";
166 return; 166 return;
167 } 167 }
168 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), handle); 168 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), handle);
169 } 169 }
170 #endif 170 #endif
171 171
172 #if defined(OS_LINUX) 172 #if defined(OS_CHROMEOS)
173 void MockRenderThread::OnAllocateTempFileForPrinting( 173 void MockRenderThread::OnAllocateTempFileForPrinting(
174 base::FileDescriptor* renderer_fd, 174 base::FileDescriptor* renderer_fd,
175 int* browser_fd) { 175 int* browser_fd) {
176 renderer_fd->fd = *browser_fd = -1; 176 renderer_fd->fd = *browser_fd = -1;
177 renderer_fd->auto_close = false; 177 renderer_fd->auto_close = false;
178 178
179 FilePath path; 179 FilePath path;
180 if (file_util::CreateTemporaryFile(&path)) { 180 if (file_util::CreateTemporaryFile(&path)) {
181 int fd = open(path.value().c_str(), O_WRONLY); 181 int fd = open(path.value().c_str(), O_WRONLY);
182 DCHECK_GE(fd, 0); 182 DCHECK_GE(fd, 0);
183 renderer_fd->fd = *browser_fd = fd; 183 renderer_fd->fd = *browser_fd = fd;
184 } 184 }
185 } 185 }
186 186
187 void MockRenderThread::OnTempFileForPrintingWritten(int browser_fd) { 187 void MockRenderThread::OnTempFileForPrintingWritten(int browser_fd) {
188 close(browser_fd); 188 close(browser_fd);
189 } 189 }
190 #endif 190 #endif // defined(OS_CHROMEOS)
191 191
192 void MockRenderThread::OnGetDefaultPrintSettings(ViewMsg_Print_Params* params) { 192 void MockRenderThread::OnGetDefaultPrintSettings(ViewMsg_Print_Params* params) {
193 if (printer_.get()) 193 if (printer_.get())
194 printer_->GetDefaultPrintSettings(params); 194 printer_->GetDefaultPrintSettings(params);
195 } 195 }
196 196
197 void MockRenderThread::OnScriptedPrint( 197 void MockRenderThread::OnScriptedPrint(
198 const ViewHostMsg_ScriptedPrint_Params& params, 198 const ViewHostMsg_ScriptedPrint_Params& params,
199 ViewMsg_PrintPages_Params* settings) { 199 ViewMsg_PrintPages_Params* settings) {
200 if (printer_.get()) { 200 if (printer_.get()) {
201 printer_->ScriptedPrint(params.cookie, 201 printer_->ScriptedPrint(params.cookie,
202 params.expected_pages_count, 202 params.expected_pages_count,
203 params.has_selection, 203 params.has_selection,
204 settings); 204 settings);
205 } 205 }
206 } 206 }
207 207
208 void MockRenderThread::OnDidGetPrintedPagesCount(int cookie, int number_pages) { 208 void MockRenderThread::OnDidGetPrintedPagesCount(int cookie, int number_pages) {
209 if (printer_.get()) 209 if (printer_.get())
210 printer_->SetPrintedPagesCount(cookie, number_pages); 210 printer_->SetPrintedPagesCount(cookie, number_pages);
211 } 211 }
212 212
213 void MockRenderThread::OnDidPrintPage( 213 void MockRenderThread::OnDidPrintPage(
214 const ViewHostMsg_DidPrintPage_Params& params) { 214 const ViewHostMsg_DidPrintPage_Params& params) {
215 if (printer_.get()) 215 if (printer_.get())
216 printer_->PrintPage(params); 216 printer_->PrintPage(params);
217 } 217 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698