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

Side by Side Diff: chrome/browser/printing/print_view_manager.cc

Issue 6826027: Connect the right metafiles for print preview on Linux and Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile issues and rename MetafileInterface to Metafile Created 9 years, 8 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/memory/scoped_ptr.h" 7 #include "base/memory/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"
11 #include "chrome/browser/printing/print_job_manager.h" 11 #include "chrome/browser/printing/print_job_manager.h"
12 #include "chrome/browser/printing/print_preview_tab_controller.h" 12 #include "chrome/browser/printing/print_preview_tab_controller.h"
13 #include "chrome/browser/printing/printer_query.h" 13 #include "chrome/browser/printing/printer_query.h"
14 #include "chrome/browser/ui/webui/print_preview_ui.h" 14 #include "chrome/browser/ui/webui/print_preview_ui.h"
15 #include "chrome/common/print_messages.h" 15 #include "chrome/common/print_messages.h"
16 #include "content/browser/renderer_host/render_view_host.h" 16 #include "content/browser/renderer_host/render_view_host.h"
17 #include "content/browser/tab_contents/navigation_entry.h" 17 #include "content/browser/tab_contents/navigation_entry.h"
18 #include "content/browser/tab_contents/tab_contents.h" 18 #include "content/browser/tab_contents/tab_contents.h"
19 #include "content/common/notification_details.h" 19 #include "content/common/notification_details.h"
20 #include "content/common/notification_source.h" 20 #include "content/common/notification_source.h"
21 #include "grit/generated_resources.h" 21 #include "grit/generated_resources.h"
22 #include "printing/native_metafile.h" 22 #include "printing/metafile.h"
23 #include "printing/native_metafile_factory.h" 23 #include "printing/metafile_impl.h"
Lei Zhang 2011/04/11 02:51:10 you probably don't need both. metafile_impl.h will
vandebo (ex-Chrome) 2011/04/11 06:16:08 I agree that in this case we probably only need me
24 #include "printing/printed_document.h" 24 #include "printing/printed_document.h"
25 #include "ui/base/l10n/l10n_util.h" 25 #include "ui/base/l10n/l10n_util.h"
26 26
27 using base::TimeDelta; 27 using base::TimeDelta;
28 28
29 namespace { 29 namespace {
30 30
31 string16 GenerateRenderSourceName(TabContents* tab_contents) { 31 string16 GenerateRenderSourceName(TabContents* tab_contents) {
32 string16 name(tab_contents->GetTitle()); 32 string16 name(tab_contents->GetTitle());
33 if (name.empty()) 33 if (name.empty())
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 139
140 base::SharedMemory shared_buf(params.metafile_data_handle, true); 140 base::SharedMemory shared_buf(params.metafile_data_handle, true);
141 if (metafile_must_be_valid) { 141 if (metafile_must_be_valid) {
142 if (!shared_buf.Map(params.data_size)) { 142 if (!shared_buf.Map(params.data_size)) {
143 NOTREACHED() << "couldn't map"; 143 NOTREACHED() << "couldn't map";
144 tab_contents()->Stop(); 144 tab_contents()->Stop();
145 return; 145 return;
146 } 146 }
147 } 147 }
148 148
149 scoped_ptr<NativeMetafile> metafile; 149 scoped_ptr<Metafile> metafile(new printing::NativeMetafile);
150 if (metafile_must_be_valid) { 150 if (metafile_must_be_valid) {
151 metafile.reset(NativeMetafileFactory::CreateFromData(shared_buf.memory(), 151 metafile->InitFromData(shared_buf.memory(), params.data_size);
Lei Zhang 2011/04/11 02:51:10 Need to check return value, and remove the if chec
vandebo (ex-Chrome) 2011/04/11 06:16:08 Done.
152 params.data_size));
153 if (!metafile.get()) { 152 if (!metafile.get()) {
154 NOTREACHED() << "Invalid metafile header"; 153 NOTREACHED() << "Invalid metafile header";
155 tab_contents()->Stop(); 154 tab_contents()->Stop();
156 return; 155 return;
157 } 156 }
158 } 157 }
159 158
160 // Update the rendered document. It will send notifications to the listener. 159 // Update the rendered document. It will send notifications to the listener.
161 document->SetPage(params.page_number, 160 document->SetPage(params.page_number,
162 metafile.release(), 161 metafile.release(),
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 return false; 447 return false;
449 } 448 }
450 449
451 // Settings are already loaded. Go ahead. This will set 450 // Settings are already loaded. Go ahead. This will set
452 // print_job_->is_job_pending() to true. 451 // print_job_->is_job_pending() to true.
453 print_job_->StartPrinting(); 452 print_job_->StartPrinting();
454 return true; 453 return true;
455 } 454 }
456 455
457 } // namespace printing 456 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698