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

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

Issue 568633002: Extracted MetafilePlayer interface from printing::MetafilePlayer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@no_expose
Patch Set: Thu Sep 11 22:54:16 PDT 2014 Created 6 years, 3 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_base.h" 5 #include "chrome/browser/printing/print_view_manager_base.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 } 123 }
124 124
125 void PrintViewManagerBase::OnDidGetDocumentCookie(int cookie) { 125 void PrintViewManagerBase::OnDidGetDocumentCookie(int cookie) {
126 cookie_ = cookie; 126 cookie_ = cookie;
127 } 127 }
128 128
129 #if defined(OS_WIN) 129 #if defined(OS_WIN)
130 void PrintViewManagerBase::OnPdfToEmfConverted( 130 void PrintViewManagerBase::OnPdfToEmfConverted(
131 const PrintHostMsg_DidPrintPage_Params& params, 131 const PrintHostMsg_DidPrintPage_Params& params,
132 double scale_factor, 132 double scale_factor,
133 ScopedVector<Metafile>* emf_files) { 133 ScopedVector<MetafilePlayer>* emf_files) {
134 if (!print_job_.get()) 134 if (!print_job_.get())
135 return; 135 return;
136 136
137 PrintedDocument* document = print_job_->document(); 137 PrintedDocument* document = print_job_->document();
138 if (!document) 138 if (!document)
139 return; 139 return;
140 140
141 for (size_t i = 0; i < emf_files->size(); ++i) { 141 for (size_t i = 0; i < emf_files->size(); ++i) {
142 if (!(*emf_files)[i]) { 142 if (!(*emf_files)[i]) {
143 web_contents()->Stop(); 143 web_contents()->Stop();
144 return; 144 return;
145 } 145 }
146 } 146 }
147 147
148 for (size_t i = 0; i < emf_files->size(); ++i) { 148 for (size_t i = 0; i < emf_files->size(); ++i) {
149 // Update the rendered document. It will send notifications to the listener. 149 // Update the rendered document. It will send notifications to the listener.
150 document->SetPage(i, 150 document->SetPage(i,
151 (*emf_files)[i], 151 make_scoped_ptr((*emf_files)[i]),
152 scale_factor, 152 scale_factor,
153 params.page_size, 153 params.page_size,
154 params.content_area); 154 params.content_area);
155 } 155 }
156 // document->SetPage took ownership of all EMFs. 156 // document->SetPage took ownership of all EMFs.
157 emf_files->weak_clear(); 157 emf_files->weak_clear();
158 158
159 ShouldQuitFromInnerMessageLoop(); 159 ShouldQuitFromInnerMessageLoop();
160 } 160 }
161 #endif // OS_WIN 161 #endif // OS_WIN
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 if (!metafile->InitFromData(shared_buf.memory(), params.data_size)) { 193 if (!metafile->InitFromData(shared_buf.memory(), params.data_size)) {
194 NOTREACHED() << "Invalid metafile header"; 194 NOTREACHED() << "Invalid metafile header";
195 web_contents()->Stop(); 195 web_contents()->Stop();
196 return; 196 return;
197 } 197 }
198 } 198 }
199 199
200 #if !defined(OS_WIN) 200 #if !defined(OS_WIN)
201 // Update the rendered document. It will send notifications to the listener. 201 // Update the rendered document. It will send notifications to the listener.
202 document->SetPage(params.page_number, 202 document->SetPage(params.page_number,
203 metafile.release(), 203 metafile.PassAs<MetafilePlayer>(),
204 params.page_size, 204 params.page_size,
205 params.content_area); 205 params.content_area);
206 206
207 ShouldQuitFromInnerMessageLoop(); 207 ShouldQuitFromInnerMessageLoop();
208 #else 208 #else
209 if (metafile_must_be_valid) { 209 if (metafile_must_be_valid) {
210 scoped_refptr<base::RefCountedBytes> bytes = new base::RefCountedBytes( 210 scoped_refptr<base::RefCountedBytes> bytes = new base::RefCountedBytes(
211 reinterpret_cast<const unsigned char*>(shared_buf.memory()), 211 reinterpret_cast<const unsigned char*>(shared_buf.memory()),
212 params.data_size); 212 params.data_size);
213 213
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 scoped_refptr<printing::PrinterQuery> printer_query; 566 scoped_refptr<printing::PrinterQuery> printer_query;
567 printer_query = queue_->PopPrinterQuery(cookie); 567 printer_query = queue_->PopPrinterQuery(cookie);
568 if (!printer_query.get()) 568 if (!printer_query.get())
569 return; 569 return;
570 BrowserThread::PostTask( 570 BrowserThread::PostTask(
571 BrowserThread::IO, FROM_HERE, 571 BrowserThread::IO, FROM_HERE,
572 base::Bind(&PrinterQuery::StopWorker, printer_query.get())); 572 base::Bind(&PrinterQuery::StopWorker, printer_query.get()));
573 } 573 }
574 574
575 } // namespace printing 575 } // namespace printing
OLDNEW
« no previous file with comments | « chrome/browser/printing/print_view_manager_base.h ('k') | chrome/browser/ui/libgtk2ui/print_dialog_gtk2.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698