| OLD | NEW |
| 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/ui/webui/print_preview_handler.h" | 5 #include "chrome/browser/ui/webui/print_preview_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/i18n/file_util_icu.h" | 9 #include "base/i18n/file_util_icu.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 preview_tab(), | 441 preview_tab(), |
| 442 platform_util::GetTopLevel(preview_tab()->GetNativeView()), | 442 platform_util::GetTopLevel(preview_tab()->GetNativeView()), |
| 443 NULL); | 443 NULL); |
| 444 } | 444 } |
| 445 | 445 |
| 446 void PrintPreviewHandler::FileSelected(const FilePath& path, | 446 void PrintPreviewHandler::FileSelected(const FilePath& path, |
| 447 int index, void* params) { | 447 int index, void* params) { |
| 448 PrintPreviewUIHTMLSource::PrintPreviewData data; | 448 PrintPreviewUIHTMLSource::PrintPreviewData data; |
| 449 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(web_ui_); | 449 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(web_ui_); |
| 450 print_preview_ui->html_source()->GetPrintPreviewData(&data); | 450 print_preview_ui->html_source()->GetPrintPreviewData(&data); |
| 451 DCHECK(data.first); | 451 if (!data.first || !data.second) { |
| 452 DCHECK_GT(data.second, 0U); | 452 NOTREACHED(); |
| 453 return; |
| 454 } |
| 453 | 455 |
| 454 printing::PreviewMetafile* metafile = new printing::PreviewMetafile; | 456 printing::PreviewMetafile* metafile = new printing::PreviewMetafile; |
| 455 metafile->InitFromData(data.first->memory(), data.second); | 457 metafile->InitFromData(data.first->memory(), data.second); |
| 456 | 458 |
| 457 // Updating last_saved_path_ to the newly selected folder. | 459 // Updating last_saved_path_ to the newly selected folder. |
| 458 *last_saved_path_ = path.DirName(); | 460 *last_saved_path_ = path.DirName(); |
| 459 | 461 |
| 460 PrintToPdfTask* task = new PrintToPdfTask(metafile, path); | 462 PrintToPdfTask* task = new PrintToPdfTask(metafile, path); |
| 461 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, task); | 463 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, task); |
| 462 | 464 |
| 463 ActivateInitiatorTabAndClosePreviewTab(); | 465 ActivateInitiatorTabAndClosePreviewTab(); |
| 464 } | 466 } |
| OLD | NEW |