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

Side by Side Diff: chrome/browser/printing/print_view_manager.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) 2011 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/browser/printing/print_view_manager.h" 5 #include "chrome/browser/printing/print_view_manager.h"
6 6
7 #include "base/scoped_ptr.h" 7 #include "base/scoped_ptr.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/printing/print_job.h" 10 #include "chrome/browser/printing/print_job.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // Windows 2000/XP: When a page in a spooled file exceeds approximately 350 107 // Windows 2000/XP: When a page in a spooled file exceeds approximately 350
108 // MB, it can fail to print and not send an error message. 108 // MB, it can fail to print and not send an error message.
109 if (params.data_size && params.data_size >= 350*1024*1024) { 109 if (params.data_size && params.data_size >= 350*1024*1024) {
110 NOTREACHED() << "size:" << params.data_size; 110 NOTREACHED() << "size:" << params.data_size;
111 TerminatePrintJob(true); 111 TerminatePrintJob(true);
112 tab_contents()->Stop(); 112 tab_contents()->Stop();
113 return; 113 return;
114 } 114 }
115 #endif 115 #endif
116 116
117 const bool metafile_must_be_valid =
118 #if defined(OS_WIN) || defined(OS_MACOSX)
119 true;
120 #elif defined(OS_POSIX)
121 (params.page_number == 0);
122 #endif
123
117 base::SharedMemory shared_buf(params.metafile_data_handle, true); 124 base::SharedMemory shared_buf(params.metafile_data_handle, true);
118 if (!shared_buf.Map(params.data_size)) { 125 if (metafile_must_be_valid) {
119 NOTREACHED() << "couldn't map"; 126 if (!shared_buf.Map(params.data_size)) {
120 tab_contents()->Stop(); 127 NOTREACHED() << "couldn't map";
121 return; 128 tab_contents()->Stop();
129 return;
130 }
122 } 131 }
123 132
124 #if defined(OS_POSIX) && !defined(OS_MACOSX)
125 NOTIMPLEMENTED() << " this printing code doesn't quite work yet.";
126 #else
127 scoped_ptr<NativeMetafile> metafile(new NativeMetafile()); 133 scoped_ptr<NativeMetafile> metafile(new NativeMetafile());
128 if (!metafile->Init(shared_buf.memory(), params.data_size)) { 134 if (metafile_must_be_valid) {
129 NOTREACHED() << "Invalid metafile header"; 135 if (!metafile->Init(shared_buf.memory(), params.data_size)) {
130 tab_contents()->Stop(); 136 NOTREACHED() << "Invalid metafile header";
131 return; 137 tab_contents()->Stop();
138 return;
139 }
132 } 140 }
133 141
134 // Update the rendered document. It will send notifications to the listener. 142 // Update the rendered document. It will send notifications to the listener.
135 document->SetPage(params.page_number, 143 document->SetPage(params.page_number,
136 metafile.release(), 144 metafile.release(),
137 params.actual_shrink, 145 params.actual_shrink,
138 params.page_size, 146 params.page_size,
139 params.content_area, 147 params.content_area,
140 params.has_visible_overlays); 148 params.has_visible_overlays);
141 #endif 149
142 ShouldQuitFromInnerMessageLoop(); 150 ShouldQuitFromInnerMessageLoop();
143 } 151 }
144 152
145 bool PrintViewManager::OnMessageReceived(const IPC::Message& message) { 153 bool PrintViewManager::OnMessageReceived(const IPC::Message& message) {
146 bool handled = true; 154 bool handled = true;
147 IPC_BEGIN_MESSAGE_MAP(PrintViewManager, message) 155 IPC_BEGIN_MESSAGE_MAP(PrintViewManager, message)
148 IPC_MESSAGE_HANDLER(ViewHostMsg_DidGetPrintedPagesCount, 156 IPC_MESSAGE_HANDLER(ViewHostMsg_DidGetPrintedPagesCount,
149 OnDidGetPrintedPagesCount) 157 OnDidGetPrintedPagesCount)
150 IPC_MESSAGE_HANDLER(ViewHostMsg_DidPrintPage, OnDidPrintPage) 158 IPC_MESSAGE_HANDLER(ViewHostMsg_DidPrintPage, OnDidPrintPage)
151 IPC_MESSAGE_UNHANDLED(handled = false) 159 IPC_MESSAGE_UNHANDLED(handled = false)
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 return false; 423 return false;
416 } 424 }
417 425
418 // Settings are already loaded. Go ahead. This will set 426 // Settings are already loaded. Go ahead. This will set
419 // print_job_->is_job_pending() to true. 427 // print_job_->is_job_pending() to true.
420 print_job_->StartPrinting(); 428 print_job_->StartPrinting();
421 return true; 429 return true;
422 } 430 }
423 431
424 } // namespace printing 432 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698