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

Side by Side Diff: chrome/browser/ui/webui/print_preview/print_preview_handler.cc

Issue 410473002: Assertion removed in print_preview_pdf_generated.cc. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed |end_loop_callback_|. Observer didn't need it as a member variable. Created 6 years, 5 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 (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 "chrome/browser/ui/webui/print_preview/print_preview_handler.h" 5 #include "chrome/browser/ui/webui/print_preview/print_preview_handler.h"
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 271
272 bool external_preview = false; 272 bool external_preview = false;
273 if (settings.GetBoolean(printing::kSettingOpenPDFInPreview, 273 if (settings.GetBoolean(printing::kSettingOpenPDFInPreview,
274 &external_preview) && external_preview) { 274 &external_preview) && external_preview) {
275 ReportPrintSettingHistogram(EXTERNAL_PDF_PREVIEW); 275 ReportPrintSettingHistogram(EXTERNAL_PDF_PREVIEW);
276 } 276 }
277 } 277 }
278 278
279 // Callback that stores a PDF file on disk. 279 // Callback that stores a PDF file on disk.
280 void PrintToPdfCallback(printing::Metafile* metafile, 280 void PrintToPdfCallback(printing::Metafile* metafile,
281 const base::FilePath& path) { 281 const base::FilePath& path,
282 const base::Closure& pdf_file_saved_callback) {
282 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 283 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
283 metafile->SaveTo(path); 284 metafile->SaveTo(path);
284 // |metafile| must be deleted on the UI thread. 285 // |metafile| must be deleted on the UI thread.
285 BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, metafile); 286 BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, metafile);
287 pdf_file_saved_callback.Run();
Lei Zhang 2014/07/22 03:04:39 What happens when you save to PDF outside of your
ivandavid 2014/07/22 19:02:01 Done.
286 } 288 }
287 289
288 std::string GetDefaultPrinterOnFileThread() { 290 std::string GetDefaultPrinterOnFileThread() {
289 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 291 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
290 292
291 scoped_refptr<printing::PrintBackend> print_backend( 293 scoped_refptr<printing::PrintBackend> print_backend(
292 printing::PrintBackend::CreateInstance(NULL)); 294 printing::PrintBackend::CreateInstance(NULL));
293 295
294 std::string default_printer = print_backend->GetDefaultPrinterName(); 296 std::string default_printer = print_backend->GetDefaultPrinterName();
295 VLOG(1) << "Default Printer: " << default_printer; 297 VLOG(1) << "Default Printer: " << default_printer;
(...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 scoped_refptr<base::RefCountedBytes> data; 1367 scoped_refptr<base::RefCountedBytes> data;
1366 base::string16 title; 1368 base::string16 title;
1367 if (!GetPreviewDataAndTitle(&data, &title)) { 1369 if (!GetPreviewDataAndTitle(&data, &title)) {
1368 NOTREACHED() << "Preview data was checked before file dialog."; 1370 NOTREACHED() << "Preview data was checked before file dialog.";
1369 return; 1371 return;
1370 } 1372 }
1371 scoped_ptr<printing::PreviewMetafile> metafile(new printing::PreviewMetafile); 1373 scoped_ptr<printing::PreviewMetafile> metafile(new printing::PreviewMetafile);
1372 metafile->InitFromData(static_cast<const void*>(data->front()), data->size()); 1374 metafile->InitFromData(static_cast<const void*>(data->front()), data->size());
1373 BrowserThread::PostTask( 1375 BrowserThread::PostTask(
1374 BrowserThread::FILE, FROM_HERE, 1376 BrowserThread::FILE, FROM_HERE,
1375 base::Bind(&PrintToPdfCallback, metafile.release(), print_to_pdf_path_)); 1377 base::Bind(&PrintToPdfCallback,
1378 metafile.release(),
1379 print_to_pdf_path_,
1380 pdf_file_saved_callback_));
1376 print_to_pdf_path_ = base::FilePath(); 1381 print_to_pdf_path_ = base::FilePath();
1377 ClosePreviewDialog(); 1382 ClosePreviewDialog();
1378 } 1383 }
1379 1384
1380 void PrintPreviewHandler::FileSelectionCanceled(void* params) { 1385 void PrintPreviewHandler::FileSelectionCanceled(void* params) {
1381 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( 1386 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(
1382 web_ui()->GetController()); 1387 web_ui()->GetController());
1383 print_preview_ui->OnFileSelectionCancelled(); 1388 print_preview_ui->OnFileSelectionCancelled();
1384 } 1389 }
1385 1390
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1624 reconcilor_ = AccountReconcilorFactory::GetForProfile(profile); 1629 reconcilor_ = AccountReconcilorFactory::GetForProfile(profile);
1625 if (reconcilor_) 1630 if (reconcilor_)
1626 reconcilor_->AddMergeSessionObserver(this); 1631 reconcilor_->AddMergeSessionObserver(this);
1627 } 1632 }
1628 } 1633 }
1629 1634
1630 void PrintPreviewHandler::UnregisterForMergeSession() { 1635 void PrintPreviewHandler::UnregisterForMergeSession() {
1631 if (reconcilor_) 1636 if (reconcilor_)
1632 reconcilor_->RemoveMergeSessionObserver(this); 1637 reconcilor_->RemoveMergeSessionObserver(this);
1633 } 1638 }
1639
1640 void PrintPreviewHandler::SetPdfSavedCallbackForTesting(
1641 const base::Closure& callback) {
1642 pdf_file_saved_callback_ = callback;
1643 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698