OLD | NEW |
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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 } | 239 } |
240 } | 240 } |
241 | 241 |
242 // Callback that stores a PDF file on disk. | 242 // Callback that stores a PDF file on disk. |
243 void PrintToPdfCallback(const scoped_refptr<base::RefCountedBytes>& data, | 243 void PrintToPdfCallback(const scoped_refptr<base::RefCountedBytes>& data, |
244 const base::FilePath& path, | 244 const base::FilePath& path, |
245 const base::Closure& pdf_file_saved_closure) { | 245 const base::Closure& pdf_file_saved_closure) { |
246 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 246 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
247 printing::PdfMetafileSkia metafile; | 247 printing::PdfMetafileSkia metafile; |
248 metafile.InitFromData(static_cast<const void*>(data->front()), data->size()); | 248 metafile.InitFromData(static_cast<const void*>(data->front()), data->size()); |
249 metafile.SaveTo(path); | 249 base::File file(path, |
| 250 base::File::FLAG_CREATE_ALWAYS || base::File::FLAG_WRITE); |
| 251 metafile.SaveTo(&file); |
250 if (!pdf_file_saved_closure.is_null()) | 252 if (!pdf_file_saved_closure.is_null()) |
251 pdf_file_saved_closure.Run(); | 253 pdf_file_saved_closure.Run(); |
252 } | 254 } |
253 | 255 |
254 std::string GetDefaultPrinterOnFileThread() { | 256 std::string GetDefaultPrinterOnFileThread() { |
255 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 257 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
256 | 258 |
257 scoped_refptr<printing::PrintBackend> print_backend( | 259 scoped_refptr<printing::PrintBackend> print_backend( |
258 printing::PrintBackend::CreateInstance(NULL)); | 260 printing::PrintBackend::CreateInstance(NULL)); |
259 | 261 |
(...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1593 | 1595 |
1594 void PrintPreviewHandler::UnregisterForMergeSession() { | 1596 void PrintPreviewHandler::UnregisterForMergeSession() { |
1595 if (reconcilor_) | 1597 if (reconcilor_) |
1596 reconcilor_->RemoveMergeSessionObserver(this); | 1598 reconcilor_->RemoveMergeSessionObserver(this); |
1597 } | 1599 } |
1598 | 1600 |
1599 void PrintPreviewHandler::SetPdfSavedClosureForTesting( | 1601 void PrintPreviewHandler::SetPdfSavedClosureForTesting( |
1600 const base::Closure& closure) { | 1602 const base::Closure& closure) { |
1601 pdf_file_saved_closure_ = closure; | 1603 pdf_file_saved_closure_ = closure; |
1602 } | 1604 } |
OLD | NEW |